repo
stringlengths
5
106
file_url
stringlengths
78
301
file_path
stringlengths
4
211
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:56:49
2026-01-05 02:23:25
truncated
bool
2 classes
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/isUndefined.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/isUndefined.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ /** * Checks if `value` is `undefined`. * * @static * @memberOf _ * @category Objects * @param {*} value The value to check. * @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`. * @example * * _.isUndefined(void 0); * // => true */ function isUndefined(value) { return typeof value == 'undefined'; } module.exports = isUndefined;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/isArguments.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/isArguments.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ /** `Object#toString` result shortcuts */ var argsClass = '[object Arguments]'; /** Used for native method references */ var objectProto = Object.prototype; /** Used to resolve the internal [[Class]] of values */ var toString = objectProto.toString; /** Native method shortcuts */ var hasOwnProperty = objectProto.hasOwnProperty, propertyIsEnumerable = objectProto.propertyIsEnumerable; /** * Checks if `value` is an `arguments` object. * * @static * @memberOf _ * @category Objects * @param {*} value The value to check. * @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`. * @example * * (function() { return _.isArguments(arguments); })(1, 2, 3); * // => true * * _.isArguments([1, 2, 3]); * // => false */ function isArguments(value) { return value && typeof value == 'object' && typeof value.length == 'number' && toString.call(value) == argsClass || false; } // fallback for browsers that can't detect `arguments` objects by [[Class]] if (!isArguments(arguments)) { isArguments = function(value) { return value && typeof value == 'object' && typeof value.length == 'number' && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false; }; } module.exports = isArguments;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/omit.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/omit.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ var baseDifference = require('../internals/baseDifference'), baseFlatten = require('../internals/baseFlatten'), forIn = require('./forIn'); /** * Creates a shallow clone of `object` excluding the specified properties. * Property names may be specified as individual arguments or as arrays of * property names. If a callback is provided it will be executed for each * property of `object` omitting the properties the callback returns truey * for. The callback is bound to `thisArg` and invoked with three arguments; * (value, key, object). * * @static * @memberOf _ * @category Objects * @param {Object} object The source object. * @param {Function|...string|string[]} [callback] The properties to omit or the * function called per iteration. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {Object} Returns an object without the omitted properties. * @example * * _.omit({ 'name': 'fred', 'age': 40 }, 'age'); * // => { 'name': 'fred' } * * _.omit({ 'name': 'fred', 'age': 40 }, function(value) { * return typeof value == 'number'; * }); * // => { 'name': 'fred' } */ function omit(object) { var props = []; forIn(object, function(value, key) { props.push(key); }); props = baseDifference(props, baseFlatten(arguments, true, false, 1)); var index = -1, length = props.length, result = {}; while (++index < length) { var key = props[index]; result[key] = object[key]; } return result; } module.exports = omit;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/isBoolean.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/isBoolean.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ /** `Object#toString` result shortcuts */ var boolClass = '[object Boolean]'; /** Used for native method references */ var objectProto = Object.prototype; /** Used to resolve the internal [[Class]] of values */ var toString = objectProto.toString; /** * Checks if `value` is a boolean value. * * @static * @memberOf _ * @category Objects * @param {*} value The value to check. * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`. * @example * * _.isBoolean(null); * // => false */ function isBoolean(value) { return value === true || value === false || value && typeof value == 'object' && toString.call(value) == boolClass || false; } module.exports = isBoolean;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/isElement.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/isElement.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ /** * Checks if `value` is a DOM element. * * @static * @memberOf _ * @category Objects * @param {*} value The value to check. * @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`. * @example * * _.isElement(document.body); * // => true */ function isElement(value) { return value && value.nodeType === 1 || false; } module.exports = isElement;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/functions.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/functions.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ var forIn = require('./forIn'), isFunction = require('./isFunction'); /** * Creates a sorted array of property names of all enumerable properties, * own and inherited, of `object` that have function values. * * @static * @memberOf _ * @alias methods * @category Objects * @param {Object} object The object to inspect. * @returns {Array} Returns an array of property names that have function values. * @example * * _.functions(_); * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] */ function functions(object) { var result = []; forIn(object, function(value, key) { if (isFunction(value)) { result.push(key); } }); return result.sort(); } module.exports = functions;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/values.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/values.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ var keys = require('./keys'); /** * Creates an array composed of the own enumerable property values of `object`. * * @static * @memberOf _ * @category Objects * @param {Object} object The object to inspect. * @returns {Array} Returns an array of property values. * @example * * _.values({ 'one': 1, 'two': 2, 'three': 3 }); * // => [1, 2, 3] (property order is not guaranteed across environments) */ function values(object) { var index = -1, props = keys(object), length = props.length, result = Array(length); while (++index < length) { result[index] = object[props[index]]; } return result; } module.exports = values;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/isEmpty.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/isEmpty.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ var isArray = require('./isArray'), isString = require('./isString'); /** Used for native method references */ var objectProto = Object.prototype; /** Native method shortcuts */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a * length of `0` and objects with no own enumerable properties are considered * "empty". * * @static * @memberOf _ * @category Objects * @param {Array|Object|string} value The value to inspect. * @returns {boolean} Returns `true` if the `value` is empty, else `false`. * @example * * _.isEmpty([1, 2, 3]); * // => false * * _.isEmpty({}); * // => true * * _.isEmpty(''); * // => true */ function isEmpty(value) { if (!value) { return true; } if (isArray(value) || isString(value)) { return !value.length; } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } return true; } module.exports = isEmpty;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/lodash-node/underscore/objects/invert.js
aws/lti-middleware/node_modules/lodash-node/underscore/objects/invert.js
/** * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> * Build: `lodash modularize underscore exports="node" -o ./underscore/` * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license <http://lodash.com/license> */ var keys = require('./keys'); /** * Creates an object composed of the inverted keys and values of the given object. * * @static * @memberOf _ * @category Objects * @param {Object} object The object to invert. * @returns {Object} Returns the created inverted object. * @example * * _.invert({ 'first': 'fred', 'second': 'barney' }); * // => { 'fred': 'first', 'barney': 'second' } */ function invert(object) { var index = -1, props = keys(object), length = props.length, result = {}; while (++index < length) { var key = props[index]; result[object[key]] = key; } return result; } module.exports = invert;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/fieldmask.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/fieldmask.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.googleProtobufFieldMaskFromProto3JSON = exports.googleProtobufFieldMaskToProto3JSON = void 0; function googleProtobufFieldMaskToProto3JSON(obj) { return obj.paths.join(','); } exports.googleProtobufFieldMaskToProto3JSON = googleProtobufFieldMaskToProto3JSON; function googleProtobufFieldMaskFromProto3JSON(json) { return { paths: json.split(','), }; } exports.googleProtobufFieldMaskFromProto3JSON = googleProtobufFieldMaskFromProto3JSON; //# sourceMappingURL=fieldmask.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/bytes.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/bytes.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.bytesFromProto3JSON = exports.bytesToProto3JSON = void 0; function bytesToProto3JSON(obj) { if (Buffer.isBuffer(obj)) { return obj.toString('base64'); } else { return Buffer.from(obj.buffer, 0, obj.byteLength).toString('base64'); } } exports.bytesToProto3JSON = bytesToProto3JSON; function bytesFromProto3JSON(json) { return Buffer.from(json, 'base64'); } exports.bytesFromProto3JSON = bytesFromProto3JSON; //# sourceMappingURL=bytes.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/enum.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/enum.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveEnumValueToString = void 0; function resolveEnumValueToString(enumType, enumValue) { // for unknown enum values, do not fail and try to do the best we could. // protobuf.js fromObject() will likely ignore unknown values, but at least // we won't fail. if (typeof enumValue === 'number') { const value = enumType.valuesById[enumValue]; if (typeof value === 'undefined') { // unknown value, cannot convert to string, returning number as is return enumValue; } return value; } if (typeof enumValue === 'string') { // for strings, just accept what we got return enumValue; } throw new Error('resolveEnumValueToString: enum value must be a string or a number'); } exports.resolveEnumValueToString = resolveEnumValueToString; //# sourceMappingURL=enum.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/any.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/any.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.googleProtobufAnyFromProto3JSON = exports.googleProtobufAnyToProto3JSON = void 0; const fromproto3json_1 = require("./fromproto3json"); const toproto3json_1 = require("./toproto3json"); // https://github.com/protocolbuffers/protobuf/blob/ba3836703b4a9e98e474aea2bac8c5b49b6d3b5c/python/google/protobuf/json_format.py#L850 const specialJSON = new Set([ 'google.protobuf.Any', 'google.protobuf.Duration', 'google.protobuf.FieldMask', 'google.protobuf.ListValue', 'google.protobuf.Struct', 'google.protobuf.Timestamp', 'google.protobuf.Value', ]); function googleProtobufAnyToProto3JSON(obj) { // https://developers.google.com/protocol-buffers/docs/proto3#json // If the Any contains a value that has a special JSON mapping, it will be converted as follows: // {"@type": xxx, "value": yyy}. // Otherwise, the value will be converted into a JSON object, and the "@type" field will be inserted // to indicate the actual data type. const typeName = obj.type_url.replace(/^.*\//, ''); let type; try { type = obj.$type.root.lookupType(typeName); } catch (err) { throw new Error(`googleProtobufAnyToProto3JSON: cannot find type ${typeName}: ${err}`); } const valueMessage = type.decode(obj.value); const valueProto3JSON = (0, toproto3json_1.toProto3JSON)(valueMessage); if (specialJSON.has(typeName)) { return { '@type': obj.type_url, value: valueProto3JSON, }; } valueProto3JSON['@type'] = obj.type_url; return valueProto3JSON; } exports.googleProtobufAnyToProto3JSON = googleProtobufAnyToProto3JSON; function googleProtobufAnyFromProto3JSON(root, json) { // Not all possible JSON values can hold Any, only real objects. if (json === null || typeof json !== 'object' || Array.isArray(json)) { throw new Error('googleProtobufAnyFromProto3JSON: must be an object to decode google.protobuf.Any'); } const typeUrl = json['@type']; if (!typeUrl || typeof typeUrl !== 'string') { throw new Error('googleProtobufAnyFromProto3JSON: JSON serialization of google.protobuf.Any must contain @type field'); } const typeName = typeUrl.replace(/^.*\//, ''); let type; try { type = root.lookupType(typeName); } catch (err) { throw new Error(`googleProtobufAnyFromProto3JSON: cannot find type ${typeName}: ${err}`); } let value = json; if (specialJSON.has(typeName)) { if (!('value' in json)) { throw new Error(`googleProtobufAnyFromProto3JSON: JSON representation of google.protobuf.Any with type ${typeName} must contain the value field`); } value = json.value; } const valueMessage = (0, fromproto3json_1.fromProto3JSON)(type, value); if (valueMessage === null) { return { type_url: typeUrl, value: null, }; } const uint8array = type.encode(valueMessage).finish(); const buffer = Buffer.from(uint8array, 0, uint8array.byteLength); const base64 = buffer.toString('base64'); return { type_url: typeUrl, value: base64, }; } exports.googleProtobufAnyFromProto3JSON = googleProtobufAnyFromProto3JSON; //# sourceMappingURL=any.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/types.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/types.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); //# sourceMappingURL=types.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/toproto3json.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/toproto3json.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.toProto3JSON = void 0; const any_1 = require("./any"); const bytes_1 = require("./bytes"); const util_1 = require("./util"); const enum_1 = require("./enum"); const value_1 = require("./value"); const duration_1 = require("./duration"); const timestamp_1 = require("./timestamp"); const wrappers_1 = require("./wrappers"); const fieldmask_1 = require("./fieldmask"); const id = (x) => { return x; }; function toProto3JSON(obj) { const objType = obj.$type; if (!objType) { throw new Error('Cannot serialize object to proto3 JSON since its .$type is unknown. Use Type.fromObject(obj) before calling toProto3JSON.'); } objType.resolveAll(); const typeName = (0, util_1.getFullyQualifiedTypeName)(objType); // Types that require special handling according to // https://developers.google.com/protocol-buffers/docs/proto3#json if (typeName === '.google.protobuf.Any') { return (0, any_1.googleProtobufAnyToProto3JSON)(obj); } if (typeName === '.google.protobuf.Value') { return (0, value_1.googleProtobufValueToProto3JSON)(obj); } if (typeName === '.google.protobuf.Struct') { return (0, value_1.googleProtobufStructToProto3JSON)(obj); } if (typeName === '.google.protobuf.ListValue') { return (0, value_1.googleProtobufListValueToProto3JSON)(obj); } if (typeName === '.google.protobuf.Duration') { return (0, duration_1.googleProtobufDurationToProto3JSON)(obj); } if (typeName === '.google.protobuf.Timestamp') { return (0, timestamp_1.googleProtobufTimestampToProto3JSON)(obj); } if (typeName === '.google.protobuf.FieldMask') { return (0, fieldmask_1.googleProtobufFieldMaskToProto3JSON)(obj); } if (util_1.wrapperTypes.has(typeName)) { return (0, wrappers_1.wrapperToProto3JSON)(obj); } const result = {}; for (const [key, value] of Object.entries(obj)) { const field = objType.fields[key]; const fieldResolvedType = field.resolvedType; const fieldFullyQualifiedTypeName = fieldResolvedType ? (0, util_1.getFullyQualifiedTypeName)(fieldResolvedType) : null; if (value === null) { result[key] = null; continue; } if (Array.isArray(value)) { if (value.length === 0) { // ignore repeated fields with no values continue; } // if the repeated value has a complex type, convert it to proto3 JSON, otherwise use as is result[key] = value.map(fieldResolvedType ? element => { return toProto3JSON(element); } : id); continue; } if (field.map) { const map = {}; for (const [mapKey, mapValue] of Object.entries(value)) { // if the map value has a complex type, convert it to proto3 JSON, otherwise use as is map[mapKey] = fieldResolvedType ? toProto3JSON(mapValue) : mapValue; } result[key] = map; continue; } if (fieldFullyQualifiedTypeName === '.google.protobuf.NullValue') { result[key] = null; continue; } if (fieldResolvedType && 'values' in fieldResolvedType && value !== null) { result[key] = (0, enum_1.resolveEnumValueToString)(fieldResolvedType, value); continue; } if (fieldResolvedType) { result[key] = toProto3JSON(value); continue; } if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null) { if (typeof value === 'number' && !Number.isFinite(value)) { result[key] = value.toString(); continue; } result[key] = value; continue; } if (Buffer.isBuffer(value) || value instanceof Uint8Array) { result[key] = (0, bytes_1.bytesToProto3JSON)(value); continue; } // The remaining case is Long, everything else is an internal error (0, util_1.assert)(value.constructor.name === 'Long', `toProto3JSON: don't know how to convert field ${key} with value ${value}`); result[key] = value.toString(); continue; } return result; } exports.toProto3JSON = toProto3JSON; //# sourceMappingURL=toproto3json.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/index.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/index.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.fromProto3JSON = exports.toProto3JSON = void 0; var toproto3json_1 = require("./toproto3json"); Object.defineProperty(exports, "toProto3JSON", { enumerable: true, get: function () { return toproto3json_1.toProto3JSON; } }); var fromproto3json_1 = require("./fromproto3json"); Object.defineProperty(exports, "fromProto3JSON", { enumerable: true, get: function () { return fromproto3json_1.fromProto3JSON; } }); //# sourceMappingURL=index.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/fromproto3json.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/fromproto3json.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.fromProto3JSON = exports.fromProto3JSONToInternalRepresentation = void 0; const any_1 = require("./any"); const bytes_1 = require("./bytes"); const enum_1 = require("./enum"); const value_1 = require("./value"); const util_1 = require("./util"); const duration_1 = require("./duration"); const timestamp_1 = require("./timestamp"); const wrappers_1 = require("./wrappers"); const fieldmask_1 = require("./fieldmask"); function fromProto3JSONToInternalRepresentation(type, json) { const fullyQualifiedTypeName = typeof type === 'string' ? type : (0, util_1.getFullyQualifiedTypeName)(type); if (typeof type !== 'string' && 'values' in type) { // type is an Enum if (fullyQualifiedTypeName === '.google.protobuf.NullValue') { return 'NULL_VALUE'; } return (0, enum_1.resolveEnumValueToString)(type, json); } if (typeof type !== 'string') { type.resolveAll(); } if (typeof type === 'string') { return json; } // Types that require special handling according to // https://developers.google.com/protocol-buffers/docs/proto3#json // Types that can have meaningful "null" value if (fullyQualifiedTypeName === '.google.protobuf.Value') { return (0, value_1.googleProtobufValueFromProto3JSON)(json); } if (util_1.wrapperTypes.has(fullyQualifiedTypeName)) { if ((json !== null && typeof json === 'object') || Array.isArray(json)) { throw new Error(`fromProto3JSONToInternalRepresentation: JSON representation for ${fullyQualifiedTypeName} expects a string, a number, or a boolean, but got ${typeof json}`); } return (0, wrappers_1.wrapperFromProto3JSON)(fullyQualifiedTypeName, json); } if (json === null) { return null; } // Types that cannot be "null" if (fullyQualifiedTypeName === '.google.protobuf.Any') { return (0, any_1.googleProtobufAnyFromProto3JSON)(type.root, json); } if (fullyQualifiedTypeName === '.google.protobuf.Struct') { if (typeof json !== 'object') { throw new Error(`fromProto3JSONToInternalRepresentation: google.protobuf.Struct must be an object but got ${typeof json}`); } if (Array.isArray(json)) { throw new Error('fromProto3JSONToInternalRepresentation: google.protobuf.Struct must be an object but got an array'); } return (0, value_1.googleProtobufStructFromProto3JSON)(json); } if (fullyQualifiedTypeName === '.google.protobuf.ListValue') { if (!Array.isArray(json)) { throw new Error(`fromProto3JSONToInternalRepresentation: google.protobuf.ListValue must be an array but got ${typeof json}`); } return (0, value_1.googleProtobufListValueFromProto3JSON)(json); } if (fullyQualifiedTypeName === '.google.protobuf.Duration') { if (typeof json !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: google.protobuf.Duration must be a string but got ${typeof json}`); } return (0, duration_1.googleProtobufDurationFromProto3JSON)(json); } if (fullyQualifiedTypeName === '.google.protobuf.Timestamp') { if (typeof json !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: google.protobuf.Timestamp must be a string but got ${typeof json}`); } return (0, timestamp_1.googleProtobufTimestampFromProto3JSON)(json); } if (fullyQualifiedTypeName === '.google.protobuf.FieldMask') { if (typeof json !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: google.protobuf.FieldMask must be a string but got ${typeof json}`); } return (0, fieldmask_1.googleProtobufFieldMaskFromProto3JSON)(json); } const result = {}; for (const [key, value] of Object.entries(json)) { const field = type.fields[key]; if (!field) { continue; } const resolvedType = field.resolvedType; const fieldType = field.type; if (field.repeated) { if (!Array.isArray(value)) { throw new Error(`fromProto3JSONToInternalRepresentation: expected an array for field ${key}`); } result[key] = value.map(element => fromProto3JSONToInternalRepresentation(resolvedType || fieldType, element)); } else if (field.map) { const map = {}; for (const [mapKey, mapValue] of Object.entries(value)) { map[mapKey] = fromProto3JSONToInternalRepresentation(resolvedType || fieldType, mapValue); } result[key] = map; } else if (fieldType.match(/^(?:(?:(?:u?int|fixed)(?:32|64))|float|double)$/)) { if (typeof value !== 'number' && typeof value !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: field ${key} of type ${field.type} cannot contain value ${value}`); } result[key] = value; } else if (fieldType === 'string') { if (typeof value !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: field ${key} of type ${field.type} cannot contain value ${value}`); } result[key] = value; } else if (fieldType === 'bool') { if (typeof value !== 'boolean') { throw new Error(`fromProto3JSONToInternalRepresentation: field ${key} of type ${field.type} cannot contain value ${value}`); } result[key] = value; } else if (fieldType === 'bytes') { if (typeof value !== 'string') { throw new Error(`fromProto3JSONToInternalRepresentation: field ${key} of type ${field.type} cannot contain value ${value}`); } result[key] = (0, bytes_1.bytesFromProto3JSON)(value); } else { // Message type (0, util_1.assert)(resolvedType !== null, `Expected to be able to resolve type for field ${field.name}`); const deserializedValue = fromProto3JSONToInternalRepresentation(resolvedType, value); result[key] = deserializedValue; } } return result; } exports.fromProto3JSONToInternalRepresentation = fromProto3JSONToInternalRepresentation; function fromProto3JSON(type, json) { const internalRepr = fromProto3JSONToInternalRepresentation(type, json); if (internalRepr === null) { return null; } // We only expect a real object here sine all special cases should be already resolved. Everything else is an internal error (0, util_1.assert)(typeof internalRepr === 'object' && !Array.isArray(internalRepr), `fromProto3JSON: expected an object, not ${json}`); return type.fromObject(internalRepr); } exports.fromProto3JSON = fromProto3JSON; //# sourceMappingURL=fromproto3json.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/wrappers.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/wrappers.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.wrapperFromProto3JSON = exports.wrapperToProto3JSON = void 0; const bytes_1 = require("./bytes"); const util_1 = require("./util"); function wrapperToProto3JSON(obj) { if (!Object.prototype.hasOwnProperty.call(obj, 'value')) { return null; } if (Buffer.isBuffer(obj.value) || obj.value instanceof Uint8Array) { return (0, bytes_1.bytesToProto3JSON)(obj.value); } if (typeof obj.value === 'object') { (0, util_1.assert)(obj.value.constructor.name === 'Long', `wrapperToProto3JSON: expected to see a number, a string, a boolean, or a Long, but got ${obj.value}`); return obj.value.toString(); } // JSON accept special string values "NaN", "Infinity", and "-Infinity". if (typeof obj.value === 'number' && !Number.isFinite(obj.value)) { return obj.value.toString(); } return obj.value; } exports.wrapperToProto3JSON = wrapperToProto3JSON; function wrapperFromProto3JSON(typeName, json) { if (json === null) { return { value: null, }; } if (typeName === '.google.protobuf.BytesValue') { if (typeof json !== 'string') { throw new Error(`numberWrapperFromProto3JSON: expected to get a string for google.protobuf.BytesValue but got ${typeof json}`); } return { value: (0, bytes_1.bytesFromProto3JSON)(json), }; } return { value: json, }; } exports.wrapperFromProto3JSON = wrapperFromProto3JSON; //# sourceMappingURL=wrappers.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/value.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/value.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.googleProtobufValueFromProto3JSON = exports.googleProtobufListValueFromProto3JSON = exports.googleProtobufStructFromProto3JSON = exports.googleProtobufValueToProto3JSON = exports.googleProtobufListValueToProto3JSON = exports.googleProtobufStructToProto3JSON = void 0; const util_1 = require("./util"); function googleProtobufStructToProto3JSON(obj) { const result = {}; const fields = obj.fields; for (const [key, value] of Object.entries(fields)) { result[key] = googleProtobufValueToProto3JSON(value); } return result; } exports.googleProtobufStructToProto3JSON = googleProtobufStructToProto3JSON; function googleProtobufListValueToProto3JSON(obj) { (0, util_1.assert)(Array.isArray(obj.values), 'ListValue internal representation must contain array of values'); return obj.values.map(googleProtobufValueToProto3JSON); } exports.googleProtobufListValueToProto3JSON = googleProtobufListValueToProto3JSON; function googleProtobufValueToProto3JSON(obj) { if (Object.prototype.hasOwnProperty.call(obj, 'nullValue')) { return null; } if (Object.prototype.hasOwnProperty.call(obj, 'numberValue') && typeof obj.numberValue === 'number') { if (!Number.isFinite(obj.numberValue)) { return obj.numberValue.toString(); } return obj.numberValue; } if (Object.prototype.hasOwnProperty.call(obj, 'stringValue') && typeof obj.stringValue === 'string') { return obj.stringValue; } if (Object.prototype.hasOwnProperty.call(obj, 'boolValue') && typeof obj.boolValue === 'boolean') { return obj.boolValue; } if (Object.prototype.hasOwnProperty.call(obj, 'structValue') && typeof obj.structValue === 'object') { return googleProtobufStructToProto3JSON(obj.structValue); } if (Object.prototype.hasOwnProperty.call(obj, 'listValue') && typeof obj === 'object' && typeof obj.listValue === 'object') { return googleProtobufListValueToProto3JSON(obj.listValue); } // Assuming empty Value to be null return null; } exports.googleProtobufValueToProto3JSON = googleProtobufValueToProto3JSON; function googleProtobufStructFromProto3JSON(json) { const fields = {}; for (const [key, value] of Object.entries(json)) { fields[key] = googleProtobufValueFromProto3JSON(value); } return { fields }; } exports.googleProtobufStructFromProto3JSON = googleProtobufStructFromProto3JSON; function googleProtobufListValueFromProto3JSON(json) { return { values: json.map(element => googleProtobufValueFromProto3JSON(element)), }; } exports.googleProtobufListValueFromProto3JSON = googleProtobufListValueFromProto3JSON; function googleProtobufValueFromProto3JSON(json) { if (json === null) { return { nullValue: 'NULL_VALUE' }; } if (typeof json === 'number') { return { numberValue: json }; } if (typeof json === 'string') { return { stringValue: json }; } if (typeof json === 'boolean') { return { boolValue: json }; } if (Array.isArray(json)) { return { listValue: googleProtobufListValueFromProto3JSON(json), }; } if (typeof json === 'object') { return { structValue: googleProtobufStructFromProto3JSON(json), }; } throw new Error(`googleProtobufValueFromProto3JSON: incorrect parameter type: ${typeof json}`); } exports.googleProtobufValueFromProto3JSON = googleProtobufValueFromProto3JSON; //# sourceMappingURL=value.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/duration.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/duration.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.googleProtobufDurationFromProto3JSON = exports.googleProtobufDurationToProto3JSON = void 0; function googleProtobufDurationToProto3JSON(obj) { // seconds is an instance of Long so it won't be undefined let durationSeconds = obj.seconds.toString(); if (typeof obj.nanos === 'number' && obj.nanos > 0) { // nanosStr should contain 3, 6, or 9 fractional digits. const nanosStr = obj.nanos .toString() .padStart(9, '0') .replace(/^((?:\d\d\d)+?)(?:0*)$/, '$1'); durationSeconds += '.' + nanosStr; } durationSeconds += 's'; return durationSeconds; } exports.googleProtobufDurationToProto3JSON = googleProtobufDurationToProto3JSON; function googleProtobufDurationFromProto3JSON(json) { const match = json.match(/^(\d*)(?:\.(\d*))?s$/); if (!match) { throw new Error(`googleProtobufDurationFromProto3JSON: incorrect value ${json} passed as google.protobuf.Duration`); } let seconds = 0; let nanos = 0; if (typeof match[1] === 'string' && match[1].length > 0) { seconds = parseInt(match[1]); } if (typeof match[2] === 'string' && match[2].length > 0) { nanos = parseInt(match[2].padEnd(9, '0')); } const result = {}; if (seconds !== 0) { result.seconds = seconds; } if (nanos !== 0) { result.nanos = nanos; } return result; } exports.googleProtobufDurationFromProto3JSON = googleProtobufDurationFromProto3JSON; //# sourceMappingURL=duration.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/util.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/util.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.assert = exports.wrapperTypes = exports.getFullyQualifiedTypeName = void 0; function getFullyQualifiedTypeName(type) { // We assume that the protobuf package tree cannot have cycles. let fullyQualifiedTypeName = ''; while (type.parent) { fullyQualifiedTypeName = `.${type.name}${fullyQualifiedTypeName}`; type = type.parent; } return fullyQualifiedTypeName; } exports.getFullyQualifiedTypeName = getFullyQualifiedTypeName; exports.wrapperTypes = new Set([ '.google.protobuf.DoubleValue', '.google.protobuf.FloatValue', '.google.protobuf.Int64Value', '.google.protobuf.UInt64Value', '.google.protobuf.Int32Value', '.google.protobuf.UInt32Value', '.google.protobuf.BoolValue', '.google.protobuf.StringValue', '.google.protobuf.BytesValue', ]); function assert(assertion, message) { if (!assertion) { throw new Error(message); } } exports.assert = assert; //# sourceMappingURL=util.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/proto3-json-serializer/build/src/timestamp.js
aws/lti-middleware/node_modules/proto3-json-serializer/build/src/timestamp.js
"use strict"; // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.googleProtobufTimestampFromProto3JSON = exports.googleProtobufTimestampToProto3JSON = void 0; function googleProtobufTimestampToProto3JSON(obj) { var _a; // seconds is an instance of Long so it won't be undefined const durationSeconds = obj.seconds; const date = new Date(durationSeconds * 1000).toISOString(); // Pad leading zeros if nano string length is less than 9. let nanos = (_a = obj.nanos) === null || _a === void 0 ? void 0 : _a.toString().padStart(9, '0'); // Trim the unsignificant zeros and keep 3, 6, or 9 decimal digits. while (nanos && nanos.length > 3 && nanos.endsWith('000')) { nanos = nanos.slice(0, -3); } return date.replace(/(?:\.\d{0,9})/, '.' + nanos); } exports.googleProtobufTimestampToProto3JSON = googleProtobufTimestampToProto3JSON; function googleProtobufTimestampFromProto3JSON(json) { const match = json.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?/); if (!match) { throw new Error(`googleProtobufDurationFromProto3JSON: incorrect value ${json} passed as google.protobuf.Duration`); } const date = new Date(json); const millisecondsSinceEpoch = date.getTime(); const seconds = Math.floor(millisecondsSinceEpoch / 1000); // The fractional seconds in the JSON timestamps can go up to 9 digits (i.e. up to 1 nanosecond resolution). // However, Javascript Date object represent any date and time to millisecond precision. // To keep the precision, we extract the fractional seconds and append 0 until the length is equal to 9. let nanos = 0; const secondsFromDate = json.split('.')[1]; if (secondsFromDate) { nanos = parseInt(secondsFromDate.slice(0, -1).padEnd(9, '0')); } const result = {}; if (seconds !== 0) { result.seconds = seconds; } if (nanos !== 0) { result.nanos = nanos; } return result; } exports.googleProtobufTimestampFromProto3JSON = googleProtobufTimestampFromProto3JSON; //# sourceMappingURL=timestamp.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/media-typer/index.js
aws/lti-middleware/node_modules/media-typer/index.js
/*! * media-typer * Copyright(c) 2014 Douglas Christopher Wilson * MIT Licensed */ /** * RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7 * * parameter = token "=" ( token | quoted-string ) * token = 1*<any CHAR except CTLs or separators> * separators = "(" | ")" | "<" | ">" | "@" * | "," | ";" | ":" | "\" | <"> * | "/" | "[" | "]" | "?" | "=" * | "{" | "}" | SP | HT * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) * qdtext = <any TEXT except <">> * quoted-pair = "\" CHAR * CHAR = <any US-ASCII character (octets 0 - 127)> * TEXT = <any OCTET except CTLs, but including LWS> * LWS = [CRLF] 1*( SP | HT ) * CRLF = CR LF * CR = <US-ASCII CR, carriage return (13)> * LF = <US-ASCII LF, linefeed (10)> * SP = <US-ASCII SP, space (32)> * SHT = <US-ASCII HT, horizontal-tab (9)> * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)> * OCTET = <any 8-bit sequence of data> */ var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g; var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/ var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ /** * RegExp to match quoted-pair in RFC 2616 * * quoted-pair = "\" CHAR * CHAR = <any US-ASCII character (octets 0 - 127)> */ var qescRegExp = /\\([\u0000-\u007f])/g; /** * RegExp to match chars that must be quoted-pair in RFC 2616 */ var quoteRegExp = /([\\"])/g; /** * RegExp to match type in RFC 6838 * * type-name = restricted-name * subtype-name = restricted-name * restricted-name = restricted-name-first *126restricted-name-chars * restricted-name-first = ALPHA / DIGIT * restricted-name-chars = ALPHA / DIGIT / "!" / "#" / * "$" / "&" / "-" / "^" / "_" * restricted-name-chars =/ "." ; Characters before first dot always * ; specify a facet name * restricted-name-chars =/ "+" ; Characters after last plus always * ; specify a structured syntax suffix * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z * DIGIT = %x30-39 ; 0-9 */ var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/ var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/ var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/; /** * Module exports. */ exports.format = format exports.parse = parse /** * Format object to media type. * * @param {object} obj * @return {string} * @api public */ function format(obj) { if (!obj || typeof obj !== 'object') { throw new TypeError('argument obj is required') } var parameters = obj.parameters var subtype = obj.subtype var suffix = obj.suffix var type = obj.type if (!type || !typeNameRegExp.test(type)) { throw new TypeError('invalid type') } if (!subtype || !subtypeNameRegExp.test(subtype)) { throw new TypeError('invalid subtype') } // format as type/subtype var string = type + '/' + subtype // append +suffix if (suffix) { if (!typeNameRegExp.test(suffix)) { throw new TypeError('invalid suffix') } string += '+' + suffix } // append parameters if (parameters && typeof parameters === 'object') { var param var params = Object.keys(parameters).sort() for (var i = 0; i < params.length; i++) { param = params[i] if (!tokenRegExp.test(param)) { throw new TypeError('invalid parameter name') } string += '; ' + param + '=' + qstring(parameters[param]) } } return string } /** * Parse media type to object. * * @param {string|object} string * @return {Object} * @api public */ function parse(string) { if (!string) { throw new TypeError('argument string is required') } // support req/res-like objects as argument if (typeof string === 'object') { string = getcontenttype(string) } if (typeof string !== 'string') { throw new TypeError('argument string is required to be a string') } var index = string.indexOf(';') var type = index !== -1 ? string.substr(0, index) : string var key var match var obj = splitType(type) var params = {} var value paramRegExp.lastIndex = index while (match = paramRegExp.exec(string)) { if (match.index !== index) { throw new TypeError('invalid parameter format') } index += match[0].length key = match[1].toLowerCase() value = match[2] if (value[0] === '"') { // remove quotes and escapes value = value .substr(1, value.length - 2) .replace(qescRegExp, '$1') } params[key] = value } if (index !== -1 && index !== string.length) { throw new TypeError('invalid parameter format') } obj.parameters = params return obj } /** * Get content-type from req/res objects. * * @param {object} * @return {Object} * @api private */ function getcontenttype(obj) { if (typeof obj.getHeader === 'function') { // res-like return obj.getHeader('content-type') } if (typeof obj.headers === 'object') { // req-like return obj.headers && obj.headers['content-type'] } } /** * Quote a string if necessary. * * @param {string} val * @return {string} * @api private */ function qstring(val) { var str = String(val) // no need to quote tokens if (tokenRegExp.test(str)) { return str } if (str.length > 0 && !textRegExp.test(str)) { throw new TypeError('invalid parameter value') } return '"' + str.replace(quoteRegExp, '\\$1') + '"' } /** * Simply "type/subtype+siffx" into parts. * * @param {string} string * @return {Object} * @api private */ function splitType(string) { var match = typeRegExp.exec(string.toLowerCase()) if (!match) { throw new TypeError('invalid media type') } var type = match[1] var subtype = match[2] var suffix // suffix after last + var index = subtype.lastIndexOf('+') if (index !== -1) { suffix = subtype.substr(index + 1) subtype = subtype.substr(0, index) } var obj = { type: type, subtype: subtype, suffix: suffix } return obj }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/fast-text-encoding/externs.js
aws/lti-middleware/node_modules/fast-text-encoding/externs.js
/** * @constructor */ var Buffer; /** * @param {!ArrayBuffer} raw * @param {number} byteOffset * @param {number} byteLength * @return {!Buffer} */ Buffer.from = function(raw, byteOffset, byteLength) {}; /** * @this {*} * @param {string} encoding * @return {string} */ Buffer.prototype.toString = function(encoding) {};
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/fast-text-encoding/text.min.js
aws/lti-middleware/node_modules/fast-text-encoding/text.min.js
(function(l){function m(){}function k(a,c){a=void 0===a?"utf-8":a;c=void 0===c?{fatal:!1}:c;if(-1===r.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}function t(a){return Buffer.from(a.buffer,a.byteOffset,a.byteLength).toString("utf-8")}function u(a){try{var c=URL.createObjectURL(new Blob([a],{type:"text/plain;charset=UTF-8"})); var f=new XMLHttpRequest;f.open("GET",c,!1);f.send();return f.responseText}catch(e){return q(a)}finally{c&&URL.revokeObjectURL(c)}}function q(a){for(var c=0,f=Math.min(65536,a.length+1),e=new Uint16Array(f),h=[],d=0;;){var b=c<a.length;if(!b||d>=f-1){h.push(String.fromCharCode.apply(null,e.subarray(0,d)));if(!b)return h.join("");a=a.subarray(c);d=c=0}b=a[c++];if(0===(b&128))e[d++]=b;else if(192===(b&224)){var g=a[c++]&63;e[d++]=(b&31)<<6|g}else if(224===(b&240)){g=a[c++]&63;var n=a[c++]&63;e[d++]= (b&31)<<12|g<<6|n}else if(240===(b&248)){g=a[c++]&63;n=a[c++]&63;var v=a[c++]&63;b=(b&7)<<18|g<<12|n<<6|v;65535<b&&(b-=65536,e[d++]=b>>>10&1023|55296,b=56320|b&1023);e[d++]=b}}}if(l.TextEncoder&&l.TextDecoder)return!1;var r=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var f=a.length,e=0,h=Math.max(32, f+(f>>>1)+7),d=new Uint8Array(h>>>3<<3);c<f;){var b=a.charCodeAt(c++);if(55296<=b&&56319>=b){if(c<f){var g=a.charCodeAt(c);56320===(g&64512)&&(++c,b=((b&1023)<<10)+(g&1023)+65536)}if(55296<=b&&56319>=b)continue}e+4>d.length&&(h+=8,h*=1+c/a.length*2,h=h>>>3<<3,g=new Uint8Array(h),g.set(d),d=g);if(0===(b&4294967168))d[e++]=b;else{if(0===(b&4294965248))d[e++]=b>>>6&31|192;else if(0===(b&4294901760))d[e++]=b>>>12&15|224,d[e++]=b>>>6&63|128;else if(0===(b&4292870144))d[e++]=b>>>18&7|240,d[e++]=b>>>12& 63|128,d[e++]=b>>>6&63|128;else continue;d[e++]=b&63|128}}return d.slice?d.slice(0,e):d.subarray(0,e)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});var p=q;"function"===typeof Buffer&&Buffer.from?p=t:"function"===typeof Blob&&"function"===typeof URL&&"function"===typeof URL.createObjectURL&&(p=u);k.prototype.decode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to decode: the 'stream' option is unsupported."); a=a instanceof Uint8Array?a:a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer):new Uint8Array(a);return p(a)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this);
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/fast-text-encoding/text.js
aws/lti-middleware/node_modules/fast-text-encoding/text.js
/* * Copyright 2017 Sam Thorogood. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ /** * @fileoverview Polyfill for TextEncoder and TextDecoder. * * You probably want `text.min.js`, and not this file directly. */ (function(scope) { 'use strict'; // fail early if (scope['TextEncoder'] && scope['TextDecoder']) { return false; } // used for FastTextDecoder const validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8']; /** * @constructor */ function FastTextEncoder() { // This does not accept an encoding, and always uses UTF-8: // https://www.w3.org/TR/encoding/#dom-textencoder } Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'}); /** * @param {string} string * @param {{stream: boolean}=} options * @return {!Uint8Array} */ FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) { if (options.stream) { throw new Error(`Failed to encode: the 'stream' option is unsupported.`); } let pos = 0; const len = string.length; let at = 0; // output position let tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size let target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset while (pos < len) { let value = string.charCodeAt(pos++); if (value >= 0xd800 && value <= 0xdbff) { // high surrogate if (pos < len) { const extra = string.charCodeAt(pos); if ((extra & 0xfc00) === 0xdc00) { ++pos; value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000; } } if (value >= 0xd800 && value <= 0xdbff) { continue; // drop lone surrogate } } // expand the buffer if we couldn't write 4 bytes if (at + 4 > target.length) { tlen += 8; // minimum extra tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining tlen = (tlen >>> 3) << 3; // 8 byte offset const update = new Uint8Array(tlen); update.set(target); target = update; } if ((value & 0xffffff80) === 0) { // 1-byte target[at++] = value; // ASCII continue; } else if ((value & 0xfffff800) === 0) { // 2-byte target[at++] = ((value >>> 6) & 0x1f) | 0xc0; } else if ((value & 0xffff0000) === 0) { // 3-byte target[at++] = ((value >>> 12) & 0x0f) | 0xe0; target[at++] = ((value >>> 6) & 0x3f) | 0x80; } else if ((value & 0xffe00000) === 0) { // 4-byte target[at++] = ((value >>> 18) & 0x07) | 0xf0; target[at++] = ((value >>> 12) & 0x3f) | 0x80; target[at++] = ((value >>> 6) & 0x3f) | 0x80; } else { continue; // out of range } target[at++] = (value & 0x3f) | 0x80; } // Use subarray if slice isn't supported (IE11). This will use more memory // because the original array still exists. return target.slice ? target.slice(0, at) : target.subarray(0, at); } /** * @constructor * @param {string=} utfLabel * @param {{fatal: boolean}=} options */ function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) { if (validUtfLabels.indexOf(utfLabel.toLowerCase()) === -1) { throw new RangeError( `Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`); } if (options.fatal) { throw new Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`); } } Object.defineProperty(FastTextDecoder.prototype, 'encoding', {value: 'utf-8'}); Object.defineProperty(FastTextDecoder.prototype, 'fatal', {value: false}); Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false}); /** * @param {!Uint8Array} bytes * @return {string} */ function decodeBuffer(bytes) { return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('utf-8'); } /** * @param {!Uint8Array} bytes * @return {string} */ function decodeSyncXHR(bytes) { let u; // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and // possibly in other places), so ensure there's a fallback call. try { const b = new Blob([bytes], {type: 'text/plain;charset=UTF-8'}); u = URL.createObjectURL(b); const x = new XMLHttpRequest(); x.open('GET', u, false); x.send(); return x.responseText; } catch (e) { return decodeFallback(bytes); } finally { if (u) { URL.revokeObjectURL(u); } } } /** * @param {!Uint8Array} bytes * @return {string} */ function decodeFallback(bytes) { let inputIndex = 0; // Create a working buffer for UTF-16 code points, but don't generate one // which is too large for small input sizes. UTF-8 to UCS-16 conversion is // going to be at most 1:1, if all code points are ASCII. The other extreme // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50% // fewer entries in the output. const pendingSize = Math.min(256 * 256, bytes.length + 1); const pending = new Uint16Array(pendingSize); const chunks = []; let pendingIndex = 0; for (;;) { const more = inputIndex < bytes.length; // If there's no more data or there'd be no room for two UTF-16 values, // create a chunk. This isn't done at the end by simply slicing the data // into equal sized chunks as we might hit a surrogate pair. if (!more || (pendingIndex >= pendingSize - 1)) { // nb. .apply and friends are *really slow*. Low-hanging fruit is to // expand this to literally pass pending[0], pending[1], ... etc, but // the output code expands pretty fast in this case. chunks.push(String.fromCharCode.apply(null, pending.subarray(0, pendingIndex))); if (!more) { return chunks.join(''); } // Move the buffer forward and create another chunk. bytes = bytes.subarray(inputIndex); inputIndex = 0; pendingIndex = 0; } // The native TextDecoder will generate "REPLACEMENT CHARACTER" where the // input data is invalid. Here, we blindly parse the data even if it's // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations. const byte1 = bytes[inputIndex++]; if ((byte1 & 0x80) === 0) { // 1-byte or null pending[pendingIndex++] = byte1; } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte const byte2 = bytes[inputIndex++] & 0x3f; pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2; } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte const byte2 = bytes[inputIndex++] & 0x3f; const byte3 = bytes[inputIndex++] & 0x3f; pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3; } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte const byte2 = bytes[inputIndex++] & 0x3f; const byte3 = bytes[inputIndex++] & 0x3f; const byte4 = bytes[inputIndex++] & 0x3f; // this can be > 0xffff, so possibly generate surrogates let codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4; if (codepoint > 0xffff) { // codepoint &= ~0x10000; codepoint -= 0x10000; pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800; codepoint = 0xdc00 | codepoint & 0x3ff; } pending[pendingIndex++] = codepoint; } else { // invalid initial byte } } } // Decoding a string is pretty slow, but use alternative options where possible. let decodeImpl = decodeFallback; if (typeof Buffer === 'function' && Buffer.from) { // Buffer.from was added in Node v5.10.0 (2015-11-17). decodeImpl = decodeBuffer; } else if (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function') { // Blob and URL.createObjectURL are available from IE10, Safari 6, Chrome 19 // (all released in 2012), Firefox 19 (2013), ... decodeImpl = decodeSyncXHR; } /** * @param {(!ArrayBuffer|!ArrayBufferView)} buffer * @param {{stream: boolean}=} options * @return {string} */ FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) { if (options['stream']) { throw new Error(`Failed to decode: the 'stream' option is unsupported.`); } let bytes; if (buffer instanceof Uint8Array) { // Accept Uint8Array instances as-is. bytes = buffer; } else if (buffer.buffer instanceof ArrayBuffer) { // Look for ArrayBufferView, which isn't a real type, but basically // represents all the valid TypedArray types plus DataView. They all have // ".buffer" as an instance of ArrayBuffer. bytes = new Uint8Array(buffer.buffer); } else { // The only other valid argument here is that "buffer" is an ArrayBuffer. // We also try to convert anything else passed to a Uint8Array, as this // catches anything that's array-like. Native code would throw here. bytes = new Uint8Array(buffer); } return decodeImpl(/** @type {!Uint8Array} */ (bytes)); } scope['TextEncoder'] = FastTextEncoder; scope['TextDecoder'] = FastTextDecoder; }(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/v4.js
aws/lti-middleware/node_modules/uuid/dist/v4.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _rng = _interopRequireDefault(require("./rng.js")); var _stringify = _interopRequireDefault(require("./stringify.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function v4(options, buf, offset) { options = options || {}; const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return (0, _stringify.default)(rnds); } var _default = v4; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/md5-browser.js
aws/lti-middleware/node_modules/uuid/dist/md5-browser.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; /* * Browser-compatible JavaScript MD5 * * Modification of JavaScript MD5 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * https://opensource.org/licenses/MIT * * Based on * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ function md5(bytes) { if (typeof bytes === 'string') { const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape bytes = new Uint8Array(msg.length); for (let i = 0; i < msg.length; ++i) { bytes[i] = msg.charCodeAt(i); } } return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8)); } /* * Convert an array of little-endian words to an array of bytes */ function md5ToHexEncodedArray(input) { const output = []; const length32 = input.length * 32; const hexTab = '0123456789abcdef'; for (let i = 0; i < length32; i += 8) { const x = input[i >> 5] >>> i % 32 & 0xff; const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16); output.push(hex); } return output; } /** * Calculate output length with padding and bit length */ function getOutputLength(inputLength8) { return (inputLength8 + 64 >>> 9 << 4) + 14 + 1; } /* * Calculate the MD5 of an array of little-endian words, and a bit length. */ function wordsToMd5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << len % 32; x[getOutputLength(len) - 1] = len; let a = 1732584193; let b = -271733879; let c = -1732584194; let d = 271733878; for (let i = 0; i < x.length; i += 16) { const olda = a; const oldb = b; const oldc = c; const oldd = d; a = md5ff(a, b, c, d, x[i], 7, -680876936); d = md5ff(d, a, b, c, x[i + 1], 12, -389564586); c = md5ff(c, d, a, b, x[i + 2], 17, 606105819); b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330); a = md5ff(a, b, c, d, x[i + 4], 7, -176418897); d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426); c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341); b = md5ff(b, c, d, a, x[i + 7], 22, -45705983); a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416); d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417); c = md5ff(c, d, a, b, x[i + 10], 17, -42063); b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162); a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682); d = md5ff(d, a, b, c, x[i + 13], 12, -40341101); c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290); b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329); a = md5gg(a, b, c, d, x[i + 1], 5, -165796510); d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632); c = md5gg(c, d, a, b, x[i + 11], 14, 643717713); b = md5gg(b, c, d, a, x[i], 20, -373897302); a = md5gg(a, b, c, d, x[i + 5], 5, -701558691); d = md5gg(d, a, b, c, x[i + 10], 9, 38016083); c = md5gg(c, d, a, b, x[i + 15], 14, -660478335); b = md5gg(b, c, d, a, x[i + 4], 20, -405537848); a = md5gg(a, b, c, d, x[i + 9], 5, 568446438); d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690); c = md5gg(c, d, a, b, x[i + 3], 14, -187363961); b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501); a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467); d = md5gg(d, a, b, c, x[i + 2], 9, -51403784); c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473); b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734); a = md5hh(a, b, c, d, x[i + 5], 4, -378558); d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463); c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562); b = md5hh(b, c, d, a, x[i + 14], 23, -35309556); a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060); d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353); c = md5hh(c, d, a, b, x[i + 7], 16, -155497632); b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640); a = md5hh(a, b, c, d, x[i + 13], 4, 681279174); d = md5hh(d, a, b, c, x[i], 11, -358537222); c = md5hh(c, d, a, b, x[i + 3], 16, -722521979); b = md5hh(b, c, d, a, x[i + 6], 23, 76029189); a = md5hh(a, b, c, d, x[i + 9], 4, -640364487); d = md5hh(d, a, b, c, x[i + 12], 11, -421815835); c = md5hh(c, d, a, b, x[i + 15], 16, 530742520); b = md5hh(b, c, d, a, x[i + 2], 23, -995338651); a = md5ii(a, b, c, d, x[i], 6, -198630844); d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415); c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905); b = md5ii(b, c, d, a, x[i + 5], 21, -57434055); a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571); d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606); c = md5ii(c, d, a, b, x[i + 10], 15, -1051523); b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799); a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359); d = md5ii(d, a, b, c, x[i + 15], 10, -30611744); c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380); b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649); a = md5ii(a, b, c, d, x[i + 4], 6, -145523070); d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379); c = md5ii(c, d, a, b, x[i + 2], 15, 718787259); b = md5ii(b, c, d, a, x[i + 9], 21, -343485551); a = safeAdd(a, olda); b = safeAdd(b, oldb); c = safeAdd(c, oldc); d = safeAdd(d, oldd); } return [a, b, c, d]; } /* * Convert an array bytes to an array of little-endian words * Characters >255 have their high-byte silently ignored. */ function bytesToWords(input) { if (input.length === 0) { return []; } const length8 = input.length * 8; const output = new Uint32Array(getOutputLength(length8)); for (let i = 0; i < length8; i += 8) { output[i >> 5] |= (input[i / 8] & 0xff) << i % 32; } return output; } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safeAdd(x, y) { const lsw = (x & 0xffff) + (y & 0xffff); const msw = (x >> 16) + (y >> 16) + (lsw >> 16); return msw << 16 | lsw & 0xffff; } /* * Bitwise rotate a 32-bit number to the left. */ function bitRotateLeft(num, cnt) { return num << cnt | num >>> 32 - cnt; } /* * These functions implement the four basic operations the algorithm uses. */ function md5cmn(q, a, b, x, s, t) { return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b); } function md5ff(a, b, c, d, x, s, t) { return md5cmn(b & c | ~b & d, a, b, x, s, t); } function md5gg(a, b, c, d, x, s, t) { return md5cmn(b & d | c & ~d, a, b, x, s, t); } function md5hh(a, b, c, d, x, s, t) { return md5cmn(b ^ c ^ d, a, b, x, s, t); } function md5ii(a, b, c, d, x, s, t) { return md5cmn(c ^ (b | ~d), a, b, x, s, t); } var _default = md5; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/rng-browser.js
aws/lti-middleware/node_modules/uuid/dist/rng-browser.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = rng; // Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). let getRandomValues; const rnds8 = new Uint8Array(16); function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, // find the complete implementation of crypto (msCrypto) on IE11. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/rng.js
aws/lti-middleware/node_modules/uuid/dist/rng.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = rng; var _crypto = _interopRequireDefault(require("crypto")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate let poolPtr = rnds8Pool.length; function rng() { if (poolPtr > rnds8Pool.length - 16) { _crypto.default.randomFillSync(rnds8Pool); poolPtr = 0; } return rnds8Pool.slice(poolPtr, poolPtr += 16); }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/md5.js
aws/lti-middleware/node_modules/uuid/dist/md5.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _crypto = _interopRequireDefault(require("crypto")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function md5(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === 'string') { bytes = Buffer.from(bytes, 'utf8'); } return _crypto.default.createHash('md5').update(bytes).digest(); } var _default = md5; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/nil.js
aws/lti-middleware/node_modules/uuid/dist/nil.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _default = '00000000-0000-0000-0000-000000000000'; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/index.js
aws/lti-middleware/node_modules/uuid/dist/index.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return _v.default; } }); Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return _v2.default; } }); Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return _v3.default; } }); Object.defineProperty(exports, "v5", { enumerable: true, get: function () { return _v4.default; } }); Object.defineProperty(exports, "NIL", { enumerable: true, get: function () { return _nil.default; } }); Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version.default; } }); Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return _validate.default; } }); Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return _stringify.default; } }); Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return _parse.default; } }); var _v = _interopRequireDefault(require("./v1.js")); var _v2 = _interopRequireDefault(require("./v3.js")); var _v3 = _interopRequireDefault(require("./v4.js")); var _v4 = _interopRequireDefault(require("./v5.js")); var _nil = _interopRequireDefault(require("./nil.js")); var _version = _interopRequireDefault(require("./version.js")); var _validate = _interopRequireDefault(require("./validate.js")); var _stringify = _interopRequireDefault(require("./stringify.js")); var _parse = _interopRequireDefault(require("./parse.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/v35.js
aws/lti-middleware/node_modules/uuid/dist/v35.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; exports.URL = exports.DNS = void 0; var _stringify = _interopRequireDefault(require("./stringify.js")); var _parse = _interopRequireDefault(require("./parse.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function stringToBytes(str) { str = unescape(encodeURIComponent(str)); // UTF8 escape const bytes = []; for (let i = 0; i < str.length; ++i) { bytes.push(str.charCodeAt(i)); } return bytes; } const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; exports.DNS = DNS; const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; exports.URL = URL; function _default(name, version, hashfunc) { function generateUUID(value, namespace, buf, offset) { if (typeof value === 'string') { value = stringToBytes(value); } if (typeof namespace === 'string') { namespace = (0, _parse.default)(namespace); } if (namespace.length !== 16) { throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); } // Compute hash of namespace and value, Per 4.3 // Future: Use spread syntax when supported on all platforms, e.g. `bytes = // hashfunc([...namespace, ... value])` let bytes = new Uint8Array(16 + value.length); bytes.set(namespace); bytes.set(value, namespace.length); bytes = hashfunc(bytes); bytes[6] = bytes[6] & 0x0f | version; bytes[8] = bytes[8] & 0x3f | 0x80; if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = bytes[i]; } return buf; } return (0, _stringify.default)(bytes); } // Function#name is not settable on some platforms (#270) try { generateUUID.name = name; // eslint-disable-next-line no-empty } catch (err) {} // For CommonJS default export support generateUUID.DNS = DNS; generateUUID.URL = URL; return generateUUID; }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/v3.js
aws/lti-middleware/node_modules/uuid/dist/v3.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _v = _interopRequireDefault(require("./v35.js")); var _md = _interopRequireDefault(require("./md5.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const v3 = (0, _v.default)('v3', 0x30, _md.default); var _default = v3; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/parse.js
aws/lti-middleware/node_modules/uuid/dist/parse.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _validate = _interopRequireDefault(require("./validate.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function parse(uuid) { if (!(0, _validate.default)(uuid)) { throw TypeError('Invalid UUID'); } let v; const arr = new Uint8Array(16); // Parse ########-....-....-....-............ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; arr[1] = v >>> 16 & 0xff; arr[2] = v >>> 8 & 0xff; arr[3] = v & 0xff; // Parse ........-####-....-....-............ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; arr[5] = v & 0xff; // Parse ........-....-####-....-............ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; arr[7] = v & 0xff; // Parse ........-....-....-####-............ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; arr[9] = v & 0xff; // Parse ........-....-....-....-############ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; arr[11] = v / 0x100000000 & 0xff; arr[12] = v >>> 24 & 0xff; arr[13] = v >>> 16 & 0xff; arr[14] = v >>> 8 & 0xff; arr[15] = v & 0xff; return arr; } var _default = parse; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/uuid-bin.js
aws/lti-middleware/node_modules/uuid/dist/uuid-bin.js
"use strict"; var _assert = _interopRequireDefault(require("assert")); var _v = _interopRequireDefault(require("./v1.js")); var _v2 = _interopRequireDefault(require("./v3.js")); var _v3 = _interopRequireDefault(require("./v4.js")); var _v4 = _interopRequireDefault(require("./v5.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function usage() { console.log('Usage:'); console.log(' uuid'); console.log(' uuid v1'); console.log(' uuid v3 <name> <namespace uuid>'); console.log(' uuid v4'); console.log(' uuid v5 <name> <namespace uuid>'); console.log(' uuid --help'); console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC4122'); } const args = process.argv.slice(2); if (args.indexOf('--help') >= 0) { usage(); process.exit(0); } const version = args.shift() || 'v4'; switch (version) { case 'v1': console.log((0, _v.default)()); break; case 'v3': { const name = args.shift(); let namespace = args.shift(); (0, _assert.default)(name != null, 'v3 name not specified'); (0, _assert.default)(namespace != null, 'v3 namespace not specified'); if (namespace === 'URL') { namespace = _v2.default.URL; } if (namespace === 'DNS') { namespace = _v2.default.DNS; } console.log((0, _v2.default)(name, namespace)); break; } case 'v4': console.log((0, _v3.default)()); break; case 'v5': { const name = args.shift(); let namespace = args.shift(); (0, _assert.default)(name != null, 'v5 name not specified'); (0, _assert.default)(namespace != null, 'v5 namespace not specified'); if (namespace === 'URL') { namespace = _v4.default.URL; } if (namespace === 'DNS') { namespace = _v4.default.DNS; } console.log((0, _v4.default)(name, namespace)); break; } default: usage(); process.exit(1); }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/stringify.js
aws/lti-middleware/node_modules/uuid/dist/stringify.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _validate = _interopRequireDefault(require("./validate.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ const byteToHex = []; for (let i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).substr(1)); } function stringify(arr, offset = 0) { // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one // of the following: // - One or more input array values don't map to a hex octet (leading to // "undefined" in the uuid) // - Invalid input values for the RFC `version` or `variant` fields if (!(0, _validate.default)(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } var _default = stringify; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/version.js
aws/lti-middleware/node_modules/uuid/dist/version.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _validate = _interopRequireDefault(require("./validate.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function version(uuid) { if (!(0, _validate.default)(uuid)) { throw TypeError('Invalid UUID'); } return parseInt(uuid.substr(14, 1), 16); } var _default = version; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/sha1.js
aws/lti-middleware/node_modules/uuid/dist/sha1.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _crypto = _interopRequireDefault(require("crypto")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function sha1(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === 'string') { bytes = Buffer.from(bytes, 'utf8'); } return _crypto.default.createHash('sha1').update(bytes).digest(); } var _default = sha1; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/validate.js
aws/lti-middleware/node_modules/uuid/dist/validate.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _regex = _interopRequireDefault(require("./regex.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function validate(uuid) { return typeof uuid === 'string' && _regex.default.test(uuid); } var _default = validate; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/v1.js
aws/lti-middleware/node_modules/uuid/dist/v1.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _rng = _interopRequireDefault(require("./rng.js")); var _stringify = _interopRequireDefault(require("./stringify.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // **`v1()` - Generate time-based UUID** // // Inspired by https://github.com/LiosK/UUID.js // and http://docs.python.org/library/uuid.html let _nodeId; let _clockseq; // Previous uuid creation time let _lastMSecs = 0; let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details function v1(options, buf, offset) { let i = buf && offset || 0; const b = buf || new Array(16); options = options || {}; let node = options.node || _nodeId; let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not // specified. We do this lazily to minimize issues related to insufficient // system entropy. See #189 if (node == null || clockseq == null) { const seedBytes = options.random || (options.rng || _rng.default)(); if (node == null) { // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } if (clockseq == null) { // Per 4.2.2, randomize (14 bit) clockseq clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; } } // UUID timestamps are 100 nano-second units since the Gregorian epoch, // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock // cycle to simulate higher resolution clock let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression if (dt < 0 && options.clockseq === undefined) { clockseq = clockseq + 1 & 0x3fff; } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new // time interval if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { nsecs = 0; } // Per 4.2.1.2 Throw error if too many uuids are requested if (nsecs >= 10000) { throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); } _lastMSecs = msecs; _lastNSecs = nsecs; _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch msecs += 12219292800000; // `time_low` const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; b[i++] = tl >>> 24 & 0xff; b[i++] = tl >>> 16 & 0xff; b[i++] = tl >>> 8 & 0xff; b[i++] = tl & 0xff; // `time_mid` const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; b[i++] = tmh >>> 8 & 0xff; b[i++] = tmh & 0xff; // `time_high_and_version` b[i++] = tmh >>> 24 & 0xf | 0x10; // include version b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` b[i++] = clockseq & 0xff; // `node` for (let n = 0; n < 6; ++n) { b[i + n] = node[n]; } return buf || (0, _stringify.default)(b); } var _default = v1; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/sha1-browser.js
aws/lti-middleware/node_modules/uuid/dist/sha1-browser.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; // Adapted from Chris Veness' SHA1 code at // http://www.movable-type.co.uk/scripts/sha1.html function f(s, x, y, z) { switch (s) { case 0: return x & y ^ ~x & z; case 1: return x ^ y ^ z; case 2: return x & y ^ x & z ^ y & z; case 3: return x ^ y ^ z; } } function ROTL(x, n) { return x << n | x >>> 32 - n; } function sha1(bytes) { const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; if (typeof bytes === 'string') { const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape bytes = []; for (let i = 0; i < msg.length; ++i) { bytes.push(msg.charCodeAt(i)); } } else if (!Array.isArray(bytes)) { // Convert Array-like to Array bytes = Array.prototype.slice.call(bytes); } bytes.push(0x80); const l = bytes.length / 4 + 2; const N = Math.ceil(l / 16); const M = new Array(N); for (let i = 0; i < N; ++i) { const arr = new Uint32Array(16); for (let j = 0; j < 16; ++j) { arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3]; } M[i] = arr; } M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); M[N - 1][14] = Math.floor(M[N - 1][14]); M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; for (let i = 0; i < N; ++i) { const W = new Uint32Array(80); for (let t = 0; t < 16; ++t) { W[t] = M[i][t]; } for (let t = 16; t < 80; ++t) { W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); } let a = H[0]; let b = H[1]; let c = H[2]; let d = H[3]; let e = H[4]; for (let t = 0; t < 80; ++t) { const s = Math.floor(t / 20); const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0; e = d; d = c; c = ROTL(b, 30) >>> 0; b = a; a = T; } H[0] = H[0] + a >>> 0; H[1] = H[1] + b >>> 0; H[2] = H[2] + c >>> 0; H[3] = H[3] + d >>> 0; H[4] = H[4] + e >>> 0; } return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; } var _default = sha1; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/regex.js
aws/lti-middleware/node_modules/uuid/dist/regex.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/v5.js
aws/lti-middleware/node_modules/uuid/dist/v5.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _v = _interopRequireDefault(require("./v35.js")); var _sha = _interopRequireDefault(require("./sha1.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const v5 = (0, _v.default)('v5', 0x50, _sha.default); var _default = v5; exports.default = _default;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidv4.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidv4.min.js
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).uuidv4=e()}(this,(function(){"use strict";var t,e=new Uint8Array(16);function o(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(e)}var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function r(t){return"string"==typeof t&&n.test(t)}for(var i=[],u=0;u<256;++u)i.push((u+256).toString(16).substr(1));return function(t,e,n){var u=(t=t||{}).random||(t.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,e){n=n||0;for(var f=0;f<16;++f)e[n+f]=u[f];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=(i[t[e+0]]+i[t[e+1]]+i[t[e+2]]+i[t[e+3]]+"-"+i[t[e+4]]+i[t[e+5]]+"-"+i[t[e+6]]+i[t[e+7]]+"-"+i[t[e+8]]+i[t[e+9]]+"-"+i[t[e+10]]+i[t[e+11]]+i[t[e+12]]+i[t[e+13]]+i[t[e+14]]+i[t[e+15]]).toLowerCase();if(!r(o))throw TypeError("Stringified UUID is invalid");return o}(u)}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidv5.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidv5.min.js
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).uuidv5=e()}(this,(function(){"use strict";var r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function e(e){return"string"==typeof e&&r.test(e)}for(var t=[],n=0;n<256;++n)t.push((n+256).toString(16).substr(1));function a(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function o(r,e){return r<<e|r>>>32-e}return function(r,n,a){function o(r,o,i,f){if("string"==typeof r&&(r=function(r){r=unescape(encodeURIComponent(r));for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}(r)),"string"==typeof o&&(o=function(r){if(!e(r))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(r.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(r.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(r.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(r.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(r.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}(o)),16!==o.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+r.length);if(s.set(o),s.set(r,o.length),(s=a(s))[6]=15&s[6]|n,s[8]=63&s[8]|128,i){f=f||0;for(var u=0;u<16;++u)i[f+u]=s[u];return i}return function(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(t[r[n+0]]+t[r[n+1]]+t[r[n+2]]+t[r[n+3]]+"-"+t[r[n+4]]+t[r[n+5]]+"-"+t[r[n+6]]+t[r[n+7]]+"-"+t[r[n+8]]+t[r[n+9]]+"-"+t[r[n+10]]+t[r[n+11]]+t[r[n+12]]+t[r[n+13]]+t[r[n+14]]+t[r[n+15]]).toLowerCase();if(!e(a))throw TypeError("Stringified UUID is invalid");return a}(s)}try{o.name=r}catch(r){}return o.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",o.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",o}("v5",80,(function(r){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof r){var n=unescape(encodeURIComponent(r));r=[];for(var i=0;i<n.length;++i)r.push(n.charCodeAt(i))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var f=r.length/4+2,s=Math.ceil(f/16),u=new Array(s),c=0;c<s;++c){for(var l=new Uint32Array(16),p=0;p<16;++p)l[p]=r[64*c+4*p]<<24|r[64*c+4*p+1]<<16|r[64*c+4*p+2]<<8|r[64*c+4*p+3];u[c]=l}u[s-1][14]=8*(r.length-1)/Math.pow(2,32),u[s-1][14]=Math.floor(u[s-1][14]),u[s-1][15]=8*(r.length-1)&4294967295;for(var d=0;d<s;++d){for(var h=new Uint32Array(80),v=0;v<16;++v)h[v]=u[d][v];for(var y=16;y<80;++y)h[y]=o(h[y-3]^h[y-8]^h[y-14]^h[y-16],1);for(var g=t[0],b=t[1],w=t[2],U=t[3],A=t[4],I=0;I<80;++I){var m=Math.floor(I/20),C=o(g,5)+a(m,b,w,U)+A+e[m]+h[I]>>>0;A=U,U=w,w=o(b,30)>>>0,b=g,g=C}t[0]=t[0]+g>>>0,t[1]=t[1]+b>>>0,t[2]=t[2]+w>>>0,t[3]=t[3]+U>>>0,t[4]=t[4]+A>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,255&t[0],t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,255&t[1],t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,255&t[2],t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,255&t[3],t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,255&t[4]]}))}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuid.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuid.min.js
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).uuid={})}(this,(function(r){"use strict";var e,n=new Uint8Array(16);function t(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(n)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function a(r){return"string"==typeof r&&o.test(r)}for(var i,u,f=[],s=0;s<256;++s)f.push((s+256).toString(16).substr(1));function c(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[r[e+0]]+f[r[e+1]]+f[r[e+2]]+f[r[e+3]]+"-"+f[r[e+4]]+f[r[e+5]]+"-"+f[r[e+6]]+f[r[e+7]]+"-"+f[r[e+8]]+f[r[e+9]]+"-"+f[r[e+10]]+f[r[e+11]]+f[r[e+12]]+f[r[e+13]]+f[r[e+14]]+f[r[e+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n}var l=0,d=0;function v(r){if(!a(r))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(r.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=255&e,n[4]=(e=parseInt(r.slice(9,13),16))>>>8,n[5]=255&e,n[6]=(e=parseInt(r.slice(14,18),16))>>>8,n[7]=255&e,n[8]=(e=parseInt(r.slice(19,23),16))>>>8,n[9]=255&e,n[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=255&e,n}function p(r,e,n){function t(r,t,o,a){if("string"==typeof r&&(r=function(r){r=unescape(encodeURIComponent(r));for(var e=[],n=0;n<r.length;++n)e.push(r.charCodeAt(n));return e}(r)),"string"==typeof t&&(t=v(t)),16!==t.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var i=new Uint8Array(16+r.length);if(i.set(t),i.set(r,t.length),(i=n(i))[6]=15&i[6]|e,i[8]=63&i[8]|128,o){a=a||0;for(var u=0;u<16;++u)o[a+u]=i[u];return o}return c(i)}try{t.name=r}catch(r){}return t.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",t.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",t}function h(r){return 14+(r+64>>>9<<4)+1}function y(r,e){var n=(65535&r)+(65535&e);return(r>>16)+(e>>16)+(n>>16)<<16|65535&n}function g(r,e,n,t,o,a){return y((i=y(y(e,r),y(t,a)))<<(u=o)|i>>>32-u,n);var i,u}function m(r,e,n,t,o,a,i){return g(e&n|~e&t,r,e,o,a,i)}function w(r,e,n,t,o,a,i){return g(e&t|n&~t,r,e,o,a,i)}function b(r,e,n,t,o,a,i){return g(e^n^t,r,e,o,a,i)}function A(r,e,n,t,o,a,i){return g(n^(e|~t),r,e,o,a,i)}var U=p("v3",48,(function(r){if("string"==typeof r){var e=unescape(encodeURIComponent(r));r=new Uint8Array(e.length);for(var n=0;n<e.length;++n)r[n]=e.charCodeAt(n)}return function(r){for(var e=[],n=32*r.length,t="0123456789abcdef",o=0;o<n;o+=8){var a=r[o>>5]>>>o%32&255,i=parseInt(t.charAt(a>>>4&15)+t.charAt(15&a),16);e.push(i)}return e}(function(r,e){r[e>>5]|=128<<e%32,r[h(e)-1]=e;for(var n=1732584193,t=-271733879,o=-1732584194,a=271733878,i=0;i<r.length;i+=16){var u=n,f=t,s=o,c=a;n=m(n,t,o,a,r[i],7,-680876936),a=m(a,n,t,o,r[i+1],12,-389564586),o=m(o,a,n,t,r[i+2],17,606105819),t=m(t,o,a,n,r[i+3],22,-1044525330),n=m(n,t,o,a,r[i+4],7,-176418897),a=m(a,n,t,o,r[i+5],12,1200080426),o=m(o,a,n,t,r[i+6],17,-1473231341),t=m(t,o,a,n,r[i+7],22,-45705983),n=m(n,t,o,a,r[i+8],7,1770035416),a=m(a,n,t,o,r[i+9],12,-1958414417),o=m(o,a,n,t,r[i+10],17,-42063),t=m(t,o,a,n,r[i+11],22,-1990404162),n=m(n,t,o,a,r[i+12],7,1804603682),a=m(a,n,t,o,r[i+13],12,-40341101),o=m(o,a,n,t,r[i+14],17,-1502002290),n=w(n,t=m(t,o,a,n,r[i+15],22,1236535329),o,a,r[i+1],5,-165796510),a=w(a,n,t,o,r[i+6],9,-1069501632),o=w(o,a,n,t,r[i+11],14,643717713),t=w(t,o,a,n,r[i],20,-373897302),n=w(n,t,o,a,r[i+5],5,-701558691),a=w(a,n,t,o,r[i+10],9,38016083),o=w(o,a,n,t,r[i+15],14,-660478335),t=w(t,o,a,n,r[i+4],20,-405537848),n=w(n,t,o,a,r[i+9],5,568446438),a=w(a,n,t,o,r[i+14],9,-1019803690),o=w(o,a,n,t,r[i+3],14,-187363961),t=w(t,o,a,n,r[i+8],20,1163531501),n=w(n,t,o,a,r[i+13],5,-1444681467),a=w(a,n,t,o,r[i+2],9,-51403784),o=w(o,a,n,t,r[i+7],14,1735328473),n=b(n,t=w(t,o,a,n,r[i+12],20,-1926607734),o,a,r[i+5],4,-378558),a=b(a,n,t,o,r[i+8],11,-2022574463),o=b(o,a,n,t,r[i+11],16,1839030562),t=b(t,o,a,n,r[i+14],23,-35309556),n=b(n,t,o,a,r[i+1],4,-1530992060),a=b(a,n,t,o,r[i+4],11,1272893353),o=b(o,a,n,t,r[i+7],16,-155497632),t=b(t,o,a,n,r[i+10],23,-1094730640),n=b(n,t,o,a,r[i+13],4,681279174),a=b(a,n,t,o,r[i],11,-358537222),o=b(o,a,n,t,r[i+3],16,-722521979),t=b(t,o,a,n,r[i+6],23,76029189),n=b(n,t,o,a,r[i+9],4,-640364487),a=b(a,n,t,o,r[i+12],11,-421815835),o=b(o,a,n,t,r[i+15],16,530742520),n=A(n,t=b(t,o,a,n,r[i+2],23,-995338651),o,a,r[i],6,-198630844),a=A(a,n,t,o,r[i+7],10,1126891415),o=A(o,a,n,t,r[i+14],15,-1416354905),t=A(t,o,a,n,r[i+5],21,-57434055),n=A(n,t,o,a,r[i+12],6,1700485571),a=A(a,n,t,o,r[i+3],10,-1894986606),o=A(o,a,n,t,r[i+10],15,-1051523),t=A(t,o,a,n,r[i+1],21,-2054922799),n=A(n,t,o,a,r[i+8],6,1873313359),a=A(a,n,t,o,r[i+15],10,-30611744),o=A(o,a,n,t,r[i+6],15,-1560198380),t=A(t,o,a,n,r[i+13],21,1309151649),n=A(n,t,o,a,r[i+4],6,-145523070),a=A(a,n,t,o,r[i+11],10,-1120210379),o=A(o,a,n,t,r[i+2],15,718787259),t=A(t,o,a,n,r[i+9],21,-343485551),n=y(n,u),t=y(t,f),o=y(o,s),a=y(a,c)}return[n,t,o,a]}(function(r){if(0===r.length)return[];for(var e=8*r.length,n=new Uint32Array(h(e)),t=0;t<e;t+=8)n[t>>5]|=(255&r[t/8])<<t%32;return n}(r),8*r.length))}));function I(r,e,n,t){switch(r){case 0:return e&n^~e&t;case 1:return e^n^t;case 2:return e&n^e&t^n&t;case 3:return e^n^t}}function C(r,e){return r<<e|r>>>32-e}var R=p("v5",80,(function(r){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof r){var t=unescape(encodeURIComponent(r));r=[];for(var o=0;o<t.length;++o)r.push(t.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var a=r.length/4+2,i=Math.ceil(a/16),u=new Array(i),f=0;f<i;++f){for(var s=new Uint32Array(16),c=0;c<16;++c)s[c]=r[64*f+4*c]<<24|r[64*f+4*c+1]<<16|r[64*f+4*c+2]<<8|r[64*f+4*c+3];u[f]=s}u[i-1][14]=8*(r.length-1)/Math.pow(2,32),u[i-1][14]=Math.floor(u[i-1][14]),u[i-1][15]=8*(r.length-1)&4294967295;for(var l=0;l<i;++l){for(var d=new Uint32Array(80),v=0;v<16;++v)d[v]=u[l][v];for(var p=16;p<80;++p)d[p]=C(d[p-3]^d[p-8]^d[p-14]^d[p-16],1);for(var h=n[0],y=n[1],g=n[2],m=n[3],w=n[4],b=0;b<80;++b){var A=Math.floor(b/20),U=C(h,5)+I(A,y,g,m)+w+e[A]+d[b]>>>0;w=m,m=g,g=C(y,30)>>>0,y=h,h=U}n[0]=n[0]+h>>>0,n[1]=n[1]+y>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));r.NIL="00000000-0000-0000-0000-000000000000",r.parse=v,r.stringify=c,r.v1=function(r,e,n){var o=e&&n||0,a=e||new Array(16),f=(r=r||{}).node||i,s=void 0!==r.clockseq?r.clockseq:u;if(null==f||null==s){var v=r.random||(r.rng||t)();null==f&&(f=i=[1|v[0],v[1],v[2],v[3],v[4],v[5]]),null==s&&(s=u=16383&(v[6]<<8|v[7]))}var p=void 0!==r.msecs?r.msecs:Date.now(),h=void 0!==r.nsecs?r.nsecs:d+1,y=p-l+(h-d)/1e4;if(y<0&&void 0===r.clockseq&&(s=s+1&16383),(y<0||p>l)&&void 0===r.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=p,d=h,u=s;var g=(1e4*(268435455&(p+=122192928e5))+h)%4294967296;a[o++]=g>>>24&255,a[o++]=g>>>16&255,a[o++]=g>>>8&255,a[o++]=255&g;var m=p/4294967296*1e4&268435455;a[o++]=m>>>8&255,a[o++]=255&m,a[o++]=m>>>24&15|16,a[o++]=m>>>16&255,a[o++]=s>>>8|128,a[o++]=255&s;for(var w=0;w<6;++w)a[o+w]=f[w];return e||c(a)},r.v3=U,r.v4=function(r,e,n){var o=(r=r||{}).random||(r.rng||t)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e){n=n||0;for(var a=0;a<16;++a)e[n+a]=o[a];return e}return c(o)},r.v5=R,r.validate=a,r.version=function(r){if(!a(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)},Object.defineProperty(r,"__esModule",{value:!0})}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidNIL.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidNIL.min.js
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidNIL=n()}(this,(function(){"use strict";return"00000000-0000-0000-0000-000000000000"}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidVersion.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidVersion.min.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidVersion=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return function(t){if(!function(t){return"string"==typeof t&&e.test(t)}(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidValidate.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidValidate.min.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidValidate=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return function(t){return"string"==typeof t&&e.test(t)}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidStringify.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidStringify.min.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidStringify=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function t(t){return"string"==typeof t&&e.test(t)}for(var i=[],n=0;n<256;++n)i.push((n+256).toString(16).substr(1));return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,f=(i[e[n+0]]+i[e[n+1]]+i[e[n+2]]+i[e[n+3]]+"-"+i[e[n+4]]+i[e[n+5]]+"-"+i[e[n+6]]+i[e[n+7]]+"-"+i[e[n+8]]+i[e[n+9]]+"-"+i[e[n+10]]+i[e[n+11]]+i[e[n+12]]+i[e[n+13]]+i[e[n+14]]+i[e[n+15]]).toLowerCase();if(!t(f))throw TypeError("Stringified UUID is invalid");return f}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidv1.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidv1.min.js
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidv1=o()}(this,(function(){"use strict";var e,o=new Uint8Array(16);function t(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function r(e){return"string"==typeof e&&n.test(e)}for(var i,u,s=[],a=0;a<256;++a)s.push((a+256).toString(16).substr(1));var d=0,f=0;return function(e,o,n){var a=o&&n||0,c=o||new Array(16),l=(e=e||{}).node||i,p=void 0!==e.clockseq?e.clockseq:u;if(null==l||null==p){var v=e.random||(e.rng||t)();null==l&&(l=i=[1|v[0],v[1],v[2],v[3],v[4],v[5]]),null==p&&(p=u=16383&(v[6]<<8|v[7]))}var y=void 0!==e.msecs?e.msecs:Date.now(),m=void 0!==e.nsecs?e.nsecs:f+1,g=y-d+(m-f)/1e4;if(g<0&&void 0===e.clockseq&&(p=p+1&16383),(g<0||y>d)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=y,f=m,u=p;var h=(1e4*(268435455&(y+=122192928e5))+m)%4294967296;c[a++]=h>>>24&255,c[a++]=h>>>16&255,c[a++]=h>>>8&255,c[a++]=255&h;var w=y/4294967296*1e4&268435455;c[a++]=w>>>8&255,c[a++]=255&w,c[a++]=w>>>24&15|16,c[a++]=w>>>16&255,c[a++]=p>>>8|128,c[a++]=255&p;for(var b=0;b<6;++b)c[a+b]=l[b];return o||function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(s[e[o+0]]+s[e[o+1]]+s[e[o+2]]+s[e[o+3]]+"-"+s[e[o+4]]+s[e[o+5]]+"-"+s[e[o+6]]+s[e[o+7]]+"-"+s[e[o+8]]+s[e[o+9]]+"-"+s[e[o+10]]+s[e[o+11]]+s[e[o+12]]+s[e[o+13]]+s[e[o+14]]+s[e[o+15]]).toLowerCase();if(!r(t))throw TypeError("Stringified UUID is invalid");return t}(c)}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidParse.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidParse.min.js
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidParse=n()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;return function(n){if(!function(n){return"string"==typeof n&&e.test(n)}(n))throw TypeError("Invalid UUID");var t,i=new Uint8Array(16);return i[0]=(t=parseInt(n.slice(0,8),16))>>>24,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i[4]=(t=parseInt(n.slice(9,13),16))>>>8,i[5]=255&t,i[6]=(t=parseInt(n.slice(14,18),16))>>>8,i[7]=255&t,i[8]=(t=parseInt(n.slice(19,23),16))>>>8,i[9]=255&t,i[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,i[11]=t/4294967296&255,i[12]=t>>>24&255,i[13]=t>>>16&255,i[14]=t>>>8&255,i[15]=255&t,i}}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/umd/uuidv3.min.js
aws/lti-middleware/node_modules/uuid/dist/umd/uuidv3.min.js
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(n="undefined"!=typeof globalThis?globalThis:n||self).uuidv3=r()}(this,(function(){"use strict";var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function r(r){return"string"==typeof r&&n.test(r)}for(var e=[],t=0;t<256;++t)e.push((t+256).toString(16).substr(1));function i(n){return 14+(n+64>>>9<<4)+1}function o(n,r){var e=(65535&n)+(65535&r);return(n>>16)+(r>>16)+(e>>16)<<16|65535&e}function a(n,r,e,t,i,a){return o((f=o(o(r,n),o(t,a)))<<(u=i)|f>>>32-u,e);var f,u}function f(n,r,e,t,i,o,f){return a(r&e|~r&t,n,r,i,o,f)}function u(n,r,e,t,i,o,f){return a(r&t|e&~t,n,r,i,o,f)}function c(n,r,e,t,i,o,f){return a(r^e^t,n,r,i,o,f)}function s(n,r,e,t,i,o,f){return a(e^(r|~t),n,r,i,o,f)}return function(n,t,i){function o(n,o,a,f){if("string"==typeof n&&(n=function(n){n=unescape(encodeURIComponent(n));for(var r=[],e=0;e<n.length;++e)r.push(n.charCodeAt(e));return r}(n)),"string"==typeof o&&(o=function(n){if(!r(n))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=255&e,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=255&e,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=255&e,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=255&e,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=255&e,t}(o)),16!==o.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+n.length);if(u.set(o),u.set(n,o.length),(u=i(u))[6]=15&u[6]|t,u[8]=63&u[8]|128,a){f=f||0;for(var c=0;c<16;++c)a[f+c]=u[c];return a}return function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(e[n[t+0]]+e[n[t+1]]+e[n[t+2]]+e[n[t+3]]+"-"+e[n[t+4]]+e[n[t+5]]+"-"+e[n[t+6]]+e[n[t+7]]+"-"+e[n[t+8]]+e[n[t+9]]+"-"+e[n[t+10]]+e[n[t+11]]+e[n[t+12]]+e[n[t+13]]+e[n[t+14]]+e[n[t+15]]).toLowerCase();if(!r(i))throw TypeError("Stringified UUID is invalid");return i}(u)}try{o.name=n}catch(n){}return o.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",o.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",o}("v3",48,(function(n){if("string"==typeof n){var r=unescape(encodeURIComponent(n));n=new Uint8Array(r.length);for(var e=0;e<r.length;++e)n[e]=r.charCodeAt(e)}return function(n){for(var r=[],e=32*n.length,t="0123456789abcdef",i=0;i<e;i+=8){var o=n[i>>5]>>>i%32&255,a=parseInt(t.charAt(o>>>4&15)+t.charAt(15&o),16);r.push(a)}return r}(function(n,r){n[r>>5]|=128<<r%32,n[i(r)-1]=r;for(var e=1732584193,t=-271733879,a=-1732584194,l=271733878,d=0;d<n.length;d+=16){var p=e,h=t,v=a,g=l;e=f(e,t,a,l,n[d],7,-680876936),l=f(l,e,t,a,n[d+1],12,-389564586),a=f(a,l,e,t,n[d+2],17,606105819),t=f(t,a,l,e,n[d+3],22,-1044525330),e=f(e,t,a,l,n[d+4],7,-176418897),l=f(l,e,t,a,n[d+5],12,1200080426),a=f(a,l,e,t,n[d+6],17,-1473231341),t=f(t,a,l,e,n[d+7],22,-45705983),e=f(e,t,a,l,n[d+8],7,1770035416),l=f(l,e,t,a,n[d+9],12,-1958414417),a=f(a,l,e,t,n[d+10],17,-42063),t=f(t,a,l,e,n[d+11],22,-1990404162),e=f(e,t,a,l,n[d+12],7,1804603682),l=f(l,e,t,a,n[d+13],12,-40341101),a=f(a,l,e,t,n[d+14],17,-1502002290),e=u(e,t=f(t,a,l,e,n[d+15],22,1236535329),a,l,n[d+1],5,-165796510),l=u(l,e,t,a,n[d+6],9,-1069501632),a=u(a,l,e,t,n[d+11],14,643717713),t=u(t,a,l,e,n[d],20,-373897302),e=u(e,t,a,l,n[d+5],5,-701558691),l=u(l,e,t,a,n[d+10],9,38016083),a=u(a,l,e,t,n[d+15],14,-660478335),t=u(t,a,l,e,n[d+4],20,-405537848),e=u(e,t,a,l,n[d+9],5,568446438),l=u(l,e,t,a,n[d+14],9,-1019803690),a=u(a,l,e,t,n[d+3],14,-187363961),t=u(t,a,l,e,n[d+8],20,1163531501),e=u(e,t,a,l,n[d+13],5,-1444681467),l=u(l,e,t,a,n[d+2],9,-51403784),a=u(a,l,e,t,n[d+7],14,1735328473),e=c(e,t=u(t,a,l,e,n[d+12],20,-1926607734),a,l,n[d+5],4,-378558),l=c(l,e,t,a,n[d+8],11,-2022574463),a=c(a,l,e,t,n[d+11],16,1839030562),t=c(t,a,l,e,n[d+14],23,-35309556),e=c(e,t,a,l,n[d+1],4,-1530992060),l=c(l,e,t,a,n[d+4],11,1272893353),a=c(a,l,e,t,n[d+7],16,-155497632),t=c(t,a,l,e,n[d+10],23,-1094730640),e=c(e,t,a,l,n[d+13],4,681279174),l=c(l,e,t,a,n[d],11,-358537222),a=c(a,l,e,t,n[d+3],16,-722521979),t=c(t,a,l,e,n[d+6],23,76029189),e=c(e,t,a,l,n[d+9],4,-640364487),l=c(l,e,t,a,n[d+12],11,-421815835),a=c(a,l,e,t,n[d+15],16,530742520),e=s(e,t=c(t,a,l,e,n[d+2],23,-995338651),a,l,n[d],6,-198630844),l=s(l,e,t,a,n[d+7],10,1126891415),a=s(a,l,e,t,n[d+14],15,-1416354905),t=s(t,a,l,e,n[d+5],21,-57434055),e=s(e,t,a,l,n[d+12],6,1700485571),l=s(l,e,t,a,n[d+3],10,-1894986606),a=s(a,l,e,t,n[d+10],15,-1051523),t=s(t,a,l,e,n[d+1],21,-2054922799),e=s(e,t,a,l,n[d+8],6,1873313359),l=s(l,e,t,a,n[d+15],10,-30611744),a=s(a,l,e,t,n[d+6],15,-1560198380),t=s(t,a,l,e,n[d+13],21,1309151649),e=s(e,t,a,l,n[d+4],6,-145523070),l=s(l,e,t,a,n[d+11],10,-1120210379),a=s(a,l,e,t,n[d+2],15,718787259),t=s(t,a,l,e,n[d+9],21,-343485551),e=o(e,p),t=o(t,h),a=o(a,v),l=o(l,g)}return[e,t,a,l]}(function(n){if(0===n.length)return[];for(var r=8*n.length,e=new Uint32Array(i(r)),t=0;t<r;t+=8)e[t>>5]|=(255&n[t/8])<<t%32;return e}(n),8*n.length))}))}));
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/v4.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/v4.js
import rng from './rng.js'; import stringify from './stringify.js'; function v4(options, buf, offset) { options = options || {}; var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (var i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return stringify(rnds); } export default v4;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/rng.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/rng.js
// Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). var getRandomValues; var rnds8 = new Uint8Array(16); export default function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, // find the complete implementation of crypto (msCrypto) on IE11. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/md5.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/md5.js
/* * Browser-compatible JavaScript MD5 * * Modification of JavaScript MD5 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * https://opensource.org/licenses/MIT * * Based on * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ function md5(bytes) { if (typeof bytes === 'string') { var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape bytes = new Uint8Array(msg.length); for (var i = 0; i < msg.length; ++i) { bytes[i] = msg.charCodeAt(i); } } return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8)); } /* * Convert an array of little-endian words to an array of bytes */ function md5ToHexEncodedArray(input) { var output = []; var length32 = input.length * 32; var hexTab = '0123456789abcdef'; for (var i = 0; i < length32; i += 8) { var x = input[i >> 5] >>> i % 32 & 0xff; var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16); output.push(hex); } return output; } /** * Calculate output length with padding and bit length */ function getOutputLength(inputLength8) { return (inputLength8 + 64 >>> 9 << 4) + 14 + 1; } /* * Calculate the MD5 of an array of little-endian words, and a bit length. */ function wordsToMd5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << len % 32; x[getOutputLength(len) - 1] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for (var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5ff(a, b, c, d, x[i], 7, -680876936); d = md5ff(d, a, b, c, x[i + 1], 12, -389564586); c = md5ff(c, d, a, b, x[i + 2], 17, 606105819); b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330); a = md5ff(a, b, c, d, x[i + 4], 7, -176418897); d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426); c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341); b = md5ff(b, c, d, a, x[i + 7], 22, -45705983); a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416); d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417); c = md5ff(c, d, a, b, x[i + 10], 17, -42063); b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162); a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682); d = md5ff(d, a, b, c, x[i + 13], 12, -40341101); c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290); b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329); a = md5gg(a, b, c, d, x[i + 1], 5, -165796510); d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632); c = md5gg(c, d, a, b, x[i + 11], 14, 643717713); b = md5gg(b, c, d, a, x[i], 20, -373897302); a = md5gg(a, b, c, d, x[i + 5], 5, -701558691); d = md5gg(d, a, b, c, x[i + 10], 9, 38016083); c = md5gg(c, d, a, b, x[i + 15], 14, -660478335); b = md5gg(b, c, d, a, x[i + 4], 20, -405537848); a = md5gg(a, b, c, d, x[i + 9], 5, 568446438); d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690); c = md5gg(c, d, a, b, x[i + 3], 14, -187363961); b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501); a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467); d = md5gg(d, a, b, c, x[i + 2], 9, -51403784); c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473); b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734); a = md5hh(a, b, c, d, x[i + 5], 4, -378558); d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463); c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562); b = md5hh(b, c, d, a, x[i + 14], 23, -35309556); a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060); d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353); c = md5hh(c, d, a, b, x[i + 7], 16, -155497632); b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640); a = md5hh(a, b, c, d, x[i + 13], 4, 681279174); d = md5hh(d, a, b, c, x[i], 11, -358537222); c = md5hh(c, d, a, b, x[i + 3], 16, -722521979); b = md5hh(b, c, d, a, x[i + 6], 23, 76029189); a = md5hh(a, b, c, d, x[i + 9], 4, -640364487); d = md5hh(d, a, b, c, x[i + 12], 11, -421815835); c = md5hh(c, d, a, b, x[i + 15], 16, 530742520); b = md5hh(b, c, d, a, x[i + 2], 23, -995338651); a = md5ii(a, b, c, d, x[i], 6, -198630844); d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415); c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905); b = md5ii(b, c, d, a, x[i + 5], 21, -57434055); a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571); d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606); c = md5ii(c, d, a, b, x[i + 10], 15, -1051523); b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799); a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359); d = md5ii(d, a, b, c, x[i + 15], 10, -30611744); c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380); b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649); a = md5ii(a, b, c, d, x[i + 4], 6, -145523070); d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379); c = md5ii(c, d, a, b, x[i + 2], 15, 718787259); b = md5ii(b, c, d, a, x[i + 9], 21, -343485551); a = safeAdd(a, olda); b = safeAdd(b, oldb); c = safeAdd(c, oldc); d = safeAdd(d, oldd); } return [a, b, c, d]; } /* * Convert an array bytes to an array of little-endian words * Characters >255 have their high-byte silently ignored. */ function bytesToWords(input) { if (input.length === 0) { return []; } var length8 = input.length * 8; var output = new Uint32Array(getOutputLength(length8)); for (var i = 0; i < length8; i += 8) { output[i >> 5] |= (input[i / 8] & 0xff) << i % 32; } return output; } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safeAdd(x, y) { var lsw = (x & 0xffff) + (y & 0xffff); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return msw << 16 | lsw & 0xffff; } /* * Bitwise rotate a 32-bit number to the left. */ function bitRotateLeft(num, cnt) { return num << cnt | num >>> 32 - cnt; } /* * These functions implement the four basic operations the algorithm uses. */ function md5cmn(q, a, b, x, s, t) { return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b); } function md5ff(a, b, c, d, x, s, t) { return md5cmn(b & c | ~b & d, a, b, x, s, t); } function md5gg(a, b, c, d, x, s, t) { return md5cmn(b & d | c & ~d, a, b, x, s, t); } function md5hh(a, b, c, d, x, s, t) { return md5cmn(b ^ c ^ d, a, b, x, s, t); } function md5ii(a, b, c, d, x, s, t) { return md5cmn(c ^ (b | ~d), a, b, x, s, t); } export default md5;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/nil.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/nil.js
export default '00000000-0000-0000-0000-000000000000';
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/index.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/index.js
export { default as v1 } from './v1.js'; export { default as v3 } from './v3.js'; export { default as v4 } from './v4.js'; export { default as v5 } from './v5.js'; export { default as NIL } from './nil.js'; export { default as version } from './version.js'; export { default as validate } from './validate.js'; export { default as stringify } from './stringify.js'; export { default as parse } from './parse.js';
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/v35.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/v35.js
import stringify from './stringify.js'; import parse from './parse.js'; function stringToBytes(str) { str = unescape(encodeURIComponent(str)); // UTF8 escape var bytes = []; for (var i = 0; i < str.length; ++i) { bytes.push(str.charCodeAt(i)); } return bytes; } export var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; export var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; export default function (name, version, hashfunc) { function generateUUID(value, namespace, buf, offset) { if (typeof value === 'string') { value = stringToBytes(value); } if (typeof namespace === 'string') { namespace = parse(namespace); } if (namespace.length !== 16) { throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); } // Compute hash of namespace and value, Per 4.3 // Future: Use spread syntax when supported on all platforms, e.g. `bytes = // hashfunc([...namespace, ... value])` var bytes = new Uint8Array(16 + value.length); bytes.set(namespace); bytes.set(value, namespace.length); bytes = hashfunc(bytes); bytes[6] = bytes[6] & 0x0f | version; bytes[8] = bytes[8] & 0x3f | 0x80; if (buf) { offset = offset || 0; for (var i = 0; i < 16; ++i) { buf[offset + i] = bytes[i]; } return buf; } return stringify(bytes); } // Function#name is not settable on some platforms (#270) try { generateUUID.name = name; // eslint-disable-next-line no-empty } catch (err) {} // For CommonJS default export support generateUUID.DNS = DNS; generateUUID.URL = URL; return generateUUID; }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/v3.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/v3.js
import v35 from './v35.js'; import md5 from './md5.js'; var v3 = v35('v3', 0x30, md5); export default v3;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/parse.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/parse.js
import validate from './validate.js'; function parse(uuid) { if (!validate(uuid)) { throw TypeError('Invalid UUID'); } var v; var arr = new Uint8Array(16); // Parse ########-....-....-....-............ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; arr[1] = v >>> 16 & 0xff; arr[2] = v >>> 8 & 0xff; arr[3] = v & 0xff; // Parse ........-####-....-....-............ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; arr[5] = v & 0xff; // Parse ........-....-####-....-............ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; arr[7] = v & 0xff; // Parse ........-....-....-####-............ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; arr[9] = v & 0xff; // Parse ........-....-....-....-############ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; arr[11] = v / 0x100000000 & 0xff; arr[12] = v >>> 24 & 0xff; arr[13] = v >>> 16 & 0xff; arr[14] = v >>> 8 & 0xff; arr[15] = v & 0xff; return arr; } export default parse;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/stringify.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/stringify.js
import validate from './validate.js'; /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ var byteToHex = []; for (var i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).substr(1)); } function stringify(arr) { var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one // of the following: // - One or more input array values don't map to a hex octet (leading to // "undefined" in the uuid) // - Invalid input values for the RFC `version` or `variant` fields if (!validate(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } export default stringify;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/version.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/version.js
import validate from './validate.js'; function version(uuid) { if (!validate(uuid)) { throw TypeError('Invalid UUID'); } return parseInt(uuid.substr(14, 1), 16); } export default version;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/sha1.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/sha1.js
// Adapted from Chris Veness' SHA1 code at // http://www.movable-type.co.uk/scripts/sha1.html function f(s, x, y, z) { switch (s) { case 0: return x & y ^ ~x & z; case 1: return x ^ y ^ z; case 2: return x & y ^ x & z ^ y & z; case 3: return x ^ y ^ z; } } function ROTL(x, n) { return x << n | x >>> 32 - n; } function sha1(bytes) { var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; if (typeof bytes === 'string') { var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape bytes = []; for (var i = 0; i < msg.length; ++i) { bytes.push(msg.charCodeAt(i)); } } else if (!Array.isArray(bytes)) { // Convert Array-like to Array bytes = Array.prototype.slice.call(bytes); } bytes.push(0x80); var l = bytes.length / 4 + 2; var N = Math.ceil(l / 16); var M = new Array(N); for (var _i = 0; _i < N; ++_i) { var arr = new Uint32Array(16); for (var j = 0; j < 16; ++j) { arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3]; } M[_i] = arr; } M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); M[N - 1][14] = Math.floor(M[N - 1][14]); M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; for (var _i2 = 0; _i2 < N; ++_i2) { var W = new Uint32Array(80); for (var t = 0; t < 16; ++t) { W[t] = M[_i2][t]; } for (var _t = 16; _t < 80; ++_t) { W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1); } var a = H[0]; var b = H[1]; var c = H[2]; var d = H[3]; var e = H[4]; for (var _t2 = 0; _t2 < 80; ++_t2) { var s = Math.floor(_t2 / 20); var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0; e = d; d = c; c = ROTL(b, 30) >>> 0; b = a; a = T; } H[0] = H[0] + a >>> 0; H[1] = H[1] + b >>> 0; H[2] = H[2] + c >>> 0; H[3] = H[3] + d >>> 0; H[4] = H[4] + e >>> 0; } return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; } export default sha1;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/validate.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/validate.js
import REGEX from './regex.js'; function validate(uuid) { return typeof uuid === 'string' && REGEX.test(uuid); } export default validate;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/v1.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/v1.js
import rng from './rng.js'; import stringify from './stringify.js'; // **`v1()` - Generate time-based UUID** // // Inspired by https://github.com/LiosK/UUID.js // and http://docs.python.org/library/uuid.html var _nodeId; var _clockseq; // Previous uuid creation time var _lastMSecs = 0; var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details function v1(options, buf, offset) { var i = buf && offset || 0; var b = buf || new Array(16); options = options || {}; var node = options.node || _nodeId; var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not // specified. We do this lazily to minimize issues related to insufficient // system entropy. See #189 if (node == null || clockseq == null) { var seedBytes = options.random || (options.rng || rng)(); if (node == null) { // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } if (clockseq == null) { // Per 4.2.2, randomize (14 bit) clockseq clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; } } // UUID timestamps are 100 nano-second units since the Gregorian epoch, // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock // cycle to simulate higher resolution clock var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression if (dt < 0 && options.clockseq === undefined) { clockseq = clockseq + 1 & 0x3fff; } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new // time interval if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { nsecs = 0; } // Per 4.2.1.2 Throw error if too many uuids are requested if (nsecs >= 10000) { throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); } _lastMSecs = msecs; _lastNSecs = nsecs; _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch msecs += 12219292800000; // `time_low` var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; b[i++] = tl >>> 24 & 0xff; b[i++] = tl >>> 16 & 0xff; b[i++] = tl >>> 8 & 0xff; b[i++] = tl & 0xff; // `time_mid` var tmh = msecs / 0x100000000 * 10000 & 0xfffffff; b[i++] = tmh >>> 8 & 0xff; b[i++] = tmh & 0xff; // `time_high_and_version` b[i++] = tmh >>> 24 & 0xf | 0x10; // include version b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` b[i++] = clockseq & 0xff; // `node` for (var n = 0; n < 6; ++n) { b[i + n] = node[n]; } return buf || stringify(b); } export default v1;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/regex.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/regex.js
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-browser/v5.js
aws/lti-middleware/node_modules/uuid/dist/esm-browser/v5.js
import v35 from './v35.js'; import sha1 from './sha1.js'; var v5 = v35('v5', 0x50, sha1); export default v5;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/v4.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/v4.js
import rng from './rng.js'; import stringify from './stringify.js'; function v4(options, buf, offset) { options = options || {}; const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return stringify(rnds); } export default v4;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/rng.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/rng.js
import crypto from 'crypto'; const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate let poolPtr = rnds8Pool.length; export default function rng() { if (poolPtr > rnds8Pool.length - 16) { crypto.randomFillSync(rnds8Pool); poolPtr = 0; } return rnds8Pool.slice(poolPtr, poolPtr += 16); }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/md5.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/md5.js
import crypto from 'crypto'; function md5(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === 'string') { bytes = Buffer.from(bytes, 'utf8'); } return crypto.createHash('md5').update(bytes).digest(); } export default md5;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/nil.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/nil.js
export default '00000000-0000-0000-0000-000000000000';
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/index.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/index.js
export { default as v1 } from './v1.js'; export { default as v3 } from './v3.js'; export { default as v4 } from './v4.js'; export { default as v5 } from './v5.js'; export { default as NIL } from './nil.js'; export { default as version } from './version.js'; export { default as validate } from './validate.js'; export { default as stringify } from './stringify.js'; export { default as parse } from './parse.js';
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/v35.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/v35.js
import stringify from './stringify.js'; import parse from './parse.js'; function stringToBytes(str) { str = unescape(encodeURIComponent(str)); // UTF8 escape const bytes = []; for (let i = 0; i < str.length; ++i) { bytes.push(str.charCodeAt(i)); } return bytes; } export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; export default function (name, version, hashfunc) { function generateUUID(value, namespace, buf, offset) { if (typeof value === 'string') { value = stringToBytes(value); } if (typeof namespace === 'string') { namespace = parse(namespace); } if (namespace.length !== 16) { throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); } // Compute hash of namespace and value, Per 4.3 // Future: Use spread syntax when supported on all platforms, e.g. `bytes = // hashfunc([...namespace, ... value])` let bytes = new Uint8Array(16 + value.length); bytes.set(namespace); bytes.set(value, namespace.length); bytes = hashfunc(bytes); bytes[6] = bytes[6] & 0x0f | version; bytes[8] = bytes[8] & 0x3f | 0x80; if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = bytes[i]; } return buf; } return stringify(bytes); } // Function#name is not settable on some platforms (#270) try { generateUUID.name = name; // eslint-disable-next-line no-empty } catch (err) {} // For CommonJS default export support generateUUID.DNS = DNS; generateUUID.URL = URL; return generateUUID; }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/v3.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/v3.js
import v35 from './v35.js'; import md5 from './md5.js'; const v3 = v35('v3', 0x30, md5); export default v3;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/parse.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/parse.js
import validate from './validate.js'; function parse(uuid) { if (!validate(uuid)) { throw TypeError('Invalid UUID'); } let v; const arr = new Uint8Array(16); // Parse ########-....-....-....-............ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; arr[1] = v >>> 16 & 0xff; arr[2] = v >>> 8 & 0xff; arr[3] = v & 0xff; // Parse ........-####-....-....-............ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; arr[5] = v & 0xff; // Parse ........-....-####-....-............ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; arr[7] = v & 0xff; // Parse ........-....-....-####-............ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; arr[9] = v & 0xff; // Parse ........-....-....-....-############ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; arr[11] = v / 0x100000000 & 0xff; arr[12] = v >>> 24 & 0xff; arr[13] = v >>> 16 & 0xff; arr[14] = v >>> 8 & 0xff; arr[15] = v & 0xff; return arr; } export default parse;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/stringify.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/stringify.js
import validate from './validate.js'; /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ const byteToHex = []; for (let i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).substr(1)); } function stringify(arr, offset = 0) { // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one // of the following: // - One or more input array values don't map to a hex octet (leading to // "undefined" in the uuid) // - Invalid input values for the RFC `version` or `variant` fields if (!validate(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } export default stringify;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/version.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/version.js
import validate from './validate.js'; function version(uuid) { if (!validate(uuid)) { throw TypeError('Invalid UUID'); } return parseInt(uuid.substr(14, 1), 16); } export default version;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/sha1.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/sha1.js
import crypto from 'crypto'; function sha1(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === 'string') { bytes = Buffer.from(bytes, 'utf8'); } return crypto.createHash('sha1').update(bytes).digest(); } export default sha1;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/validate.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/validate.js
import REGEX from './regex.js'; function validate(uuid) { return typeof uuid === 'string' && REGEX.test(uuid); } export default validate;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/v1.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/v1.js
import rng from './rng.js'; import stringify from './stringify.js'; // **`v1()` - Generate time-based UUID** // // Inspired by https://github.com/LiosK/UUID.js // and http://docs.python.org/library/uuid.html let _nodeId; let _clockseq; // Previous uuid creation time let _lastMSecs = 0; let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details function v1(options, buf, offset) { let i = buf && offset || 0; const b = buf || new Array(16); options = options || {}; let node = options.node || _nodeId; let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not // specified. We do this lazily to minimize issues related to insufficient // system entropy. See #189 if (node == null || clockseq == null) { const seedBytes = options.random || (options.rng || rng)(); if (node == null) { // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } if (clockseq == null) { // Per 4.2.2, randomize (14 bit) clockseq clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; } } // UUID timestamps are 100 nano-second units since the Gregorian epoch, // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock // cycle to simulate higher resolution clock let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression if (dt < 0 && options.clockseq === undefined) { clockseq = clockseq + 1 & 0x3fff; } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new // time interval if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { nsecs = 0; } // Per 4.2.1.2 Throw error if too many uuids are requested if (nsecs >= 10000) { throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); } _lastMSecs = msecs; _lastNSecs = nsecs; _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch msecs += 12219292800000; // `time_low` const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; b[i++] = tl >>> 24 & 0xff; b[i++] = tl >>> 16 & 0xff; b[i++] = tl >>> 8 & 0xff; b[i++] = tl & 0xff; // `time_mid` const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; b[i++] = tmh >>> 8 & 0xff; b[i++] = tmh & 0xff; // `time_high_and_version` b[i++] = tmh >>> 24 & 0xf | 0x10; // include version b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` b[i++] = clockseq & 0xff; // `node` for (let n = 0; n < 6; ++n) { b[i + n] = node[n]; } return buf || stringify(b); } export default v1;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/regex.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/regex.js
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/uuid/dist/esm-node/v5.js
aws/lti-middleware/node_modules/uuid/dist/esm-node/v5.js
import v35 from './v35.js'; import sha1 from './sha1.js'; const v5 = v35('v5', 0x50, sha1); export default v5;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/raw-body/index.js
aws/lti-middleware/node_modules/raw-body/index.js
/*! * raw-body * Copyright(c) 2013-2014 Jonathan Ong * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ 'use strict' /** * Module dependencies. * @private */ var bytes = require('bytes') var createError = require('http-errors') var iconv = require('iconv-lite') var unpipe = require('unpipe') /** * Module exports. * @public */ module.exports = getRawBody /** * Module variables. * @private */ var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: / /** * Get the decoder for a given encoding. * * @param {string} encoding * @private */ function getDecoder (encoding) { if (!encoding) return null try { return iconv.getDecoder(encoding) } catch (e) { // error getting decoder if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e // the encoding was not found throw createError(415, 'specified encoding unsupported', { encoding: encoding, type: 'encoding.unsupported' }) } } /** * Get the raw body of a stream (typically HTTP). * * @param {object} stream * @param {object|string|function} [options] * @param {function} [callback] * @public */ function getRawBody (stream, options, callback) { var done = callback var opts = options || {} if (options === true || typeof options === 'string') { // short cut for encoding opts = { encoding: options } } if (typeof options === 'function') { done = options opts = {} } // validate callback is a function, if provided if (done !== undefined && typeof done !== 'function') { throw new TypeError('argument callback must be a function') } // require the callback without promises if (!done && !global.Promise) { throw new TypeError('argument callback is required') } // get encoding var encoding = opts.encoding !== true ? opts.encoding : 'utf-8' // convert the limit to an integer var limit = bytes.parse(opts.limit) // convert the expected length to an integer var length = opts.length != null && !isNaN(opts.length) ? parseInt(opts.length, 10) : null if (done) { // classic callback style return readStream(stream, encoding, length, limit, done) } return new Promise(function executor (resolve, reject) { readStream(stream, encoding, length, limit, function onRead (err, buf) { if (err) return reject(err) resolve(buf) }) }) } /** * Halt a stream. * * @param {Object} stream * @private */ function halt (stream) { // unpipe everything from the stream unpipe(stream) // pause stream if (typeof stream.pause === 'function') { stream.pause() } } /** * Read the data from the stream. * * @param {object} stream * @param {string} encoding * @param {number} length * @param {number} limit * @param {function} callback * @public */ function readStream (stream, encoding, length, limit, callback) { var complete = false var sync = true // check the length and limit options. // note: we intentionally leave the stream paused, // so users should handle the stream themselves. if (limit !== null && length !== null && length > limit) { return done(createError(413, 'request entity too large', { expected: length, length: length, limit: limit, type: 'entity.too.large' })) } // streams1: assert request encoding is buffer. // streams2+: assert the stream encoding is buffer. // stream._decoder: streams1 // state.encoding: streams2 // state.decoder: streams2, specifically < 0.10.6 var state = stream._readableState if (stream._decoder || (state && (state.encoding || state.decoder))) { // developer error return done(createError(500, 'stream encoding should not be set', { type: 'stream.encoding.set' })) } var received = 0 var decoder try { decoder = getDecoder(encoding) } catch (err) { return done(err) } var buffer = decoder ? '' : [] // attach listeners stream.on('aborted', onAborted) stream.on('close', cleanup) stream.on('data', onData) stream.on('end', onEnd) stream.on('error', onEnd) // mark sync section complete sync = false function done () { var args = new Array(arguments.length) // copy arguments for (var i = 0; i < args.length; i++) { args[i] = arguments[i] } // mark complete complete = true if (sync) { process.nextTick(invokeCallback) } else { invokeCallback() } function invokeCallback () { cleanup() if (args[0]) { // halt the stream on error halt(stream) } callback.apply(null, args) } } function onAborted () { if (complete) return done(createError(400, 'request aborted', { code: 'ECONNABORTED', expected: length, length: length, received: received, type: 'request.aborted' })) } function onData (chunk) { if (complete) return received += chunk.length if (limit !== null && received > limit) { done(createError(413, 'request entity too large', { limit: limit, received: received, type: 'entity.too.large' })) } else if (decoder) { buffer += decoder.write(chunk) } else { buffer.push(chunk) } } function onEnd (err) { if (complete) return if (err) return done(err) if (length !== null && received !== length) { done(createError(400, 'request size did not match content length', { expected: length, length: length, received: received, type: 'request.size.invalid' })) } else { var string = decoder ? buffer + (decoder.end() || '') : Buffer.concat(buffer) done(null, string) } } function cleanup () { buffer = null stream.removeListener('aborted', onAborted) stream.removeListener('data', onData) stream.removeListener('end', onEnd) stream.removeListener('error', onEnd) stream.removeListener('close', cleanup) } }
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/color-convert/route.js
aws/lti-middleware/node_modules/color-convert/route.js
const conversions = require('./conversions'); /* This function routes a model to all other models. all functions that are routed have a property `.conversion` attached to the returned synthetic function. This property is an array of strings, each with the steps in between the 'from' and 'to' color models (inclusive). conversions that are not possible simply are not included. */ function buildGraph() { const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3 const models = Object.keys(conversions); for (let len = models.length, i = 0; i < len; i++) { graph[models[i]] = { // http://jsperf.com/1-vs-infinity // micro-opt, but this is simple. distance: -1, parent: null }; } return graph; } // https://en.wikipedia.org/wiki/Breadth-first_search function deriveBFS(fromModel) { const graph = buildGraph(); const queue = [fromModel]; // Unshift -> queue -> pop graph[fromModel].distance = 0; while (queue.length) { const current = queue.pop(); const adjacents = Object.keys(conversions[current]); for (let len = adjacents.length, i = 0; i < len; i++) { const adjacent = adjacents[i]; const node = graph[adjacent]; if (node.distance === -1) { node.distance = graph[current].distance + 1; node.parent = current; queue.unshift(adjacent); } } } return graph; } function link(from, to) { return function (args) { return to(from(args)); }; } function wrapConversion(toModel, graph) { const path = [graph[toModel].parent, toModel]; let fn = conversions[graph[toModel].parent][toModel]; let cur = graph[toModel].parent; while (graph[cur].parent) { path.unshift(graph[cur].parent); fn = link(conversions[graph[cur].parent][cur], fn); cur = graph[cur].parent; } fn.conversion = path; return fn; } module.exports = function (fromModel) { const graph = deriveBFS(fromModel); const conversion = {}; const models = Object.keys(graph); for (let len = models.length, i = 0; i < len; i++) { const toModel = models[i]; const node = graph[toModel]; if (node.parent === null) { // No possible conversion, or this node is the source model. continue; } conversion[toModel] = wrapConversion(toModel, graph); } return conversion; };
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/color-convert/index.js
aws/lti-middleware/node_modules/color-convert/index.js
const conversions = require('./conversions'); const route = require('./route'); const convert = {}; const models = Object.keys(conversions); function wrapRaw(fn) { const wrappedFn = function (...args) { const arg0 = args[0]; if (arg0 === undefined || arg0 === null) { return arg0; } if (arg0.length > 1) { args = arg0; } return fn(args); }; // Preserve .conversion property if there is one if ('conversion' in fn) { wrappedFn.conversion = fn.conversion; } return wrappedFn; } function wrapRounded(fn) { const wrappedFn = function (...args) { const arg0 = args[0]; if (arg0 === undefined || arg0 === null) { return arg0; } if (arg0.length > 1) { args = arg0; } const result = fn(args); // We're assuming the result is an array here. // see notice in conversions.js; don't use box types // in conversion functions. if (typeof result === 'object') { for (let len = result.length, i = 0; i < len; i++) { result[i] = Math.round(result[i]); } } return result; }; // Preserve .conversion property if there is one if ('conversion' in fn) { wrappedFn.conversion = fn.conversion; } return wrappedFn; } models.forEach(fromModel => { convert[fromModel] = {}; Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); const routes = route(fromModel); const routeModels = Object.keys(routes); routeModels.forEach(toModel => { const fn = routes[toModel]; convert[fromModel][toModel] = wrapRounded(fn); convert[fromModel][toModel].raw = wrapRaw(fn); }); }); module.exports = convert;
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/color-convert/conversions.js
aws/lti-middleware/node_modules/color-convert/conversions.js
/* MIT license */ /* eslint-disable no-mixed-operators */ const cssKeywords = require('color-name'); // NOTE: conversions should only return primitive values (i.e. arrays, or // values that give correct `typeof` results). // do not use box values types (i.e. Number(), String(), etc.) const reverseKeywords = {}; for (const key of Object.keys(cssKeywords)) { reverseKeywords[cssKeywords[key]] = key; } const convert = { rgb: {channels: 3, labels: 'rgb'}, hsl: {channels: 3, labels: 'hsl'}, hsv: {channels: 3, labels: 'hsv'}, hwb: {channels: 3, labels: 'hwb'}, cmyk: {channels: 4, labels: 'cmyk'}, xyz: {channels: 3, labels: 'xyz'}, lab: {channels: 3, labels: 'lab'}, lch: {channels: 3, labels: 'lch'}, hex: {channels: 1, labels: ['hex']}, keyword: {channels: 1, labels: ['keyword']}, ansi16: {channels: 1, labels: ['ansi16']}, ansi256: {channels: 1, labels: ['ansi256']}, hcg: {channels: 3, labels: ['h', 'c', 'g']}, apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, gray: {channels: 1, labels: ['gray']} }; module.exports = convert; // Hide .channels and .labels properties for (const model of Object.keys(convert)) { if (!('channels' in convert[model])) { throw new Error('missing channels property: ' + model); } if (!('labels' in convert[model])) { throw new Error('missing channel labels property: ' + model); } if (convert[model].labels.length !== convert[model].channels) { throw new Error('channel and label counts mismatch: ' + model); } const {channels, labels} = convert[model]; delete convert[model].channels; delete convert[model].labels; Object.defineProperty(convert[model], 'channels', {value: channels}); Object.defineProperty(convert[model], 'labels', {value: labels}); } convert.rgb.hsl = function (rgb) { const r = rgb[0] / 255; const g = rgb[1] / 255; const b = rgb[2] / 255; const min = Math.min(r, g, b); const max = Math.max(r, g, b); const delta = max - min; let h; let s; if (max === min) { h = 0; } else if (r === max) { h = (g - b) / delta; } else if (g === max) { h = 2 + (b - r) / delta; } else if (b === max) { h = 4 + (r - g) / delta; } h = Math.min(h * 60, 360); if (h < 0) { h += 360; } const l = (min + max) / 2; if (max === min) { s = 0; } else if (l <= 0.5) { s = delta / (max + min); } else { s = delta / (2 - max - min); } return [h, s * 100, l * 100]; }; convert.rgb.hsv = function (rgb) { let rdif; let gdif; let bdif; let h; let s; const r = rgb[0] / 255; const g = rgb[1] / 255; const b = rgb[2] / 255; const v = Math.max(r, g, b); const diff = v - Math.min(r, g, b); const diffc = function (c) { return (v - c) / 6 / diff + 1 / 2; }; if (diff === 0) { h = 0; s = 0; } else { s = diff / v; rdif = diffc(r); gdif = diffc(g); bdif = diffc(b); if (r === v) { h = bdif - gdif; } else if (g === v) { h = (1 / 3) + rdif - bdif; } else if (b === v) { h = (2 / 3) + gdif - rdif; } if (h < 0) { h += 1; } else if (h > 1) { h -= 1; } } return [ h * 360, s * 100, v * 100 ]; }; convert.rgb.hwb = function (rgb) { const r = rgb[0]; const g = rgb[1]; let b = rgb[2]; const h = convert.rgb.hsl(rgb)[0]; const w = 1 / 255 * Math.min(r, Math.min(g, b)); b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); return [h, w * 100, b * 100]; }; convert.rgb.cmyk = function (rgb) { const r = rgb[0] / 255; const g = rgb[1] / 255; const b = rgb[2] / 255; const k = Math.min(1 - r, 1 - g, 1 - b); const c = (1 - r - k) / (1 - k) || 0; const m = (1 - g - k) / (1 - k) || 0; const y = (1 - b - k) / (1 - k) || 0; return [c * 100, m * 100, y * 100, k * 100]; }; function comparativeDistance(x, y) { /* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance */ return ( ((x[0] - y[0]) ** 2) + ((x[1] - y[1]) ** 2) + ((x[2] - y[2]) ** 2) ); } convert.rgb.keyword = function (rgb) { const reversed = reverseKeywords[rgb]; if (reversed) { return reversed; } let currentClosestDistance = Infinity; let currentClosestKeyword; for (const keyword of Object.keys(cssKeywords)) { const value = cssKeywords[keyword]; // Compute comparative distance const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest if (distance < currentClosestDistance) { currentClosestDistance = distance; currentClosestKeyword = keyword; } } return currentClosestKeyword; }; convert.keyword.rgb = function (keyword) { return cssKeywords[keyword]; }; convert.rgb.xyz = function (rgb) { let r = rgb[0] / 255; let g = rgb[1] / 255; let b = rgb[2] / 255; // Assume sRGB r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92); g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92); b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92); const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); return [x * 100, y * 100, z * 100]; }; convert.rgb.lab = function (rgb) { const xyz = convert.rgb.xyz(rgb); let x = xyz[0]; let y = xyz[1]; let z = xyz[2]; x /= 95.047; y /= 100; z /= 108.883; x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); const l = (116 * y) - 16; const a = 500 * (x - y); const b = 200 * (y - z); return [l, a, b]; }; convert.hsl.rgb = function (hsl) { const h = hsl[0] / 360; const s = hsl[1] / 100; const l = hsl[2] / 100; let t2; let t3; let val; if (s === 0) { val = l * 255; return [val, val, val]; } if (l < 0.5) { t2 = l * (1 + s); } else { t2 = l + s - l * s; } const t1 = 2 * l - t2; const rgb = [0, 0, 0]; for (let i = 0; i < 3; i++) { t3 = h + 1 / 3 * -(i - 1); if (t3 < 0) { t3++; } if (t3 > 1) { t3--; } if (6 * t3 < 1) { val = t1 + (t2 - t1) * 6 * t3; } else if (2 * t3 < 1) { val = t2; } else if (3 * t3 < 2) { val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; } else { val = t1; } rgb[i] = val * 255; } return rgb; }; convert.hsl.hsv = function (hsl) { const h = hsl[0]; let s = hsl[1] / 100; let l = hsl[2] / 100; let smin = s; const lmin = Math.max(l, 0.01); l *= 2; s *= (l <= 1) ? l : 2 - l; smin *= lmin <= 1 ? lmin : 2 - lmin; const v = (l + s) / 2; const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); return [h, sv * 100, v * 100]; }; convert.hsv.rgb = function (hsv) { const h = hsv[0] / 60; const s = hsv[1] / 100; let v = hsv[2] / 100; const hi = Math.floor(h) % 6; const f = h - Math.floor(h); const p = 255 * v * (1 - s); const q = 255 * v * (1 - (s * f)); const t = 255 * v * (1 - (s * (1 - f))); v *= 255; switch (hi) { case 0: return [v, t, p]; case 1: return [q, v, p]; case 2: return [p, v, t]; case 3: return [p, q, v]; case 4: return [t, p, v]; case 5: return [v, p, q]; } }; convert.hsv.hsl = function (hsv) { const h = hsv[0]; const s = hsv[1] / 100; const v = hsv[2] / 100; const vmin = Math.max(v, 0.01); let sl; let l; l = (2 - s) * v; const lmin = (2 - s) * vmin; sl = s * vmin; sl /= (lmin <= 1) ? lmin : 2 - lmin; sl = sl || 0; l /= 2; return [h, sl * 100, l * 100]; }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb convert.hwb.rgb = function (hwb) { const h = hwb[0] / 360; let wh = hwb[1] / 100; let bl = hwb[2] / 100; const ratio = wh + bl; let f; // Wh + bl cant be > 1 if (ratio > 1) { wh /= ratio; bl /= ratio; } const i = Math.floor(6 * h); const v = 1 - bl; f = 6 * h - i; if ((i & 0x01) !== 0) { f = 1 - f; } const n = wh + f * (v - wh); // Linear interpolation let r; let g; let b; /* eslint-disable max-statements-per-line,no-multi-spaces */ switch (i) { default: case 6: case 0: r = v; g = n; b = wh; break; case 1: r = n; g = v; b = wh; break; case 2: r = wh; g = v; b = n; break; case 3: r = wh; g = n; b = v; break; case 4: r = n; g = wh; b = v; break; case 5: r = v; g = wh; b = n; break; } /* eslint-enable max-statements-per-line,no-multi-spaces */ return [r * 255, g * 255, b * 255]; }; convert.cmyk.rgb = function (cmyk) { const c = cmyk[0] / 100; const m = cmyk[1] / 100; const y = cmyk[2] / 100; const k = cmyk[3] / 100; const r = 1 - Math.min(1, c * (1 - k) + k); const g = 1 - Math.min(1, m * (1 - k) + k); const b = 1 - Math.min(1, y * (1 - k) + k); return [r * 255, g * 255, b * 255]; }; convert.xyz.rgb = function (xyz) { const x = xyz[0] / 100; const y = xyz[1] / 100; const z = xyz[2] / 100; let r; let g; let b; r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); // Assume sRGB r = r > 0.0031308 ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055) : r * 12.92; g = g > 0.0031308 ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055) : g * 12.92; b = b > 0.0031308 ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055) : b * 12.92; r = Math.min(Math.max(0, r), 1); g = Math.min(Math.max(0, g), 1); b = Math.min(Math.max(0, b), 1); return [r * 255, g * 255, b * 255]; }; convert.xyz.lab = function (xyz) { let x = xyz[0]; let y = xyz[1]; let z = xyz[2]; x /= 95.047; y /= 100; z /= 108.883; x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); const l = (116 * y) - 16; const a = 500 * (x - y); const b = 200 * (y - z); return [l, a, b]; }; convert.lab.xyz = function (lab) { const l = lab[0]; const a = lab[1]; const b = lab[2]; let x; let y; let z; y = (l + 16) / 116; x = a / 500 + y; z = y - b / 200; const y2 = y ** 3; const x2 = x ** 3; const z2 = z ** 3; y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; x *= 95.047; y *= 100; z *= 108.883; return [x, y, z]; }; convert.lab.lch = function (lab) { const l = lab[0]; const a = lab[1]; const b = lab[2]; let h; const hr = Math.atan2(b, a); h = hr * 360 / 2 / Math.PI; if (h < 0) { h += 360; } const c = Math.sqrt(a * a + b * b); return [l, c, h]; }; convert.lch.lab = function (lch) { const l = lch[0]; const c = lch[1]; const h = lch[2]; const hr = h / 360 * 2 * Math.PI; const a = c * Math.cos(hr); const b = c * Math.sin(hr); return [l, a, b]; }; convert.rgb.ansi16 = function (args, saturation = null) { const [r, g, b] = args; let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization value = Math.round(value / 50); if (value === 0) { return 30; } let ansi = 30 + ((Math.round(b / 255) << 2) | (Math.round(g / 255) << 1) | Math.round(r / 255)); if (value === 2) { ansi += 60; } return ansi; }; convert.hsv.ansi16 = function (args) { // Optimization here; we already know the value and don't need to get // it converted for us. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); }; convert.rgb.ansi256 = function (args) { const r = args[0]; const g = args[1]; const b = args[2]; // We use the extended greyscale palette here, with the exception of // black and white. normal palette only has 4 greyscale shades. if (r === g && g === b) { if (r < 8) { return 16; } if (r > 248) { return 231; } return Math.round(((r - 8) / 247) * 24) + 232; } const ansi = 16 + (36 * Math.round(r / 255 * 5)) + (6 * Math.round(g / 255 * 5)) + Math.round(b / 255 * 5); return ansi; }; convert.ansi16.rgb = function (args) { let color = args % 10; // Handle greyscale if (color === 0 || color === 7) { if (args > 50) { color += 3.5; } color = color / 10.5 * 255; return [color, color, color]; } const mult = (~~(args > 50) + 1) * 0.5; const r = ((color & 1) * mult) * 255; const g = (((color >> 1) & 1) * mult) * 255; const b = (((color >> 2) & 1) * mult) * 255; return [r, g, b]; }; convert.ansi256.rgb = function (args) { // Handle greyscale if (args >= 232) { const c = (args - 232) * 10 + 8; return [c, c, c]; } args -= 16; let rem; const r = Math.floor(args / 36) / 5 * 255; const g = Math.floor((rem = args % 36) / 6) / 5 * 255; const b = (rem % 6) / 5 * 255; return [r, g, b]; }; convert.rgb.hex = function (args) { const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF); const string = integer.toString(16).toUpperCase(); return '000000'.substring(string.length) + string; }; convert.hex.rgb = function (args) { const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); if (!match) { return [0, 0, 0]; } let colorString = match[0]; if (match[0].length === 3) { colorString = colorString.split('').map(char => { return char + char; }).join(''); } const integer = parseInt(colorString, 16); const r = (integer >> 16) & 0xFF; const g = (integer >> 8) & 0xFF; const b = integer & 0xFF; return [r, g, b]; }; convert.rgb.hcg = function (rgb) { const r = rgb[0] / 255; const g = rgb[1] / 255; const b = rgb[2] / 255; const max = Math.max(Math.max(r, g), b); const min = Math.min(Math.min(r, g), b); const chroma = (max - min); let grayscale; let hue; if (chroma < 1) { grayscale = min / (1 - chroma); } else { grayscale = 0; } if (chroma <= 0) { hue = 0; } else if (max === r) { hue = ((g - b) / chroma) % 6; } else if (max === g) { hue = 2 + (b - r) / chroma; } else { hue = 4 + (r - g) / chroma; } hue /= 6; hue %= 1; return [hue * 360, chroma * 100, grayscale * 100]; }; convert.hsl.hcg = function (hsl) { const s = hsl[1] / 100; const l = hsl[2] / 100; const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l)); let f = 0; if (c < 1.0) { f = (l - 0.5 * c) / (1.0 - c); } return [hsl[0], c * 100, f * 100]; }; convert.hsv.hcg = function (hsv) { const s = hsv[1] / 100; const v = hsv[2] / 100; const c = s * v; let f = 0; if (c < 1.0) { f = (v - c) / (1 - c); } return [hsv[0], c * 100, f * 100]; }; convert.hcg.rgb = function (hcg) { const h = hcg[0] / 360; const c = hcg[1] / 100; const g = hcg[2] / 100; if (c === 0.0) { return [g * 255, g * 255, g * 255]; } const pure = [0, 0, 0]; const hi = (h % 1) * 6; const v = hi % 1; const w = 1 - v; let mg = 0; /* eslint-disable max-statements-per-line */ switch (Math.floor(hi)) { case 0: pure[0] = 1; pure[1] = v; pure[2] = 0; break; case 1: pure[0] = w; pure[1] = 1; pure[2] = 0; break; case 2: pure[0] = 0; pure[1] = 1; pure[2] = v; break; case 3: pure[0] = 0; pure[1] = w; pure[2] = 1; break; case 4: pure[0] = v; pure[1] = 0; pure[2] = 1; break; default: pure[0] = 1; pure[1] = 0; pure[2] = w; } /* eslint-enable max-statements-per-line */ mg = (1.0 - c) * g; return [ (c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255 ]; }; convert.hcg.hsv = function (hcg) { const c = hcg[1] / 100; const g = hcg[2] / 100; const v = c + g * (1.0 - c); let f = 0; if (v > 0.0) { f = c / v; } return [hcg[0], f * 100, v * 100]; }; convert.hcg.hsl = function (hcg) { const c = hcg[1] / 100; const g = hcg[2] / 100; const l = g * (1.0 - c) + 0.5 * c; let s = 0; if (l > 0.0 && l < 0.5) { s = c / (2 * l); } else if (l >= 0.5 && l < 1.0) { s = c / (2 * (1 - l)); } return [hcg[0], s * 100, l * 100]; }; convert.hcg.hwb = function (hcg) { const c = hcg[1] / 100; const g = hcg[2] / 100; const v = c + g * (1.0 - c); return [hcg[0], (v - c) * 100, (1 - v) * 100]; }; convert.hwb.hcg = function (hwb) { const w = hwb[1] / 100; const b = hwb[2] / 100; const v = 1 - b; const c = v - w; let g = 0; if (c < 1) { g = (v - c) / (1 - c); } return [hwb[0], c * 100, g * 100]; }; convert.apple.rgb = function (apple) { return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; }; convert.rgb.apple = function (rgb) { return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; }; convert.gray.rgb = function (args) { return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; }; convert.gray.hsl = function (args) { return [0, 0, args[0]]; }; convert.gray.hsv = convert.gray.hsl; convert.gray.hwb = function (gray) { return [0, 100, gray[0]]; }; convert.gray.cmyk = function (gray) { return [0, 0, 0, gray[0]]; }; convert.gray.lab = function (gray) { return [gray[0], 0, 0]; }; convert.gray.hex = function (gray) { const val = Math.round(gray[0] / 100 * 255) & 0xFF; const integer = (val << 16) + (val << 8) + val; const string = integer.toString(16).toUpperCase(); return '000000'.substring(string.length) + string; }; convert.rgb.gray = function (rgb) { const val = (rgb[0] + rgb[1] + rgb[2]) / 3; return [val / 255 * 100]; };
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/util/dist/index.esm5.js
aws/lti-middleware/node_modules/@firebase/util/dist/index.esm5.js
import { __assign, __extends } from 'tslib'; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time. */ var CONSTANTS = { /** * @define {boolean} Whether this is the client Node.js SDK. */ NODE_CLIENT: false, /** * @define {boolean} Whether this is the Admin Node.js SDK. */ NODE_ADMIN: false, /** * Firebase SDK Version */ SDK_VERSION: '${JSCORE_VERSION}' }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Throws an error if the provided assertion is falsy */ var assert = function (assertion, message) { if (!assertion) { throw assertionError(message); } }; /** * Returns an Error object suitable for throwing. */ var assertionError = function (message) { return new Error('Firebase Database (' + CONSTANTS.SDK_VERSION + ') INTERNAL ASSERT FAILED: ' + message); }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var stringToByteArray$1 = function (str) { // TODO(user): Use native implementations if/when available var out = []; var p = 0; for (var i = 0; i < str.length; i++) { var c = str.charCodeAt(i); if (c < 128) { out[p++] = c; } else if (c < 2048) { out[p++] = (c >> 6) | 192; out[p++] = (c & 63) | 128; } else if ((c & 0xfc00) === 0xd800 && i + 1 < str.length && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) { // Surrogate Pair c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff); out[p++] = (c >> 18) | 240; out[p++] = ((c >> 12) & 63) | 128; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } else { out[p++] = (c >> 12) | 224; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } } return out; }; /** * Turns an array of numbers into the string given by the concatenation of the * characters to which the numbers correspond. * @param bytes Array of numbers representing characters. * @return Stringification of the array. */ var byteArrayToString = function (bytes) { // TODO(user): Use native implementations if/when available var out = []; var pos = 0, c = 0; while (pos < bytes.length) { var c1 = bytes[pos++]; if (c1 < 128) { out[c++] = String.fromCharCode(c1); } else if (c1 > 191 && c1 < 224) { var c2 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else if (c1 > 239 && c1 < 365) { // Surrogate Pair var c2 = bytes[pos++]; var c3 = bytes[pos++]; var c4 = bytes[pos++]; var u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) - 0x10000; out[c++] = String.fromCharCode(0xd800 + (u >> 10)); out[c++] = String.fromCharCode(0xdc00 + (u & 1023)); } else { var c2 = bytes[pos++]; var c3 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); } } return out.join(''); }; // We define it as an object literal instead of a class because a class compiled down to es5 can't // be treeshaked. https://github.com/rollup/rollup/issues/1691 // Static lookup maps, lazily populated by init_() var base64 = { /** * Maps bytes to characters. */ byteToCharMap_: null, /** * Maps characters to bytes. */ charToByteMap_: null, /** * Maps bytes to websafe characters. * @private */ byteToCharMapWebSafe_: null, /** * Maps websafe characters to bytes. * @private */ charToByteMapWebSafe_: null, /** * Our default alphabet, shared between * ENCODED_VALS and ENCODED_VALS_WEBSAFE */ ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789', /** * Our default alphabet. Value 64 (=) is special; it means "nothing." */ get ENCODED_VALS() { return this.ENCODED_VALS_BASE + '+/='; }, /** * Our websafe alphabet. */ get ENCODED_VALS_WEBSAFE() { return this.ENCODED_VALS_BASE + '-_.'; }, /** * Whether this browser supports the atob and btoa functions. This extension * started at Mozilla but is now implemented by many browsers. We use the * ASSUME_* variables to avoid pulling in the full useragent detection library * but still allowing the standard per-browser compilations. * */ HAS_NATIVE_SUPPORT: typeof atob === 'function', /** * Base64-encode an array of bytes. * * @param input An array of bytes (numbers with * value in [0, 255]) to encode. * @param webSafe Boolean indicating we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeByteArray: function (input, webSafe) { if (!Array.isArray(input)) { throw Error('encodeByteArray takes an array as a parameter'); } this.init_(); var byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_; var output = []; for (var i = 0; i < input.length; i += 3) { var byte1 = input[i]; var haveByte2 = i + 1 < input.length; var byte2 = haveByte2 ? input[i + 1] : 0; var haveByte3 = i + 2 < input.length; var byte3 = haveByte3 ? input[i + 2] : 0; var outByte1 = byte1 >> 2; var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); var outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); var outByte4 = byte3 & 0x3f; if (!haveByte3) { outByte4 = 64; if (!haveByte2) { outByte3 = 64; } } output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]); } return output.join(''); }, /** * Base64-encode a string. * * @param input A string to encode. * @param webSafe If true, we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeString: function (input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return btoa(input); } return this.encodeByteArray(stringToByteArray$1(input), webSafe); }, /** * Base64-decode a string. * * @param input to decode. * @param webSafe True if we should use the * alternative alphabet. * @return string representing the decoded value. */ decodeString: function (input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return atob(input); } return byteArrayToString(this.decodeStringToByteArray(input, webSafe)); }, /** * Base64-decode a string. * * In base-64 decoding, groups of four characters are converted into three * bytes. If the encoder did not apply padding, the input length may not * be a multiple of 4. * * In this case, the last group will have fewer than 4 characters, and * padding will be inferred. If the group has one or two characters, it decodes * to one byte. If the group has three characters, it decodes to two bytes. * * @param input Input to decode. * @param webSafe True if we should use the web-safe alphabet. * @return bytes representing the decoded value. */ decodeStringToByteArray: function (input, webSafe) { this.init_(); var charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_; var output = []; for (var i = 0; i < input.length;) { var byte1 = charToByteMap[input.charAt(i++)]; var haveByte2 = i < input.length; var byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0; ++i; var haveByte3 = i < input.length; var byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64; ++i; var haveByte4 = i < input.length; var byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64; ++i; if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) { throw Error(); } var outByte1 = (byte1 << 2) | (byte2 >> 4); output.push(outByte1); if (byte3 !== 64) { var outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2); output.push(outByte2); if (byte4 !== 64) { var outByte3 = ((byte3 << 6) & 0xc0) | byte4; output.push(outByte3); } } } return output; }, /** * Lazy static initialization function. Called before * accessing any of the static map variables. * @private */ init_: function () { if (!this.byteToCharMap_) { this.byteToCharMap_ = {}; this.charToByteMap_ = {}; this.byteToCharMapWebSafe_ = {}; this.charToByteMapWebSafe_ = {}; // We want quick mappings back and forth, so we precompute two maps. for (var i = 0; i < this.ENCODED_VALS.length; i++) { this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i); this.charToByteMap_[this.byteToCharMap_[i]] = i; this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i); this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i; // Be forgiving when decoding and correctly decode both encodings. if (i >= this.ENCODED_VALS_BASE.length) { this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i; this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i; } } } } }; /** * URL-safe base64 encoding */ var base64Encode = function (str) { var utf8Bytes = stringToByteArray$1(str); return base64.encodeByteArray(utf8Bytes, true); }; /** * URL-safe base64 encoding (without "." padding in the end). * e.g. Used in JSON Web Token (JWT) parts. */ var base64urlEncodeWithoutPadding = function (str) { // Use base64url encoding and remove padding in the end (dot characters). return base64Encode(str).replace(/\./g, ''); }; /** * URL-safe base64 decoding * * NOTE: DO NOT use the global atob() function - it does NOT support the * base64Url variant encoding. * * @param str To be decoded * @return Decoded result, if possible */ var base64Decode = function (str) { try { return base64.decodeString(str, true); } catch (e) { console.error('base64Decode failed: ', e); } return null; }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Do a deep-copy of basic JavaScript Objects or Arrays. */ function deepCopy(value) { return deepExtend(undefined, value); } /** * Copy properties from source to target (recursively allows extension * of Objects and Arrays). Scalar values in the target are over-written. * If target is undefined, an object of the appropriate type will be created * (and returned). * * We recursively copy all child properties of plain Objects in the source- so * that namespace- like dictionaries are merged. * * Note that the target can be a function, in which case the properties in * the source Object are copied onto it as static properties of the Function. * * Note: we don't merge __proto__ to prevent prototype pollution */ function deepExtend(target, source) { if (!(source instanceof Object)) { return source; } switch (source.constructor) { case Date: // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! var dateValue = source; return new Date(dateValue.getTime()); case Object: if (target === undefined) { target = {}; } break; case Array: // Always copy the array source and overwrite the target. target = []; break; default: // Not a plain Object - treat it as a scalar. return source; } for (var prop in source) { // use isValidKey to guard against prototype pollution. See https://snyk.io/vuln/SNYK-JS-LODASH-450202 if (!source.hasOwnProperty(prop) || !isValidKey(prop)) { continue; } target[prop] = deepExtend(target[prop], source[prop]); } return target; } function isValidKey(key) { return key !== '__proto__'; } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var Deferred = /** @class */ (function () { function Deferred() { var _this = this; this.reject = function () { }; this.resolve = function () { }; this.promise = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); } /** * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback * and returns a node-style callback which will resolve or reject the Deferred's promise. */ Deferred.prototype.wrapCallback = function (callback) { var _this = this; return function (error, value) { if (error) { _this.reject(error); } else { _this.resolve(value); } if (typeof callback === 'function') { // Attaching noop handler just in case developer wasn't expecting // promises _this.promise.catch(function () { }); // Some of our callbacks don't expect a value and our own tests // assert that the parameter length is 1 if (callback.length === 1) { callback(error); } else { callback(error, value); } } }; }; return Deferred; }()); /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function createMockUserToken(token, projectId) { if (token.uid) { throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.'); } // Unsecured JWTs use "none" as the algorithm. var header = { alg: 'none', type: 'JWT' }; var project = projectId || 'demo-project'; var iat = token.iat || 0; var sub = token.sub || token.user_id; if (!sub) { throw new Error("mockUserToken must contain 'sub' or 'user_id' field!"); } var payload = __assign({ // Set all required fields to decent defaults iss: "https://securetoken.google.com/" + project, aud: project, iat: iat, exp: iat + 3600, auth_time: iat, sub: sub, user_id: sub, firebase: { sign_in_provider: 'custom', identities: {} } }, token); // Unsecured JWTs use the empty string as a signature. var signature = ''; return [ base64urlEncodeWithoutPadding(JSON.stringify(header)), base64urlEncodeWithoutPadding(JSON.stringify(payload)), signature ].join('.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Returns navigator.userAgent string or '' if it's not defined. * @return user agent string */ function getUA() { if (typeof navigator !== 'undefined' && typeof navigator['userAgent'] === 'string') { return navigator['userAgent']; } else { return ''; } } /** * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device. * * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally * wait for a callback. */ function isMobileCordova() { return (typeof window !== 'undefined' && // @ts-ignore Setting up an broadly applicable index signature for Window // just to deal with this case would probably be a bad idea. !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())); } /** * Detect Node.js. * * @return true if Node.js environment is detected. */ // Node detection logic from: https://github.com/iliakan/detect-node/ function isNode() { try { return (Object.prototype.toString.call(global.process) === '[object process]'); } catch (e) { return false; } } /** * Detect Browser Environment */ function isBrowser() { return typeof self === 'object' && self.self === self; } function isBrowserExtension() { var runtime = typeof chrome === 'object' ? chrome.runtime : typeof browser === 'object' ? browser.runtime : undefined; return typeof runtime === 'object' && runtime.id !== undefined; } /** * Detect React Native. * * @return true if ReactNative environment is detected. */ function isReactNative() { return (typeof navigator === 'object' && navigator['product'] === 'ReactNative'); } /** Detects Electron apps. */ function isElectron() { return getUA().indexOf('Electron/') >= 0; } /** Detects Internet Explorer. */ function isIE() { var ua = getUA(); return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0; } /** Detects Universal Windows Platform apps. */ function isUWP() { return getUA().indexOf('MSAppHost/') >= 0; } /** * Detect whether the current SDK build is the Node version. * * @return true if it's the Node SDK build. */ function isNodeSdk() { return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true; } /** Returns true if we are running in Safari. */ function isSafari() { return (!isNode() && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')); } /** * This method checks if indexedDB is supported by current browser/service worker context * @return true if indexedDB is supported by current browser/service worker context */ function isIndexedDBAvailable() { return typeof indexedDB === 'object'; } /** * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject * if errors occur during the database open operation. * * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox * private browsing) */ function validateIndexedDBOpenable() { return new Promise(function (resolve, reject) { try { var preExist_1 = true; var DB_CHECK_NAME_1 = 'validate-browser-context-for-indexeddb-analytics-module'; var request_1 = self.indexedDB.open(DB_CHECK_NAME_1); request_1.onsuccess = function () { request_1.result.close(); // delete database only when it doesn't pre-exist if (!preExist_1) { self.indexedDB.deleteDatabase(DB_CHECK_NAME_1); } resolve(true); }; request_1.onupgradeneeded = function () { preExist_1 = false; }; request_1.onerror = function () { var _a; reject(((_a = request_1.error) === null || _a === void 0 ? void 0 : _a.message) || ''); }; } catch (error) { reject(error); } }); } /** * * This method checks whether cookie is enabled within current browser * @return true if cookie is enabled within current browser */ function areCookiesEnabled() { if (typeof navigator === 'undefined' || !navigator.cookieEnabled) { return false; } return true; } /** * Polyfill for `globalThis` object. * @returns the `globalThis` object for the given environment. */ function getGlobal() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } throw new Error('Unable to locate global object.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var ERROR_NAME = 'FirebaseError'; // Based on code from: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types var FirebaseError = /** @class */ (function (_super) { __extends(FirebaseError, _super); function FirebaseError( /** The error code for this error. */ code, message, /** Custom data for this error. */ customData) { var _this = _super.call(this, message) || this; _this.code = code; _this.customData = customData; /** The custom name for all FirebaseErrors. */ _this.name = ERROR_NAME; // Fix For ES5 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(_this, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. // Only available on V8. if (Error.captureStackTrace) { Error.captureStackTrace(_this, ErrorFactory.prototype.create); } return _this; } return FirebaseError; }(Error)); var ErrorFactory = /** @class */ (function () { function ErrorFactory(service, serviceName, errors) { this.service = service; this.serviceName = serviceName; this.errors = errors; } ErrorFactory.prototype.create = function (code) { var data = []; for (var _i = 1; _i < arguments.length; _i++) { data[_i - 1] = arguments[_i]; } var customData = data[0] || {}; var fullCode = this.service + "/" + code; var template = this.errors[code]; var message = template ? replaceTemplate(template, customData) : 'Error'; // Service Name: Error message (service/code). var fullMessage = this.serviceName + ": " + message + " (" + fullCode + ")."; var error = new FirebaseError(fullCode, fullMessage, customData); return error; }; return ErrorFactory; }()); function replaceTemplate(template, data) { return template.replace(PATTERN, function (_, key) { var value = data[key]; return value != null ? String(value) : "<" + key + "?>"; }); } var PATTERN = /\{\$([^}]+)}/g; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Evaluates a JSON string into a javascript object. * * @param {string} str A string containing JSON. * @return {*} The javascript object representing the specified JSON. */ function jsonEval(str) { return JSON.parse(str); } /** * Returns JSON representing a javascript object. * @param {*} data Javascript object to be stringified. * @return {string} The JSON contents of the object. */ function stringify(data) { return JSON.stringify(data); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Decodes a Firebase auth. token into constituent parts. * * Notes: * - May return with invalid / incomplete claims if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var decode = function (token) { var header = {}, claims = {}, data = {}, signature = ''; try { var parts = token.split('.'); header = jsonEval(base64Decode(parts[0]) || ''); claims = jsonEval(base64Decode(parts[1]) || ''); signature = parts[2]; data = claims['d'] || {}; delete claims['d']; } catch (e) { } return { header: header, claims: claims, data: data, signature: signature }; }; /** * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isValidTimestamp = function (token) { var claims = decode(token).claims; var now = Math.floor(new Date().getTime() / 1000); var validSince = 0, validUntil = 0; if (typeof claims === 'object') { if (claims.hasOwnProperty('nbf')) { validSince = claims['nbf']; } else if (claims.hasOwnProperty('iat')) { validSince = claims['iat']; } if (claims.hasOwnProperty('exp')) { validUntil = claims['exp']; } else { // token will expire after 24h by default validUntil = validSince + 86400; } } return (!!now && !!validSince && !!validUntil && now >= validSince && now <= validUntil); }; /** * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise. * * Notes: * - May return null if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var issuedAtTime = function (token) { var claims = decode(token).claims; if (typeof claims === 'object' && claims.hasOwnProperty('iat')) { return claims['iat']; } return null; }; /** * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isValidFormat = function (token) { var decoded = decode(token), claims = decoded.claims; return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat'); }; /** * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isAdmin = function (token) { var claims = decode(token).claims; return typeof claims === 'object' && claims['admin'] === true; }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License");
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/util/dist/index.esm2017.js
aws/lti-middleware/node_modules/@firebase/util/dist/index.esm2017.js
/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time. */ const CONSTANTS = { /** * @define {boolean} Whether this is the client Node.js SDK. */ NODE_CLIENT: false, /** * @define {boolean} Whether this is the Admin Node.js SDK. */ NODE_ADMIN: false, /** * Firebase SDK Version */ SDK_VERSION: '${JSCORE_VERSION}' }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Throws an error if the provided assertion is falsy */ const assert = function (assertion, message) { if (!assertion) { throw assertionError(message); } }; /** * Returns an Error object suitable for throwing. */ const assertionError = function (message) { return new Error('Firebase Database (' + CONSTANTS.SDK_VERSION + ') INTERNAL ASSERT FAILED: ' + message); }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const stringToByteArray$1 = function (str) { // TODO(user): Use native implementations if/when available const out = []; let p = 0; for (let i = 0; i < str.length; i++) { let c = str.charCodeAt(i); if (c < 128) { out[p++] = c; } else if (c < 2048) { out[p++] = (c >> 6) | 192; out[p++] = (c & 63) | 128; } else if ((c & 0xfc00) === 0xd800 && i + 1 < str.length && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) { // Surrogate Pair c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff); out[p++] = (c >> 18) | 240; out[p++] = ((c >> 12) & 63) | 128; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } else { out[p++] = (c >> 12) | 224; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } } return out; }; /** * Turns an array of numbers into the string given by the concatenation of the * characters to which the numbers correspond. * @param bytes Array of numbers representing characters. * @return Stringification of the array. */ const byteArrayToString = function (bytes) { // TODO(user): Use native implementations if/when available const out = []; let pos = 0, c = 0; while (pos < bytes.length) { const c1 = bytes[pos++]; if (c1 < 128) { out[c++] = String.fromCharCode(c1); } else if (c1 > 191 && c1 < 224) { const c2 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else if (c1 > 239 && c1 < 365) { // Surrogate Pair const c2 = bytes[pos++]; const c3 = bytes[pos++]; const c4 = bytes[pos++]; const u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) - 0x10000; out[c++] = String.fromCharCode(0xd800 + (u >> 10)); out[c++] = String.fromCharCode(0xdc00 + (u & 1023)); } else { const c2 = bytes[pos++]; const c3 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); } } return out.join(''); }; // We define it as an object literal instead of a class because a class compiled down to es5 can't // be treeshaked. https://github.com/rollup/rollup/issues/1691 // Static lookup maps, lazily populated by init_() const base64 = { /** * Maps bytes to characters. */ byteToCharMap_: null, /** * Maps characters to bytes. */ charToByteMap_: null, /** * Maps bytes to websafe characters. * @private */ byteToCharMapWebSafe_: null, /** * Maps websafe characters to bytes. * @private */ charToByteMapWebSafe_: null, /** * Our default alphabet, shared between * ENCODED_VALS and ENCODED_VALS_WEBSAFE */ ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789', /** * Our default alphabet. Value 64 (=) is special; it means "nothing." */ get ENCODED_VALS() { return this.ENCODED_VALS_BASE + '+/='; }, /** * Our websafe alphabet. */ get ENCODED_VALS_WEBSAFE() { return this.ENCODED_VALS_BASE + '-_.'; }, /** * Whether this browser supports the atob and btoa functions. This extension * started at Mozilla but is now implemented by many browsers. We use the * ASSUME_* variables to avoid pulling in the full useragent detection library * but still allowing the standard per-browser compilations. * */ HAS_NATIVE_SUPPORT: typeof atob === 'function', /** * Base64-encode an array of bytes. * * @param input An array of bytes (numbers with * value in [0, 255]) to encode. * @param webSafe Boolean indicating we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeByteArray(input, webSafe) { if (!Array.isArray(input)) { throw Error('encodeByteArray takes an array as a parameter'); } this.init_(); const byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_; const output = []; for (let i = 0; i < input.length; i += 3) { const byte1 = input[i]; const haveByte2 = i + 1 < input.length; const byte2 = haveByte2 ? input[i + 1] : 0; const haveByte3 = i + 2 < input.length; const byte3 = haveByte3 ? input[i + 2] : 0; const outByte1 = byte1 >> 2; const outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); let outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); let outByte4 = byte3 & 0x3f; if (!haveByte3) { outByte4 = 64; if (!haveByte2) { outByte3 = 64; } } output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]); } return output.join(''); }, /** * Base64-encode a string. * * @param input A string to encode. * @param webSafe If true, we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeString(input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return btoa(input); } return this.encodeByteArray(stringToByteArray$1(input), webSafe); }, /** * Base64-decode a string. * * @param input to decode. * @param webSafe True if we should use the * alternative alphabet. * @return string representing the decoded value. */ decodeString(input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return atob(input); } return byteArrayToString(this.decodeStringToByteArray(input, webSafe)); }, /** * Base64-decode a string. * * In base-64 decoding, groups of four characters are converted into three * bytes. If the encoder did not apply padding, the input length may not * be a multiple of 4. * * In this case, the last group will have fewer than 4 characters, and * padding will be inferred. If the group has one or two characters, it decodes * to one byte. If the group has three characters, it decodes to two bytes. * * @param input Input to decode. * @param webSafe True if we should use the web-safe alphabet. * @return bytes representing the decoded value. */ decodeStringToByteArray(input, webSafe) { this.init_(); const charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_; const output = []; for (let i = 0; i < input.length;) { const byte1 = charToByteMap[input.charAt(i++)]; const haveByte2 = i < input.length; const byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0; ++i; const haveByte3 = i < input.length; const byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64; ++i; const haveByte4 = i < input.length; const byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64; ++i; if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) { throw Error(); } const outByte1 = (byte1 << 2) | (byte2 >> 4); output.push(outByte1); if (byte3 !== 64) { const outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2); output.push(outByte2); if (byte4 !== 64) { const outByte3 = ((byte3 << 6) & 0xc0) | byte4; output.push(outByte3); } } } return output; }, /** * Lazy static initialization function. Called before * accessing any of the static map variables. * @private */ init_() { if (!this.byteToCharMap_) { this.byteToCharMap_ = {}; this.charToByteMap_ = {}; this.byteToCharMapWebSafe_ = {}; this.charToByteMapWebSafe_ = {}; // We want quick mappings back and forth, so we precompute two maps. for (let i = 0; i < this.ENCODED_VALS.length; i++) { this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i); this.charToByteMap_[this.byteToCharMap_[i]] = i; this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i); this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i; // Be forgiving when decoding and correctly decode both encodings. if (i >= this.ENCODED_VALS_BASE.length) { this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i; this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i; } } } } }; /** * URL-safe base64 encoding */ const base64Encode = function (str) { const utf8Bytes = stringToByteArray$1(str); return base64.encodeByteArray(utf8Bytes, true); }; /** * URL-safe base64 encoding (without "." padding in the end). * e.g. Used in JSON Web Token (JWT) parts. */ const base64urlEncodeWithoutPadding = function (str) { // Use base64url encoding and remove padding in the end (dot characters). return base64Encode(str).replace(/\./g, ''); }; /** * URL-safe base64 decoding * * NOTE: DO NOT use the global atob() function - it does NOT support the * base64Url variant encoding. * * @param str To be decoded * @return Decoded result, if possible */ const base64Decode = function (str) { try { return base64.decodeString(str, true); } catch (e) { console.error('base64Decode failed: ', e); } return null; }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Do a deep-copy of basic JavaScript Objects or Arrays. */ function deepCopy(value) { return deepExtend(undefined, value); } /** * Copy properties from source to target (recursively allows extension * of Objects and Arrays). Scalar values in the target are over-written. * If target is undefined, an object of the appropriate type will be created * (and returned). * * We recursively copy all child properties of plain Objects in the source- so * that namespace- like dictionaries are merged. * * Note that the target can be a function, in which case the properties in * the source Object are copied onto it as static properties of the Function. * * Note: we don't merge __proto__ to prevent prototype pollution */ function deepExtend(target, source) { if (!(source instanceof Object)) { return source; } switch (source.constructor) { case Date: // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! const dateValue = source; return new Date(dateValue.getTime()); case Object: if (target === undefined) { target = {}; } break; case Array: // Always copy the array source and overwrite the target. target = []; break; default: // Not a plain Object - treat it as a scalar. return source; } for (const prop in source) { // use isValidKey to guard against prototype pollution. See https://snyk.io/vuln/SNYK-JS-LODASH-450202 if (!source.hasOwnProperty(prop) || !isValidKey(prop)) { continue; } target[prop] = deepExtend(target[prop], source[prop]); } return target; } function isValidKey(key) { return key !== '__proto__'; } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class Deferred { constructor() { this.reject = () => { }; this.resolve = () => { }; this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); } /** * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback * and returns a node-style callback which will resolve or reject the Deferred's promise. */ wrapCallback(callback) { return (error, value) => { if (error) { this.reject(error); } else { this.resolve(value); } if (typeof callback === 'function') { // Attaching noop handler just in case developer wasn't expecting // promises this.promise.catch(() => { }); // Some of our callbacks don't expect a value and our own tests // assert that the parameter length is 1 if (callback.length === 1) { callback(error); } else { callback(error, value); } } }; } } /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function createMockUserToken(token, projectId) { if (token.uid) { throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.'); } // Unsecured JWTs use "none" as the algorithm. const header = { alg: 'none', type: 'JWT' }; const project = projectId || 'demo-project'; const iat = token.iat || 0; const sub = token.sub || token.user_id; if (!sub) { throw new Error("mockUserToken must contain 'sub' or 'user_id' field!"); } const payload = Object.assign({ // Set all required fields to decent defaults iss: `https://securetoken.google.com/${project}`, aud: project, iat, exp: iat + 3600, auth_time: iat, sub, user_id: sub, firebase: { sign_in_provider: 'custom', identities: {} } }, token); // Unsecured JWTs use the empty string as a signature. const signature = ''; return [ base64urlEncodeWithoutPadding(JSON.stringify(header)), base64urlEncodeWithoutPadding(JSON.stringify(payload)), signature ].join('.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Returns navigator.userAgent string or '' if it's not defined. * @return user agent string */ function getUA() { if (typeof navigator !== 'undefined' && typeof navigator['userAgent'] === 'string') { return navigator['userAgent']; } else { return ''; } } /** * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device. * * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally * wait for a callback. */ function isMobileCordova() { return (typeof window !== 'undefined' && // @ts-ignore Setting up an broadly applicable index signature for Window // just to deal with this case would probably be a bad idea. !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())); } /** * Detect Node.js. * * @return true if Node.js environment is detected. */ // Node detection logic from: https://github.com/iliakan/detect-node/ function isNode() { try { return (Object.prototype.toString.call(global.process) === '[object process]'); } catch (e) { return false; } } /** * Detect Browser Environment */ function isBrowser() { return typeof self === 'object' && self.self === self; } function isBrowserExtension() { const runtime = typeof chrome === 'object' ? chrome.runtime : typeof browser === 'object' ? browser.runtime : undefined; return typeof runtime === 'object' && runtime.id !== undefined; } /** * Detect React Native. * * @return true if ReactNative environment is detected. */ function isReactNative() { return (typeof navigator === 'object' && navigator['product'] === 'ReactNative'); } /** Detects Electron apps. */ function isElectron() { return getUA().indexOf('Electron/') >= 0; } /** Detects Internet Explorer. */ function isIE() { const ua = getUA(); return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0; } /** Detects Universal Windows Platform apps. */ function isUWP() { return getUA().indexOf('MSAppHost/') >= 0; } /** * Detect whether the current SDK build is the Node version. * * @return true if it's the Node SDK build. */ function isNodeSdk() { return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true; } /** Returns true if we are running in Safari. */ function isSafari() { return (!isNode() && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')); } /** * This method checks if indexedDB is supported by current browser/service worker context * @return true if indexedDB is supported by current browser/service worker context */ function isIndexedDBAvailable() { return typeof indexedDB === 'object'; } /** * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject * if errors occur during the database open operation. * * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox * private browsing) */ function validateIndexedDBOpenable() { return new Promise((resolve, reject) => { try { let preExist = true; const DB_CHECK_NAME = 'validate-browser-context-for-indexeddb-analytics-module'; const request = self.indexedDB.open(DB_CHECK_NAME); request.onsuccess = () => { request.result.close(); // delete database only when it doesn't pre-exist if (!preExist) { self.indexedDB.deleteDatabase(DB_CHECK_NAME); } resolve(true); }; request.onupgradeneeded = () => { preExist = false; }; request.onerror = () => { var _a; reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || ''); }; } catch (error) { reject(error); } }); } /** * * This method checks whether cookie is enabled within current browser * @return true if cookie is enabled within current browser */ function areCookiesEnabled() { if (typeof navigator === 'undefined' || !navigator.cookieEnabled) { return false; } return true; } /** * Polyfill for `globalThis` object. * @returns the `globalThis` object for the given environment. */ function getGlobal() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } throw new Error('Unable to locate global object.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Standardized Firebase Error. * * Usage: * * // Typescript string literals for type-safe codes * type Err = * 'unknown' | * 'object-not-found' * ; * * // Closure enum for type-safe error codes * // at-enum {string} * var Err = { * UNKNOWN: 'unknown', * OBJECT_NOT_FOUND: 'object-not-found', * } * * let errors: Map<Err, string> = { * 'generic-error': "Unknown error", * 'file-not-found': "Could not find file: {$file}", * }; * * // Type-safe function - must pass a valid error code as param. * let error = new ErrorFactory<Err>('service', 'Service', errors); * * ... * throw error.create(Err.GENERIC); * ... * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName}); * ... * // Service: Could not file file: foo.txt (service/file-not-found). * * catch (e) { * assert(e.message === "Could not find file: foo.txt."); * if (e.code === 'service/file-not-found') { * console.log("Could not read file: " + e['file']); * } * } */ const ERROR_NAME = 'FirebaseError'; // Based on code from: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types class FirebaseError extends Error { constructor( /** The error code for this error. */ code, message, /** Custom data for this error. */ customData) { super(message); this.code = code; this.customData = customData; /** The custom name for all FirebaseErrors. */ this.name = ERROR_NAME; // Fix For ES5 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(this, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. // Only available on V8. if (Error.captureStackTrace) { Error.captureStackTrace(this, ErrorFactory.prototype.create); } } } class ErrorFactory { constructor(service, serviceName, errors) { this.service = service; this.serviceName = serviceName; this.errors = errors; } create(code, ...data) { const customData = data[0] || {}; const fullCode = `${this.service}/${code}`; const template = this.errors[code]; const message = template ? replaceTemplate(template, customData) : 'Error'; // Service Name: Error message (service/code). const fullMessage = `${this.serviceName}: ${message} (${fullCode}).`; const error = new FirebaseError(fullCode, fullMessage, customData); return error; } } function replaceTemplate(template, data) { return template.replace(PATTERN, (_, key) => { const value = data[key]; return value != null ? String(value) : `<${key}?>`; }); } const PATTERN = /\{\$([^}]+)}/g; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Evaluates a JSON string into a javascript object. * * @param {string} str A string containing JSON. * @return {*} The javascript object representing the specified JSON. */ function jsonEval(str) { return JSON.parse(str); } /** * Returns JSON representing a javascript object. * @param {*} data Javascript object to be stringified. * @return {string} The JSON contents of the object. */ function stringify(data) { return JSON.stringify(data); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Decodes a Firebase auth. token into constituent parts. * * Notes: * - May return with invalid / incomplete claims if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const decode = function (token) { let header = {}, claims = {}, data = {}, signature = ''; try { const parts = token.split('.'); header = jsonEval(base64Decode(parts[0]) || ''); claims = jsonEval(base64Decode(parts[1]) || ''); signature = parts[2]; data = claims['d'] || {}; delete claims['d']; } catch (e) { } return { header, claims, data, signature }; }; /** * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const isValidTimestamp = function (token) { const claims = decode(token).claims; const now = Math.floor(new Date().getTime() / 1000); let validSince = 0, validUntil = 0; if (typeof claims === 'object') { if (claims.hasOwnProperty('nbf')) { validSince = claims['nbf']; } else if (claims.hasOwnProperty('iat')) { validSince = claims['iat']; } if (claims.hasOwnProperty('exp')) { validUntil = claims['exp']; } else { // token will expire after 24h by default validUntil = validSince + 86400; } } return (!!now && !!validSince && !!validUntil && now >= validSince && now <= validUntil); }; /** * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise. * * Notes: * - May return null if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const issuedAtTime = function (token) { const claims = decode(token).claims; if (typeof claims === 'object' && claims.hasOwnProperty('iat')) { return claims['iat']; } return null; }; /** * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const isValidFormat = function (token) { const decoded = decode(token), claims = decoded.claims; return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat'); }; /** * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion. * * Notes:
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/util/dist/index.node.cjs.js
aws/lti-middleware/node_modules/@firebase/util/dist/index.node.cjs.js
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time. */ var CONSTANTS = { /** * @define {boolean} Whether this is the client Node.js SDK. */ NODE_CLIENT: false, /** * @define {boolean} Whether this is the Admin Node.js SDK. */ NODE_ADMIN: false, /** * Firebase SDK Version */ SDK_VERSION: '${JSCORE_VERSION}' }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Throws an error if the provided assertion is falsy */ var assert = function (assertion, message) { if (!assertion) { throw assertionError(message); } }; /** * Returns an Error object suitable for throwing. */ var assertionError = function (message) { return new Error('Firebase Database (' + CONSTANTS.SDK_VERSION + ') INTERNAL ASSERT FAILED: ' + message); }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var stringToByteArray$1 = function (str) { // TODO(user): Use native implementations if/when available var out = []; var p = 0; for (var i = 0; i < str.length; i++) { var c = str.charCodeAt(i); if (c < 128) { out[p++] = c; } else if (c < 2048) { out[p++] = (c >> 6) | 192; out[p++] = (c & 63) | 128; } else if ((c & 0xfc00) === 0xd800 && i + 1 < str.length && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) { // Surrogate Pair c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff); out[p++] = (c >> 18) | 240; out[p++] = ((c >> 12) & 63) | 128; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } else { out[p++] = (c >> 12) | 224; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } } return out; }; /** * Turns an array of numbers into the string given by the concatenation of the * characters to which the numbers correspond. * @param bytes Array of numbers representing characters. * @return Stringification of the array. */ var byteArrayToString = function (bytes) { // TODO(user): Use native implementations if/when available var out = []; var pos = 0, c = 0; while (pos < bytes.length) { var c1 = bytes[pos++]; if (c1 < 128) { out[c++] = String.fromCharCode(c1); } else if (c1 > 191 && c1 < 224) { var c2 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else if (c1 > 239 && c1 < 365) { // Surrogate Pair var c2 = bytes[pos++]; var c3 = bytes[pos++]; var c4 = bytes[pos++]; var u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) - 0x10000; out[c++] = String.fromCharCode(0xd800 + (u >> 10)); out[c++] = String.fromCharCode(0xdc00 + (u & 1023)); } else { var c2 = bytes[pos++]; var c3 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); } } return out.join(''); }; // We define it as an object literal instead of a class because a class compiled down to es5 can't // be treeshaked. https://github.com/rollup/rollup/issues/1691 // Static lookup maps, lazily populated by init_() var base64 = { /** * Maps bytes to characters. */ byteToCharMap_: null, /** * Maps characters to bytes. */ charToByteMap_: null, /** * Maps bytes to websafe characters. * @private */ byteToCharMapWebSafe_: null, /** * Maps websafe characters to bytes. * @private */ charToByteMapWebSafe_: null, /** * Our default alphabet, shared between * ENCODED_VALS and ENCODED_VALS_WEBSAFE */ ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789', /** * Our default alphabet. Value 64 (=) is special; it means "nothing." */ get ENCODED_VALS() { return this.ENCODED_VALS_BASE + '+/='; }, /** * Our websafe alphabet. */ get ENCODED_VALS_WEBSAFE() { return this.ENCODED_VALS_BASE + '-_.'; }, /** * Whether this browser supports the atob and btoa functions. This extension * started at Mozilla but is now implemented by many browsers. We use the * ASSUME_* variables to avoid pulling in the full useragent detection library * but still allowing the standard per-browser compilations. * */ HAS_NATIVE_SUPPORT: typeof atob === 'function', /** * Base64-encode an array of bytes. * * @param input An array of bytes (numbers with * value in [0, 255]) to encode. * @param webSafe Boolean indicating we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeByteArray: function (input, webSafe) { if (!Array.isArray(input)) { throw Error('encodeByteArray takes an array as a parameter'); } this.init_(); var byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_; var output = []; for (var i = 0; i < input.length; i += 3) { var byte1 = input[i]; var haveByte2 = i + 1 < input.length; var byte2 = haveByte2 ? input[i + 1] : 0; var haveByte3 = i + 2 < input.length; var byte3 = haveByte3 ? input[i + 2] : 0; var outByte1 = byte1 >> 2; var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); var outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); var outByte4 = byte3 & 0x3f; if (!haveByte3) { outByte4 = 64; if (!haveByte2) { outByte3 = 64; } } output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]); } return output.join(''); }, /** * Base64-encode a string. * * @param input A string to encode. * @param webSafe If true, we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeString: function (input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return btoa(input); } return this.encodeByteArray(stringToByteArray$1(input), webSafe); }, /** * Base64-decode a string. * * @param input to decode. * @param webSafe True if we should use the * alternative alphabet. * @return string representing the decoded value. */ decodeString: function (input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return atob(input); } return byteArrayToString(this.decodeStringToByteArray(input, webSafe)); }, /** * Base64-decode a string. * * In base-64 decoding, groups of four characters are converted into three * bytes. If the encoder did not apply padding, the input length may not * be a multiple of 4. * * In this case, the last group will have fewer than 4 characters, and * padding will be inferred. If the group has one or two characters, it decodes * to one byte. If the group has three characters, it decodes to two bytes. * * @param input Input to decode. * @param webSafe True if we should use the web-safe alphabet. * @return bytes representing the decoded value. */ decodeStringToByteArray: function (input, webSafe) { this.init_(); var charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_; var output = []; for (var i = 0; i < input.length;) { var byte1 = charToByteMap[input.charAt(i++)]; var haveByte2 = i < input.length; var byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0; ++i; var haveByte3 = i < input.length; var byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64; ++i; var haveByte4 = i < input.length; var byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64; ++i; if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) { throw Error(); } var outByte1 = (byte1 << 2) | (byte2 >> 4); output.push(outByte1); if (byte3 !== 64) { var outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2); output.push(outByte2); if (byte4 !== 64) { var outByte3 = ((byte3 << 6) & 0xc0) | byte4; output.push(outByte3); } } } return output; }, /** * Lazy static initialization function. Called before * accessing any of the static map variables. * @private */ init_: function () { if (!this.byteToCharMap_) { this.byteToCharMap_ = {}; this.charToByteMap_ = {}; this.byteToCharMapWebSafe_ = {}; this.charToByteMapWebSafe_ = {}; // We want quick mappings back and forth, so we precompute two maps. for (var i = 0; i < this.ENCODED_VALS.length; i++) { this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i); this.charToByteMap_[this.byteToCharMap_[i]] = i; this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i); this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i; // Be forgiving when decoding and correctly decode both encodings. if (i >= this.ENCODED_VALS_BASE.length) { this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i; this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i; } } } } }; /** * URL-safe base64 encoding */ var base64Encode = function (str) { var utf8Bytes = stringToByteArray$1(str); return base64.encodeByteArray(utf8Bytes, true); }; /** * URL-safe base64 encoding (without "." padding in the end). * e.g. Used in JSON Web Token (JWT) parts. */ var base64urlEncodeWithoutPadding = function (str) { // Use base64url encoding and remove padding in the end (dot characters). return base64Encode(str).replace(/\./g, ''); }; /** * URL-safe base64 decoding * * NOTE: DO NOT use the global atob() function - it does NOT support the * base64Url variant encoding. * * @param str To be decoded * @return Decoded result, if possible */ var base64Decode = function (str) { try { return base64.decodeString(str, true); } catch (e) { console.error('base64Decode failed: ', e); } return null; }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Do a deep-copy of basic JavaScript Objects or Arrays. */ function deepCopy(value) { return deepExtend(undefined, value); } /** * Copy properties from source to target (recursively allows extension * of Objects and Arrays). Scalar values in the target are over-written. * If target is undefined, an object of the appropriate type will be created * (and returned). * * We recursively copy all child properties of plain Objects in the source- so * that namespace- like dictionaries are merged. * * Note that the target can be a function, in which case the properties in * the source Object are copied onto it as static properties of the Function. * * Note: we don't merge __proto__ to prevent prototype pollution */ function deepExtend(target, source) { if (!(source instanceof Object)) { return source; } switch (source.constructor) { case Date: // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! var dateValue = source; return new Date(dateValue.getTime()); case Object: if (target === undefined) { target = {}; } break; case Array: // Always copy the array source and overwrite the target. target = []; break; default: // Not a plain Object - treat it as a scalar. return source; } for (var prop in source) { // use isValidKey to guard against prototype pollution. See https://snyk.io/vuln/SNYK-JS-LODASH-450202 if (!source.hasOwnProperty(prop) || !isValidKey(prop)) { continue; } target[prop] = deepExtend(target[prop], source[prop]); } return target; } function isValidKey(key) { return key !== '__proto__'; } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var Deferred = /** @class */ (function () { function Deferred() { var _this = this; this.reject = function () { }; this.resolve = function () { }; this.promise = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); } /** * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback * and returns a node-style callback which will resolve or reject the Deferred's promise. */ Deferred.prototype.wrapCallback = function (callback) { var _this = this; return function (error, value) { if (error) { _this.reject(error); } else { _this.resolve(value); } if (typeof callback === 'function') { // Attaching noop handler just in case developer wasn't expecting // promises _this.promise.catch(function () { }); // Some of our callbacks don't expect a value and our own tests // assert that the parameter length is 1 if (callback.length === 1) { callback(error); } else { callback(error, value); } } }; }; return Deferred; }()); /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function createMockUserToken(token, projectId) { if (token.uid) { throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.'); } // Unsecured JWTs use "none" as the algorithm. var header = { alg: 'none', type: 'JWT' }; var project = projectId || 'demo-project'; var iat = token.iat || 0; var sub = token.sub || token.user_id; if (!sub) { throw new Error("mockUserToken must contain 'sub' or 'user_id' field!"); } var payload = tslib.__assign({ // Set all required fields to decent defaults iss: "https://securetoken.google.com/" + project, aud: project, iat: iat, exp: iat + 3600, auth_time: iat, sub: sub, user_id: sub, firebase: { sign_in_provider: 'custom', identities: {} } }, token); // Unsecured JWTs use the empty string as a signature. var signature = ''; return [ base64urlEncodeWithoutPadding(JSON.stringify(header)), base64urlEncodeWithoutPadding(JSON.stringify(payload)), signature ].join('.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Returns navigator.userAgent string or '' if it's not defined. * @return user agent string */ function getUA() { if (typeof navigator !== 'undefined' && typeof navigator['userAgent'] === 'string') { return navigator['userAgent']; } else { return ''; } } /** * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device. * * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally * wait for a callback. */ function isMobileCordova() { return (typeof window !== 'undefined' && // @ts-ignore Setting up an broadly applicable index signature for Window // just to deal with this case would probably be a bad idea. !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())); } /** * Detect Node.js. * * @return true if Node.js environment is detected. */ // Node detection logic from: https://github.com/iliakan/detect-node/ function isNode() { try { return (Object.prototype.toString.call(global.process) === '[object process]'); } catch (e) { return false; } } /** * Detect Browser Environment */ function isBrowser() { return typeof self === 'object' && self.self === self; } function isBrowserExtension() { var runtime = typeof chrome === 'object' ? chrome.runtime : typeof browser === 'object' ? browser.runtime : undefined; return typeof runtime === 'object' && runtime.id !== undefined; } /** * Detect React Native. * * @return true if ReactNative environment is detected. */ function isReactNative() { return (typeof navigator === 'object' && navigator['product'] === 'ReactNative'); } /** Detects Electron apps. */ function isElectron() { return getUA().indexOf('Electron/') >= 0; } /** Detects Internet Explorer. */ function isIE() { var ua = getUA(); return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0; } /** Detects Universal Windows Platform apps. */ function isUWP() { return getUA().indexOf('MSAppHost/') >= 0; } /** * Detect whether the current SDK build is the Node version. * * @return true if it's the Node SDK build. */ function isNodeSdk() { return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true; } /** Returns true if we are running in Safari. */ function isSafari() { return (!isNode() && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')); } /** * This method checks if indexedDB is supported by current browser/service worker context * @return true if indexedDB is supported by current browser/service worker context */ function isIndexedDBAvailable() { return typeof indexedDB === 'object'; } /** * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject * if errors occur during the database open operation. * * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox * private browsing) */ function validateIndexedDBOpenable() { return new Promise(function (resolve, reject) { try { var preExist_1 = true; var DB_CHECK_NAME_1 = 'validate-browser-context-for-indexeddb-analytics-module'; var request_1 = self.indexedDB.open(DB_CHECK_NAME_1); request_1.onsuccess = function () { request_1.result.close(); // delete database only when it doesn't pre-exist if (!preExist_1) { self.indexedDB.deleteDatabase(DB_CHECK_NAME_1); } resolve(true); }; request_1.onupgradeneeded = function () { preExist_1 = false; }; request_1.onerror = function () { var _a; reject(((_a = request_1.error) === null || _a === void 0 ? void 0 : _a.message) || ''); }; } catch (error) { reject(error); } }); } /** * * This method checks whether cookie is enabled within current browser * @return true if cookie is enabled within current browser */ function areCookiesEnabled() { if (typeof navigator === 'undefined' || !navigator.cookieEnabled) { return false; } return true; } /** * Polyfill for `globalThis` object. * @returns the `globalThis` object for the given environment. */ function getGlobal() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } throw new Error('Unable to locate global object.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var ERROR_NAME = 'FirebaseError'; // Based on code from: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types var FirebaseError = /** @class */ (function (_super) { tslib.__extends(FirebaseError, _super); function FirebaseError( /** The error code for this error. */ code, message, /** Custom data for this error. */ customData) { var _this = _super.call(this, message) || this; _this.code = code; _this.customData = customData; /** The custom name for all FirebaseErrors. */ _this.name = ERROR_NAME; // Fix For ES5 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(_this, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. // Only available on V8. if (Error.captureStackTrace) { Error.captureStackTrace(_this, ErrorFactory.prototype.create); } return _this; } return FirebaseError; }(Error)); var ErrorFactory = /** @class */ (function () { function ErrorFactory(service, serviceName, errors) { this.service = service; this.serviceName = serviceName; this.errors = errors; } ErrorFactory.prototype.create = function (code) { var data = []; for (var _i = 1; _i < arguments.length; _i++) { data[_i - 1] = arguments[_i]; } var customData = data[0] || {}; var fullCode = this.service + "/" + code; var template = this.errors[code]; var message = template ? replaceTemplate(template, customData) : 'Error'; // Service Name: Error message (service/code). var fullMessage = this.serviceName + ": " + message + " (" + fullCode + ")."; var error = new FirebaseError(fullCode, fullMessage, customData); return error; }; return ErrorFactory; }()); function replaceTemplate(template, data) { return template.replace(PATTERN, function (_, key) { var value = data[key]; return value != null ? String(value) : "<" + key + "?>"; }); } var PATTERN = /\{\$([^}]+)}/g; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Evaluates a JSON string into a javascript object. * * @param {string} str A string containing JSON. * @return {*} The javascript object representing the specified JSON. */ function jsonEval(str) { return JSON.parse(str); } /** * Returns JSON representing a javascript object. * @param {*} data Javascript object to be stringified. * @return {string} The JSON contents of the object. */ function stringify(data) { return JSON.stringify(data); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Decodes a Firebase auth. token into constituent parts. * * Notes: * - May return with invalid / incomplete claims if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var decode = function (token) { var header = {}, claims = {}, data = {}, signature = ''; try { var parts = token.split('.'); header = jsonEval(base64Decode(parts[0]) || ''); claims = jsonEval(base64Decode(parts[1]) || ''); signature = parts[2]; data = claims['d'] || {}; delete claims['d']; } catch (e) { } return { header: header, claims: claims, data: data, signature: signature }; }; /** * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isValidTimestamp = function (token) { var claims = decode(token).claims; var now = Math.floor(new Date().getTime() / 1000); var validSince = 0, validUntil = 0; if (typeof claims === 'object') { if (claims.hasOwnProperty('nbf')) { validSince = claims['nbf']; } else if (claims.hasOwnProperty('iat')) { validSince = claims['iat']; } if (claims.hasOwnProperty('exp')) { validUntil = claims['exp']; } else { // token will expire after 24h by default validUntil = validSince + 86400; } } return (!!now && !!validSince && !!validUntil && now >= validSince && now <= validUntil); }; /** * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise. * * Notes: * - May return null if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var issuedAtTime = function (token) { var claims = decode(token).claims; if (typeof claims === 'object' && claims.hasOwnProperty('iat')) { return claims['iat']; } return null; }; /** * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isValidFormat = function (token) { var decoded = decode(token), claims = decoded.claims; return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat'); }; /** * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ var isAdmin = function (token) { var claims = decode(token).claims; return typeof claims === 'object' && claims['admin'] === true; }; /** * @license * Copyright 2017 Google LLC *
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/util/dist/node-esm/index.node.esm.js
aws/lti-middleware/node_modules/@firebase/util/dist/node-esm/index.node.esm.js
/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time. */ const CONSTANTS = { /** * @define {boolean} Whether this is the client Node.js SDK. */ NODE_CLIENT: false, /** * @define {boolean} Whether this is the Admin Node.js SDK. */ NODE_ADMIN: false, /** * Firebase SDK Version */ SDK_VERSION: '${JSCORE_VERSION}' }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Throws an error if the provided assertion is falsy */ const assert = function (assertion, message) { if (!assertion) { throw assertionError(message); } }; /** * Returns an Error object suitable for throwing. */ const assertionError = function (message) { return new Error('Firebase Database (' + CONSTANTS.SDK_VERSION + ') INTERNAL ASSERT FAILED: ' + message); }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const stringToByteArray$1 = function (str) { // TODO(user): Use native implementations if/when available const out = []; let p = 0; for (let i = 0; i < str.length; i++) { let c = str.charCodeAt(i); if (c < 128) { out[p++] = c; } else if (c < 2048) { out[p++] = (c >> 6) | 192; out[p++] = (c & 63) | 128; } else if ((c & 0xfc00) === 0xd800 && i + 1 < str.length && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) { // Surrogate Pair c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff); out[p++] = (c >> 18) | 240; out[p++] = ((c >> 12) & 63) | 128; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } else { out[p++] = (c >> 12) | 224; out[p++] = ((c >> 6) & 63) | 128; out[p++] = (c & 63) | 128; } } return out; }; /** * Turns an array of numbers into the string given by the concatenation of the * characters to which the numbers correspond. * @param bytes Array of numbers representing characters. * @return Stringification of the array. */ const byteArrayToString = function (bytes) { // TODO(user): Use native implementations if/when available const out = []; let pos = 0, c = 0; while (pos < bytes.length) { const c1 = bytes[pos++]; if (c1 < 128) { out[c++] = String.fromCharCode(c1); } else if (c1 > 191 && c1 < 224) { const c2 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else if (c1 > 239 && c1 < 365) { // Surrogate Pair const c2 = bytes[pos++]; const c3 = bytes[pos++]; const c4 = bytes[pos++]; const u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) - 0x10000; out[c++] = String.fromCharCode(0xd800 + (u >> 10)); out[c++] = String.fromCharCode(0xdc00 + (u & 1023)); } else { const c2 = bytes[pos++]; const c3 = bytes[pos++]; out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); } } return out.join(''); }; // We define it as an object literal instead of a class because a class compiled down to es5 can't // be treeshaked. https://github.com/rollup/rollup/issues/1691 // Static lookup maps, lazily populated by init_() const base64 = { /** * Maps bytes to characters. */ byteToCharMap_: null, /** * Maps characters to bytes. */ charToByteMap_: null, /** * Maps bytes to websafe characters. * @private */ byteToCharMapWebSafe_: null, /** * Maps websafe characters to bytes. * @private */ charToByteMapWebSafe_: null, /** * Our default alphabet, shared between * ENCODED_VALS and ENCODED_VALS_WEBSAFE */ ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789', /** * Our default alphabet. Value 64 (=) is special; it means "nothing." */ get ENCODED_VALS() { return this.ENCODED_VALS_BASE + '+/='; }, /** * Our websafe alphabet. */ get ENCODED_VALS_WEBSAFE() { return this.ENCODED_VALS_BASE + '-_.'; }, /** * Whether this browser supports the atob and btoa functions. This extension * started at Mozilla but is now implemented by many browsers. We use the * ASSUME_* variables to avoid pulling in the full useragent detection library * but still allowing the standard per-browser compilations. * */ HAS_NATIVE_SUPPORT: typeof atob === 'function', /** * Base64-encode an array of bytes. * * @param input An array of bytes (numbers with * value in [0, 255]) to encode. * @param webSafe Boolean indicating we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeByteArray(input, webSafe) { if (!Array.isArray(input)) { throw Error('encodeByteArray takes an array as a parameter'); } this.init_(); const byteToCharMap = webSafe ? this.byteToCharMapWebSafe_ : this.byteToCharMap_; const output = []; for (let i = 0; i < input.length; i += 3) { const byte1 = input[i]; const haveByte2 = i + 1 < input.length; const byte2 = haveByte2 ? input[i + 1] : 0; const haveByte3 = i + 2 < input.length; const byte3 = haveByte3 ? input[i + 2] : 0; const outByte1 = byte1 >> 2; const outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4); let outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6); let outByte4 = byte3 & 0x3f; if (!haveByte3) { outByte4 = 64; if (!haveByte2) { outByte3 = 64; } } output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]); } return output.join(''); }, /** * Base64-encode a string. * * @param input A string to encode. * @param webSafe If true, we should use the * alternative alphabet. * @return The base64 encoded string. */ encodeString(input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return btoa(input); } return this.encodeByteArray(stringToByteArray$1(input), webSafe); }, /** * Base64-decode a string. * * @param input to decode. * @param webSafe True if we should use the * alternative alphabet. * @return string representing the decoded value. */ decodeString(input, webSafe) { // Shortcut for Mozilla browsers that implement // a native base64 encoder in the form of "btoa/atob" if (this.HAS_NATIVE_SUPPORT && !webSafe) { return atob(input); } return byteArrayToString(this.decodeStringToByteArray(input, webSafe)); }, /** * Base64-decode a string. * * In base-64 decoding, groups of four characters are converted into three * bytes. If the encoder did not apply padding, the input length may not * be a multiple of 4. * * In this case, the last group will have fewer than 4 characters, and * padding will be inferred. If the group has one or two characters, it decodes * to one byte. If the group has three characters, it decodes to two bytes. * * @param input Input to decode. * @param webSafe True if we should use the web-safe alphabet. * @return bytes representing the decoded value. */ decodeStringToByteArray(input, webSafe) { this.init_(); const charToByteMap = webSafe ? this.charToByteMapWebSafe_ : this.charToByteMap_; const output = []; for (let i = 0; i < input.length;) { const byte1 = charToByteMap[input.charAt(i++)]; const haveByte2 = i < input.length; const byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0; ++i; const haveByte3 = i < input.length; const byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64; ++i; const haveByte4 = i < input.length; const byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64; ++i; if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) { throw Error(); } const outByte1 = (byte1 << 2) | (byte2 >> 4); output.push(outByte1); if (byte3 !== 64) { const outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2); output.push(outByte2); if (byte4 !== 64) { const outByte3 = ((byte3 << 6) & 0xc0) | byte4; output.push(outByte3); } } } return output; }, /** * Lazy static initialization function. Called before * accessing any of the static map variables. * @private */ init_() { if (!this.byteToCharMap_) { this.byteToCharMap_ = {}; this.charToByteMap_ = {}; this.byteToCharMapWebSafe_ = {}; this.charToByteMapWebSafe_ = {}; // We want quick mappings back and forth, so we precompute two maps. for (let i = 0; i < this.ENCODED_VALS.length; i++) { this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i); this.charToByteMap_[this.byteToCharMap_[i]] = i; this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i); this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i; // Be forgiving when decoding and correctly decode both encodings. if (i >= this.ENCODED_VALS_BASE.length) { this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i; this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i; } } } } }; /** * URL-safe base64 encoding */ const base64Encode = function (str) { const utf8Bytes = stringToByteArray$1(str); return base64.encodeByteArray(utf8Bytes, true); }; /** * URL-safe base64 encoding (without "." padding in the end). * e.g. Used in JSON Web Token (JWT) parts. */ const base64urlEncodeWithoutPadding = function (str) { // Use base64url encoding and remove padding in the end (dot characters). return base64Encode(str).replace(/\./g, ''); }; /** * URL-safe base64 decoding * * NOTE: DO NOT use the global atob() function - it does NOT support the * base64Url variant encoding. * * @param str To be decoded * @return Decoded result, if possible */ const base64Decode = function (str) { try { return base64.decodeString(str, true); } catch (e) { console.error('base64Decode failed: ', e); } return null; }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Do a deep-copy of basic JavaScript Objects or Arrays. */ function deepCopy(value) { return deepExtend(undefined, value); } /** * Copy properties from source to target (recursively allows extension * of Objects and Arrays). Scalar values in the target are over-written. * If target is undefined, an object of the appropriate type will be created * (and returned). * * We recursively copy all child properties of plain Objects in the source- so * that namespace- like dictionaries are merged. * * Note that the target can be a function, in which case the properties in * the source Object are copied onto it as static properties of the Function. * * Note: we don't merge __proto__ to prevent prototype pollution */ function deepExtend(target, source) { if (!(source instanceof Object)) { return source; } switch (source.constructor) { case Date: // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! const dateValue = source; return new Date(dateValue.getTime()); case Object: if (target === undefined) { target = {}; } break; case Array: // Always copy the array source and overwrite the target. target = []; break; default: // Not a plain Object - treat it as a scalar. return source; } for (const prop in source) { // use isValidKey to guard against prototype pollution. See https://snyk.io/vuln/SNYK-JS-LODASH-450202 if (!source.hasOwnProperty(prop) || !isValidKey(prop)) { continue; } target[prop] = deepExtend(target[prop], source[prop]); } return target; } function isValidKey(key) { return key !== '__proto__'; } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class Deferred { constructor() { this.reject = () => { }; this.resolve = () => { }; this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); } /** * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback * and returns a node-style callback which will resolve or reject the Deferred's promise. */ wrapCallback(callback) { return (error, value) => { if (error) { this.reject(error); } else { this.resolve(value); } if (typeof callback === 'function') { // Attaching noop handler just in case developer wasn't expecting // promises this.promise.catch(() => { }); // Some of our callbacks don't expect a value and our own tests // assert that the parameter length is 1 if (callback.length === 1) { callback(error); } else { callback(error, value); } } }; } } /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function createMockUserToken(token, projectId) { if (token.uid) { throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.'); } // Unsecured JWTs use "none" as the algorithm. const header = { alg: 'none', type: 'JWT' }; const project = projectId || 'demo-project'; const iat = token.iat || 0; const sub = token.sub || token.user_id; if (!sub) { throw new Error("mockUserToken must contain 'sub' or 'user_id' field!"); } const payload = Object.assign({ // Set all required fields to decent defaults iss: `https://securetoken.google.com/${project}`, aud: project, iat, exp: iat + 3600, auth_time: iat, sub, user_id: sub, firebase: { sign_in_provider: 'custom', identities: {} } }, token); // Unsecured JWTs use the empty string as a signature. const signature = ''; return [ base64urlEncodeWithoutPadding(JSON.stringify(header)), base64urlEncodeWithoutPadding(JSON.stringify(payload)), signature ].join('.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Returns navigator.userAgent string or '' if it's not defined. * @return user agent string */ function getUA() { if (typeof navigator !== 'undefined' && typeof navigator['userAgent'] === 'string') { return navigator['userAgent']; } else { return ''; } } /** * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device. * * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally * wait for a callback. */ function isMobileCordova() { return (typeof window !== 'undefined' && // @ts-ignore Setting up an broadly applicable index signature for Window // just to deal with this case would probably be a bad idea. !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA())); } /** * Detect Node.js. * * @return true if Node.js environment is detected. */ // Node detection logic from: https://github.com/iliakan/detect-node/ function isNode() { try { return (Object.prototype.toString.call(global.process) === '[object process]'); } catch (e) { return false; } } /** * Detect Browser Environment */ function isBrowser() { return typeof self === 'object' && self.self === self; } function isBrowserExtension() { const runtime = typeof chrome === 'object' ? chrome.runtime : typeof browser === 'object' ? browser.runtime : undefined; return typeof runtime === 'object' && runtime.id !== undefined; } /** * Detect React Native. * * @return true if ReactNative environment is detected. */ function isReactNative() { return (typeof navigator === 'object' && navigator['product'] === 'ReactNative'); } /** Detects Electron apps. */ function isElectron() { return getUA().indexOf('Electron/') >= 0; } /** Detects Internet Explorer. */ function isIE() { const ua = getUA(); return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0; } /** Detects Universal Windows Platform apps. */ function isUWP() { return getUA().indexOf('MSAppHost/') >= 0; } /** * Detect whether the current SDK build is the Node version. * * @return true if it's the Node SDK build. */ function isNodeSdk() { return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true; } /** Returns true if we are running in Safari. */ function isSafari() { return (!isNode() && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')); } /** * This method checks if indexedDB is supported by current browser/service worker context * @return true if indexedDB is supported by current browser/service worker context */ function isIndexedDBAvailable() { return typeof indexedDB === 'object'; } /** * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject * if errors occur during the database open operation. * * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox * private browsing) */ function validateIndexedDBOpenable() { return new Promise((resolve, reject) => { try { let preExist = true; const DB_CHECK_NAME = 'validate-browser-context-for-indexeddb-analytics-module'; const request = self.indexedDB.open(DB_CHECK_NAME); request.onsuccess = () => { request.result.close(); // delete database only when it doesn't pre-exist if (!preExist) { self.indexedDB.deleteDatabase(DB_CHECK_NAME); } resolve(true); }; request.onupgradeneeded = () => { preExist = false; }; request.onerror = () => { var _a; reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || ''); }; } catch (error) { reject(error); } }); } /** * * This method checks whether cookie is enabled within current browser * @return true if cookie is enabled within current browser */ function areCookiesEnabled() { if (typeof navigator === 'undefined' || !navigator.cookieEnabled) { return false; } return true; } /** * Polyfill for `globalThis` object. * @returns the `globalThis` object for the given environment. */ function getGlobal() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } throw new Error('Unable to locate global object.'); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Standardized Firebase Error. * * Usage: * * // Typescript string literals for type-safe codes * type Err = * 'unknown' | * 'object-not-found' * ; * * // Closure enum for type-safe error codes * // at-enum {string} * var Err = { * UNKNOWN: 'unknown', * OBJECT_NOT_FOUND: 'object-not-found', * } * * let errors: Map<Err, string> = { * 'generic-error': "Unknown error", * 'file-not-found': "Could not find file: {$file}", * }; * * // Type-safe function - must pass a valid error code as param. * let error = new ErrorFactory<Err>('service', 'Service', errors); * * ... * throw error.create(Err.GENERIC); * ... * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName}); * ... * // Service: Could not file file: foo.txt (service/file-not-found). * * catch (e) { * assert(e.message === "Could not find file: foo.txt."); * if (e.code === 'service/file-not-found') { * console.log("Could not read file: " + e['file']); * } * } */ const ERROR_NAME = 'FirebaseError'; // Based on code from: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types class FirebaseError extends Error { constructor( /** The error code for this error. */ code, message, /** Custom data for this error. */ customData) { super(message); this.code = code; this.customData = customData; /** The custom name for all FirebaseErrors. */ this.name = ERROR_NAME; // Fix For ES5 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(this, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. // Only available on V8. if (Error.captureStackTrace) { Error.captureStackTrace(this, ErrorFactory.prototype.create); } } } class ErrorFactory { constructor(service, serviceName, errors) { this.service = service; this.serviceName = serviceName; this.errors = errors; } create(code, ...data) { const customData = data[0] || {}; const fullCode = `${this.service}/${code}`; const template = this.errors[code]; const message = template ? replaceTemplate(template, customData) : 'Error'; // Service Name: Error message (service/code). const fullMessage = `${this.serviceName}: ${message} (${fullCode}).`; const error = new FirebaseError(fullCode, fullMessage, customData); return error; } } function replaceTemplate(template, data) { return template.replace(PATTERN, (_, key) => { const value = data[key]; return value != null ? String(value) : `<${key}?>`; }); } const PATTERN = /\{\$([^}]+)}/g; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Evaluates a JSON string into a javascript object. * * @param {string} str A string containing JSON. * @return {*} The javascript object representing the specified JSON. */ function jsonEval(str) { return JSON.parse(str); } /** * Returns JSON representing a javascript object. * @param {*} data Javascript object to be stringified. * @return {string} The JSON contents of the object. */ function stringify(data) { return JSON.stringify(data); } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Decodes a Firebase auth. token into constituent parts. * * Notes: * - May return with invalid / incomplete claims if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const decode = function (token) { let header = {}, claims = {}, data = {}, signature = ''; try { const parts = token.split('.'); header = jsonEval(base64Decode(parts[0]) || ''); claims = jsonEval(base64Decode(parts[1]) || ''); signature = parts[2]; data = claims['d'] || {}; delete claims['d']; } catch (e) { } return { header, claims, data, signature }; }; /** * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const isValidTimestamp = function (token) { const claims = decode(token).claims; const now = Math.floor(new Date().getTime() / 1000); let validSince = 0, validUntil = 0; if (typeof claims === 'object') { if (claims.hasOwnProperty('nbf')) { validSince = claims['nbf']; } else if (claims.hasOwnProperty('iat')) { validSince = claims['iat']; } if (claims.hasOwnProperty('exp')) { validUntil = claims['exp']; } else { // token will expire after 24h by default validUntil = validSince + 86400; } } return (!!now && !!validSince && !!validUntil && now >= validSince && now <= validUntil); }; /** * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise. * * Notes: * - May return null if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const issuedAtTime = function (token) { const claims = decode(token).claims; if (typeof claims === 'object' && claims.hasOwnProperty('iat')) { return claims['iat']; } return null; }; /** * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time. * * Notes: * - May return a false negative if there's no native base64 decoding support. * - Doesn't check if the token is actually valid. */ const isValidFormat = function (token) { const decoded = decode(token), claims = decoded.claims; return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat'); }; /** * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion. * * Notes:
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/logger/dist/index.cjs.js
aws/lti-middleware/node_modules/@firebase/logger/dist/index.cjs.js
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var _a; /** * A container for all of the Logger instances */ var instances = []; /** * The JS SDK supports 5 log levels and also allows a user the ability to * silence the logs altogether. * * The order is a follows: * DEBUG < VERBOSE < INFO < WARN < ERROR * * All of the log types above the current log level will be captured (i.e. if * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and * `VERBOSE` logs will not) */ exports.LogLevel = void 0; (function (LogLevel) { LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG"; LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE"; LogLevel[LogLevel["INFO"] = 2] = "INFO"; LogLevel[LogLevel["WARN"] = 3] = "WARN"; LogLevel[LogLevel["ERROR"] = 4] = "ERROR"; LogLevel[LogLevel["SILENT"] = 5] = "SILENT"; })(exports.LogLevel || (exports.LogLevel = {})); var levelStringToEnum = { 'debug': exports.LogLevel.DEBUG, 'verbose': exports.LogLevel.VERBOSE, 'info': exports.LogLevel.INFO, 'warn': exports.LogLevel.WARN, 'error': exports.LogLevel.ERROR, 'silent': exports.LogLevel.SILENT }; /** * The default log level */ var defaultLogLevel = exports.LogLevel.INFO; /** * By default, `console.debug` is not displayed in the developer console (in * chrome). To avoid forcing users to have to opt-in to these logs twice * (i.e. once for firebase, and once in the console), we are sending `DEBUG` * logs to the `console.log` function. */ var ConsoleMethod = (_a = {}, _a[exports.LogLevel.DEBUG] = 'log', _a[exports.LogLevel.VERBOSE] = 'log', _a[exports.LogLevel.INFO] = 'info', _a[exports.LogLevel.WARN] = 'warn', _a[exports.LogLevel.ERROR] = 'error', _a); /** * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR * messages on to their corresponding console counterparts (if the log method * is supported by the current log level) */ var defaultLogHandler = function (instance, logType) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } if (logType < instance.logLevel) { return; } var now = new Date().toISOString(); var method = ConsoleMethod[logType]; if (method) { console[method].apply(console, tslib.__spreadArray(["[" + now + "] " + instance.name + ":"], args)); } else { throw new Error("Attempted to log a message with an invalid logType (value: " + logType + ")"); } }; var Logger = /** @class */ (function () { /** * Gives you an instance of a Logger to capture messages according to * Firebase's logging scheme. * * @param name The name that the logs will be associated with */ function Logger(name) { this.name = name; /** * The log level of the given Logger instance. */ this._logLevel = defaultLogLevel; /** * The main (internal) log handler for the Logger instance. * Can be set to a new function in internal package code but not by user. */ this._logHandler = defaultLogHandler; /** * The optional, additional, user-defined log handler for the Logger instance. */ this._userLogHandler = null; /** * Capture the current instance for later use */ instances.push(this); } Object.defineProperty(Logger.prototype, "logLevel", { get: function () { return this._logLevel; }, set: function (val) { if (!(val in exports.LogLevel)) { throw new TypeError("Invalid value \"" + val + "\" assigned to `logLevel`"); } this._logLevel = val; }, enumerable: false, configurable: true }); // Workaround for setter/getter having to be the same type. Logger.prototype.setLogLevel = function (val) { this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val; }; Object.defineProperty(Logger.prototype, "logHandler", { get: function () { return this._logHandler; }, set: function (val) { if (typeof val !== 'function') { throw new TypeError('Value assigned to `logHandler` must be a function'); } this._logHandler = val; }, enumerable: false, configurable: true }); Object.defineProperty(Logger.prototype, "userLogHandler", { get: function () { return this._userLogHandler; }, set: function (val) { this._userLogHandler = val; }, enumerable: false, configurable: true }); /** * The functions below are all based on the `console` interface */ Logger.prototype.debug = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.DEBUG], args)); this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.DEBUG], args)); }; Logger.prototype.log = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.VERBOSE], args)); this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.VERBOSE], args)); }; Logger.prototype.info = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.INFO], args)); this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.INFO], args)); }; Logger.prototype.warn = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.WARN], args)); this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.WARN], args)); }; Logger.prototype.error = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.ERROR], args)); this._logHandler.apply(this, tslib.__spreadArray([this, exports.LogLevel.ERROR], args)); }; return Logger; }()); function setLogLevel(level) { instances.forEach(function (inst) { inst.setLogLevel(level); }); } function setUserLogHandler(logCallback, options) { var _loop_1 = function (instance) { var customLogLevel = null; if (options && options.level) { customLogLevel = levelStringToEnum[options.level]; } if (logCallback === null) { instance.userLogHandler = null; } else { instance.userLogHandler = function (instance, level) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } var message = args .map(function (arg) { if (arg == null) { return null; } else if (typeof arg === 'string') { return arg; } else if (typeof arg === 'number' || typeof arg === 'boolean') { return arg.toString(); } else if (arg instanceof Error) { return arg.message; } else { try { return JSON.stringify(arg); } catch (ignored) { return null; } } }) .filter(function (arg) { return arg; }) .join(' '); if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) { logCallback({ level: exports.LogLevel[level].toLowerCase(), message: message, args: args, type: instance.name }); } }; } }; for (var _i = 0, instances_1 = instances; _i < instances_1.length; _i++) { var instance = instances_1[_i]; _loop_1(instance); } } exports.Logger = Logger; exports.setLogLevel = setLogLevel; exports.setUserLogHandler = setUserLogHandler; //# sourceMappingURL=index.cjs.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/logger/dist/esm/index.esm5.js
aws/lti-middleware/node_modules/@firebase/logger/dist/esm/index.esm5.js
import { __spreadArray } from 'tslib'; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var _a; /** * A container for all of the Logger instances */ var instances = []; /** * The JS SDK supports 5 log levels and also allows a user the ability to * silence the logs altogether. * * The order is a follows: * DEBUG < VERBOSE < INFO < WARN < ERROR * * All of the log types above the current log level will be captured (i.e. if * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and * `VERBOSE` logs will not) */ var LogLevel; (function (LogLevel) { LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG"; LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE"; LogLevel[LogLevel["INFO"] = 2] = "INFO"; LogLevel[LogLevel["WARN"] = 3] = "WARN"; LogLevel[LogLevel["ERROR"] = 4] = "ERROR"; LogLevel[LogLevel["SILENT"] = 5] = "SILENT"; })(LogLevel || (LogLevel = {})); var levelStringToEnum = { 'debug': LogLevel.DEBUG, 'verbose': LogLevel.VERBOSE, 'info': LogLevel.INFO, 'warn': LogLevel.WARN, 'error': LogLevel.ERROR, 'silent': LogLevel.SILENT }; /** * The default log level */ var defaultLogLevel = LogLevel.INFO; /** * By default, `console.debug` is not displayed in the developer console (in * chrome). To avoid forcing users to have to opt-in to these logs twice * (i.e. once for firebase, and once in the console), we are sending `DEBUG` * logs to the `console.log` function. */ var ConsoleMethod = (_a = {}, _a[LogLevel.DEBUG] = 'log', _a[LogLevel.VERBOSE] = 'log', _a[LogLevel.INFO] = 'info', _a[LogLevel.WARN] = 'warn', _a[LogLevel.ERROR] = 'error', _a); /** * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR * messages on to their corresponding console counterparts (if the log method * is supported by the current log level) */ var defaultLogHandler = function (instance, logType) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } if (logType < instance.logLevel) { return; } var now = new Date().toISOString(); var method = ConsoleMethod[logType]; if (method) { console[method].apply(console, __spreadArray(["[" + now + "] " + instance.name + ":"], args)); } else { throw new Error("Attempted to log a message with an invalid logType (value: " + logType + ")"); } }; var Logger = /** @class */ (function () { /** * Gives you an instance of a Logger to capture messages according to * Firebase's logging scheme. * * @param name The name that the logs will be associated with */ function Logger(name) { this.name = name; /** * The log level of the given Logger instance. */ this._logLevel = defaultLogLevel; /** * The main (internal) log handler for the Logger instance. * Can be set to a new function in internal package code but not by user. */ this._logHandler = defaultLogHandler; /** * The optional, additional, user-defined log handler for the Logger instance. */ this._userLogHandler = null; /** * Capture the current instance for later use */ instances.push(this); } Object.defineProperty(Logger.prototype, "logLevel", { get: function () { return this._logLevel; }, set: function (val) { if (!(val in LogLevel)) { throw new TypeError("Invalid value \"" + val + "\" assigned to `logLevel`"); } this._logLevel = val; }, enumerable: false, configurable: true }); // Workaround for setter/getter having to be the same type. Logger.prototype.setLogLevel = function (val) { this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val; }; Object.defineProperty(Logger.prototype, "logHandler", { get: function () { return this._logHandler; }, set: function (val) { if (typeof val !== 'function') { throw new TypeError('Value assigned to `logHandler` must be a function'); } this._logHandler = val; }, enumerable: false, configurable: true }); Object.defineProperty(Logger.prototype, "userLogHandler", { get: function () { return this._userLogHandler; }, set: function (val) { this._userLogHandler = val; }, enumerable: false, configurable: true }); /** * The functions below are all based on the `console` interface */ Logger.prototype.debug = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.DEBUG], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.DEBUG], args)); }; Logger.prototype.log = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.VERBOSE], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.VERBOSE], args)); }; Logger.prototype.info = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.INFO], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.INFO], args)); }; Logger.prototype.warn = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.WARN], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.WARN], args)); }; Logger.prototype.error = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this._userLogHandler && this._userLogHandler.apply(this, __spreadArray([this, LogLevel.ERROR], args)); this._logHandler.apply(this, __spreadArray([this, LogLevel.ERROR], args)); }; return Logger; }()); function setLogLevel(level) { instances.forEach(function (inst) { inst.setLogLevel(level); }); } function setUserLogHandler(logCallback, options) { var _loop_1 = function (instance) { var customLogLevel = null; if (options && options.level) { customLogLevel = levelStringToEnum[options.level]; } if (logCallback === null) { instance.userLogHandler = null; } else { instance.userLogHandler = function (instance, level) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } var message = args .map(function (arg) { if (arg == null) { return null; } else if (typeof arg === 'string') { return arg; } else if (typeof arg === 'number' || typeof arg === 'boolean') { return arg.toString(); } else if (arg instanceof Error) { return arg.message; } else { try { return JSON.stringify(arg); } catch (ignored) { return null; } } }) .filter(function (arg) { return arg; }) .join(' '); if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) { logCallback({ level: LogLevel[level].toLowerCase(), message: message, args: args, type: instance.name }); } }; } }; for (var _i = 0, instances_1 = instances; _i < instances_1.length; _i++) { var instance = instances_1[_i]; _loop_1(instance); } } export { LogLevel, Logger, setLogLevel, setUserLogHandler }; //# sourceMappingURL=index.esm5.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/logger/dist/esm/index.esm2017.js
aws/lti-middleware/node_modules/@firebase/logger/dist/esm/index.esm2017.js
/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * A container for all of the Logger instances */ const instances = []; /** * The JS SDK supports 5 log levels and also allows a user the ability to * silence the logs altogether. * * The order is a follows: * DEBUG < VERBOSE < INFO < WARN < ERROR * * All of the log types above the current log level will be captured (i.e. if * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and * `VERBOSE` logs will not) */ var LogLevel; (function (LogLevel) { LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG"; LogLevel[LogLevel["VERBOSE"] = 1] = "VERBOSE"; LogLevel[LogLevel["INFO"] = 2] = "INFO"; LogLevel[LogLevel["WARN"] = 3] = "WARN"; LogLevel[LogLevel["ERROR"] = 4] = "ERROR"; LogLevel[LogLevel["SILENT"] = 5] = "SILENT"; })(LogLevel || (LogLevel = {})); const levelStringToEnum = { 'debug': LogLevel.DEBUG, 'verbose': LogLevel.VERBOSE, 'info': LogLevel.INFO, 'warn': LogLevel.WARN, 'error': LogLevel.ERROR, 'silent': LogLevel.SILENT }; /** * The default log level */ const defaultLogLevel = LogLevel.INFO; /** * By default, `console.debug` is not displayed in the developer console (in * chrome). To avoid forcing users to have to opt-in to these logs twice * (i.e. once for firebase, and once in the console), we are sending `DEBUG` * logs to the `console.log` function. */ const ConsoleMethod = { [LogLevel.DEBUG]: 'log', [LogLevel.VERBOSE]: 'log', [LogLevel.INFO]: 'info', [LogLevel.WARN]: 'warn', [LogLevel.ERROR]: 'error' }; /** * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR * messages on to their corresponding console counterparts (if the log method * is supported by the current log level) */ const defaultLogHandler = (instance, logType, ...args) => { if (logType < instance.logLevel) { return; } const now = new Date().toISOString(); const method = ConsoleMethod[logType]; if (method) { console[method](`[${now}] ${instance.name}:`, ...args); } else { throw new Error(`Attempted to log a message with an invalid logType (value: ${logType})`); } }; class Logger { /** * Gives you an instance of a Logger to capture messages according to * Firebase's logging scheme. * * @param name The name that the logs will be associated with */ constructor(name) { this.name = name; /** * The log level of the given Logger instance. */ this._logLevel = defaultLogLevel; /** * The main (internal) log handler for the Logger instance. * Can be set to a new function in internal package code but not by user. */ this._logHandler = defaultLogHandler; /** * The optional, additional, user-defined log handler for the Logger instance. */ this._userLogHandler = null; /** * Capture the current instance for later use */ instances.push(this); } get logLevel() { return this._logLevel; } set logLevel(val) { if (!(val in LogLevel)) { throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``); } this._logLevel = val; } // Workaround for setter/getter having to be the same type. setLogLevel(val) { this._logLevel = typeof val === 'string' ? levelStringToEnum[val] : val; } get logHandler() { return this._logHandler; } set logHandler(val) { if (typeof val !== 'function') { throw new TypeError('Value assigned to `logHandler` must be a function'); } this._logHandler = val; } get userLogHandler() { return this._userLogHandler; } set userLogHandler(val) { this._userLogHandler = val; } /** * The functions below are all based on the `console` interface */ debug(...args) { this._userLogHandler && this._userLogHandler(this, LogLevel.DEBUG, ...args); this._logHandler(this, LogLevel.DEBUG, ...args); } log(...args) { this._userLogHandler && this._userLogHandler(this, LogLevel.VERBOSE, ...args); this._logHandler(this, LogLevel.VERBOSE, ...args); } info(...args) { this._userLogHandler && this._userLogHandler(this, LogLevel.INFO, ...args); this._logHandler(this, LogLevel.INFO, ...args); } warn(...args) { this._userLogHandler && this._userLogHandler(this, LogLevel.WARN, ...args); this._logHandler(this, LogLevel.WARN, ...args); } error(...args) { this._userLogHandler && this._userLogHandler(this, LogLevel.ERROR, ...args); this._logHandler(this, LogLevel.ERROR, ...args); } } function setLogLevel(level) { instances.forEach(inst => { inst.setLogLevel(level); }); } function setUserLogHandler(logCallback, options) { for (const instance of instances) { let customLogLevel = null; if (options && options.level) { customLogLevel = levelStringToEnum[options.level]; } if (logCallback === null) { instance.userLogHandler = null; } else { instance.userLogHandler = (instance, level, ...args) => { const message = args .map(arg => { if (arg == null) { return null; } else if (typeof arg === 'string') { return arg; } else if (typeof arg === 'number' || typeof arg === 'boolean') { return arg.toString(); } else if (arg instanceof Error) { return arg.message; } else { try { return JSON.stringify(arg); } catch (ignored) { return null; } } }) .filter(arg => arg) .join(' '); if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) { logCallback({ level: LogLevel[level].toLowerCase(), message, args, type: instance.name }); } }; } } } export { LogLevel, Logger, setLogLevel, setUserLogHandler }; //# sourceMappingURL=index.esm2017.js.map
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
false
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.standalone.js
aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.standalone.js
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var require$$2 = require('util'); var require$$0 = require('buffer'); var require$$1 = require('events'); var require$$0$1 = require('stream'); var require$$1$1 = require('crypto'); var require$$2$1 = require('url'); var require$$0$2 = require('assert'); var require$$1$2 = require('net'); var require$$2$2 = require('tls'); var require$$1$3 = require('@firebase/util'); var require$$2$3 = require('tslib'); var require$$3 = require('@firebase/logger'); var component = require('@firebase/component'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1); var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1); var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2); var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2); var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3); var require$$2__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$2$3); var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); var index_standalone = {}; var safeBuffer = {exports: {}}; /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ (function (module, exports) { /* eslint-disable node/no-deprecated-api */ var buffer = require$$0__default["default"]; var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers function copyProps (src, dst) { for (var key in src) { dst[key] = src[key]; } } if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { module.exports = buffer; } else { // Copy properties from require('buffer') copyProps(buffer, exports); exports.Buffer = SafeBuffer; } function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } SafeBuffer.prototype = Object.create(Buffer.prototype); // Copy static methods from Buffer copyProps(Buffer, SafeBuffer); SafeBuffer.from = function (arg, encodingOrOffset, length) { if (typeof arg === 'number') { throw new TypeError('Argument must not be a number') } return Buffer(arg, encodingOrOffset, length) }; SafeBuffer.alloc = function (size, fill, encoding) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } var buf = Buffer(size); if (fill !== undefined) { if (typeof encoding === 'string') { buf.fill(fill, encoding); } else { buf.fill(fill); } } else { buf.fill(0); } return buf }; SafeBuffer.allocUnsafe = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return Buffer(size) }; SafeBuffer.allocUnsafeSlow = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return buffer.SlowBuffer(size) }; }(safeBuffer, safeBuffer.exports)); var streams$1 = {}; /** Streams in a WebSocket connection --------------------------------- We model a WebSocket as two duplex streams: one stream is for the wire protocol over an I/O socket, and the other is for incoming/outgoing messages. +----------+ +---------+ +----------+ [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2] | | +----+----+ | | | | | | | | IO | | [5] | Messages | | | V | | | | +---------+ | | [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3] +----------+ +---------+ +----------+ Message transfer in each direction is simple: IO receives a byte stream [1] and sends this stream for parsing. The parser will periodically emit a complete message text on the Messages stream [2]. Similarly, when messages are written to the Messages stream [3], they are framed using the WebSocket wire format and emitted via IO [4]. There is a feedback loop via [5] since some input from [1] will be things like ping, pong and close frames. In these cases the protocol responds by emitting responses directly back to [4] rather than emitting messages via [2]. For the purposes of flow control, we consider the sources of each Readable stream to be as follows: * [2] receives input from [1] * [4] receives input from [1] and [3] The classes below express the relationships described above without prescribing anything about how parse() and frame() work, other than assuming they emit 'data' events to the IO and Messages streams. They will work with any protocol driver having these two methods. **/ var Stream$3 = require$$0__default$1["default"].Stream, util$c = require$$2__default["default"]; var IO = function(driver) { this.readable = this.writable = true; this._paused = false; this._driver = driver; }; util$c.inherits(IO, Stream$3); // The IO pause() and resume() methods will be called when the socket we are // piping to gets backed up and drains. Since IO output [4] comes from IO input // [1] and Messages input [3], we need to tell both of those to return false // from write() when this stream is paused. IO.prototype.pause = function() { this._paused = true; this._driver.messages._paused = true; }; IO.prototype.resume = function() { this._paused = false; this.emit('drain'); var messages = this._driver.messages; messages._paused = false; messages.emit('drain'); }; // When we receive input from a socket, send it to the parser and tell the // source whether to back off. IO.prototype.write = function(chunk) { if (!this.writable) return false; this._driver.parse(chunk); return !this._paused; }; // The IO end() method will be called when the socket piping into it emits // 'close' or 'end', i.e. the socket is closed. In this situation the Messages // stream will not emit any more data so we emit 'end'. IO.prototype.end = function(chunk) { if (!this.writable) return; if (chunk !== undefined) this.write(chunk); this.writable = false; var messages = this._driver.messages; if (messages.readable) { messages.readable = messages.writable = false; messages.emit('end'); } }; IO.prototype.destroy = function() { this.end(); }; var Messages = function(driver) { this.readable = this.writable = true; this._paused = false; this._driver = driver; }; util$c.inherits(Messages, Stream$3); // The Messages pause() and resume() methods will be called when the app that's // processing the messages gets backed up and drains. If we're emitting // messages too fast we should tell the source to slow down. Message output [2] // comes from IO input [1]. Messages.prototype.pause = function() { this._driver.io._paused = true; }; Messages.prototype.resume = function() { this._driver.io._paused = false; this._driver.io.emit('drain'); }; // When we receive messages from the user, send them to the formatter and tell // the source whether to back off. Messages.prototype.write = function(message) { if (!this.writable) return false; if (typeof message === 'string') this._driver.text(message); else this._driver.binary(message); return !this._paused; }; // The Messages end() method will be called when a stream piping into it emits // 'end'. Many streams may be piped into the WebSocket and one of them ending // does not mean the whole socket is done, so just process the input and move // on leaving the socket open. Messages.prototype.end = function(message) { if (message !== undefined) this.write(message); }; Messages.prototype.destroy = function() {}; streams$1.IO = IO; streams$1.Messages = Messages; var Headers$3 = function() { this.clear(); }; Headers$3.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate']; Headers$3.prototype.clear = function() { this._sent = {}; this._lines = []; }; Headers$3.prototype.set = function(name, value) { if (value === undefined) return; name = this._strip(name); value = this._strip(value); var key = name.toLowerCase(); if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) { this._sent[key] = true; this._lines.push(name + ': ' + value + '\r\n'); } }; Headers$3.prototype.toString = function() { return this._lines.join(''); }; Headers$3.prototype._strip = function(string) { return string.toString().replace(/^ */, '').replace(/ *$/, ''); }; var headers = Headers$3; var Buffer$9 = safeBuffer.exports.Buffer; var StreamReader = function() { this._queue = []; this._queueSize = 0; this._offset = 0; }; StreamReader.prototype.put = function(buffer) { if (!buffer || buffer.length === 0) return; if (!Buffer$9.isBuffer(buffer)) buffer = Buffer$9.from(buffer); this._queue.push(buffer); this._queueSize += buffer.length; }; StreamReader.prototype.read = function(length) { if (length > this._queueSize) return null; if (length === 0) return Buffer$9.alloc(0); this._queueSize -= length; var queue = this._queue, remain = length, first = queue[0], buffers, buffer; if (first.length >= length) { if (first.length === length) { return queue.shift(); } else { buffer = first.slice(0, length); queue[0] = first.slice(length); return buffer; } } for (var i = 0, n = queue.length; i < n; i++) { if (remain < queue[i].length) break; remain -= queue[i].length; } buffers = queue.splice(0, i); if (remain > 0 && queue.length > 0) { buffers.push(queue[0].slice(0, remain)); queue[0] = queue[0].slice(remain); } return Buffer$9.concat(buffers, length); }; StreamReader.prototype.eachByte = function(callback, context) { var buffer, n, index; while (this._queue.length > 0) { buffer = this._queue[0]; n = buffer.length; while (this._offset < n) { index = this._offset; this._offset += 1; callback.call(context, buffer[index]); } this._offset = 0; this._queue.shift(); } }; var stream_reader = StreamReader; var Buffer$8 = safeBuffer.exports.Buffer, Emitter = require$$1__default["default"].EventEmitter, util$b = require$$2__default["default"], streams = streams$1, Headers$2 = headers, Reader = stream_reader; var Base$7 = function(request, url, options) { Emitter.call(this); Base$7.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']); this._request = request; this._reader = new Reader(); this._options = options || {}; this._maxLength = this._options.maxLength || this.MAX_LENGTH; this._headers = new Headers$2(); this.__queue = []; this.readyState = 0; this.url = url; this.io = new streams.IO(this); this.messages = new streams.Messages(this); this._bindEventListeners(); }; util$b.inherits(Base$7, Emitter); Base$7.isWebSocket = function(request) { var connection = request.headers.connection || '', upgrade = request.headers.upgrade || ''; return request.method === 'GET' && connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 && upgrade.toLowerCase() === 'websocket'; }; Base$7.validateOptions = function(options, validKeys) { for (var key in options) { if (validKeys.indexOf(key) < 0) throw new Error('Unrecognized option: ' + key); } }; var instance$b = { // This is 64MB, small enough for an average VPS to handle without // crashing from process out of memory MAX_LENGTH: 0x3ffffff, STATES: ['connecting', 'open', 'closing', 'closed'], _bindEventListeners: function() { var self = this; // Protocol errors are informational and do not have to be handled this.messages.on('error', function() {}); this.on('message', function(event) { var messages = self.messages; if (messages.readable) messages.emit('data', event.data); }); this.on('error', function(error) { var messages = self.messages; if (messages.readable) messages.emit('error', error); }); this.on('close', function() { var messages = self.messages; if (!messages.readable) return; messages.readable = messages.writable = false; messages.emit('end'); }); }, getState: function() { return this.STATES[this.readyState] || null; }, addExtension: function(extension) { return false; }, setHeader: function(name, value) { if (this.readyState > 0) return false; this._headers.set(name, value); return true; }, start: function() { if (this.readyState !== 0) return false; if (!Base$7.isWebSocket(this._request)) return this._failHandshake(new Error('Not a WebSocket request')); var response; try { response = this._handshakeResponse(); } catch (error) { return this._failHandshake(error); } this._write(response); if (this._stage !== -1) this._open(); return true; }, _failHandshake: function(error) { var headers = new Headers$2(); headers.set('Content-Type', 'text/plain'); headers.set('Content-Length', Buffer$8.byteLength(error.message, 'utf8')); headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message]; this._write(Buffer$8.from(headers.join('\r\n'), 'utf8')); this._fail('protocol_error', error.message); return false; }, text: function(message) { return this.frame(message); }, binary: function(message) { return false; }, ping: function() { return false; }, pong: function() { return false; }, close: function(reason, code) { if (this.readyState !== 1) return false; this.readyState = 3; this.emit('close', new Base$7.CloseEvent(null, null)); return true; }, _open: function() { this.readyState = 1; this.__queue.forEach(function(args) { this.frame.apply(this, args); }, this); this.__queue = []; this.emit('open', new Base$7.OpenEvent()); }, _queue: function(message) { this.__queue.push(message); return true; }, _write: function(chunk) { var io = this.io; if (io.readable) io.emit('data', chunk); }, _fail: function(type, message) { this.readyState = 2; this.emit('error', new Error(message)); this.close(); } }; for (var key$b in instance$b) Base$7.prototype[key$b] = instance$b[key$b]; Base$7.ConnectEvent = function() {}; Base$7.OpenEvent = function() {}; Base$7.CloseEvent = function(code, reason) { this.code = code; this.reason = reason; }; Base$7.MessageEvent = function(data) { this.data = data; }; Base$7.PingEvent = function(data) { this.data = data; }; Base$7.PongEvent = function(data) { this.data = data; }; var base = Base$7; var httpParser = {}; /*jshint node:true */ var assert = require$$0__default$2["default"]; httpParser.HTTPParser = HTTPParser; function HTTPParser(type) { assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined); if (type === undefined) ; else { this.initialize(type); } } HTTPParser.prototype.initialize = function (type, async_resource) { assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE); this.type = type; this.state = type + '_LINE'; this.info = { headers: [], upgrade: false }; this.trailers = []; this.line = ''; this.isChunked = false; this.connection = ''; this.headerSize = 0; // for preventing too big headers this.body_bytes = null; this.isUserCall = false; this.hadError = false; }; HTTPParser.encoding = 'ascii'; HTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default; HTTPParser.REQUEST = 'REQUEST'; HTTPParser.RESPONSE = 'RESPONSE'; // Note: *not* starting with kOnHeaders=0 line the Node parser, because any // newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0! var kOnHeaders = HTTPParser.kOnHeaders = 1; var kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2; var kOnBody = HTTPParser.kOnBody = 3; var kOnMessageComplete = HTTPParser.kOnMessageComplete = 4; // Some handler stubs, needed for compatibility HTTPParser.prototype[kOnHeaders] = HTTPParser.prototype[kOnHeadersComplete] = HTTPParser.prototype[kOnBody] = HTTPParser.prototype[kOnMessageComplete] = function () {}; var compatMode0_12 = true; Object.defineProperty(HTTPParser, 'kOnExecute', { get: function () { // hack for backward compatibility compatMode0_12 = false; return 99; } }); var methods = httpParser.methods = HTTPParser.methods = [ 'DELETE', 'GET', 'HEAD', 'POST', 'PUT', 'CONNECT', 'OPTIONS', 'TRACE', 'COPY', 'LOCK', 'MKCOL', 'MOVE', 'PROPFIND', 'PROPPATCH', 'SEARCH', 'UNLOCK', 'BIND', 'REBIND', 'UNBIND', 'ACL', 'REPORT', 'MKACTIVITY', 'CHECKOUT', 'MERGE', 'M-SEARCH', 'NOTIFY', 'SUBSCRIBE', 'UNSUBSCRIBE', 'PATCH', 'PURGE', 'MKCALENDAR', 'LINK', 'UNLINK' ]; var method_connect = methods.indexOf('CONNECT'); HTTPParser.prototype.reinitialize = HTTPParser; HTTPParser.prototype.close = HTTPParser.prototype.pause = HTTPParser.prototype.resume = HTTPParser.prototype.free = function () {}; HTTPParser.prototype._compatMode0_11 = false; HTTPParser.prototype.getAsyncId = function() { return 0; }; var headerState = { REQUEST_LINE: true, RESPONSE_LINE: true, HEADER: true }; HTTPParser.prototype.execute = function (chunk, start, length) { if (!(this instanceof HTTPParser)) { throw new TypeError('not a HTTPParser'); } // backward compat to node < 0.11.4 // Note: the start and length params were removed in newer version start = start || 0; length = typeof length === 'number' ? length : chunk.length; this.chunk = chunk; this.offset = start; var end = this.end = start + length; try { while (this.offset < end) { if (this[this.state]()) { break; } } } catch (err) { if (this.isUserCall) { throw err; } this.hadError = true; return err; } this.chunk = null; length = this.offset - start; if (headerState[this.state]) { this.headerSize += length; if (this.headerSize > HTTPParser.maxHeaderSize) { return new Error('max header size exceeded'); } } return length; }; var stateFinishAllowed = { REQUEST_LINE: true, RESPONSE_LINE: true, BODY_RAW: true }; HTTPParser.prototype.finish = function () { if (this.hadError) { return; } if (!stateFinishAllowed[this.state]) { return new Error('invalid state for EOF'); } if (this.state === 'BODY_RAW') { this.userCall()(this[kOnMessageComplete]()); } }; // These three methods are used for an internal speed optimization, and it also // works if theses are noops. Basically consume() asks us to read the bytes // ourselves, but if we don't do it we get them through execute(). HTTPParser.prototype.consume = HTTPParser.prototype.unconsume = HTTPParser.prototype.getCurrentBuffer = function () {}; //For correct error handling - see HTTPParser#execute //Usage: this.userCall()(userFunction('arg')); HTTPParser.prototype.userCall = function () { this.isUserCall = true; var self = this; return function (ret) { self.isUserCall = false; return ret; }; }; HTTPParser.prototype.nextRequest = function () { this.userCall()(this[kOnMessageComplete]()); this.reinitialize(this.type); }; HTTPParser.prototype.consumeLine = function () { var end = this.end, chunk = this.chunk; for (var i = this.offset; i < end; i++) { if (chunk[i] === 0x0a) { // \n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i); if (line.charAt(line.length - 1) === '\r') { line = line.substr(0, line.length - 1); } this.line = ''; this.offset = i + 1; return line; } } //line split over multiple chunks this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end); this.offset = this.end; }; var headerExp = /^([^: \t]+):[ \t]*((?:.*[^ \t])|)/; var headerContinueExp = /^[ \t]+(.*[^ \t])/; HTTPParser.prototype.parseHeader = function (line, headers) { if (line.indexOf('\r') !== -1) { throw parseErrorCode('HPE_LF_EXPECTED'); } var match = headerExp.exec(line); var k = match && match[1]; if (k) { // skip empty string (malformed header) headers.push(k); headers.push(match[2]); } else { var matchContinue = headerContinueExp.exec(line); if (matchContinue && headers.length) { if (headers[headers.length - 1]) { headers[headers.length - 1] += ' '; } headers[headers.length - 1] += matchContinue[1]; } } }; var requestExp = /^([A-Z-]+) ([^ ]+) HTTP\/(\d)\.(\d)$/; HTTPParser.prototype.REQUEST_LINE = function () { var line = this.consumeLine(); if (!line) { return; } var match = requestExp.exec(line); if (match === null) { throw parseErrorCode('HPE_INVALID_CONSTANT'); } this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]); if (this.info.method === -1) { throw new Error('invalid request method'); } this.info.url = match[2]; this.info.versionMajor = +match[3]; this.info.versionMinor = +match[4]; this.body_bytes = 0; this.state = 'HEADER'; }; var responseExp = /^HTTP\/(\d)\.(\d) (\d{3}) ?(.*)$/; HTTPParser.prototype.RESPONSE_LINE = function () { var line = this.consumeLine(); if (!line) { return; } var match = responseExp.exec(line); if (match === null) { throw parseErrorCode('HPE_INVALID_CONSTANT'); } this.info.versionMajor = +match[1]; this.info.versionMinor = +match[2]; var statusCode = this.info.statusCode = +match[3]; this.info.statusMessage = match[4]; // Implied zero length. if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) { this.body_bytes = 0; } this.state = 'HEADER'; }; HTTPParser.prototype.shouldKeepAlive = function () { if (this.info.versionMajor > 0 && this.info.versionMinor > 0) { if (this.connection.indexOf('close') !== -1) { return false; } } else if (this.connection.indexOf('keep-alive') === -1) { return false; } if (this.body_bytes !== null || this.isChunked) { // || skipBody return true; } return false; }; HTTPParser.prototype.HEADER = function () { var line = this.consumeLine(); if (line === undefined) { return; } var info = this.info; if (line) { this.parseHeader(line, info.headers); } else { var headers = info.headers; var hasContentLength = false; var currentContentLengthValue; var hasUpgradeHeader = false; for (var i = 0; i < headers.length; i += 2) { switch (headers[i].toLowerCase()) { case 'transfer-encoding': this.isChunked = headers[i + 1].toLowerCase() === 'chunked'; break; case 'content-length': currentContentLengthValue = +headers[i + 1]; if (hasContentLength) { // Fix duplicate Content-Length header with same values. // Throw error only if values are different. // Known issues: // https://github.com/request/request/issues/2091#issuecomment-328715113 // https://github.com/nodejs/node/issues/6517#issuecomment-216263771 if (currentContentLengthValue !== this.body_bytes) { throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH'); } } else { hasContentLength = true; this.body_bytes = currentContentLengthValue; } break; case 'connection': this.connection += headers[i + 1].toLowerCase(); break; case 'upgrade': hasUpgradeHeader = true; break; } } // if both isChunked and hasContentLength, isChunked wins // This is required so the body is parsed using the chunked method, and matches // Chrome's behavior. We could, maybe, ignore them both (would get chunked // encoding into the body), and/or disable shouldKeepAlive to be more // resilient. if (this.isChunked && hasContentLength) { hasContentLength = false; this.body_bytes = null; } // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737 // "For responses, "Upgrade: foo" and "Connection: upgrade" are // mandatory only when it is a 101 Switching Protocols response, // otherwise it is purely informational, to announce support. if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) { info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101; } else { info.upgrade = info.method === method_connect; } if (this.isChunked && info.upgrade) { this.isChunked = false; } info.shouldKeepAlive = this.shouldKeepAlive(); //problem which also exists in original node: we should know skipBody before calling onHeadersComplete var skipBody; if (compatMode0_12) { skipBody = this.userCall()(this[kOnHeadersComplete](info)); } else { skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor, info.versionMinor, info.headers, info.method, info.url, info.statusCode, info.statusMessage, info.upgrade, info.shouldKeepAlive)); } if (skipBody === 2) { this.nextRequest(); return true; } else if (this.isChunked && !skipBody) { this.state = 'BODY_CHUNKHEAD'; } else if (skipBody || this.body_bytes === 0) { this.nextRequest(); // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true, // need this "return true;" if it's an upgrade request. return info.upgrade; } else if (this.body_bytes === null) { this.state = 'BODY_RAW'; } else { this.state = 'BODY_SIZED'; } } }; HTTPParser.prototype.BODY_CHUNKHEAD = function () { var line = this.consumeLine(); if (line === undefined) { return; } this.body_bytes = parseInt(line, 16); if (!this.body_bytes) { this.state = 'BODY_CHUNKTRAILERS'; } else { this.state = 'BODY_CHUNK'; } }; HTTPParser.prototype.BODY_CHUNK = function () { var length = Math.min(this.end - this.offset, this.body_bytes); this.userCall()(this[kOnBody](this.chunk, this.offset, length)); this.offset += length; this.body_bytes -= length; if (!this.body_bytes) { this.state = 'BODY_CHUNKEMPTYLINE'; } }; HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () { var line = this.consumeLine(); if (line === undefined) { return; } assert.equal(line, ''); this.state = 'BODY_CHUNKHEAD'; }; HTTPParser.prototype.BODY_CHUNKTRAILERS = function () { var line = this.consumeLine(); if (line === undefined) { return; } if (line) { this.parseHeader(line, this.trailers); } else { if (this.trailers.length) { this.userCall()(this[kOnHeaders](this.trailers, '')); } this.nextRequest(); } }; HTTPParser.prototype.BODY_RAW = function () { var length = this.end - this.offset; this.userCall()(this[kOnBody](this.chunk, this.offset, length)); this.offset = this.end; }; HTTPParser.prototype.BODY_SIZED = function () { var length = Math.min(this.end - this.offset, this.body_bytes); this.userCall()(this[kOnBody](this.chunk, this.offset, length)); this.offset += length; this.body_bytes -= length; if (!this.body_bytes) { this.nextRequest(); } }; // backward compat to node < 0.11.6 ['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) { var k = HTTPParser['kOn' + name]; Object.defineProperty(HTTPParser.prototype, 'on' + name, { get: function () { return this[k]; }, set: function (to) { // hack for backward compatibility this._compatMode0_11 = true; method_connect = 'CONNECT'; return (this[k] = to); } }); }); function parseErrorCode(code) { var err = new Error('Parse Error'); err.code = code; return err; } var NodeHTTPParser = httpParser.HTTPParser, Buffer$7 = safeBuffer.exports.Buffer; var TYPES = { request: NodeHTTPParser.REQUEST || 'request', response: NodeHTTPParser.RESPONSE || 'response' }; var HttpParser$3 = function(type) { this._type = type; this._parser = new NodeHTTPParser(TYPES[type]); this._complete = false; this.headers = {}; var current = null, self = this; this._parser.onHeaderField = function(b, start, length) { current = b.toString('utf8', start, start + length).toLowerCase(); }; this._parser.onHeaderValue = function(b, start, length) { var value = b.toString('utf8', start, start + length); if (self.headers.hasOwnProperty(current)) self.headers[current] += ', ' + value; else self.headers[current] = value; }; this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] = function(majorVersion, minorVersion, headers, method, pathname, statusCode) { var info = arguments[0]; if (typeof info === 'object') { method = info.method; pathname = info.url; statusCode = info.statusCode; headers = info.headers; } self.method = (typeof method === 'number') ? HttpParser$3.METHODS[method] : method; self.statusCode = statusCode; self.url = pathname; if (!headers) return; for (var i = 0, n = headers.length, key, value; i < n; i += 2) { key = headers[i].toLowerCase(); value = headers[i+1]; if (self.headers.hasOwnProperty(key)) self.headers[key] += ', ' + value; else self.headers[key] = value; } self._complete = true; }; }; HttpParser$3.METHODS = { 0: 'DELETE', 1: 'GET', 2: 'HEAD', 3: 'POST', 4: 'PUT', 5: 'CONNECT', 6: 'OPTIONS', 7: 'TRACE', 8: 'COPY', 9: 'LOCK', 10: 'MKCOL', 11: 'MOVE', 12: 'PROPFIND', 13: 'PROPPATCH', 14: 'SEARCH', 15: 'UNLOCK', 16: 'BIND', 17: 'REBIND', 18: 'UNBIND', 19: 'ACL', 20: 'REPORT', 21: 'MKACTIVITY', 22: 'CHECKOUT', 23: 'MERGE', 24: 'M-SEARCH', 25: 'NOTIFY', 26: 'SUBSCRIBE', 27: 'UNSUBSCRIBE', 28: 'PATCH', 29: 'PURGE', 30: 'MKCALENDAR', 31: 'LINK', 32: 'UNLINK' }; var VERSION = process.version ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) }) : []; if (VERSION[0] === 0 && VERSION[1] === 12) { HttpParser$3.METHODS[16] = 'REPORT'; HttpParser$3.METHODS[17] = 'MKACTIVITY'; HttpParser$3.METHODS[18] = 'CHECKOUT'; HttpParser$3.METHODS[19] = 'MERGE'; HttpParser$3.METHODS[20] = 'M-SEARCH'; HttpParser$3.METHODS[21] = 'NOTIFY'; HttpParser$3.METHODS[22] = 'SUBSCRIBE'; HttpParser$3.METHODS[23] = 'UNSUBSCRIBE'; HttpParser$3.METHODS[24] = 'PATCH'; HttpParser$3.METHODS[25] = 'PURGE'; } HttpParser$3.prototype.isComplete = function() { return this._complete; }; HttpParser$3.prototype.parse = function(chunk) { var consumed = this._parser.execute(chunk, 0, chunk.length); if (typeof consumed !== 'number') { this.error = consumed; this._complete = true; return; } if (this._complete) this.body = (consumed < chunk.length) ? chunk.slice(consumed) : Buffer$7.alloc(0); }; var http_parser = HttpParser$3; var TOKEN = /([!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+)/, NOTOKEN = /([^!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z])/g, QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"\\])*)"/, PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'), EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'), EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'), NUMBER = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?$/; var hasOwnProperty = Object.prototype.hasOwnProperty; var Parser$1 = { parseHeader: function(header) { var offers = new Offers();
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.esm5.js
aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.esm5.js
import firebase from '@firebase/app-compat'; import { Provider, ComponentContainer, Component } from '@firebase/component'; import { _validatePathString, onChildMoved, onChildChanged, onChildRemoved, onChildAdded, onValue, off, get, query, limitToFirst, limitToLast, orderByChild, orderByKey, orderByPriority, orderByValue, startAt, startAfter, endAt, endBefore, equalTo, _ReferenceImpl, _QueryImpl, _QueryParams, child, set, _validateWritablePath, update, setWithPriority, remove, runTransaction, setPriority, push, OnDisconnect as OnDisconnect$1, connectDatabaseEmulator, refFromURL, ref, goOffline, goOnline, serverTimestamp, increment, forceWebSockets, forceLongPolling, _setSDKVersion, _repoManagerDatabaseFromApp, enableLogging } from '@firebase/database'; import { errorPrefix, validateArgCount, validateCallback, validateContextObject, Deferred } from '@firebase/util'; import { __extends } from 'tslib'; import { Logger } from '@firebase/logger'; var name = "@firebase/database-compat"; var version = "0.2.1"; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var logClient = new Logger('@firebase/database-compat'); var warn = function (msg) { var message = 'FIREBASE WARNING: ' + msg; logClient.warn(message); }; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var validateBoolean = function (fnName, argumentName, bool, optional) { if (optional && bool === undefined) { return; } if (typeof bool !== 'boolean') { throw new Error(errorPrefix(fnName, argumentName) + 'must be a boolean.'); } }; var validateEventType = function (fnName, eventType, optional) { if (optional && eventType === undefined) { return; } switch (eventType) { case 'value': case 'child_added': case 'child_removed': case 'child_changed': case 'child_moved': break; default: throw new Error(errorPrefix(fnName, 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var OnDisconnect = /** @class */ (function () { function OnDisconnect(_delegate) { this._delegate = _delegate; } OnDisconnect.prototype.cancel = function (onComplete) { validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length); validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true); var result = this._delegate.cancel(); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.remove = function (onComplete) { validateArgCount('OnDisconnect.remove', 0, 1, arguments.length); validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true); var result = this._delegate.remove(); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.set = function (value, onComplete) { validateArgCount('OnDisconnect.set', 1, 2, arguments.length); validateCallback('OnDisconnect.set', 'onComplete', onComplete, true); var result = this._delegate.set(value); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.setWithPriority = function (value, priority, onComplete) { validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length); validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true); var result = this._delegate.setWithPriority(value, priority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.update = function (objectToMerge, onComplete) { validateArgCount('OnDisconnect.update', 1, 2, arguments.length); if (Array.isArray(objectToMerge)) { var newObjectToMerge = {}; for (var i = 0; i < objectToMerge.length; ++i) { newObjectToMerge['' + i] = objectToMerge[i]; } objectToMerge = newObjectToMerge; warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' + 'existing data, or an Object with integer keys if you really do want to only update some of the children.'); } validateCallback('OnDisconnect.update', 'onComplete', onComplete, true); var result = this._delegate.update(objectToMerge); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; return OnDisconnect; }()); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var TransactionResult = /** @class */ (function () { /** * A type for the resolve value of Firebase.transaction. */ function TransactionResult(committed, snapshot) { this.committed = committed; this.snapshot = snapshot; } // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users TransactionResult.prototype.toJSON = function () { validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length); return { committed: this.committed, snapshot: this.snapshot.toJSON() }; }; return TransactionResult; }()); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Class representing a firebase data snapshot. It wraps a SnapshotNode and * surfaces the public methods (val, forEach, etc.) we want to expose. */ var DataSnapshot = /** @class */ (function () { function DataSnapshot(_database, _delegate) { this._database = _database; this._delegate = _delegate; } /** * Retrieves the snapshot contents as JSON. Returns null if the snapshot is * empty. * * @returns JSON representation of the DataSnapshot contents, or null if empty. */ DataSnapshot.prototype.val = function () { validateArgCount('DataSnapshot.val', 0, 0, arguments.length); return this._delegate.val(); }; /** * Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting * the entire node contents. * @returns JSON representation of the DataSnapshot contents, or null if empty. */ DataSnapshot.prototype.exportVal = function () { validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length); return this._delegate.exportVal(); }; // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users DataSnapshot.prototype.toJSON = function () { // Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); }; /** * Returns whether the snapshot contains a non-null value. * * @returns Whether the snapshot contains a non-null value, or is empty. */ DataSnapshot.prototype.exists = function () { validateArgCount('DataSnapshot.exists', 0, 0, arguments.length); return this._delegate.exists(); }; /** * Returns a DataSnapshot of the specified child node's contents. * * @param path - Path to a child. * @returns DataSnapshot for child node. */ DataSnapshot.prototype.child = function (path) { validateArgCount('DataSnapshot.child', 0, 1, arguments.length); // Ensure the childPath is a string (can be a number) path = String(path); _validatePathString('DataSnapshot.child', 'path', path, false); return new DataSnapshot(this._database, this._delegate.child(path)); }; /** * Returns whether the snapshot contains a child at the specified path. * * @param path - Path to a child. * @returns Whether the child exists. */ DataSnapshot.prototype.hasChild = function (path) { validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length); _validatePathString('DataSnapshot.hasChild', 'path', path, false); return this._delegate.hasChild(path); }; /** * Returns the priority of the object, or null if no priority was set. * * @returns The priority. */ DataSnapshot.prototype.getPriority = function () { validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length); return this._delegate.priority; }; /** * Iterates through child nodes and calls the specified action for each one. * * @param action - Callback function to be called * for each child. * @returns True if forEach was canceled by action returning true for * one of the child nodes. */ DataSnapshot.prototype.forEach = function (action) { var _this = this; validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length); validateCallback('DataSnapshot.forEach', 'action', action, false); return this._delegate.forEach(function (expDataSnapshot) { return action(new DataSnapshot(_this._database, expDataSnapshot)); }); }; /** * Returns whether this DataSnapshot has children. * @returns True if the DataSnapshot contains 1 or more child nodes. */ DataSnapshot.prototype.hasChildren = function () { validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length); return this._delegate.hasChildren(); }; Object.defineProperty(DataSnapshot.prototype, "key", { get: function () { return this._delegate.key; }, enumerable: false, configurable: true }); /** * Returns the number of children for this DataSnapshot. * @returns The number of children that this DataSnapshot contains. */ DataSnapshot.prototype.numChildren = function () { validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length); return this._delegate.size; }; /** * @returns The Firebase reference for the location this snapshot's data came * from. */ DataSnapshot.prototype.getRef = function () { validateArgCount('DataSnapshot.ref', 0, 0, arguments.length); return new Reference(this._database, this._delegate.ref); }; Object.defineProperty(DataSnapshot.prototype, "ref", { get: function () { return this.getRef(); }, enumerable: false, configurable: true }); return DataSnapshot; }()); /** * A Query represents a filter to be applied to a firebase location. This object purely represents the * query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js. * * Since every Firebase reference is a query, Firebase inherits from this object. */ var Query = /** @class */ (function () { function Query(database, _delegate) { this.database = database; this._delegate = _delegate; } Query.prototype.on = function (eventType, callback, cancelCallbackOrContext, context) { var _this = this; var _a; validateArgCount('Query.on', 2, 4, arguments.length); validateCallback('Query.on', 'callback', callback, false); var ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context); var valueCallback = function (expSnapshot, previousChildName) { callback.call(ret.context, new DataSnapshot(_this.database, expSnapshot), previousChildName); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; var cancelCallback = (_a = ret.cancel) === null || _a === void 0 ? void 0 : _a.bind(ret.context); switch (eventType) { case 'value': onValue(this._delegate, valueCallback, cancelCallback); return callback; case 'child_added': onChildAdded(this._delegate, valueCallback, cancelCallback); return callback; case 'child_removed': onChildRemoved(this._delegate, valueCallback, cancelCallback); return callback; case 'child_changed': onChildChanged(this._delegate, valueCallback, cancelCallback); return callback; case 'child_moved': onChildMoved(this._delegate, valueCallback, cancelCallback); return callback; default: throw new Error(errorPrefix('Query.on', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } }; Query.prototype.off = function (eventType, callback, context) { validateArgCount('Query.off', 0, 3, arguments.length); validateEventType('Query.off', eventType, true); validateCallback('Query.off', 'callback', callback, true); validateContextObject('Query.off', 'context', context, true); if (callback) { var valueCallback = function () { }; valueCallback.userCallback = callback; valueCallback.context = context; off(this._delegate, eventType, valueCallback); } else { off(this._delegate, eventType); } }; /** * Get the server-value for this query, or return a cached value if not connected. */ Query.prototype.get = function () { var _this = this; return get(this._delegate).then(function (expSnapshot) { return new DataSnapshot(_this.database, expSnapshot); }); }; /** * Attaches a listener, waits for the first event, and then removes the listener */ Query.prototype.once = function (eventType, callback, failureCallbackOrContext, context) { var _this = this; validateArgCount('Query.once', 1, 4, arguments.length); validateCallback('Query.once', 'callback', callback, true); var ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context); var deferred = new Deferred(); var valueCallback = function (expSnapshot, previousChildName) { var result = new DataSnapshot(_this.database, expSnapshot); if (callback) { callback.call(ret.context, result, previousChildName); } deferred.resolve(result); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; var cancelCallback = function (error) { if (ret.cancel) { ret.cancel.call(ret.context, error); } deferred.reject(error); }; switch (eventType) { case 'value': onValue(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_added': onChildAdded(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_removed': onChildRemoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_changed': onChildChanged(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_moved': onChildMoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; default: throw new Error(errorPrefix('Query.once', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } return deferred.promise; }; /** * Set a limit and anchor it to the start of the window. */ Query.prototype.limitToFirst = function (limit) { validateArgCount('Query.limitToFirst', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, limitToFirst(limit))); }; /** * Set a limit and anchor it to the end of the window. */ Query.prototype.limitToLast = function (limit) { validateArgCount('Query.limitToLast', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, limitToLast(limit))); }; /** * Given a child path, return a new query ordered by the specified grandchild path. */ Query.prototype.orderByChild = function (path) { validateArgCount('Query.orderByChild', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, orderByChild(path))); }; /** * Return a new query ordered by the KeyIndex */ Query.prototype.orderByKey = function () { validateArgCount('Query.orderByKey', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByKey())); }; /** * Return a new query ordered by the PriorityIndex */ Query.prototype.orderByPriority = function () { validateArgCount('Query.orderByPriority', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByPriority())); }; /** * Return a new query ordered by the ValueIndex */ Query.prototype.orderByValue = function () { validateArgCount('Query.orderByValue', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByValue())); }; Query.prototype.startAt = function (value, name) { if (value === void 0) { value = null; } validateArgCount('Query.startAt', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, startAt(value, name))); }; Query.prototype.startAfter = function (value, name) { if (value === void 0) { value = null; } validateArgCount('Query.startAfter', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, startAfter(value, name))); }; Query.prototype.endAt = function (value, name) { if (value === void 0) { value = null; } validateArgCount('Query.endAt', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, endAt(value, name))); }; Query.prototype.endBefore = function (value, name) { if (value === void 0) { value = null; } validateArgCount('Query.endBefore', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, endBefore(value, name))); }; /** * Load the selection of children with exactly the specified value, and, optionally, * the specified name. */ Query.prototype.equalTo = function (value, name) { validateArgCount('Query.equalTo', 1, 2, arguments.length); return new Query(this.database, query(this._delegate, equalTo(value, name))); }; /** * @returns URL for this location. */ Query.prototype.toString = function () { validateArgCount('Query.toString', 0, 0, arguments.length); return this._delegate.toString(); }; // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users. Query.prototype.toJSON = function () { // An optional spacer argument is unnecessary for a string. validateArgCount('Query.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); }; /** * Return true if this query and the provided query are equivalent; otherwise, return false. */ Query.prototype.isEqual = function (other) { validateArgCount('Query.isEqual', 1, 1, arguments.length); if (!(other instanceof Query)) { var error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.'; throw new Error(error); } return this._delegate.isEqual(other._delegate); }; /** * Helper used by .on and .once to extract the context and or cancel arguments. * @param fnName - The function name (on or once) * */ Query.getCancelAndContextArgs_ = function (fnName, cancelOrContext, context) { var ret = { cancel: undefined, context: undefined }; if (cancelOrContext && context) { ret.cancel = cancelOrContext; validateCallback(fnName, 'cancel', ret.cancel, true); ret.context = context; validateContextObject(fnName, 'context', ret.context, true); } else if (cancelOrContext) { // we have either a cancel callback or a context. if (typeof cancelOrContext === 'object' && cancelOrContext !== null) { // it's a context! ret.context = cancelOrContext; } else if (typeof cancelOrContext === 'function') { ret.cancel = cancelOrContext; } else { throw new Error(errorPrefix(fnName, 'cancelOrContext') + ' must either be a cancel callback or a context object.'); } } return ret; }; Object.defineProperty(Query.prototype, "ref", { get: function () { return new Reference(this.database, new _ReferenceImpl(this._delegate._repo, this._delegate._path)); }, enumerable: false, configurable: true }); return Query; }()); var Reference = /** @class */ (function (_super) { __extends(Reference, _super); /** * Call options: * new Reference(Repo, Path) or * new Reference(url: string, string|RepoManager) * * Externally - this is the firebase.database.Reference type. */ function Reference(database, _delegate) { var _this = _super.call(this, database, new _QueryImpl(_delegate._repo, _delegate._path, new _QueryParams(), false)) || this; _this.database = database; _this._delegate = _delegate; return _this; } /** @returns {?string} */ Reference.prototype.getKey = function () { validateArgCount('Reference.key', 0, 0, arguments.length); return this._delegate.key; }; Reference.prototype.child = function (pathString) { validateArgCount('Reference.child', 1, 1, arguments.length); if (typeof pathString === 'number') { pathString = String(pathString); } return new Reference(this.database, child(this._delegate, pathString)); }; /** @returns {?Reference} */ Reference.prototype.getParent = function () { validateArgCount('Reference.parent', 0, 0, arguments.length); var parent = this._delegate.parent; return parent ? new Reference(this.database, parent) : null; }; /** @returns {!Reference} */ Reference.prototype.getRoot = function () { validateArgCount('Reference.root', 0, 0, arguments.length); return new Reference(this.database, this._delegate.root); }; Reference.prototype.set = function (newVal, onComplete) { validateArgCount('Reference.set', 1, 2, arguments.length); validateCallback('Reference.set', 'onComplete', onComplete, true); var result = set(this._delegate, newVal); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.update = function (values, onComplete) { validateArgCount('Reference.update', 1, 2, arguments.length); if (Array.isArray(values)) { var newObjectToMerge = {}; for (var i = 0; i < values.length; ++i) { newObjectToMerge['' + i] = values[i]; } values = newObjectToMerge; warn('Passing an Array to Firebase.update() is deprecated. ' + 'Use set() if you want to overwrite the existing data, or ' + 'an Object with integer keys if you really do want to ' + 'only update some of the children.'); } _validateWritablePath('Reference.update', this._delegate._path); validateCallback('Reference.update', 'onComplete', onComplete, true); var result = update(this._delegate, values); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.setWithPriority = function (newVal, newPriority, onComplete) { validateArgCount('Reference.setWithPriority', 2, 3, arguments.length); validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true); var result = setWithPriority(this._delegate, newVal, newPriority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.remove = function (onComplete) { validateArgCount('Reference.remove', 0, 1, arguments.length); validateCallback('Reference.remove', 'onComplete', onComplete, true); var result = remove(this._delegate); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.transaction = function (transactionUpdate, onComplete, applyLocally) { var _this = this; validateArgCount('Reference.transaction', 1, 3, arguments.length); validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false); validateCallback('Reference.transaction', 'onComplete', onComplete, true); validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true); var result = runTransaction(this._delegate, transactionUpdate, { applyLocally: applyLocally }).then(function (transactionResult) { return new TransactionResult(transactionResult.committed, new DataSnapshot(_this.database, transactionResult.snapshot)); }); if (onComplete) { result.then(function (transactionResult) { return onComplete(null, transactionResult.committed, transactionResult.snapshot); }, function (error) { return onComplete(error, false, null); }); } return result; }; Reference.prototype.setPriority = function (priority, onComplete) { validateArgCount('Reference.setPriority', 1, 2, arguments.length); validateCallback('Reference.setPriority', 'onComplete', onComplete, true); var result = setPriority(this._delegate, priority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.push = function (value, onComplete) { var _this = this; validateArgCount('Reference.push', 0, 2, arguments.length); validateCallback('Reference.push', 'onComplete', onComplete, true); var expPromise = push(this._delegate, value); var promise = expPromise.then(function (expRef) { return new Reference(_this.database, expRef); }); if (onComplete) { promise.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } var result = new Reference(this.database, expPromise); result.then = promise.then.bind(promise); result.catch = promise.catch.bind(promise, undefined); return result; }; Reference.prototype.onDisconnect = function () { _validateWritablePath('Reference.onDisconnect', this._delegate._path); return new OnDisconnect(new OnDisconnect$1(this._delegate._repo, this._delegate._path)); }; Object.defineProperty(Reference.prototype, "key", { get: function () { return this.getKey(); }, enumerable: false, configurable: true }); Object.defineProperty(Reference.prototype, "parent", { get: function () { return this.getParent(); }, enumerable: false, configurable: true }); Object.defineProperty(Reference.prototype, "root", { get: function () { return this.getRoot(); }, enumerable: false, configurable: true }); return Reference; }(Query)); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.js
aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.js
'use strict'; var firebase = require('@firebase/app-compat'); var component = require('@firebase/component'); var database = require('@firebase/database'); var util = require('@firebase/util'); var tslib = require('tslib'); var logger = require('@firebase/logger'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase); var name = "@firebase/database-compat"; var version = "0.2.1"; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var logClient = new logger.Logger('@firebase/database-compat'); var warn = function (msg) { var message = 'FIREBASE WARNING: ' + msg; logClient.warn(message); }; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var validateBoolean = function (fnName, argumentName, bool, optional) { if (optional && bool === undefined) { return; } if (typeof bool !== 'boolean') { throw new Error(util.errorPrefix(fnName, argumentName) + 'must be a boolean.'); } }; var validateEventType = function (fnName, eventType, optional) { if (optional && eventType === undefined) { return; } switch (eventType) { case 'value': case 'child_added': case 'child_removed': case 'child_changed': case 'child_moved': break; default: throw new Error(util.errorPrefix(fnName, 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var OnDisconnect = /** @class */ (function () { function OnDisconnect(_delegate) { this._delegate = _delegate; } OnDisconnect.prototype.cancel = function (onComplete) { util.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length); util.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true); var result = this._delegate.cancel(); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.remove = function (onComplete) { util.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length); util.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true); var result = this._delegate.remove(); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.set = function (value, onComplete) { util.validateArgCount('OnDisconnect.set', 1, 2, arguments.length); util.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true); var result = this._delegate.set(value); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.setWithPriority = function (value, priority, onComplete) { util.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length); util.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true); var result = this._delegate.setWithPriority(value, priority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; OnDisconnect.prototype.update = function (objectToMerge, onComplete) { util.validateArgCount('OnDisconnect.update', 1, 2, arguments.length); if (Array.isArray(objectToMerge)) { var newObjectToMerge = {}; for (var i = 0; i < objectToMerge.length; ++i) { newObjectToMerge['' + i] = objectToMerge[i]; } objectToMerge = newObjectToMerge; warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' + 'existing data, or an Object with integer keys if you really do want to only update some of the children.'); } util.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true); var result = this._delegate.update(objectToMerge); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; return OnDisconnect; }()); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var TransactionResult = /** @class */ (function () { /** * A type for the resolve value of Firebase.transaction. */ function TransactionResult(committed, snapshot) { this.committed = committed; this.snapshot = snapshot; } // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users TransactionResult.prototype.toJSON = function () { util.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length); return { committed: this.committed, snapshot: this.snapshot.toJSON() }; }; return TransactionResult; }()); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Class representing a firebase data snapshot. It wraps a SnapshotNode and * surfaces the public methods (val, forEach, etc.) we want to expose. */ var DataSnapshot = /** @class */ (function () { function DataSnapshot(_database, _delegate) { this._database = _database; this._delegate = _delegate; } /** * Retrieves the snapshot contents as JSON. Returns null if the snapshot is * empty. * * @returns JSON representation of the DataSnapshot contents, or null if empty. */ DataSnapshot.prototype.val = function () { util.validateArgCount('DataSnapshot.val', 0, 0, arguments.length); return this._delegate.val(); }; /** * Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting * the entire node contents. * @returns JSON representation of the DataSnapshot contents, or null if empty. */ DataSnapshot.prototype.exportVal = function () { util.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length); return this._delegate.exportVal(); }; // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users DataSnapshot.prototype.toJSON = function () { // Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content util.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); }; /** * Returns whether the snapshot contains a non-null value. * * @returns Whether the snapshot contains a non-null value, or is empty. */ DataSnapshot.prototype.exists = function () { util.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length); return this._delegate.exists(); }; /** * Returns a DataSnapshot of the specified child node's contents. * * @param path - Path to a child. * @returns DataSnapshot for child node. */ DataSnapshot.prototype.child = function (path) { util.validateArgCount('DataSnapshot.child', 0, 1, arguments.length); // Ensure the childPath is a string (can be a number) path = String(path); database._validatePathString('DataSnapshot.child', 'path', path, false); return new DataSnapshot(this._database, this._delegate.child(path)); }; /** * Returns whether the snapshot contains a child at the specified path. * * @param path - Path to a child. * @returns Whether the child exists. */ DataSnapshot.prototype.hasChild = function (path) { util.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length); database._validatePathString('DataSnapshot.hasChild', 'path', path, false); return this._delegate.hasChild(path); }; /** * Returns the priority of the object, or null if no priority was set. * * @returns The priority. */ DataSnapshot.prototype.getPriority = function () { util.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length); return this._delegate.priority; }; /** * Iterates through child nodes and calls the specified action for each one. * * @param action - Callback function to be called * for each child. * @returns True if forEach was canceled by action returning true for * one of the child nodes. */ DataSnapshot.prototype.forEach = function (action) { var _this = this; util.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length); util.validateCallback('DataSnapshot.forEach', 'action', action, false); return this._delegate.forEach(function (expDataSnapshot) { return action(new DataSnapshot(_this._database, expDataSnapshot)); }); }; /** * Returns whether this DataSnapshot has children. * @returns True if the DataSnapshot contains 1 or more child nodes. */ DataSnapshot.prototype.hasChildren = function () { util.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length); return this._delegate.hasChildren(); }; Object.defineProperty(DataSnapshot.prototype, "key", { get: function () { return this._delegate.key; }, enumerable: false, configurable: true }); /** * Returns the number of children for this DataSnapshot. * @returns The number of children that this DataSnapshot contains. */ DataSnapshot.prototype.numChildren = function () { util.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length); return this._delegate.size; }; /** * @returns The Firebase reference for the location this snapshot's data came * from. */ DataSnapshot.prototype.getRef = function () { util.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length); return new Reference(this._database, this._delegate.ref); }; Object.defineProperty(DataSnapshot.prototype, "ref", { get: function () { return this.getRef(); }, enumerable: false, configurable: true }); return DataSnapshot; }()); /** * A Query represents a filter to be applied to a firebase location. This object purely represents the * query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js. * * Since every Firebase reference is a query, Firebase inherits from this object. */ var Query = /** @class */ (function () { function Query(database, _delegate) { this.database = database; this._delegate = _delegate; } Query.prototype.on = function (eventType, callback, cancelCallbackOrContext, context) { var _this = this; var _a; util.validateArgCount('Query.on', 2, 4, arguments.length); util.validateCallback('Query.on', 'callback', callback, false); var ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context); var valueCallback = function (expSnapshot, previousChildName) { callback.call(ret.context, new DataSnapshot(_this.database, expSnapshot), previousChildName); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; var cancelCallback = (_a = ret.cancel) === null || _a === void 0 ? void 0 : _a.bind(ret.context); switch (eventType) { case 'value': database.onValue(this._delegate, valueCallback, cancelCallback); return callback; case 'child_added': database.onChildAdded(this._delegate, valueCallback, cancelCallback); return callback; case 'child_removed': database.onChildRemoved(this._delegate, valueCallback, cancelCallback); return callback; case 'child_changed': database.onChildChanged(this._delegate, valueCallback, cancelCallback); return callback; case 'child_moved': database.onChildMoved(this._delegate, valueCallback, cancelCallback); return callback; default: throw new Error(util.errorPrefix('Query.on', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } }; Query.prototype.off = function (eventType, callback, context) { util.validateArgCount('Query.off', 0, 3, arguments.length); validateEventType('Query.off', eventType, true); util.validateCallback('Query.off', 'callback', callback, true); util.validateContextObject('Query.off', 'context', context, true); if (callback) { var valueCallback = function () { }; valueCallback.userCallback = callback; valueCallback.context = context; database.off(this._delegate, eventType, valueCallback); } else { database.off(this._delegate, eventType); } }; /** * Get the server-value for this query, or return a cached value if not connected. */ Query.prototype.get = function () { var _this = this; return database.get(this._delegate).then(function (expSnapshot) { return new DataSnapshot(_this.database, expSnapshot); }); }; /** * Attaches a listener, waits for the first event, and then removes the listener */ Query.prototype.once = function (eventType, callback, failureCallbackOrContext, context) { var _this = this; util.validateArgCount('Query.once', 1, 4, arguments.length); util.validateCallback('Query.once', 'callback', callback, true); var ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context); var deferred = new util.Deferred(); var valueCallback = function (expSnapshot, previousChildName) { var result = new DataSnapshot(_this.database, expSnapshot); if (callback) { callback.call(ret.context, result, previousChildName); } deferred.resolve(result); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; var cancelCallback = function (error) { if (ret.cancel) { ret.cancel.call(ret.context, error); } deferred.reject(error); }; switch (eventType) { case 'value': database.onValue(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_added': database.onChildAdded(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_removed': database.onChildRemoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_changed': database.onChildChanged(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_moved': database.onChildMoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; default: throw new Error(util.errorPrefix('Query.once', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } return deferred.promise; }; /** * Set a limit and anchor it to the start of the window. */ Query.prototype.limitToFirst = function (limit) { util.validateArgCount('Query.limitToFirst', 1, 1, arguments.length); return new Query(this.database, database.query(this._delegate, database.limitToFirst(limit))); }; /** * Set a limit and anchor it to the end of the window. */ Query.prototype.limitToLast = function (limit) { util.validateArgCount('Query.limitToLast', 1, 1, arguments.length); return new Query(this.database, database.query(this._delegate, database.limitToLast(limit))); }; /** * Given a child path, return a new query ordered by the specified grandchild path. */ Query.prototype.orderByChild = function (path) { util.validateArgCount('Query.orderByChild', 1, 1, arguments.length); return new Query(this.database, database.query(this._delegate, database.orderByChild(path))); }; /** * Return a new query ordered by the KeyIndex */ Query.prototype.orderByKey = function () { util.validateArgCount('Query.orderByKey', 0, 0, arguments.length); return new Query(this.database, database.query(this._delegate, database.orderByKey())); }; /** * Return a new query ordered by the PriorityIndex */ Query.prototype.orderByPriority = function () { util.validateArgCount('Query.orderByPriority', 0, 0, arguments.length); return new Query(this.database, database.query(this._delegate, database.orderByPriority())); }; /** * Return a new query ordered by the ValueIndex */ Query.prototype.orderByValue = function () { util.validateArgCount('Query.orderByValue', 0, 0, arguments.length); return new Query(this.database, database.query(this._delegate, database.orderByValue())); }; Query.prototype.startAt = function (value, name) { if (value === void 0) { value = null; } util.validateArgCount('Query.startAt', 0, 2, arguments.length); return new Query(this.database, database.query(this._delegate, database.startAt(value, name))); }; Query.prototype.startAfter = function (value, name) { if (value === void 0) { value = null; } util.validateArgCount('Query.startAfter', 0, 2, arguments.length); return new Query(this.database, database.query(this._delegate, database.startAfter(value, name))); }; Query.prototype.endAt = function (value, name) { if (value === void 0) { value = null; } util.validateArgCount('Query.endAt', 0, 2, arguments.length); return new Query(this.database, database.query(this._delegate, database.endAt(value, name))); }; Query.prototype.endBefore = function (value, name) { if (value === void 0) { value = null; } util.validateArgCount('Query.endBefore', 0, 2, arguments.length); return new Query(this.database, database.query(this._delegate, database.endBefore(value, name))); }; /** * Load the selection of children with exactly the specified value, and, optionally, * the specified name. */ Query.prototype.equalTo = function (value, name) { util.validateArgCount('Query.equalTo', 1, 2, arguments.length); return new Query(this.database, database.query(this._delegate, database.equalTo(value, name))); }; /** * @returns URL for this location. */ Query.prototype.toString = function () { util.validateArgCount('Query.toString', 0, 0, arguments.length); return this._delegate.toString(); }; // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users. Query.prototype.toJSON = function () { // An optional spacer argument is unnecessary for a string. util.validateArgCount('Query.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); }; /** * Return true if this query and the provided query are equivalent; otherwise, return false. */ Query.prototype.isEqual = function (other) { util.validateArgCount('Query.isEqual', 1, 1, arguments.length); if (!(other instanceof Query)) { var error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.'; throw new Error(error); } return this._delegate.isEqual(other._delegate); }; /** * Helper used by .on and .once to extract the context and or cancel arguments. * @param fnName - The function name (on or once) * */ Query.getCancelAndContextArgs_ = function (fnName, cancelOrContext, context) { var ret = { cancel: undefined, context: undefined }; if (cancelOrContext && context) { ret.cancel = cancelOrContext; util.validateCallback(fnName, 'cancel', ret.cancel, true); ret.context = context; util.validateContextObject(fnName, 'context', ret.context, true); } else if (cancelOrContext) { // we have either a cancel callback or a context. if (typeof cancelOrContext === 'object' && cancelOrContext !== null) { // it's a context! ret.context = cancelOrContext; } else if (typeof cancelOrContext === 'function') { ret.cancel = cancelOrContext; } else { throw new Error(util.errorPrefix(fnName, 'cancelOrContext') + ' must either be a cancel callback or a context object.'); } } return ret; }; Object.defineProperty(Query.prototype, "ref", { get: function () { return new Reference(this.database, new database._ReferenceImpl(this._delegate._repo, this._delegate._path)); }, enumerable: false, configurable: true }); return Query; }()); var Reference = /** @class */ (function (_super) { tslib.__extends(Reference, _super); /** * Call options: * new Reference(Repo, Path) or * new Reference(url: string, string|RepoManager) * * Externally - this is the firebase.database.Reference type. */ function Reference(database$1, _delegate) { var _this = _super.call(this, database$1, new database._QueryImpl(_delegate._repo, _delegate._path, new database._QueryParams(), false)) || this; _this.database = database$1; _this._delegate = _delegate; return _this; } /** @returns {?string} */ Reference.prototype.getKey = function () { util.validateArgCount('Reference.key', 0, 0, arguments.length); return this._delegate.key; }; Reference.prototype.child = function (pathString) { util.validateArgCount('Reference.child', 1, 1, arguments.length); if (typeof pathString === 'number') { pathString = String(pathString); } return new Reference(this.database, database.child(this._delegate, pathString)); }; /** @returns {?Reference} */ Reference.prototype.getParent = function () { util.validateArgCount('Reference.parent', 0, 0, arguments.length); var parent = this._delegate.parent; return parent ? new Reference(this.database, parent) : null; }; /** @returns {!Reference} */ Reference.prototype.getRoot = function () { util.validateArgCount('Reference.root', 0, 0, arguments.length); return new Reference(this.database, this._delegate.root); }; Reference.prototype.set = function (newVal, onComplete) { util.validateArgCount('Reference.set', 1, 2, arguments.length); util.validateCallback('Reference.set', 'onComplete', onComplete, true); var result = database.set(this._delegate, newVal); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.update = function (values, onComplete) { util.validateArgCount('Reference.update', 1, 2, arguments.length); if (Array.isArray(values)) { var newObjectToMerge = {}; for (var i = 0; i < values.length; ++i) { newObjectToMerge['' + i] = values[i]; } values = newObjectToMerge; warn('Passing an Array to Firebase.update() is deprecated. ' + 'Use set() if you want to overwrite the existing data, or ' + 'an Object with integer keys if you really do want to ' + 'only update some of the children.'); } database._validateWritablePath('Reference.update', this._delegate._path); util.validateCallback('Reference.update', 'onComplete', onComplete, true); var result = database.update(this._delegate, values); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.setWithPriority = function (newVal, newPriority, onComplete) { util.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length); util.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true); var result = database.setWithPriority(this._delegate, newVal, newPriority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.remove = function (onComplete) { util.validateArgCount('Reference.remove', 0, 1, arguments.length); util.validateCallback('Reference.remove', 'onComplete', onComplete, true); var result = database.remove(this._delegate); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.transaction = function (transactionUpdate, onComplete, applyLocally) { var _this = this; util.validateArgCount('Reference.transaction', 1, 3, arguments.length); util.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false); util.validateCallback('Reference.transaction', 'onComplete', onComplete, true); validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true); var result = database.runTransaction(this._delegate, transactionUpdate, { applyLocally: applyLocally }).then(function (transactionResult) { return new TransactionResult(transactionResult.committed, new DataSnapshot(_this.database, transactionResult.snapshot)); }); if (onComplete) { result.then(function (transactionResult) { return onComplete(null, transactionResult.committed, transactionResult.snapshot); }, function (error) { return onComplete(error, false, null); }); } return result; }; Reference.prototype.setPriority = function (priority, onComplete) { util.validateArgCount('Reference.setPriority', 1, 2, arguments.length); util.validateCallback('Reference.setPriority', 'onComplete', onComplete, true); var result = database.setPriority(this._delegate, priority); if (onComplete) { result.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } return result; }; Reference.prototype.push = function (value, onComplete) { var _this = this; util.validateArgCount('Reference.push', 0, 2, arguments.length); util.validateCallback('Reference.push', 'onComplete', onComplete, true); var expPromise = database.push(this._delegate, value); var promise = expPromise.then(function (expRef) { return new Reference(_this.database, expRef); }); if (onComplete) { promise.then(function () { return onComplete(null); }, function (error) { return onComplete(error); }); } var result = new Reference(this.database, expPromise); result.then = promise.then.bind(promise); result.catch = promise.catch.bind(promise, undefined); return result; }; Reference.prototype.onDisconnect = function () { database._validateWritablePath('Reference.onDisconnect', this._delegate._path); return new OnDisconnect(new database.OnDisconnect(this._delegate._repo, this._delegate._path)); }; Object.defineProperty(Reference.prototype, "key", { get: function () { return this.getKey(); }, enumerable: false, configurable: true }); Object.defineProperty(Reference.prototype, "parent", { get: function () { return this.getParent(); }, enumerable: false, configurable: true }); Object.defineProperty(Reference.prototype, "root", { get: function () { return this.getRoot(); }, enumerable: false, configurable: true }); return Reference; }(Query)); /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License");
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true
CAHLR/OATutor
https://github.com/CAHLR/OATutor/blob/10a5baf153a505267af8045b05c217b4be6bd8b4/aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.esm2017.js
aws/lti-middleware/node_modules/@firebase/database-compat/dist/index.esm2017.js
import firebase from '@firebase/app-compat'; import { Provider, ComponentContainer, Component } from '@firebase/component'; import { _validatePathString, onChildMoved, onChildChanged, onChildRemoved, onChildAdded, onValue, off, get, query, limitToFirst, limitToLast, orderByChild, orderByKey, orderByPriority, orderByValue, startAt, startAfter, endAt, endBefore, equalTo, _ReferenceImpl, _QueryImpl, _QueryParams, child, set, _validateWritablePath, update, setWithPriority, remove, runTransaction, setPriority, push, OnDisconnect as OnDisconnect$1, forceWebSockets, forceLongPolling, connectDatabaseEmulator, refFromURL, ref, goOffline, goOnline, serverTimestamp, increment, _setSDKVersion, _repoManagerDatabaseFromApp, enableLogging } from '@firebase/database'; import { errorPrefix, validateArgCount, validateCallback, validateContextObject, Deferred } from '@firebase/util'; import { Logger } from '@firebase/logger'; const name = "@firebase/database-compat"; const version = "0.2.1"; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const logClient = new Logger('@firebase/database-compat'); const warn = function (msg) { const message = 'FIREBASE WARNING: ' + msg; logClient.warn(message); }; /** * @license * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const validateBoolean = function (fnName, argumentName, bool, optional) { if (optional && bool === undefined) { return; } if (typeof bool !== 'boolean') { throw new Error(errorPrefix(fnName, argumentName) + 'must be a boolean.'); } }; const validateEventType = function (fnName, eventType, optional) { if (optional && eventType === undefined) { return; } switch (eventType) { case 'value': case 'child_added': case 'child_removed': case 'child_changed': case 'child_moved': break; default: throw new Error(errorPrefix(fnName, 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class OnDisconnect { constructor(_delegate) { this._delegate = _delegate; } cancel(onComplete) { validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length); validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true); const result = this._delegate.cancel(); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } remove(onComplete) { validateArgCount('OnDisconnect.remove', 0, 1, arguments.length); validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true); const result = this._delegate.remove(); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } set(value, onComplete) { validateArgCount('OnDisconnect.set', 1, 2, arguments.length); validateCallback('OnDisconnect.set', 'onComplete', onComplete, true); const result = this._delegate.set(value); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } setWithPriority(value, priority, onComplete) { validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length); validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true); const result = this._delegate.setWithPriority(value, priority); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } update(objectToMerge, onComplete) { validateArgCount('OnDisconnect.update', 1, 2, arguments.length); if (Array.isArray(objectToMerge)) { const newObjectToMerge = {}; for (let i = 0; i < objectToMerge.length; ++i) { newObjectToMerge['' + i] = objectToMerge[i]; } objectToMerge = newObjectToMerge; warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' + 'existing data, or an Object with integer keys if you really do want to only update some of the children.'); } validateCallback('OnDisconnect.update', 'onComplete', onComplete, true); const result = this._delegate.update(objectToMerge); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class TransactionResult { /** * A type for the resolve value of Firebase.transaction. */ constructor(committed, snapshot) { this.committed = committed; this.snapshot = snapshot; } // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users toJSON() { validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length); return { committed: this.committed, snapshot: this.snapshot.toJSON() }; } } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Class representing a firebase data snapshot. It wraps a SnapshotNode and * surfaces the public methods (val, forEach, etc.) we want to expose. */ class DataSnapshot { constructor(_database, _delegate) { this._database = _database; this._delegate = _delegate; } /** * Retrieves the snapshot contents as JSON. Returns null if the snapshot is * empty. * * @returns JSON representation of the DataSnapshot contents, or null if empty. */ val() { validateArgCount('DataSnapshot.val', 0, 0, arguments.length); return this._delegate.val(); } /** * Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting * the entire node contents. * @returns JSON representation of the DataSnapshot contents, or null if empty. */ exportVal() { validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length); return this._delegate.exportVal(); } // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users toJSON() { // Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); } /** * Returns whether the snapshot contains a non-null value. * * @returns Whether the snapshot contains a non-null value, or is empty. */ exists() { validateArgCount('DataSnapshot.exists', 0, 0, arguments.length); return this._delegate.exists(); } /** * Returns a DataSnapshot of the specified child node's contents. * * @param path - Path to a child. * @returns DataSnapshot for child node. */ child(path) { validateArgCount('DataSnapshot.child', 0, 1, arguments.length); // Ensure the childPath is a string (can be a number) path = String(path); _validatePathString('DataSnapshot.child', 'path', path, false); return new DataSnapshot(this._database, this._delegate.child(path)); } /** * Returns whether the snapshot contains a child at the specified path. * * @param path - Path to a child. * @returns Whether the child exists. */ hasChild(path) { validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length); _validatePathString('DataSnapshot.hasChild', 'path', path, false); return this._delegate.hasChild(path); } /** * Returns the priority of the object, or null if no priority was set. * * @returns The priority. */ getPriority() { validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length); return this._delegate.priority; } /** * Iterates through child nodes and calls the specified action for each one. * * @param action - Callback function to be called * for each child. * @returns True if forEach was canceled by action returning true for * one of the child nodes. */ forEach(action) { validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length); validateCallback('DataSnapshot.forEach', 'action', action, false); return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot))); } /** * Returns whether this DataSnapshot has children. * @returns True if the DataSnapshot contains 1 or more child nodes. */ hasChildren() { validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length); return this._delegate.hasChildren(); } get key() { return this._delegate.key; } /** * Returns the number of children for this DataSnapshot. * @returns The number of children that this DataSnapshot contains. */ numChildren() { validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length); return this._delegate.size; } /** * @returns The Firebase reference for the location this snapshot's data came * from. */ getRef() { validateArgCount('DataSnapshot.ref', 0, 0, arguments.length); return new Reference(this._database, this._delegate.ref); } get ref() { return this.getRef(); } } /** * A Query represents a filter to be applied to a firebase location. This object purely represents the * query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js. * * Since every Firebase reference is a query, Firebase inherits from this object. */ class Query { constructor(database, _delegate) { this.database = database; this._delegate = _delegate; } on(eventType, callback, cancelCallbackOrContext, context) { var _a; validateArgCount('Query.on', 2, 4, arguments.length); validateCallback('Query.on', 'callback', callback, false); const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context); const valueCallback = (expSnapshot, previousChildName) => { callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; const cancelCallback = (_a = ret.cancel) === null || _a === void 0 ? void 0 : _a.bind(ret.context); switch (eventType) { case 'value': onValue(this._delegate, valueCallback, cancelCallback); return callback; case 'child_added': onChildAdded(this._delegate, valueCallback, cancelCallback); return callback; case 'child_removed': onChildRemoved(this._delegate, valueCallback, cancelCallback); return callback; case 'child_changed': onChildChanged(this._delegate, valueCallback, cancelCallback); return callback; case 'child_moved': onChildMoved(this._delegate, valueCallback, cancelCallback); return callback; default: throw new Error(errorPrefix('Query.on', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } } off(eventType, callback, context) { validateArgCount('Query.off', 0, 3, arguments.length); validateEventType('Query.off', eventType, true); validateCallback('Query.off', 'callback', callback, true); validateContextObject('Query.off', 'context', context, true); if (callback) { const valueCallback = () => { }; valueCallback.userCallback = callback; valueCallback.context = context; off(this._delegate, eventType, valueCallback); } else { off(this._delegate, eventType); } } /** * Get the server-value for this query, or return a cached value if not connected. */ get() { return get(this._delegate).then(expSnapshot => { return new DataSnapshot(this.database, expSnapshot); }); } /** * Attaches a listener, waits for the first event, and then removes the listener */ once(eventType, callback, failureCallbackOrContext, context) { validateArgCount('Query.once', 1, 4, arguments.length); validateCallback('Query.once', 'callback', callback, true); const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context); const deferred = new Deferred(); const valueCallback = (expSnapshot, previousChildName) => { const result = new DataSnapshot(this.database, expSnapshot); if (callback) { callback.call(ret.context, result, previousChildName); } deferred.resolve(result); }; valueCallback.userCallback = callback; valueCallback.context = ret.context; const cancelCallback = (error) => { if (ret.cancel) { ret.cancel.call(ret.context, error); } deferred.reject(error); }; switch (eventType) { case 'value': onValue(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_added': onChildAdded(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_removed': onChildRemoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_changed': onChildChanged(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; case 'child_moved': onChildMoved(this._delegate, valueCallback, cancelCallback, { onlyOnce: true }); break; default: throw new Error(errorPrefix('Query.once', 'eventType') + 'must be a valid event type = "value", "child_added", "child_removed", ' + '"child_changed", or "child_moved".'); } return deferred.promise; } /** * Set a limit and anchor it to the start of the window. */ limitToFirst(limit) { validateArgCount('Query.limitToFirst', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, limitToFirst(limit))); } /** * Set a limit and anchor it to the end of the window. */ limitToLast(limit) { validateArgCount('Query.limitToLast', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, limitToLast(limit))); } /** * Given a child path, return a new query ordered by the specified grandchild path. */ orderByChild(path) { validateArgCount('Query.orderByChild', 1, 1, arguments.length); return new Query(this.database, query(this._delegate, orderByChild(path))); } /** * Return a new query ordered by the KeyIndex */ orderByKey() { validateArgCount('Query.orderByKey', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByKey())); } /** * Return a new query ordered by the PriorityIndex */ orderByPriority() { validateArgCount('Query.orderByPriority', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByPriority())); } /** * Return a new query ordered by the ValueIndex */ orderByValue() { validateArgCount('Query.orderByValue', 0, 0, arguments.length); return new Query(this.database, query(this._delegate, orderByValue())); } startAt(value = null, name) { validateArgCount('Query.startAt', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, startAt(value, name))); } startAfter(value = null, name) { validateArgCount('Query.startAfter', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, startAfter(value, name))); } endAt(value = null, name) { validateArgCount('Query.endAt', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, endAt(value, name))); } endBefore(value = null, name) { validateArgCount('Query.endBefore', 0, 2, arguments.length); return new Query(this.database, query(this._delegate, endBefore(value, name))); } /** * Load the selection of children with exactly the specified value, and, optionally, * the specified name. */ equalTo(value, name) { validateArgCount('Query.equalTo', 1, 2, arguments.length); return new Query(this.database, query(this._delegate, equalTo(value, name))); } /** * @returns URL for this location. */ toString() { validateArgCount('Query.toString', 0, 0, arguments.length); return this._delegate.toString(); } // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary // for end-users. toJSON() { // An optional spacer argument is unnecessary for a string. validateArgCount('Query.toJSON', 0, 1, arguments.length); return this._delegate.toJSON(); } /** * Return true if this query and the provided query are equivalent; otherwise, return false. */ isEqual(other) { validateArgCount('Query.isEqual', 1, 1, arguments.length); if (!(other instanceof Query)) { const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.'; throw new Error(error); } return this._delegate.isEqual(other._delegate); } /** * Helper used by .on and .once to extract the context and or cancel arguments. * @param fnName - The function name (on or once) * */ static getCancelAndContextArgs_(fnName, cancelOrContext, context) { const ret = { cancel: undefined, context: undefined }; if (cancelOrContext && context) { ret.cancel = cancelOrContext; validateCallback(fnName, 'cancel', ret.cancel, true); ret.context = context; validateContextObject(fnName, 'context', ret.context, true); } else if (cancelOrContext) { // we have either a cancel callback or a context. if (typeof cancelOrContext === 'object' && cancelOrContext !== null) { // it's a context! ret.context = cancelOrContext; } else if (typeof cancelOrContext === 'function') { ret.cancel = cancelOrContext; } else { throw new Error(errorPrefix(fnName, 'cancelOrContext') + ' must either be a cancel callback or a context object.'); } } return ret; } get ref() { return new Reference(this.database, new _ReferenceImpl(this._delegate._repo, this._delegate._path)); } } class Reference extends Query { /** * Call options: * new Reference(Repo, Path) or * new Reference(url: string, string|RepoManager) * * Externally - this is the firebase.database.Reference type. */ constructor(database, _delegate) { super(database, new _QueryImpl(_delegate._repo, _delegate._path, new _QueryParams(), false)); this.database = database; this._delegate = _delegate; } /** @returns {?string} */ getKey() { validateArgCount('Reference.key', 0, 0, arguments.length); return this._delegate.key; } child(pathString) { validateArgCount('Reference.child', 1, 1, arguments.length); if (typeof pathString === 'number') { pathString = String(pathString); } return new Reference(this.database, child(this._delegate, pathString)); } /** @returns {?Reference} */ getParent() { validateArgCount('Reference.parent', 0, 0, arguments.length); const parent = this._delegate.parent; return parent ? new Reference(this.database, parent) : null; } /** @returns {!Reference} */ getRoot() { validateArgCount('Reference.root', 0, 0, arguments.length); return new Reference(this.database, this._delegate.root); } set(newVal, onComplete) { validateArgCount('Reference.set', 1, 2, arguments.length); validateCallback('Reference.set', 'onComplete', onComplete, true); const result = set(this._delegate, newVal); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } update(values, onComplete) { validateArgCount('Reference.update', 1, 2, arguments.length); if (Array.isArray(values)) { const newObjectToMerge = {}; for (let i = 0; i < values.length; ++i) { newObjectToMerge['' + i] = values[i]; } values = newObjectToMerge; warn('Passing an Array to Firebase.update() is deprecated. ' + 'Use set() if you want to overwrite the existing data, or ' + 'an Object with integer keys if you really do want to ' + 'only update some of the children.'); } _validateWritablePath('Reference.update', this._delegate._path); validateCallback('Reference.update', 'onComplete', onComplete, true); const result = update(this._delegate, values); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } setWithPriority(newVal, newPriority, onComplete) { validateArgCount('Reference.setWithPriority', 2, 3, arguments.length); validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true); const result = setWithPriority(this._delegate, newVal, newPriority); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } remove(onComplete) { validateArgCount('Reference.remove', 0, 1, arguments.length); validateCallback('Reference.remove', 'onComplete', onComplete, true); const result = remove(this._delegate); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } transaction(transactionUpdate, onComplete, applyLocally) { validateArgCount('Reference.transaction', 1, 3, arguments.length); validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false); validateCallback('Reference.transaction', 'onComplete', onComplete, true); validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true); const result = runTransaction(this._delegate, transactionUpdate, { applyLocally }).then(transactionResult => new TransactionResult(transactionResult.committed, new DataSnapshot(this.database, transactionResult.snapshot))); if (onComplete) { result.then(transactionResult => onComplete(null, transactionResult.committed, transactionResult.snapshot), error => onComplete(error, false, null)); } return result; } setPriority(priority, onComplete) { validateArgCount('Reference.setPriority', 1, 2, arguments.length); validateCallback('Reference.setPriority', 'onComplete', onComplete, true); const result = setPriority(this._delegate, priority); if (onComplete) { result.then(() => onComplete(null), error => onComplete(error)); } return result; } push(value, onComplete) { validateArgCount('Reference.push', 0, 2, arguments.length); validateCallback('Reference.push', 'onComplete', onComplete, true); const expPromise = push(this._delegate, value); const promise = expPromise.then(expRef => new Reference(this.database, expRef)); if (onComplete) { promise.then(() => onComplete(null), error => onComplete(error)); } const result = new Reference(this.database, expPromise); result.then = promise.then.bind(promise); result.catch = promise.catch.bind(promise, undefined); return result; } onDisconnect() { _validateWritablePath('Reference.onDisconnect', this._delegate._path); return new OnDisconnect(new OnDisconnect$1(this._delegate._repo, this._delegate._path)); } get key() { return this.getKey(); } get parent() { return this.getParent(); } get root() { return this.getRoot(); } } /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Class representing a firebase database. */ class Database { /** * The constructor should not be called by users of our public API. */ constructor(_delegate, app) { this._delegate = _delegate; this.app = app; this.INTERNAL = { delete: () => this._delegate._delete(), forceWebSockets, forceLongPolling }; } /** * Modify this instance to communicate with the Realtime Database emulator. * * <p>Note: This method must be called before performing any other operation. * * @param host - the emulator host (ex: localhost) * @param port - the emulator port (ex: 8080) * @param options.mockUserToken - the mock auth token to use for unit testing Security Rules */ useEmulator(host, port, options = {}) { connectDatabaseEmulator(this._delegate, host, port, options); } ref(path) { validateArgCount('database.ref', 0, 1, arguments.length); if (path instanceof Reference) { const childRef = refFromURL(this._delegate, path.toString()); return new Reference(this, childRef); } else { const childRef = ref(this._delegate, path); return new Reference(this, childRef); } } /** * Returns a reference to the root or the path specified in url. * We throw a exception if the url is not in the same domain as the * current repo. * @returns Firebase reference. */ refFromURL(url) { const apiName = 'database.refFromURL'; validateArgCount(apiName, 1, 1, arguments.length); const childRef = refFromURL(this._delegate, url); return new Reference(this, childRef); } // Make individual repo go offline. goOffline() { validateArgCount('database.goOffline', 0, 0, arguments.length); return goOffline(this._delegate); } goOnline() { validateArgCount('database.goOnline', 0, 0, arguments.length); return goOnline(this._delegate); } } Database.ServerValue = { TIMESTAMP: serverTimestamp(), increment: (delta) => increment(delta) }; /** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Used by console to create a database based on the app, * passed database URL and a custom auth implementation. * * @param app - A valid FirebaseApp-like object * @param url - A valid Firebase databaseURL * @param version - custom version e.g. firebase-admin version * @param customAuthImpl - custom auth implementation */ function initStandalone({ app, url, version, customAuthImpl, namespace, nodeAdmin = false }) { _setSDKVersion(version); /** * ComponentContainer('database-standalone') is just a placeholder that doesn't perform * any actual function. */ const authProvider = new Provider('auth-internal', new ComponentContainer('database-standalone')); authProvider.setComponent(new Component('auth-internal', () => customAuthImpl, "PRIVATE" /* PRIVATE */)); return {
javascript
MIT
10a5baf153a505267af8045b05c217b4be6bd8b4
2026-01-05T03:39:09.711315Z
true