Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 32f81b3

Browse files
author
Eric Koleda
committed
1.18.0
1 parent 49754de commit 32f81b3

File tree

4 files changed

+41
-1714
lines changed

4 files changed

+41
-1714
lines changed

dist/OAuth1.gs

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MemoryProperties.prototype.getKeys = function() {
3636
* @see {@link https://developers.google.com/apps-script/reference/properties/properties#getproperties}
3737
*/
3838
MemoryProperties.prototype.getProperties = function() {
39-
return _.clone(this.properties);
39+
return extend_({}, this.properties);
4040
};
4141

4242
/**
@@ -84,10 +84,6 @@ MemoryProperties.prototype.setProperty = function(key, value) {
8484
* required setup.
8585
*/
8686

87-
// Load the Underscore.js library. This library was added using the script ID
88-
// "1I21uLOwDKdyF3_W_hvh6WXiIKWJWno8yG9lB8lf1VBnZFQ6jAAhyNTRG".
89-
90-
9187
/**
9288
* Creates a new OAuth1 service with the name specified. It's usually best to
9389
* create and configure your service once at the start of your script, and then
@@ -551,14 +547,15 @@ Service_.prototype.fetchInternal_ = function(url, params, opt_token,
551547
}
552548
switch (this.paramLocation_) {
553549
case 'auth-header':
554-
params.headers = _.extend({}, params.headers,
555-
signer.toHeader(oauthParams));
550+
params.headers =
551+
assign_({}, params.headers, signer.toHeader(oauthParams));
556552
break;
557553
case 'uri-query':
558554
url = buildUrl_(url, oauthParams);
559555
break;
560556
case 'post-body':
561-
params.payload = _.extend({}, params.payload, oauthParams);
557+
// Clone the payload.
558+
params.payload = assign_({}, params.payload, oauthParams);
562559
break;
563560
default:
564561
throw 'Unknown param location: ' + this.paramLocation_;
@@ -1047,30 +1044,52 @@ function buildUrl_(url, params) {
10471044

10481045
/**
10491046
* Validates that all of the values in the object are non-empty. If an empty
1050-
* value is found, an error is thrown using the key as the name.
1047+
* value is found, and error is thrown using the key as the name.
10511048
* @param {Object.<string, string>} params The values to validate.
10521049
* @private
10531050
*/
10541051
function validate_(params) {
10551052
Object.keys(params).forEach(function(name) {
10561053
var value = params[name];
1057-
if (isEmpty_(value)) {
1058-
throw Utilities.formatString('%s is required.', name);
1054+
if (!value) {
1055+
throw new Error(name + ' is required.');
10591056
}
10601057
});
10611058
}
10621059

10631060
/**
1064-
* Returns true if the given value is empty, false otherwise. An empty value
1065-
* is one of null, undefined, a zero-length string, a zero-length array or an
1066-
* object with no keys.
1067-
* @param {?} value The value to test.
1068-
* @returns {boolean} True if the value is empty, false otherwise.
1069-
* @private
1061+
* Polyfill for Object.assign, which isn't available on the legacy runtime.
1062+
* Not assigning to Object to avoid overwriting behavior in the parent
1063+
* script(s).
1064+
* @param {Object} target The target object to apply the sources’ properties to,
1065+
* which is returned after it is modified.
1066+
* @param {...Object} sources The source object(s) containing the properties you
1067+
* want to apply.
1068+
* @returns {Object} The target object.
1069+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill}
1070+
* @license Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
10701071
*/
1071-
function isEmpty_(value) {
1072-
return value === null || value === undefined ||
1073-
((_.isObject(value) || _.isString(value)) && _.isEmpty(value));
1072+
function assign_(target, varArgs) {
1073+
if (typeof Object.assign === 'function') {
1074+
return Object.assign.apply(null, arguments);
1075+
}
1076+
if (target === null || target === undefined) {
1077+
throw new TypeError('Cannot convert undefined or null to object');
1078+
}
1079+
var to = Object(target);
1080+
for (var index = 1; index < arguments.length; index++) {
1081+
var nextSource = arguments[index];
1082+
1083+
if (nextSource !== null && nextSource !== undefined) {
1084+
for (var nextKey in nextSource) {
1085+
// Avoid bugs when hasOwnProperty is shadowed
1086+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
1087+
to[nextKey] = nextSource[nextKey];
1088+
}
1089+
}
1090+
}
1091+
}
1092+
return to;
10741093
}
10751094

10761095
/**

0 commit comments

Comments
 (0)