new license file version [CI SKIP]

This commit is contained in:
2023-03-15 12:34:41 +00:00
parent 0a6d92a1f3
commit 61328d20ed
13115 changed files with 1892314 additions and 1 deletions

View File

@@ -0,0 +1,133 @@
'use strict';
var isMergeableObject = function isMergeableObject(value) {
return isNonNullObject(value)
&& !isSpecial(value)
};
function isNonNullObject(value) {
return !!value && typeof value === 'object'
}
function isSpecial(value) {
var stringValue = Object.prototype.toString.call(value);
return stringValue === '[object RegExp]'
|| stringValue === '[object Date]'
|| isReactElement(value)
}
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
function isReactElement(value) {
return value.$$typeof === REACT_ELEMENT_TYPE
}
function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
}
function cloneUnlessOtherwiseSpecified(value, options) {
return (options.clone !== false && options.isMergeableObject(value))
? deepmerge(emptyTarget(value), value, options)
: value
}
function defaultArrayMerge(target, source, options) {
return target.concat(source).map(function(element) {
return cloneUnlessOtherwiseSpecified(element, options)
})
}
function getMergeFunction(key, options) {
if (!options.customMerge) {
return deepmerge
}
var customMerge = options.customMerge(key);
return typeof customMerge === 'function' ? customMerge : deepmerge
}
function getEnumerableOwnPropertySymbols(target) {
return Object.getOwnPropertySymbols
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
return Object.propertyIsEnumerable.call(target, symbol)
})
: []
}
function getKeys(target) {
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
}
function propertyIsOnObject(object, property) {
try {
return property in object
} catch(_) {
return false
}
}
// Protects from prototype poisoning and unexpected merging up the prototype chain.
function propertyIsUnsafe(target, key) {
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
}
function mergeObject(target, source, options) {
var destination = {};
if (options.isMergeableObject(target)) {
getKeys(target).forEach(function(key) {
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
});
}
getKeys(source).forEach(function(key) {
if (propertyIsUnsafe(target, key)) {
return
}
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
} else {
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
}
});
return destination
}
function deepmerge(target, source, options) {
options = options || {};
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
// implementations can use it. The caller may not replace it.
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
var sourceIsArray = Array.isArray(source);
var targetIsArray = Array.isArray(target);
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
if (!sourceAndTargetTypesMatch) {
return cloneUnlessOtherwiseSpecified(source, options)
} else if (sourceIsArray) {
return options.arrayMerge(target, source, options)
} else {
return mergeObject(target, source, options)
}
}
deepmerge.all = function deepmergeAll(array, options) {
if (!Array.isArray(array)) {
throw new Error('first argument should be an array')
}
return array.reduce(function(prev, next) {
return deepmerge(prev, next, options)
}, {})
};
var deepmerge_1 = deepmerge;
module.exports = deepmerge_1;

View File

@@ -0,0 +1,189 @@
import { BLAKE2, SIGMA } from './_blake2.js';
import u64 from './_u64.js';
import { toBytes, u32, wrapConstructorWithOpts } from './utils.js';
// Same as SHA-512 but LE
// prettier-ignore
const IV = new Uint32Array([
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a,
0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19
]);
// Temporary buffer
const BUF = new Uint32Array(32);
// Mixing function G splitted in two halfs
function G1(a, b, c, d, msg, x) {
// NOTE: V is LE here
const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore
let Al = BUF[2 * a], Ah = BUF[2 * a + 1]; // prettier-ignore
let Bl = BUF[2 * b], Bh = BUF[2 * b + 1]; // prettier-ignore
let Cl = BUF[2 * c], Ch = BUF[2 * c + 1]; // prettier-ignore
let Dl = BUF[2 * d], Dh = BUF[2 * d + 1]; // prettier-ignore
// v[a] = (v[a] + v[b] + x) | 0;
let ll = u64.add3L(Al, Bl, Xl);
Ah = u64.add3H(ll, Ah, Bh, Xh);
Al = ll | 0;
// v[d] = rotr(v[d] ^ v[a], 32)
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
({ Dh, Dl } = { Dh: u64.rotr32H(Dh, Dl), Dl: u64.rotr32L(Dh, Dl) });
// v[c] = (v[c] + v[d]) | 0;
({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl));
// v[b] = rotr(v[b] ^ v[c], 24)
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
({ Bh, Bl } = { Bh: u64.rotrSH(Bh, Bl, 24), Bl: u64.rotrSL(Bh, Bl, 24) });
(BUF[2 * a] = Al), (BUF[2 * a + 1] = Ah);
(BUF[2 * b] = Bl), (BUF[2 * b + 1] = Bh);
(BUF[2 * c] = Cl), (BUF[2 * c + 1] = Ch);
(BUF[2 * d] = Dl), (BUF[2 * d + 1] = Dh);
}
function G2(a, b, c, d, msg, x) {
// NOTE: V is LE here
const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore
let Al = BUF[2 * a], Ah = BUF[2 * a + 1]; // prettier-ignore
let Bl = BUF[2 * b], Bh = BUF[2 * b + 1]; // prettier-ignore
let Cl = BUF[2 * c], Ch = BUF[2 * c + 1]; // prettier-ignore
let Dl = BUF[2 * d], Dh = BUF[2 * d + 1]; // prettier-ignore
// v[a] = (v[a] + v[b] + x) | 0;
let ll = u64.add3L(Al, Bl, Xl);
Ah = u64.add3H(ll, Ah, Bh, Xh);
Al = ll | 0;
// v[d] = rotr(v[d] ^ v[a], 16)
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
({ Dh, Dl } = { Dh: u64.rotrSH(Dh, Dl, 16), Dl: u64.rotrSL(Dh, Dl, 16) });
// v[c] = (v[c] + v[d]) | 0;
({ h: Ch, l: Cl } = u64.add(Ch, Cl, Dh, Dl));
// v[b] = rotr(v[b] ^ v[c], 63)
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
({ Bh, Bl } = { Bh: u64.rotrBH(Bh, Bl, 63), Bl: u64.rotrBL(Bh, Bl, 63) });
(BUF[2 * a] = Al), (BUF[2 * a + 1] = Ah);
(BUF[2 * b] = Bl), (BUF[2 * b + 1] = Bh);
(BUF[2 * c] = Cl), (BUF[2 * c + 1] = Ch);
(BUF[2 * d] = Dl), (BUF[2 * d + 1] = Dh);
}
class BLAKE2b extends BLAKE2 {
constructor(opts = {}) {
super(128, opts.dkLen === undefined ? 64 : opts.dkLen, opts, 64, 16, 16);
// Same as SHA-512, but LE
this.v0l = IV[0] | 0;
this.v0h = IV[1] | 0;
this.v1l = IV[2] | 0;
this.v1h = IV[3] | 0;
this.v2l = IV[4] | 0;
this.v2h = IV[5] | 0;
this.v3l = IV[6] | 0;
this.v3h = IV[7] | 0;
this.v4l = IV[8] | 0;
this.v4h = IV[9] | 0;
this.v5l = IV[10] | 0;
this.v5h = IV[11] | 0;
this.v6l = IV[12] | 0;
this.v6h = IV[13] | 0;
this.v7l = IV[14] | 0;
this.v7h = IV[15] | 0;
const keyLength = opts.key ? opts.key.length : 0;
this.v0l ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24);
if (opts.salt) {
const salt = u32(toBytes(opts.salt));
this.v4l ^= salt[0];
this.v4h ^= salt[1];
this.v5l ^= salt[2];
this.v5h ^= salt[3];
}
if (opts.personalization) {
const pers = u32(toBytes(opts.personalization));
this.v6l ^= pers[0];
this.v6h ^= pers[1];
this.v7l ^= pers[2];
this.v7h ^= pers[3];
}
if (opts.key) {
// Pad to blockLen and update
const tmp = new Uint8Array(this.blockLen);
tmp.set(toBytes(opts.key));
this.update(tmp);
}
}
// prettier-ignore
get() {
let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
return [v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h];
}
// prettier-ignore
set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) {
this.v0l = v0l | 0;
this.v0h = v0h | 0;
this.v1l = v1l | 0;
this.v1h = v1h | 0;
this.v2l = v2l | 0;
this.v2h = v2h | 0;
this.v3l = v3l | 0;
this.v3h = v3h | 0;
this.v4l = v4l | 0;
this.v4h = v4h | 0;
this.v5l = v5l | 0;
this.v5h = v5h | 0;
this.v6l = v6l | 0;
this.v6h = v6h | 0;
this.v7l = v7l | 0;
this.v7h = v7h | 0;
}
compress(msg, offset, isLast) {
this.get().forEach((v, i) => (BUF[i] = v)); // First half from state.
BUF.set(IV, 16); // Second half from IV.
let { h, l } = u64.fromBig(BigInt(this.length));
BUF[24] = IV[8] ^ l; // Low word of the offset.
BUF[25] = IV[9] ^ h; // High word.
// Invert all bits for last block
if (isLast) {
BUF[28] = ~BUF[28];
BUF[29] = ~BUF[29];
}
let j = 0;
const s = SIGMA;
for (let i = 0; i < 12; i++) {
G1(0, 4, 8, 12, msg, offset + 2 * s[j++]);
G2(0, 4, 8, 12, msg, offset + 2 * s[j++]);
G1(1, 5, 9, 13, msg, offset + 2 * s[j++]);
G2(1, 5, 9, 13, msg, offset + 2 * s[j++]);
G1(2, 6, 10, 14, msg, offset + 2 * s[j++]);
G2(2, 6, 10, 14, msg, offset + 2 * s[j++]);
G1(3, 7, 11, 15, msg, offset + 2 * s[j++]);
G2(3, 7, 11, 15, msg, offset + 2 * s[j++]);
G1(0, 5, 10, 15, msg, offset + 2 * s[j++]);
G2(0, 5, 10, 15, msg, offset + 2 * s[j++]);
G1(1, 6, 11, 12, msg, offset + 2 * s[j++]);
G2(1, 6, 11, 12, msg, offset + 2 * s[j++]);
G1(2, 7, 8, 13, msg, offset + 2 * s[j++]);
G2(2, 7, 8, 13, msg, offset + 2 * s[j++]);
G1(3, 4, 9, 14, msg, offset + 2 * s[j++]);
G2(3, 4, 9, 14, msg, offset + 2 * s[j++]);
}
this.v0l ^= BUF[0] ^ BUF[16];
this.v0h ^= BUF[1] ^ BUF[17];
this.v1l ^= BUF[2] ^ BUF[18];
this.v1h ^= BUF[3] ^ BUF[19];
this.v2l ^= BUF[4] ^ BUF[20];
this.v2h ^= BUF[5] ^ BUF[21];
this.v3l ^= BUF[6] ^ BUF[22];
this.v3h ^= BUF[7] ^ BUF[23];
this.v4l ^= BUF[8] ^ BUF[24];
this.v4h ^= BUF[9] ^ BUF[25];
this.v5l ^= BUF[10] ^ BUF[26];
this.v5h ^= BUF[11] ^ BUF[27];
this.v6l ^= BUF[12] ^ BUF[28];
this.v6h ^= BUF[13] ^ BUF[29];
this.v7l ^= BUF[14] ^ BUF[30];
this.v7h ^= BUF[15] ^ BUF[31];
BUF.fill(0);
}
destroy() {
this.destroyed = true;
this.buffer32.fill(0);
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
}
/**
* BLAKE2b - optimized for 64-bit platforms. JS doesn't have uint64, so it's slower than BLAKE2s.
* @param msg - message that would be hashed
* @param opts - dkLen, key, salt, personalization
*/
export const blake2b = wrapConstructorWithOpts((opts) => new BLAKE2b(opts));
//# sourceMappingURL=blake2b.js.map

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"J D E F CC","900":"A B"},B:{"1":"N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","388":"L G M","900":"C K"},C:{"1":"RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"DC tB EC FC","260":"PB QB","388":"5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB","900":"0 1 2 3 4 I v J D E F A B C K L G M N O w g x y z"},D:{"1":"GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","16":"I v J D E F A B C K L","388":"1 2 3 4 5 6 7 8 9 AB BB CB DB EB FB","900":"0 G M N O w g x y z"},E:{"1":"A B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","16":"I v HC zB","388":"E F KC LC","900":"J D IC JC"},F:{"1":"3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","16":"F B PC QC RC SC qB AC","388":"0 1 2 G M N O w g x y z","900":"C TC rB"},G:{"1":"bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","16":"zB UC BC","388":"E XC YC ZC aC","900":"VC WC"},H:{"2":"oC"},I:{"1":"f","16":"tB pC qC rC","388":"tC uC","900":"I sC BC"},J:{"16":"D","388":"A"},K:{"1":"h","16":"A B qB AC","900":"C rB"},L:{"1":"H"},M:{"1":"H"},N:{"900":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","388":"AD"}},B:1,C:"Constraint Validation API"};

View File

@@ -0,0 +1,16 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"eqnull": true,
"latedef": true,
"noarg": true,
"noempty": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"node": true
}

View File

@@ -0,0 +1,240 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.blake3 = void 0;
const _assert_js_1 = require("./_assert.js");
const _u64_js_1 = require("./_u64.js");
const _blake2_js_1 = require("./_blake2.js");
const blake2s_js_1 = require("./blake2s.js");
const utils_js_1 = require("./utils.js");
// Flag bitset
var Flags;
(function (Flags) {
Flags[Flags["CHUNK_START"] = 1] = "CHUNK_START";
Flags[Flags["CHUNK_END"] = 2] = "CHUNK_END";
Flags[Flags["PARENT"] = 4] = "PARENT";
Flags[Flags["ROOT"] = 8] = "ROOT";
Flags[Flags["KEYED_HASH"] = 16] = "KEYED_HASH";
Flags[Flags["DERIVE_KEY_CONTEXT"] = 32] = "DERIVE_KEY_CONTEXT";
Flags[Flags["DERIVE_KEY_MATERIAL"] = 64] = "DERIVE_KEY_MATERIAL";
})(Flags || (Flags = {}));
const SIGMA = (() => {
const Id = Array.from({ length: 16 }, (_, i) => i);
const permute = (arr) => [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]);
const res = [];
for (let i = 0, v = Id; i < 7; i++, v = permute(v))
res.push(...v);
return Uint8Array.from(res);
})();
// Why is this so slow? It should be 6x faster than blake2b.
// - There is only 30% reduction in number of rounds from blake2s
// - This function uses tree mode to achive parallelisation via SIMD and threading,
// however in JS we don't have threads and SIMD, so we get only overhead from tree structure
// - It is possible to speed it up via Web Workers, hovewer it will make code singnificantly more
// complicated, which we are trying to avoid, since this library is intended to be used
// for cryptographic purposes. Also, parallelization happens only on chunk level (1024 bytes),
// which won't really benefit small inputs.
class BLAKE3 extends _blake2_js_1.BLAKE2 {
constructor(opts = {}, flags = 0) {
super(64, opts.dkLen === undefined ? 32 : opts.dkLen, {}, Number.MAX_SAFE_INTEGER, 0, 0);
this.flags = 0 | 0;
this.chunkPos = 0; // Position of current block in chunk
this.chunksDone = 0; // How many chunks we already have
this.stack = [];
// Output
this.posOut = 0;
this.bufferOut32 = new Uint32Array(16);
this.chunkOut = 0; // index of output chunk
this.enableXOF = true;
this.outputLen = opts.dkLen === undefined ? 32 : opts.dkLen;
_assert_js_1.default.number(this.outputLen);
if (opts.key !== undefined && opts.context !== undefined)
throw new Error('Blake3: only key or context can be specified at same time');
else if (opts.key !== undefined) {
const key = (0, utils_js_1.toBytes)(opts.key);
if (key.length !== 32)
throw new Error('Blake3: key should be 32 byte');
this.IV = (0, utils_js_1.u32)(key);
this.flags = flags | Flags.KEYED_HASH;
}
else if (opts.context !== undefined) {
const context_key = new BLAKE3({ dkLen: 32 }, Flags.DERIVE_KEY_CONTEXT)
.update(opts.context)
.digest();
this.IV = (0, utils_js_1.u32)(context_key);
this.flags = flags | Flags.DERIVE_KEY_MATERIAL;
}
else {
this.IV = blake2s_js_1.IV.slice();
this.flags = flags;
}
this.state = this.IV.slice();
this.bufferOut = (0, utils_js_1.u8)(this.bufferOut32);
}
// Unused
get() {
return [];
}
set() { }
b2Compress(counter, flags, buf, bufPos = 0) {
const { state: s, pos } = this;
const { h, l } = _u64_js_1.default.fromBig(BigInt(counter), true);
// prettier-ignore
const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = (0, blake2s_js_1.compress)(SIGMA, bufPos, buf, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], blake2s_js_1.IV[0], blake2s_js_1.IV[1], blake2s_js_1.IV[2], blake2s_js_1.IV[3], h, l, pos, flags);
s[0] = v0 ^ v8;
s[1] = v1 ^ v9;
s[2] = v2 ^ v10;
s[3] = v3 ^ v11;
s[4] = v4 ^ v12;
s[5] = v5 ^ v13;
s[6] = v6 ^ v14;
s[7] = v7 ^ v15;
}
compress(buf, bufPos = 0, isLast = false) {
// Compress last block
let flags = this.flags;
if (!this.chunkPos)
flags |= Flags.CHUNK_START;
if (this.chunkPos === 15 || isLast)
flags |= Flags.CHUNK_END;
if (!isLast)
this.pos = this.blockLen;
this.b2Compress(this.chunksDone, flags, buf, bufPos);
this.chunkPos += 1;
// If current block is last in chunk (16 blocks), then compress chunks
if (this.chunkPos === 16 || isLast) {
let chunk = this.state;
this.state = this.IV.slice();
// If not the last one, compress only when there are trailing zeros in chunk counter
// chunks used as binary tree where current stack is path. Zero means current leaf is finished and can be compressed.
// 1 (001) - leaf not finished (just push current chunk to stack)
// 2 (010) - leaf finished at depth=1 (merge with last elm on stack and push back)
// 3 (011) - last leaf not finished
// 4 (100) - leafs finished at depth=1 and depth=2
for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) {
if (!(last = this.stack.pop()))
break;
this.buffer32.set(last, 0);
this.buffer32.set(chunk, 8);
this.pos = this.blockLen;
this.b2Compress(0, this.flags | Flags.PARENT, this.buffer32, 0);
chunk = this.state;
this.state = this.IV.slice();
}
this.chunksDone++;
this.chunkPos = 0;
this.stack.push(chunk);
}
this.pos = 0;
}
_cloneInto(to) {
to = super._cloneInto(to);
const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this;
to.state.set(state.slice());
to.stack = stack.map((i) => Uint32Array.from(i));
to.IV.set(IV);
to.flags = flags;
to.chunkPos = chunkPos;
to.chunksDone = chunksDone;
to.posOut = posOut;
to.chunkOut = chunkOut;
to.enableXOF = this.enableXOF;
to.bufferOut32.set(this.bufferOut32);
return to;
}
destroy() {
this.destroyed = true;
this.state.fill(0);
this.buffer32.fill(0);
this.IV.fill(0);
this.bufferOut32.fill(0);
for (let i of this.stack)
i.fill(0);
}
// Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8)
b2CompressOut() {
const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this;
const { h, l } = _u64_js_1.default.fromBig(BigInt(this.chunkOut++));
// prettier-ignore
const { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = (0, blake2s_js_1.compress)(SIGMA, 0, buffer32, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], blake2s_js_1.IV[0], blake2s_js_1.IV[1], blake2s_js_1.IV[2], blake2s_js_1.IV[3], l, h, pos, flags);
out32[0] = v0 ^ v8;
out32[1] = v1 ^ v9;
out32[2] = v2 ^ v10;
out32[3] = v3 ^ v11;
out32[4] = v4 ^ v12;
out32[5] = v5 ^ v13;
out32[6] = v6 ^ v14;
out32[7] = v7 ^ v15;
out32[8] = s[0] ^ v8;
out32[9] = s[1] ^ v9;
out32[10] = s[2] ^ v10;
out32[11] = s[3] ^ v11;
out32[12] = s[4] ^ v12;
out32[13] = s[5] ^ v13;
out32[14] = s[6] ^ v14;
out32[15] = s[7] ^ v15;
this.posOut = 0;
}
finish() {
if (this.finished)
return;
this.finished = true;
// Padding
this.buffer.fill(0, this.pos);
// Process last chunk
let flags = this.flags | Flags.ROOT;
if (this.stack.length) {
flags |= Flags.PARENT;
this.compress(this.buffer32, 0, true);
this.chunksDone = 0;
this.pos = this.blockLen;
}
else {
flags |= (!this.chunkPos ? Flags.CHUNK_START : 0) | Flags.CHUNK_END;
}
this.flags = flags;
this.b2CompressOut();
}
writeInto(out) {
_assert_js_1.default.exists(this, false);
_assert_js_1.default.bytes(out);
this.finish();
const { blockLen, bufferOut } = this;
for (let pos = 0, len = out.length; pos < len;) {
if (this.posOut >= blockLen)
this.b2CompressOut();
const take = Math.min(blockLen - this.posOut, len - pos);
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
this.posOut += take;
pos += take;
}
return out;
}
xofInto(out) {
if (!this.enableXOF)
throw new Error('XOF is not possible after digest call');
return this.writeInto(out);
}
xof(bytes) {
_assert_js_1.default.number(bytes);
return this.xofInto(new Uint8Array(bytes));
}
digestInto(out) {
_assert_js_1.default.output(out, this);
if (this.finished)
throw new Error('digest() was already called');
this.enableXOF = false;
this.writeInto(out);
this.destroy();
return out;
}
digest() {
return this.digestInto(new Uint8Array(this.outputLen));
}
}
/**
* BLAKE3 hash function.
* @param msg - message that would be hashed
* @param opts - dkLen, key, context
*/
exports.blake3 = (0, utils_js_1.wrapConstructorWithOpts)((opts) => new BLAKE3(opts));
//# sourceMappingURL=blake3.js.map

View File

@@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a function", arguments[1]);
};

View File

@@ -0,0 +1,5 @@
import rtrim from './rtrim';
import ltrim from './ltrim';
export default function trim(str, chars) {
return rtrim(ltrim(str, chars), chars);
}

View File

@@ -0,0 +1,49 @@
{
"name": "raw-body",
"description": "Get and validate the raw body of a readable stream.",
"version": "2.5.2",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>",
"Raynos <raynos2@gmail.com>"
],
"license": "MIT",
"repository": "stream-utils/raw-body",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"devDependencies": {
"bluebird": "3.7.2",
"eslint": "8.34.0",
"eslint-config-standard": "15.0.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-markdown": "3.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-standard": "4.1.0",
"mocha": "10.2.0",
"nyc": "15.1.0",
"readable-stream": "2.3.7",
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.8"
},
"files": [
"HISTORY.md",
"LICENSE",
"README.md",
"SECURITY.md",
"index.d.ts",
"index.js"
],
"scripts": {
"lint": "eslint .",
"test": "mocha --trace-deprecation --reporter spec --bail --check-leaks test/",
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}

View File

@@ -0,0 +1,2 @@
declare function coerceToNaturalNumber(value: any): number | null;
export default coerceToNaturalNumber;

View File

@@ -0,0 +1,77 @@
import assert from './_assert.js';
import { Hash, toBytes } from './utils.js';
// HMAC (RFC 2104)
class HMAC extends Hash {
constructor(hash, _key) {
super();
this.finished = false;
this.destroyed = false;
assert.hash(hash);
const key = toBytes(_key);
this.iHash = hash.create();
if (typeof this.iHash.update !== 'function')
throw new TypeError('Expected instance of class which extends utils.Hash');
this.blockLen = this.iHash.blockLen;
this.outputLen = this.iHash.outputLen;
const blockLen = this.blockLen;
const pad = new Uint8Array(blockLen);
// blockLen can be bigger than outputLen
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
for (let i = 0; i < pad.length; i++)
pad[i] ^= 0x36;
this.iHash.update(pad);
// By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
this.oHash = hash.create();
// Undo internal XOR && apply outer XOR
for (let i = 0; i < pad.length; i++)
pad[i] ^= 0x36 ^ 0x5c;
this.oHash.update(pad);
pad.fill(0);
}
update(buf) {
assert.exists(this);
this.iHash.update(buf);
return this;
}
digestInto(out) {
assert.exists(this);
assert.bytes(out, this.outputLen);
this.finished = true;
this.iHash.digestInto(out);
this.oHash.update(out);
this.oHash.digestInto(out);
this.destroy();
}
digest() {
const out = new Uint8Array(this.oHash.outputLen);
this.digestInto(out);
return out;
}
_cloneInto(to) {
// Create new instance without calling constructor since key already in state and we don't know it.
to || (to = Object.create(Object.getPrototypeOf(this), {}));
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
to = to;
to.finished = finished;
to.destroyed = destroyed;
to.blockLen = blockLen;
to.outputLen = outputLen;
to.oHash = oHash._cloneInto(to.oHash);
to.iHash = iHash._cloneInto(to.iHash);
return to;
}
destroy() {
this.destroyed = true;
this.oHash.destroy();
this.iHash.destroy();
}
}
/**
* HMAC: RFC2104 message authentication code.
* @param hash - function that would be used e.g. sha256
* @param key - message key
* @param message - message data
*/
export const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
hmac.create = (hash, key) => new HMAC(hash, key);
//# sourceMappingURL=hmac.js.map

View File

@@ -0,0 +1,2 @@
import { Token, Authentication } from "./types";
export declare function auth(token: Token): Promise<Authentication>;

View File

@@ -0,0 +1,18 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ca-file"), exports);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1,48 @@
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
/**
* Returns an Observable that skips items emitted by the source Observable until a second Observable emits an item.
*
* The `skipUntil` operator causes the observable stream to skip the emission of values until the passed in observable
* emits the first value. This can be particularly useful in combination with user interactions, responses of HTTP
* requests or waiting for specific times to pass by.
*
* ![](skipUntil.png)
*
* Internally, the `skipUntil` operator subscribes to the passed in `notifier` `ObservableInput` (which gets converted
* to an Observable) in order to recognize the emission of its first value. When `notifier` emits next, the operator
* unsubscribes from it and starts emitting the values of the *source* observable until it completes or errors. It
* will never let the *source* observable emit any values if the `notifier` completes or throws an error without
* emitting a value before.
*
* ## Example
*
* In the following example, all emitted values of the interval observable are skipped until the user clicks anywhere
* within the page
*
* ```ts
* import { interval, fromEvent, skipUntil } from 'rxjs';
*
* const intervalObservable = interval(1000);
* const click = fromEvent(document, 'click');
*
* const emitAfterClick = intervalObservable.pipe(
* skipUntil(click)
* );
* // clicked at 4.6s. output: 5...6...7...8........ or
* // clicked at 7.3s. output: 8...9...10..11.......
* emitAfterClick.subscribe(value => console.log(value));
* ```
*
* @see {@link last}
* @see {@link skip}
* @see {@link skipWhile}
* @see {@link skipLast}
*
* @param notifier An `ObservableInput` that has to emit an item before the source Observable elements begin to
* be mirrored by the resulting Observable.
* @return A function that returns an Observable that skips items from the
* source Observable until the `notifier` Observable emits an item, then emits the
* remaining items.
*/
export declare function skipUntil<T>(notifier: ObservableInput<any>): MonoTypeOperatorFunction<T>;
//# sourceMappingURL=skipUntil.d.ts.map

View File

@@ -0,0 +1,8 @@
import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
/** @deprecated Will be removed in v9. Use {@link switchMap} instead: `switchMap(() => result)` */
export declare function switchMapTo<O extends ObservableInput<unknown>>(observable: O): OperatorFunction<unknown, ObservedValueOf<O>>;
/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */
export declare function switchMapTo<O extends ObservableInput<unknown>>(observable: O, resultSelector: undefined): OperatorFunction<unknown, ObservedValueOf<O>>;
/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */
export declare function switchMapTo<T, R, O extends ObservableInput<unknown>>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R): OperatorFunction<T, R>;
//# sourceMappingURL=switchMapTo.d.ts.map

View File

@@ -0,0 +1 @@
{"name":"globalyzer","version":"0.1.0","files":{"package.json":{"checkedAt":1678883668792,"integrity":"sha512-6qzOhkzaJzeUkrIqnRudgu+KKCWhFcfbYKAXWuyWGHMZl+JIUXB89SfT+3I7ofGuoTxVxVb66onJacKP9atLXg==","mode":420,"size":521},"readme.md":{"checkedAt":1678883668792,"integrity":"sha512-JzgLEbjwg3nn5U/J7NTuXcC1rw1RInyZWnrmgYjG0+DS4tANK2qBbNKjxFq+AZ1GjIKrXCZl3Ytt6kxNjQImiA==","mode":420,"size":966},"license":{"checkedAt":1678883668792,"integrity":"sha512-0y0FZw1t32uFvTh5h0IBAEbxr+otb7ic29DW3BW4BGv3aF7Kcn7jIZ2/0C1+VYXO46HABlriOpgTOAhJCqShpg==","mode":420,"size":1079},"src/.DS_Store":{"checkedAt":1678883668792,"integrity":"sha512-WJQSFKgzQzHlIRSquFH8PY1dpd0UmD+TPahzXCSw3crBNOjxNpJVMZnE2aFKSzGItih4owudaW7doSBGZrYINw==","mode":420,"size":6148},"src/index.js":{"checkedAt":1678883668792,"integrity":"sha512-eNMgOQ3L7jCi2bEiGRfQzkw5enW9Oy9u/LUhkJ+hlcU4HdnnSOYq3LjwdjVI3sWIYzJxV6BgaaR4gJ0Tp41Bhw==","mode":420,"size":2702}}}

View File

@@ -0,0 +1 @@
{"name":"responselike","version":"3.0.0","files":{"license":{"checkedAt":1678883671081,"integrity":"sha512-099RpbX0MiZ1dvqIkWef/f9yKoew+2OZacJdzFh7z8hXG6qlTBkJhQYfv9t3RgJchGforhc9gNduAey0ExBhPA==","mode":420,"size":1196},"index.js":{"checkedAt":1678883671081,"integrity":"sha512-F5q//YELY2ELihEOZpu5PYslfP7etgY1PNM5X5iW2QwUM0i40h0WIBGp/FKuccs4VXJm2dhyoMBeChS7EOqiZQ==","mode":420,"size":861},"readme.md":{"checkedAt":1678883671081,"integrity":"sha512-wMyPOoS1+l+qdCggX1Gbpo9VESFsuJcmzVnu7++KIy+lRew13yADiEJUlYFn0ePFiNPos4qckIhnIY2nLeqe/Q==","mode":420,"size":1316},"package.json":{"checkedAt":1678883671081,"integrity":"sha512-Gep0UujvuDlGOMXGMcJnF//V2grc99C61LzMypaxjq9oxnpo9SCeWdHIAOl8+zltLknj5NW+gSuAGN/HI1OJlQ==","mode":420,"size":772},"index.d.ts":{"checkedAt":1678883671081,"integrity":"sha512-gKEWUM18ZbnIKJRG9F2JFL8ruOpph7NxoLQ1IrglT2EGIuqTQnvT2WyMR+LLUt3eupVOiBcEyjyUDczVTPr0PQ==","mode":420,"size":1409}}}

View File

@@ -0,0 +1,100 @@
"use strict";
function isDirectoryIndex(resource, options)
{
var verdict = false;
options.directoryIndexes.every( function(index)
{
if (index === resource)
{
verdict = true;
return false;
}
return true;
});
return verdict;
}
function parsePath(urlObj, options)
{
var path = urlObj.path.absolute.string;
if (path)
{
var lastSlash = path.lastIndexOf("/");
if (lastSlash > -1)
{
if (++lastSlash < path.length)
{
var resource = path.substr(lastSlash);
if (resource!=="." && resource!=="..")
{
urlObj.resource = resource;
path = path.substr(0, lastSlash);
}
else
{
path += "/";
}
}
urlObj.path.absolute.string = path;
urlObj.path.absolute.array = splitPath(path);
}
else if (path==="." || path==="..")
{
// "..?var", "..#anchor", etc ... not "..index.html"
path += "/";
urlObj.path.absolute.string = path;
urlObj.path.absolute.array = splitPath(path);
}
else
{
// Resource-only
urlObj.resource = path;
urlObj.path.absolute.string = null;
}
urlObj.extra.resourceIsIndex = isDirectoryIndex(urlObj.resource, options);
}
// Else: query/hash-only or empty
}
function splitPath(path)
{
// TWEAK :: condition only for speed optimization
if (path !== "/")
{
var cleaned = [];
path.split("/").forEach( function(dir)
{
// Cleanup -- splitting "/dir/" becomes ["","dir",""]
if (dir !== "")
{
cleaned.push(dir);
}
});
return cleaned;
}
else
{
// Faster to skip the above block and just create an array
return [];
}
}
module.exports = parsePath;

View File

@@ -0,0 +1 @@
{"name":"is-number","version":"7.0.0","files":{"LICENSE":{"checkedAt":1678883670924,"integrity":"sha512-cjkrzNiWTIjsiqPYFXRqK2pEZtnHyo9CjX0PPiuxFnTvSUyjNciyVe7lglwIene7RaXWACXzGLeKZOGb7M0jxw==","mode":420,"size":1091},"package.json":{"checkedAt":1678883670940,"integrity":"sha512-24Z5g85m+XlX2XVK6kHyUdX3hFNpOxU624oX8RlsWpl/UzKbaIPSw06ekTONi+jJJdWw+NOABfUFclBvoKqSvg==","mode":420,"size":1599},"README.md":{"checkedAt":1678883670940,"integrity":"sha512-cOqfmZYLP/oeP9sTRYOF1MMz0/2OjwpevKhEMVamN49Wbrs8f4E8/PWpnL0xfLgKtrOnkfUxkiwEOcYgqg4r2A==","mode":420,"size":6514},"index.js":{"checkedAt":1678883670940,"integrity":"sha512-dPUftdHbweyj4NBWhxpyvzxkcW6YFzLL7vZRxRou5KkDw8AHSQ6EWbDRuvwHXrSeuZkTyHqQFcevEigzacotog==","mode":420,"size":411}}}

View File

@@ -0,0 +1 @@
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0.00155,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0.00155,"100":0,"101":0,"102":0.00155,"103":0,"104":0,"105":0,"106":0,"107":0.00155,"108":0.00155,"109":0.14551,"110":0.06502,"111":0.00619,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0.00155,"38":0,"39":0.00155,"40":0.0031,"41":0,"42":0,"43":0.00155,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00155,"57":0.0031,"58":0,"59":0,"60":0.00774,"61":0,"62":0,"63":0.00155,"64":0,"65":0,"66":0,"67":0,"68":0.00155,"69":0.00155,"70":0.00155,"71":0,"72":0.00155,"73":0,"74":0.00155,"75":0,"76":0.00155,"77":0.00155,"78":0.00155,"79":0.00464,"80":0.00155,"81":0.02012,"83":0.00155,"84":0.00155,"85":0.00155,"86":0.00155,"87":0.00155,"88":0,"89":0.00155,"90":0.00774,"91":0,"92":0,"93":0.00155,"94":0,"95":0.00155,"96":0,"97":0.00155,"98":0.00155,"99":0,"100":0,"101":0.0031,"102":0,"103":0.01238,"104":0.0031,"105":0.00155,"106":0.0031,"107":0.01858,"108":0.03096,"109":0.5387,"110":0.26316,"111":0.00155,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0.00155,"60":0.00464,"62":0,"63":0.00464,"64":0.00155,"65":0,"66":0.00464,"67":0.02632,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.00155,"94":0.01238,"95":0.02477,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0.0031},B:{"12":0.0031,"13":0,"14":0,"15":0.00155,"16":0,"17":0,"18":0.0031,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00155,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0.00155,"107":0.00155,"108":0.0031,"109":0.07121,"110":0.113},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.00155,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0.00155,"6.1":0,"7.1":0,"9.1":0.0031,"10.1":0,"11.1":0,"12.1":0,"13.1":0.0031,"14.1":0.00155,"15.1":0.00155,"15.2-15.3":0,"15.4":0,"15.5":0.00774,"15.6":0.02632,"16.0":0.00155,"16.1":0.00774,"16.2":0.00619,"16.3":0.00774,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.02379,"6.0-6.1":0,"7.0-7.1":0.28289,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.71647,"10.0-10.2":0,"10.3":0.95442,"11.0-11.2":0,"11.3-11.4":0.04494,"12.0-12.1":1.1765,"12.2-12.5":5.35901,"13.0-13.1":0.45209,"13.2":0.02644,"13.3":0.71383,"13.4-13.7":0.16127,"14.0-14.4":1.3695,"14.5-14.8":1.81101,"15.0-15.1":0.58164,"15.2-15.3":0.58164,"15.4":0.98614,"15.5":1.09983,"15.6":1.3272,"16.0":1.44352,"16.1":3.03774,"16.2":1.40915,"16.3":1.07868,"16.4":0.00529},P:{"4":0.89218,"20":0.20748,"5.0-5.4":0.02075,"6.2-6.4":0.03112,"7.2-7.4":0.18674,"8.2":0.01037,"9.2":0.17636,"10.1":0,"11.1-11.2":0.0415,"12.0":0,"13.0":0.06225,"14.0":0.01037,"15.0":0.01037,"16.0":0.0415,"17.0":0.03112,"18.0":0.42534,"19.0":0.95443},I:{"0":0,"3":0,"4":0.00024,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00795,"4.2-4.3":0.01406,"4.4":0,"4.4.3-4.4.4":0.03729},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00155,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.27046},H:{"0":0.76017},L:{"0":68.82355},R:{_:"0"},M:{"0":0.02536},Q:{"13.1":0}};

View File

@@ -0,0 +1,4 @@
import { cloneDeep } from '../util/cloneDeep'
import defaultConfig from '../../stubs/defaultConfig.stub'
export default cloneDeep(defaultConfig)

View File

@@ -0,0 +1,2 @@
module.exports=function(t,e,l,n,o){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:o;return t===o?l:t};
//# sourceMappingURL=dlv.js.map

View File

@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}

View File

@@ -0,0 +1,5 @@
var convert = require('./convert'),
func = convert('random', require('../random'));
func.placeholder = require('./placeholder');
module.exports = func;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.statSync = exports.stat = exports.Settings = void 0;
const async = require("./providers/async");
const sync = require("./providers/sync");
const settings_1 = require("./settings");
exports.Settings = settings_1.default;
function stat(path, optionsOrSettingsOrCallback, callback) {
if (typeof optionsOrSettingsOrCallback === 'function') {
async.read(path, getSettings(), optionsOrSettingsOrCallback);
return;
}
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
}
exports.stat = stat;
function statSync(path, optionsOrSettings) {
const settings = getSettings(optionsOrSettings);
return sync.read(path, settings);
}
exports.statSync = statSync;
function getSettings(settingsOrOptions = {}) {
if (settingsOrOptions instanceof settings_1.default) {
return settingsOrOptions;
}
return new settings_1.default(settingsOrOptions);
}

View File

@@ -0,0 +1 @@
{"name":"is-unicode-supported","version":"1.3.0","files":{"license":{"checkedAt":1678883669302,"integrity":"sha512-0fM2/ycrxrltyaBKfQ748Ck23VlPUUBgNAR47ldf4B1V/HoXTfWBSk+vcshGKwEpmOynu4mOP5o+hyBfuRNa8g==","mode":420,"size":1117},"index.js":{"checkedAt":1678883671213,"integrity":"sha512-6csf6G6YL1XPPQDfNiOj/kYc3ecxJ7XdDvhfLGgsCrkjutAwO2J9Esilm+EXdAE/FZEhmNrpJkx+Yifyoc37Jg==","mode":420,"size":651},"package.json":{"checkedAt":1678883671213,"integrity":"sha512-QLDXDDyRAzgqBYuZ9ATq3r/2QxkpIc6VSLK2TjnAbsKF5e49KjNoUfxzFqtVpteNa+JVPuXp5tuhD3IFqQa7Og==","mode":420,"size":779},"readme.md":{"checkedAt":1678883671213,"integrity":"sha512-G8917ZjFlPRXTx4QAeOLlAQtZhO15CiUpJQnhFN9M9eknsdg5Wc6OFaAVKXBHJuG9xSRQbKpnfItCl4cw7uvSw==","mode":420,"size":1123},"index.d.ts":{"checkedAt":1678883671213,"integrity":"sha512-NQ+c0dqIjg2Prf4KY4jF5kClb981qOtVfclgxh1/VhZL127BcERoj25ADsdqeM70BDeeAoF9WgBSS1+Tm7RWbA==","mode":420,"size":214}}}

View File

@@ -0,0 +1,41 @@
var arrayEach = require('./_arrayEach'),
baseAssignValue = require('./_baseAssignValue'),
bind = require('./bind'),
flatRest = require('./_flatRest'),
toKey = require('./_toKey');
/**
* Binds methods of an object to the object itself, overwriting the existing
* method.
*
* **Note:** This method doesn't set the "length" property of bound functions.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*
* var view = {
* 'label': 'docs',
* 'click': function() {
* console.log('clicked ' + this.label);
* }
* };
*
* _.bindAll(view, ['click']);
* jQuery(element).on('click', view.click);
* // => Logs 'clicked docs' when clicked.
*/
var bindAll = flatRest(function(object, methodNames) {
arrayEach(methodNames, function(key) {
key = toKey(key);
baseAssignValue(object, key, bind(object[key], object));
});
return object;
});
module.exports = bindAll;

View File

@@ -0,0 +1 @@
{"version":3,"file":"exhaustMap.js","sourceRoot":"","sources":["../../../../src/internal/operators/exhaustMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AA8DhE,MAAM,UAAU,UAAU,CACxB,OAAuC,EACvC,cAA6G;IAE7G,IAAI,cAAc,EAAE;QAElB,OAAO,CAAC,MAAqB,EAAE,EAAE,CAC/B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAO,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3H;IACD,OAAO,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACpC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,QAAQ,GAAyB,IAAI,CAAC;QAC1C,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,MAAM,CAAC,SAAS,CACd,wBAAwB,CACtB,UAAU,EACV,CAAC,UAAU,EAAE,EAAE;YACb,IAAI,CAAC,QAAQ,EAAE;gBACb,QAAQ,GAAG,wBAAwB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE;oBAC9D,QAAQ,GAAG,IAAI,CAAC;oBAChB,UAAU,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACtC,CAAC,CAAC,CAAC;gBACH,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;aAC7D;QACH,CAAC,EACD,GAAG,EAAE;YACH,UAAU,GAAG,IAAI,CAAC;YAClB,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACrC,CAAC,CACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}

View File

@@ -0,0 +1,5 @@
var convert = require('./convert'),
func = convert('min', require('../min'), require('./_falseOptions'));
func.placeholder = require('./placeholder');
module.exports = func;

View File

@@ -0,0 +1,138 @@
import net from 'node:net';
import unhandler from './utils/unhandle.js';
const reentry = Symbol('reentry');
const noop = () => { };
export class TimeoutError extends Error {
constructor(threshold, event) {
super(`Timeout awaiting '${event}' for ${threshold}ms`);
Object.defineProperty(this, "event", {
enumerable: true,
configurable: true,
writable: true,
value: event
});
Object.defineProperty(this, "code", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.name = 'TimeoutError';
this.code = 'ETIMEDOUT';
}
}
export default function timedOut(request, delays, options) {
if (reentry in request) {
return noop;
}
request[reentry] = true;
const cancelers = [];
const { once, unhandleAll } = unhandler();
const addTimeout = (delay, callback, event) => {
const timeout = setTimeout(callback, delay, delay, event);
timeout.unref?.();
const cancel = () => {
clearTimeout(timeout);
};
cancelers.push(cancel);
return cancel;
};
const { host, hostname } = options;
const timeoutHandler = (delay, event) => {
request.destroy(new TimeoutError(delay, event));
};
const cancelTimeouts = () => {
for (const cancel of cancelers) {
cancel();
}
unhandleAll();
};
request.once('error', error => {
cancelTimeouts();
// Save original behavior
/* istanbul ignore next */
if (request.listenerCount('error') === 0) {
throw error;
}
});
if (typeof delays.request !== 'undefined') {
const cancelTimeout = addTimeout(delays.request, timeoutHandler, 'request');
once(request, 'response', (response) => {
once(response, 'end', cancelTimeout);
});
}
if (typeof delays.socket !== 'undefined') {
const { socket } = delays;
const socketTimeoutHandler = () => {
timeoutHandler(socket, 'socket');
};
request.setTimeout(socket, socketTimeoutHandler);
// `request.setTimeout(0)` causes a memory leak.
// We can just remove the listener and forget about the timer - it's unreffed.
// See https://github.com/sindresorhus/got/issues/690
cancelers.push(() => {
request.removeListener('timeout', socketTimeoutHandler);
});
}
const hasLookup = typeof delays.lookup !== 'undefined';
const hasConnect = typeof delays.connect !== 'undefined';
const hasSecureConnect = typeof delays.secureConnect !== 'undefined';
const hasSend = typeof delays.send !== 'undefined';
if (hasLookup || hasConnect || hasSecureConnect || hasSend) {
once(request, 'socket', (socket) => {
const { socketPath } = request;
/* istanbul ignore next: hard to test */
if (socket.connecting) {
const hasPath = Boolean(socketPath ?? net.isIP(hostname ?? host ?? '') !== 0);
if (hasLookup && !hasPath && typeof socket.address().address === 'undefined') {
const cancelTimeout = addTimeout(delays.lookup, timeoutHandler, 'lookup');
once(socket, 'lookup', cancelTimeout);
}
if (hasConnect) {
const timeConnect = () => addTimeout(delays.connect, timeoutHandler, 'connect');
if (hasPath) {
once(socket, 'connect', timeConnect());
}
else {
once(socket, 'lookup', (error) => {
if (error === null) {
once(socket, 'connect', timeConnect());
}
});
}
}
if (hasSecureConnect && options.protocol === 'https:') {
once(socket, 'connect', () => {
const cancelTimeout = addTimeout(delays.secureConnect, timeoutHandler, 'secureConnect');
once(socket, 'secureConnect', cancelTimeout);
});
}
}
if (hasSend) {
const timeRequest = () => addTimeout(delays.send, timeoutHandler, 'send');
/* istanbul ignore next: hard to test */
if (socket.connecting) {
once(socket, 'connect', () => {
once(request, 'upload-complete', timeRequest());
});
}
else {
once(request, 'upload-complete', timeRequest());
}
}
});
}
if (typeof delays.response !== 'undefined') {
once(request, 'upload-complete', () => {
const cancelTimeout = addTimeout(delays.response, timeoutHandler, 'response');
once(request, 'response', cancelTimeout);
});
}
if (typeof delays.read !== 'undefined') {
once(request, 'response', (response) => {
const cancelTimeout = addTimeout(delays.read, timeoutHandler, 'read');
once(response, 'end', cancelTimeout);
});
}
return cancelTimeouts;
}

View File

@@ -0,0 +1,2 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n((e||self).jsxRuntime={},e.preact)}(this,function(e,n){var o=0;function t(e,t,r,f,i,u){var _,l,c={};for(l in t)"ref"==l?_=t[l]:c[l]=t[l];var p={type:e,props:c,key:r,ref:_,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--o,__source:i,__self:u};if("function"==typeof e&&(_=e.defaultProps))for(l in _)void 0===c[l]&&(c[l]=_[l]);return n.options.vnode&&n.options.vnode(p),p}Object.defineProperty(e,"Fragment",{enumerable:!0,get:function(){return n.Fragment}}),e.jsx=t,e.jsxDEV=t,e.jsxs=t});
//# sourceMappingURL=jsxRuntime.umd.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bindCallbackInternals.js","sourceRoot":"","sources":["../../../../src/internal/observable/bindCallbackInternals.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAkD;AAClD,4CAA2C;AAC3C,wDAAuD;AACvD,6DAA4D;AAC5D,oDAAmD;AACnD,gDAA+C;AAE/C,SAAgB,qBAAqB,CACnC,WAAoB,EACpB,YAAiB,EACjB,cAAoB,EACpB,SAAyB;IAEzB,IAAI,cAAc,EAAE;QAClB,IAAI,yBAAW,CAAC,cAAc,CAAC,EAAE;YAC/B,SAAS,GAAG,cAAc,CAAC;SAC5B;aAAM;YAEL,OAAO;gBAAqB,cAAc;qBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;oBAAd,yBAAc;;gBACxC,OAAQ,qBAAqB,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,CAAS;qBACxE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;qBACjB,IAAI,CAAC,mCAAgB,CAAC,cAAqB,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC;SACH;KACF;IAID,IAAI,SAAS,EAAE;QACb,OAAO;YAAqB,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YACxC,OAAQ,qBAAqB,CAAC,WAAW,EAAE,YAAY,CAAS;iBAC7D,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;iBACjB,IAAI,CAAC,yBAAW,CAAC,SAAU,CAAC,EAAE,qBAAS,CAAC,SAAU,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC;KACH;IAED,OAAO;QAAA,iBAgFN;QAhF2B,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QAGxC,IAAM,OAAO,GAAG,IAAI,2BAAY,EAAO,CAAC;QAGxC,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,uBAAU,CAAC,UAAC,UAAU;YAE/B,IAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAE3C,IAAI,aAAa,EAAE;gBACjB,aAAa,GAAG,KAAK,CAAC;gBAMtB,IAAI,SAAO,GAAG,KAAK,CAAC;gBAGpB,IAAI,YAAU,GAAG,KAAK,CAAC;gBAKvB,YAAY,CAAC,KAAK,CAEhB,KAAI,yCAGC,IAAI;oBAEP;wBAAC,iBAAiB;6BAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;4BAAjB,4BAAiB;;wBAChB,IAAI,WAAW,EAAE;4BAIf,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;4BAC5B,IAAI,GAAG,IAAI,IAAI,EAAE;gCACf,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gCAGnB,OAAO;6BACR;yBACF;wBAKD,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;wBAGxD,YAAU,GAAG,IAAI,CAAC;wBAMlB,IAAI,SAAO,EAAE;4BACX,OAAO,CAAC,QAAQ,EAAE,CAAC;yBACpB;oBACH,CAAC;mBAEJ,CAAC;gBAIF,IAAI,YAAU,EAAE;oBACd,OAAO,CAAC,QAAQ,EAAE,CAAC;iBACpB;gBAID,SAAO,GAAG,IAAI,CAAC;aAChB;YAGD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA9GD,sDA8GC"}

View File

@@ -0,0 +1,4 @@
export default function parseLinkHeader(link: string): {
reference: string;
parameters: Record<string, string>;
}[];

View File

@@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupContactService = void 0;
const request_1 = require("../core/request");
class GroupContactService {
/**
* Get all
* Lists all contacts. <br> This includes the contact's associated groups.
* @result ResponseGroupContact
* @throws ApiError
*/
static async groupContactControllerGetAll() {
const result = await (0, request_1.request)({
method: 'GET',
path: `/api/contacts`,
});
return result.body;
}
/**
* Post
* Create a new contact.
* @param requestBody CreateGroupContact
* @result ResponseGroupContact
* @throws ApiError
*/
static async groupContactControllerPost(requestBody) {
const result = await (0, request_1.request)({
method: 'POST',
path: `/api/contacts`,
body: requestBody,
});
return result.body;
}
/**
* Get one
* Lists all information about the contact whose id got provided. <br> This includes the contact's associated groups.
* @param id
* @result ResponseGroupContact
* @throws ApiError
*/
static async groupContactControllerGetOne(id) {
const result = await (0, request_1.request)({
method: 'GET',
path: `/api/contacts/${id}`,
});
return result.body;
}
/**
* Put
* Update the contact whose id you provided. <br> Please remember that ids can't be changed.
* @param id
* @param requestBody UpdateGroupContact
* @result ResponseGroupContact
* @throws ApiError
*/
static async groupContactControllerPut(id, requestBody) {
const result = await (0, request_1.request)({
method: 'PUT',
path: `/api/contacts/${id}`,
body: requestBody,
});
return result.body;
}
/**
* Remove
* Delete the contact whose id you provided. <br> If no contact with this id exists it will just return 204(no content). <br> This won't delete any groups associated with the contact.
* @param id
* @param force
* @result ResponseGroupContact
* @result ResponseEmpty
* @throws ApiError
*/
static async groupContactControllerRemove(id, force) {
const result = await (0, request_1.request)({
method: 'DELETE',
path: `/api/contacts/${id}`,
query: {
'force': force,
},
});
return result.body;
}
}
exports.GroupContactService = GroupContactService;

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L","4100":"G M N O"},C:{"1":"LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 6 DC tB I v J D E F A B C K L G M N O w g x y z EC FC","132":"7 8 9 AB","260":"BB","516":"CB DB EB FB GB HB IB JB KB"},D:{"1":"GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB","1028":"CB DB EB","2052":"FB"},E:{"1":"A B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F HC zB IC JC KC LC"},F:{"1":"3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C G M N O w g x y PC QC RC SC qB AC TC rB","1028":"0 1 z","2052":"2"},G:{"1":"bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC aC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:2,C:"Content Security Policy Level 2"};

View File

@@ -0,0 +1,5 @@
var convert = require('./convert'),
func = convert('trimCharsStart', require('../trimStart'));
func.placeholder = require('./placeholder');
module.exports = func;

View File

@@ -0,0 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v1.0.0 - 2023-02-28
### Commits
- Initial implementation, tests, readme [`2db6cad`](https://github.com/inspect-js/array-buffer-byte-length/commit/2db6cad79270ab1966f5ea80160abbcd4534c91d)
- Initial commit [`b2a0c9c`](https://github.com/inspect-js/array-buffer-byte-length/commit/b2a0c9c2246514b7999d331aad868c4f32326db7)
- npm init [`376acdb`](https://github.com/inspect-js/array-buffer-byte-length/commit/376acdbd4435cb1d4c31d107cacb3b86f2363aee)
- Only apps should have lockfiles [`70cf325`](https://github.com/inspect-js/array-buffer-byte-length/commit/70cf32526fc727d0d16a12d85a4bddea70075e31)

View File

@@ -0,0 +1,232 @@
'use strict';
var hasSymbols = require('has-symbols/shams')();
var forEach = require('for-each');
var has = require('has');
var mockProperty = require('mock-property');
module.exports = function (assign, t) {
t.test('error cases', function (st) {
st['throws'](function () { assign(null); }, TypeError, 'target must be an object');
st['throws'](function () { assign(undefined); }, TypeError, 'target must be an object');
st['throws'](function () { assign(null, {}); }, TypeError, 'target must be an object');
st['throws'](function () { assign(undefined, {}); }, TypeError, 'target must be an object');
st.end();
});
t.test('non-object target, no sources', function (st) {
var bool = assign(true);
st.equal(typeof bool, 'object', 'bool is object');
st.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
var number = assign(1);
st.equal(typeof number, 'object', 'number is object');
st.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
var string = assign('1');
st.equal(typeof string, 'object', 'number is object');
st.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
st.end();
});
t.test('non-object target, with sources', function (st) {
var signal = {};
st.test('boolean', function (st2) {
var bool = assign(true, { a: signal });
st2.equal(typeof bool, 'object', 'bool is object');
st2.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
st2.equal(bool.a, signal, 'source properties copied');
st2.end();
});
st.test('number', function (st2) {
var number = assign(1, { a: signal });
st2.equal(typeof number, 'object', 'number is object');
st2.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
st2.equal(number.a, signal, 'source properties copied');
st2.end();
});
st.test('string', function (st2) {
var string = assign('1', { a: signal });
st2.equal(typeof string, 'object', 'number is object');
st2.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
st2.equal(string.a, signal, 'source properties copied');
st2.end();
});
st.end();
});
t.test('non-object sources', function (st) {
st.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 }, 'ignores null source');
st.deepEqual(assign({ a: 1 }, { b: 2 }, undefined), { a: 1, b: 2 }, 'ignores undefined source');
st.end();
});
t.test('returns the modified target object', function (st) {
var target = {};
var returned = assign(target, { a: 1 });
st.equal(returned, target, 'returned object is the same reference as the target object');
st.end();
});
t.test('has the right length', function (st) {
st.equal(assign.length, 2, 'length is 2 => 2 required arguments');
st.end();
});
t.test('merge two objects', function (st) {
var target = { a: 1 };
var returned = assign(target, { b: 2 });
st.deepEqual(returned, { a: 1, b: 2 }, 'returned object has properties from both');
st.end();
});
t.test('works with functions', function (st) {
var target = function () {};
target.a = 1;
var returned = assign(target, { b: 2 });
st.equal(target, returned, 'returned object is target');
st.equal(returned.a, 1);
st.equal(returned.b, 2);
st.end();
});
t.test('works with primitives', function (st) {
var target = 2;
var source = { b: 42 };
var returned = assign(target, source);
st.equal(Object.prototype.toString.call(returned), '[object Number]', 'returned is object form of number primitive');
st.equal(Number(returned), target, 'returned and target have same valueOf');
st.equal(returned.b, source.b);
st.end();
});
/* globals window */
t.test('works with window.location', { skip: typeof window === 'undefined' }, function (st) {
var target = {};
assign(target, window.location);
for (var prop in window.location) {
if (has(window.location, prop)) {
st.deepEqual(target[prop], window.location[prop], prop + ' is copied');
}
}
st.end();
});
t.test('merge N objects', function (st) {
var target = { a: 1 };
var source1 = { b: 2 };
var source2 = { c: 3 };
var returned = assign(target, source1, source2);
st.deepEqual(returned, { a: 1, b: 2, c: 3 }, 'returned object has properties from all sources');
st.end();
});
t.test('only iterates over own keys', function (st) {
var Foo = function () {};
Foo.prototype.bar = true;
var foo = new Foo();
foo.baz = true;
var target = { a: 1 };
var returned = assign(target, foo);
st.equal(returned, target, 'returned object is the same reference as the target object');
st.deepEqual(target, { a: 1, baz: true }, 'returned object has only own properties from both');
st.end();
});
t.test('includes enumerable symbols, after keys', { skip: !hasSymbols }, function (st) {
var visited = [];
var obj = {};
Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
var symbol = Symbol('enumerable');
Object.defineProperty(obj, symbol, {
enumerable: true,
get: function () { visited.push(symbol); return Infinity; }
});
var nonEnumSymbol = Symbol('non-enumerable');
Object.defineProperty(obj, nonEnumSymbol, {
enumerable: false,
get: function () { visited.push(nonEnumSymbol); return -Infinity; }
});
var target = assign({}, obj);
st.deepEqual(visited, ['a', symbol], 'key is visited first, then symbol');
st.equal(target.a, 42, 'target.a is 42');
st.equal(target[symbol], Infinity, 'target[symbol] is Infinity');
st.notEqual(target[nonEnumSymbol], -Infinity, 'target[nonEnumSymbol] is not -Infinity');
st.end();
});
t.test('does not fail when symbols are not present', { skip: !Object.isFrozen || Object.isFrozen(Object) }, function (st) {
st.teardown(mockProperty(Object, 'getOwnPropertySymbols', { 'delete': true }));
var visited = [];
var obj = {};
Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
var keys = ['a'];
if (hasSymbols) {
var symbol = Symbol('sym');
Object.defineProperty(obj, symbol, {
enumerable: true,
get: function () { visited.push(symbol); return Infinity; }
});
keys.push(symbol);
}
var target = assign({}, obj);
st.deepEqual(visited, keys, 'assign visits expected keys');
st.equal(target.a, 42, 'target.a is 42');
if (hasSymbols) {
st.equal(target[symbol], Infinity);
}
st.end();
});
t.test('preserves correct property enumeration order', function (st) {
var str = 'abcdefghijklmnopqrst';
var letters = {};
forEach(str.split(''), function (letter) {
letters[letter] = letter;
});
var n = 5;
st.comment('run the next test ' + n + ' times');
var object = assign({}, letters);
var actual = '';
for (var k in object) {
actual += k;
}
for (var i = 0; i < n; ++i) {
st.equal(actual, str, 'property enumeration order should be followed');
}
st.end();
});
t.test('checks enumerability and existence, in case of modification during [[Get]]', { skip: !Object.defineProperty }, function (st) {
var targetBvalue = {};
var targetCvalue = {};
var target = { b: targetBvalue, c: targetCvalue };
var source = {};
Object.defineProperty(source, 'a', {
enumerable: true,
get: function () {
delete this.b;
Object.defineProperty(this, 'c', { enumerable: false });
return 'a';
}
});
var sourceBvalue = {};
var sourceCvalue = {};
source.b = sourceBvalue;
source.c = sourceCvalue;
var result = assign(target, source);
st.equal(result, target, 'sanity check: result is === target');
st.equal(result.b, targetBvalue, 'target key not overwritten by deleted source key');
st.equal(result.c, targetCvalue, 'target key not overwritten by non-enumerable source key');
st.end();
});
};

View File

@@ -0,0 +1,146 @@
import isPlainObject from 'lodash/isPlainObject.js';
import get from 'lodash/get.js';
import set from 'lodash/set.js';
const _ = {
isPlainObject,
set,
get,
};
import { defer, empty, from, of } from 'rxjs';
import { concatMap, filter, publish, reduce } from 'rxjs';
import runAsync from 'run-async';
import * as utils from '../utils/utils.js';
import Base from './baseUI.js';
/**
* Base interface class other can inherits from
*/
export default class PromptUI extends Base {
constructor(prompts, opt) {
super(opt);
this.prompts = prompts;
}
run(questions, answers) {
// Keep global reference to the answers
if (_.isPlainObject(answers)) {
this.answers = { ...answers };
} else {
this.answers = {};
}
// Make sure questions is an array.
if (_.isPlainObject(questions)) {
// It's either an object of questions or a single question
questions = Object.values(questions).every(
(v) => _.isPlainObject(v) && v.name === undefined
)
? Object.entries(questions).map(([name, question]) => ({ name, ...question }))
: [questions];
}
// Create an observable, unless we received one as parameter.
// Note: As this is a public interface, we cannot do an instanceof check as we won't
// be using the exact same object in memory.
const obs = Array.isArray(questions) ? from(questions) : questions;
this.process = obs.pipe(
concatMap(this.processQuestion.bind(this)),
publish() // Creates a hot Observable. It prevents duplicating prompts.
);
this.process.connect();
return this.process
.pipe(
reduce((answers, answer) => {
_.set(answers, answer.name, answer.answer);
return answers;
}, this.answers)
)
.toPromise(Promise)
.then(this.onCompletion.bind(this), this.onError.bind(this));
}
/**
* Once all prompt are over
*/
onCompletion() {
this.close();
return this.answers;
}
onError(error) {
this.close();
return Promise.reject(error);
}
processQuestion(question) {
question = { ...question };
return defer(() => {
const obs = of(question);
return obs.pipe(
concatMap(this.setDefaultType.bind(this)),
concatMap(this.filterIfRunnable.bind(this)),
concatMap(() =>
utils.fetchAsyncQuestionProperty(question, 'message', this.answers)
),
concatMap(() =>
utils.fetchAsyncQuestionProperty(question, 'default', this.answers)
),
concatMap(() =>
utils.fetchAsyncQuestionProperty(question, 'choices', this.answers)
),
concatMap(this.fetchAnswer.bind(this))
);
});
}
fetchAnswer(question) {
const Prompt = this.prompts[question.type];
this.activePrompt = new Prompt(question, this.rl, this.answers);
return defer(() =>
from(this.activePrompt.run().then((answer) => ({ name: question.name, answer })))
);
}
setDefaultType(question) {
// Default type to input
if (!this.prompts[question.type]) {
question.type = 'input';
}
return defer(() => of(question));
}
filterIfRunnable(question) {
if (
question.askAnswered !== true &&
_.get(this.answers, question.name) !== undefined
) {
return empty();
}
if (question.when === false) {
return empty();
}
if (typeof question.when !== 'function') {
return of(question);
}
const { answers } = this;
return defer(() =>
from(
runAsync(question.when)(answers).then((shouldRun) => {
if (shouldRun) {
return question;
}
})
).pipe(filter((val) => val != null))
);
}
}

View File

@@ -0,0 +1,50 @@
var test = require('tape')
var toBuffer = require('../')
test('convert to buffer from Uint8Array', function (t) {
if (typeof Uint8Array !== 'undefined') {
var arr = new Uint8Array([1, 2, 3])
arr = toBuffer(arr)
t.deepEqual(arr, Buffer.from([1, 2, 3]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')
t.equal(arr.readUInt8(0), 1)
t.equal(arr.readUInt8(1), 2)
t.equal(arr.readUInt8(2), 3)
} else {
t.pass('browser lacks Uint8Array support, skip test')
}
t.end()
})
test('convert to buffer from another arrayview type (Uint32Array)', function (t) {
if (typeof Uint32Array !== 'undefined' && Buffer.TYPED_ARRAY_SUPPORT !== false) {
var arr = new Uint32Array([1, 2, 3])
arr = toBuffer(arr)
t.deepEqual(arr, Buffer.from([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')
t.equal(arr.readUInt32LE(0), 1)
t.equal(arr.readUInt32LE(4), 2)
t.equal(arr.readUInt32LE(8), 3)
t.equal(arr instanceof Uint8Array, true)
} else {
t.pass('browser lacks Uint32Array support, skip test')
}
t.end()
})
test('convert to buffer from ArrayBuffer', function (t) {
if (typeof Uint32Array !== 'undefined' && Buffer.TYPED_ARRAY_SUPPORT !== false) {
var arr = new Uint32Array([1, 2, 3]).subarray(1, 2)
arr = toBuffer(arr)
t.deepEqual(arr, Buffer.from([2, 0, 0, 0]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')
t.equal(arr.readUInt32LE(0), 2)
t.equal(arr instanceof Uint8Array, true)
} else {
t.pass('browser lacks ArrayBuffer support, skip test')
}
t.end()
})

View File

@@ -0,0 +1,9 @@
"use strict";
var safeToString = require("../safe-to-string")
, isPromise = require("./is-promise");
module.exports = function (value) {
if (!isPromise(value)) throw new TypeError(safeToString(value) + " is not a promise");
return value;
};

View File

@@ -0,0 +1,28 @@
{
"name": "is-yarn-global",
"version": "0.4.1",
"description": "Check if installed by yarn globally without any `fs` calls",
"repository": "git@github.com:LitoMore/is-yarn-global.git",
"author": "LitoMore (litomore@gmail.com)",
"type": "module",
"exports": "./dist/index.js",
"types": "dist",
"files": [
"dist"
],
"engines": {
"node": ">=12"
},
"license": "MIT",
"scripts": {
"build": "tsc",
"test": "xo"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^1.0.2",
"xo": "^0.39.1"
},
"xo": {
"prettier": true
}
}

View File

@@ -0,0 +1,66 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
function parseProxyResponse(socket) {
return new Promise((resolve, reject) => {
// we need to buffer any HTTP traffic that happens with the proxy before we get
// the CONNECT response, so that if the response is anything other than an "200"
// response code, then we can re-play the "data" events on the socket once the
// HTTP parser is hooked up...
let buffersLength = 0;
const buffers = [];
function read() {
const b = socket.read();
if (b)
ondata(b);
else
socket.once('readable', read);
}
function cleanup() {
socket.removeListener('end', onend);
socket.removeListener('error', onerror);
socket.removeListener('close', onclose);
socket.removeListener('readable', read);
}
function onclose(err) {
debug('onclose had error %o', err);
}
function onend() {
debug('onend');
}
function onerror(err) {
cleanup();
debug('onerror %o', err);
reject(err);
}
function ondata(b) {
buffers.push(b);
buffersLength += b.length;
const buffered = Buffer.concat(buffers, buffersLength);
const endOfHeaders = buffered.indexOf('\r\n\r\n');
if (endOfHeaders === -1) {
// keep buffering
debug('have not received end of HTTP headers yet...');
read();
return;
}
const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
const statusCode = +firstLine.split(' ')[1];
debug('got proxy server response: %o', firstLine);
resolve({
statusCode,
buffered
});
}
socket.on('error', onerror);
socket.on('close', onclose);
socket.on('end', onend);
read();
});
}
exports.default = parseProxyResponse;
//# sourceMappingURL=parse-proxy-response.js.map

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PartitionPattern = void 0;
var utils_1 = require("./utils");
/**
* https://tc39.es/ecma402/#sec-partitionpattern
* @param pattern
*/
function PartitionPattern(pattern) {
var result = [];
var beginIndex = pattern.indexOf('{');
var endIndex = 0;
var nextIndex = 0;
var length = pattern.length;
while (beginIndex < pattern.length && beginIndex > -1) {
endIndex = pattern.indexOf('}', beginIndex);
(0, utils_1.invariant)(endIndex > beginIndex, "Invalid pattern ".concat(pattern));
if (beginIndex > nextIndex) {
result.push({
type: 'literal',
value: pattern.substring(nextIndex, beginIndex),
});
}
result.push({
type: pattern.substring(beginIndex + 1, endIndex),
value: undefined,
});
nextIndex = endIndex + 1;
beginIndex = pattern.indexOf('{', nextIndex);
}
if (nextIndex < length) {
result.push({
type: 'literal',
value: pattern.substring(nextIndex, length),
});
}
return result;
}
exports.PartitionPattern = PartitionPattern;

View File

@@ -0,0 +1,34 @@
var specificity = require('./specificity');
function specificitiesOverlap(selector1, selector2, cache) {
var specificity1;
var specificity2;
var i, l;
var j, m;
for (i = 0, l = selector1.length; i < l; i++) {
specificity1 = findSpecificity(selector1[i][1], cache);
for (j = 0, m = selector2.length; j < m; j++) {
specificity2 = findSpecificity(selector2[j][1], cache);
if (specificity1[0] === specificity2[0] && specificity1[1] === specificity2[1] && specificity1[2] === specificity2[2]) {
return true;
}
}
}
return false;
}
function findSpecificity(selector, cache) {
var value;
if (!(selector in cache)) {
cache[selector] = value = specificity(selector);
}
return value || cache[selector];
}
module.exports = specificitiesOverlap;

View File

@@ -0,0 +1,40 @@
'use strict';
var callBound = require('call-bind/callBound');
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
var Get = require('./Get');
var ToObject = require('./ToObject');
var ToPropertyDescriptor = require('./ToPropertyDescriptor');
var forEach = require('../helpers/forEach');
var getOwnPropertyDescriptor = require('gopd');
var OwnPropertyKeys = require('../helpers/OwnPropertyKeys');
var $push = callBound('Array.prototype.push');
// https://262.ecma-international.org/6.0/#sec-objectdefineproperties
module.exports = function ObjectDefineProperties(O, Properties) {
var props = ToObject(Properties); // step 1
var keys = OwnPropertyKeys(props); // step 2
var descriptors = []; // step 3
forEach(keys, function (nextKey) { // step 4
var propDesc = ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a
if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b
var descObj = Get(props, nextKey); // step 4.b.i
var desc = ToPropertyDescriptor(descObj); // step 4.b.ii
$push(descriptors, [nextKey, desc]); // step 4.b.iii
}
});
forEach(descriptors, function (pair) { // step 5
var P = pair[0]; // step 5.a
var desc = pair[1]; // step 5.b
desc = FromPropertyDescriptor(desc); // TODO: remove this once DefinePropertyOrThrow is fixed
DefinePropertyOrThrow(O, P, desc); // step 5.c
});
return O; // step 6
};

View File

@@ -0,0 +1,305 @@
# validator.js
[![NPM version][npm-image]][npm-url]
[![CI][ci-image]][ci-url]
[![Coverage][codecov-image]][codecov-url]
[![Downloads][downloads-image]][npm-url]
[![Backers on Open Collective](https://opencollective.com/validatorjs/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/validatorjs/sponsors/badge.svg)](#sponsors)
[![Gitter][gitter-image]][gitter-url]
[![Disclose a vulnerability][huntr-image]][huntr-url]
A library of string validators and sanitizers.
## Strings only
**This library validates and sanitizes strings only.**
If you're not sure if your input is a string, coerce it using `input + ''`.
Passing anything other than a string will result in an error.
## Installation and Usage
### Server-side usage
Install the library with `npm install validator`
#### No ES6
```javascript
var validator = require('validator');
validator.isEmail('foo@bar.com'); //=> true
```
#### ES6
```javascript
import validator from 'validator';
```
Or, import only a subset of the library:
```javascript
import isEmail from 'validator/lib/isEmail';
```
#### Tree-shakeable ES imports
```javascript
import isEmail from 'validator/es/lib/isEmail';
```
### Client-side usage
The library can be loaded either as a standalone script, or through an [AMD][amd]-compatible loader
```html
<script type="text/javascript" src="validator.min.js"></script>
<script type="text/javascript">
validator.isEmail('foo@bar.com'); //=> true
</script>
```
The library can also be installed through [bower][bower]
```bash
$ bower install validator-js
```
CDN
```html
<script src="https://unpkg.com/validator@latest/validator.min.js"></script>
```
## Contributors
[Become a backer](https://opencollective.com/validatorjs#backer)
[Become a sponsor](https://opencollective.com/validatorjs#sponsor)
Thank you to the people who have already contributed:
<a href="https://github.com/validatorjs/validator.js/graphs/contributors"><img src="https://opencollective.com/validatorjs/contributors.svg?width=890" /></a>
## Validators
Here is a list of the validators currently available.
Validator | Description
--------------------------------------- | --------------------------------------
**contains(str, seed [, options])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.<br />Options: <br/> `ignoreCase`: Ignore case when doing comparison, default false.<br/>`minOccurences`: Minimum number of occurrences for the seed in the string. Defaults to 1.
**equals(str, comparison)** | check if the string matches the comparison.
**isAfter(str [, options])** | check if the string is a date that is after the specified date.<br/><br/>`options` is an object that defaults to `{ comparisonDate: Date().toString() }`.<br/>**Options:**<br/>`comparisonDate`: Date to compare to. Defaults to `Date().toString()` (now).
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'bn', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ko-KR', 'ja-JP', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']` and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bn', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ko-KR', 'ja-JP','ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
**isAscii(str)** | check if the string contains ASCII chars only.
**isBase32(str [, options])** | check if the string is base32 encoded. `options` is optional and defaults to `{ crockford: false }`.<br/> When `crockford` is true it tests the given base32 encoded string using [Crockford's base32 alternative][Crockford Base32].
**isBase58(str)** | check if the string is base58 encoded.
**isBase64(str [, options])** | check if the string is base64 encoded. `options` is optional and defaults to `{ urlSafe: false }`<br/> when `urlSafe` is true it tests the given base64 encoded string is [url safe][Base64 URL Safe].
**isBefore(str [, date])** | check if the string is a date that is before the specified date.
**isBIC(str)** | check if the string is a BIC (Bank Identification Code) or SWIFT code.
**isBoolean(str [, options])** | check if the string is a boolean.<br/>`options` is an object which defaults to `{ loose: false }`. If `loose` is is set to false, the validator will strictly match ['true', 'false', '0', '1']. If `loose` is set to true, the validator will also match 'yes', 'no', and will match a valid boolean string of any case. (e.g.: ['true', 'True', 'TRUE']).
**isBtcAddress(str)** | check if the string is a valid BTC address.
**isByteLength(str [, options])** | check if the string's length (in UTF-8 bytes) falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`.
**isCreditCard(str [, options])** | check if the string is a credit card number.<br/><br/> `options` is an optional object that can be supplied with the following key(s): `provider` is an optional key whose value should be a string, and defines the company issuing the credit card. Valid values include `['amex', 'dinersclub', 'discover', 'jcb', 'mastercard', 'unionpay', 'visa']` or blank will check for any provider.
**isCurrency(str [, options])** | check if the string is a valid currency amount.<br/><br/>`options` is an object which defaults to `{ symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false }`.<br/>**Note:** The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range 1 to 3 will be given as [1, 2, 3].
**isDataURI(str)** | check if the string is a [data uri format][Data URI Format].
**isDate(str [, options])** | check if the string is a valid date. e.g. [`2002-07-15`, new Date()].<br/><br/> `options` is an object which can contain the keys `format`, `strictMode` and/or `delimiters`.<br/><br/>`format` is a string and defaults to `YYYY/MM/DD`.<br/><br/>`strictMode` is a boolean and defaults to `false`. If `strictMode` is set to true, the validator will reject strings different from `format`.<br/><br/> `delimiters` is an array of allowed date delimiters and defaults to `['/', '-']`.
**isDecimal(str [, options])** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.<br/><br/>`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`.<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa', 'fa-AF', 'fa-IR', 'fr-FR', 'fr-CA', 'hu-HU', 'id-ID', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']`.<br/>**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'.
**isDivisibleBy(str, number)** | check if the string is a number that is divisible by another.
**isEAN(str)** | check if the string is an [EAN (European Article Number)][European Article Number].
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '', host_blacklist: [] }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, email addresses without a TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by Gmail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. If `host_blacklist` is set to an array of strings and the part of the email after the `@` symbol matches one of the strings defined in it, the validation fails. If `host_whitelist` is set to an array of strings and the part of the email after the `@` symbol matches none of the strings defined in it, the validation fails.
**isEmpty(str [, options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace: false }`.
**isEthereumAddress(str)** | check if the string is an [Ethereum][Ethereum] address. Does not validate address checksums.
**isFloat(str [, options])** | check if the string is a float.<br/><br/>`options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`) it also has `locale` as an option.<br/><br/>`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. Locale list is `validator.isFloatLocales`.
**isFQDN(str [, options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false, allow_numeric_tld: false, allow_wildcard: false, ignore_max_length: false }`. If `allow_wildcard` is set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
**isFullWidth(str)** | check if the string contains any full-width chars.
**isHalfWidth(str)** | check if the string contains any half-width chars.
**isHash(str, algorithm)** | check if the string is a hash of type algorithm.<br/><br/>Algorithm is one of `['crc32', 'crc32b', 'md4', 'md5', 'ripemd128', 'ripemd160', 'sha1', 'sha256', 'sha384', 'sha512', 'tiger128', 'tiger160', 'tiger192']`.
**isHexadecimal(str)** | check if the string is a hexadecimal number.
**isHexColor(str)** | check if the string is a hexadecimal color.
**isHSL(str)** | check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on [CSS Colors Level 4 specification][CSS Colors Level 4 Specification].<br/><br/>Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: `hsl(200grad+.1%62%/1)`).
**isIBAN(str)** | check if the string is an IBAN (International Bank Account Number).
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['LK', 'PL', 'ES', 'FI', 'IN', 'IT', 'IR', 'MZ', 'NO', 'TH', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN', 'zh-HK']` OR `'any'`. If 'any' is used, function will check if any of the locales match.<br/><br/>Defaults to 'any'.
**isIMEI(str [, options]))** | check if the string is a valid [IMEI number][IMEI]. IMEI should be of format `###############` or `##-######-######-#`.<br/><br/>`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format. If `allow_hyphens` is set to true, the validator will validate the second format.
**isIn(str, values)** | check if the string is in an array of allowed values.
**isInt(str [, options])** | check if the string is an integer.<br/><br/>`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4).
**isIP(str [, version])** | check if the string is an IP (version 4 or 6).
**isIPRange(str [, version])** | check if the string is an IP Range (version 4 or 6).
**isISBN(str [, options])** | check if the string is an [ISBN][ISBN].<br/><br/>`options` is an object that has no default.<br/>**Options:**<br/>`version`: ISBN version to compare to. Accepted values are '10' and '13'. If none provided, both will be tested.
**isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier).
**isISO6391(str)** | check if the string is a valid [ISO 639-1][ISO 639-1] language code.
**isISO8601(str [, options])** | check if the string is a valid [ISO 8601][ISO 8601] date. <br/>`options` is an object which defaults to `{ strict: false, strictSeparator: false }`. If `strict` is true, date strings with invalid dates like `2009-02-29` will be invalid. If `strictSeparator` is true, date strings with date and time separated by anything other than a T will be invalid.
**isISO31661Alpha2(str)** | check if the string is a valid [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2] officially assigned country code.
**isISO31661Alpha3(str)** | check if the string is a valid [ISO 3166-1 alpha-3][ISO 3166-1 alpha-3] officially assigned country code.
**isISO4217(str)** | check if the string is a valid [ISO 4217][ISO 4217] officially assigned currency code.
**isISRC(str)** | check if the string is an [ISRC][ISRC].
**isISSN(str [, options])** | check if the string is an [ISSN][ISSN].<br/><br/>`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected.
**isJSON(str [, options])** | check if the string is valid JSON (note: uses JSON.parse).<br/><br/>`options` is an object which defaults to `{ allow_primitives: false }`. If `allow_primitives` is true, the primitives 'true', 'false' and 'null' are accepted as valid JSON values.
**isJWT(str)** | check if the string is valid JWT token.
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
**isLength(str [, options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`. Note: this function takes into account surrogate pairs.
**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.<br/><br/>`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE']` or `'any'`.
**isLocale(str)** | check if the string is a locale.
**isLowercase(str)** | check if the string is lowercase.
**isLuhnNumber(str)** | check if the string passes the [Luhn algorithm check](https://en.wikipedia.org/wiki/Luhn_algorithm).
**isMACAddress(str [, options])** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{ no_separators: false }`. If `no_separators` is true, the validator will allow MAC addresses without separators. Also, it allows the use of hyphens, spaces or dots e.g. '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. The options also allow a `eui` property to specify if it needs to be validated against EUI-48 or EUI-64. The accepted values of `eui` are: 48, 64.
**isMagnetURI(str)** | check if the string is a [Magnet URI format][Magnet URI Format].
**isMD5(str)** | check if the string is a MD5 hash.<br/><br/>Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA).
**isMimeType(str)** | check if the string matches to a valid [MIME type][MIME Type] format.
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>`locale` is either an array of locales (e.g. `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-EH', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-PS', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'az-AZ', 'az-LB', 'az-LY', 'be-BY', 'bg-BG', 'bn-BD', 'bs-BA', 'ca-AD', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LU', 'dv-MV', 'dz-BT', 'el-CY', 'el-GR', 'en-AG', 'en-AI', 'en-AU', 'en-BM', 'en-BS', 'en-BW', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-IE', 'en-IN', 'en-JM', 'en-KE', 'en-KI', 'en-KN', 'en-LS', 'en-MO', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PG', 'en-PH', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-SS', 'en-TZ', 'en-UG', 'en-US', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-EC', 'es-ES', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-AF', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-BJ', 'fr-CD', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'ir-IR', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'ky-KG', 'lt-LT', 'mg-MG', 'mn-MN', 'ms-MY', 'my-MM', 'mz-MZ', 'nb-NO', 'ne-NP', 'nl-AW', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-AO', 'pt-BR', 'pt-PT', 'ro-Md', 'ro-RO', 'ru-RU', 'si-LK', 'sk-SK', 'sl-SI', 'sq-AL', 'sr-RS', 'sv-SE', 'tg-TJ', 'th-TH', 'tk-TM', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to `'any'`. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
**isNumeric(str [, options])** | check if the string contains only numbers.<br/><br/>`options` is an object which defaults to `{ no_symbols: false }` it also has `locale` as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fr-CA', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`.
**isOctal(str)** | check if the string is a valid octal number.
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>`countryCode` is one of `['AM', 'AR', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US']`.
**isPort(str)** | check if the string is a valid port number.
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
**isRFC3339(str)** | check if the string is a valid [RFC 3339][RFC 3339] date.
**isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.<br/><br/>`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false.
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
**isUppercase(str)** | check if the string is uppercase.
**isSlug(str)** | check if the string is of type slug.
**isStrongPassword(str [, options])** | check if the string can be considered a strong password or not. Allows for custom requirements or scoring rules. If `returnScore` is true, then the function returns an integer score for the password rather than a boolean.<br/>Default options: <br/>`{ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1, returnScore: false, pointsPerUnique: 1, pointsPerRepeat: 0.5, pointsForContainingLower: 10, pointsForContainingUpper: 10, pointsForContainingNumber: 10, pointsForContainingSymbol: 10 }`
**isTime(str [, options])** | check if the string is a valid time e.g. [`23:01:59`, new Date().toLocaleTimeString()].<br/><br/> `options` is an object which can contain the keys `hourFormat` or `mode`.<br/><br/>`hourFormat` is a key and defaults to `'hour24'`.<br/><br/>`mode` is a key and defaults to `'default'`. <br/><br/>`hourFomat` can contain the values `'hour12'` or `'hour24'`, `'hour24'` will validate hours in 24 format and `'hour12'` will validate hours in 12 format. <br/><br/>`mode` can contain the values `'default'` or `'withSeconds'`, `'default'` will validate `HH:MM` format, `'withSeconds'` will validate the `HH:MM:SS` format.
**isTaxID(str, locale)** | check if the string is a valid Tax Identification Number. Default locale is `en-US`.<br/><br/>More info about exact TIN support can be found in `src/lib/isTaxID.js`.<br/><br/>Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-CA', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV', 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]`.
**isURL(str [, options])** | check if the string is a URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, allow_fragments: true, allow_query_components: true, disallow_auth: false, validate_length: true }`.<br/><br/>`require_protocol` - if set to true isURL will return false if protocol is not present in the URL.<br/>`require_valid_protocol` - isURL will check if the URL's protocol is present in the protocols option.<br/>`protocols` - valid protocols can be modified with this option.<br/>`require_host` - if set to false isURL will not check if host is present in the URL.<br/>`require_port` - if set to true isURL will check if port is present in the URL.<br/>`allow_protocol_relative_urls` - if set to true protocol relative URLs will be allowed.<br/>`allow_fragments` - if set to false isURL will return false if fragments are present.<br/>`allow_query_components` - if set to false isURL will return false if query components are present.<br/>`validate_length` - if set to false isURL will skip string length validation (2083 characters is IE max URL length).
**isUUID(str [, version])** | check if the string is a UUID (version 1, 2, 3, 4 or 5).
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars.
**isVAT(str, countryCode)** | check if the string is a [valid VAT number][VAT Number] if validation is available for the given country code matching [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2]. <br/><br/>`countryCode` is one of `['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE']`.
**isWhitelisted(str, chars)** | check if the string consists only of characters that appear in the whitelist `chars`.
**matches(str, pattern [, modifiers])** | check if the string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`.
## Sanitizers
Here is a list of the sanitizers currently available.
Sanitizer | Description
-------------------------------------- | -------------------------------
**blacklist(input, chars)** | remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`.
**escape(input)** | replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities.
**ltrim(input [, chars])** | trim characters from the left-side of the input.
**normalizeEmail(email [, options])** | canonicalize an email address. (This doesn't validate that the input is an email, if you want to validate the email use isEmail beforehand).<br/><br/>`options` is an object with the following keys and default values:<br/><ul><li>*all_lowercase: true* - Transforms the local part (before the @ symbol) of all email addresses to lowercase. Please note that this may violate RFC 5321, which gives providers the possibility to treat the local part of email addresses in a case sensitive way (although in practice most - yet not all - providers don't). The domain part of the email address is always lowercased, as it is case insensitive per RFC 1035.</li><li>*gmail_lowercase: true* - Gmail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Gmail addresses are lowercased regardless of the value of this setting.</li><li>*gmail_remove_dots: true*: Removes dots from the local part of the email address, as Gmail ignores them (e.g. "john.doe" and "johndoe" are considered equal).</li><li>*gmail_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@gmail.com" becomes "foo@gmail.com").</li><li>*gmail_convert_googlemaildotcom: true*: Converts addresses with domain @googlemail.com to @gmail.com, as they're equivalent.</li><li>*outlookdotcom_lowercase: true* - Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Outlook.com addresses are lowercased regardless of the value of this setting.</li><li>*outlookdotcom_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@outlook.com" becomes "foo@outlook.com").</li><li>*yahoo_lowercase: true* - Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Yahoo Mail addresses are lowercased regardless of the value of this setting.</li><li>*yahoo_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "-" sign (e.g. "foo-bar@yahoo.com" becomes "foo@yahoo.com").</li><li>*icloud_lowercase: true* - iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, iCloud addresses are lowercased regardless of the value of this setting.</li><li>*icloud_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@icloud.com" becomes "foo@icloud.com").</li></ul>
**rtrim(input [, chars])** | trim characters from the right-side of the input.
**stripLow(input [, keep_new_lines])** | remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript.
**toBoolean(input [, strict])** | convert the input string to a boolean. Everything except for `'0'`, `'false'` and `''` returns `true`. In strict mode only `'1'` and `'true'` return `true`.
**toDate(input)** | convert the input string to a date, or `null` if the input is not a date.
**toFloat(input)** | convert the input string to a float, or `NaN` if the input is not a float.
**toInt(input [, radix])** | convert the input string to an integer, or `NaN` if the input is not an integer.
**trim(input [, chars])** | trim characters (whitespace by default) from both sides of the input.
**unescape(input)** | replace HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`.
**whitelist(input, chars)** | remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
### XSS Sanitization
XSS sanitization was removed from the library in [2d5d6999](https://github.com/validatorjs/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e).
For an alternative, have a look at Yahoo's [xss-filters library](https://github.com/yahoo/xss-filters) or at [DOMPurify](https://github.com/cure53/DOMPurify).
## Contributing
In general, we follow the "fork-and-pull" Git workflow.
1. Fork the repo on GitHub
2. Clone the project to your own machine
3. Work on your fork
1. Make your changes and additions
- Most of your changes should be focused on `src/` and `test/` folders and/or `README.md`.
- Files such as `validator.js`, `validator.min.js` and files in `lib/` folder are autogenerated when running tests (`npm test`) and need not to be changed **manually**.
2. Change or add tests if needed
3. Run tests and make sure they pass
4. Add changes to README.md if needed
4. Commit changes to your own branch
5. **Make sure** you merge the latest from "upstream" and resolve conflicts if there is any
6. Repeat step 3(3) above
7. Push your work back up to your fork
8. Submit a Pull request so that we can review your changes
## Tests
Tests are using mocha, to run the tests use:
```sh
$ npm test
```
## Maintainers
- [chriso](https://github.com/chriso) - **Chris O'Hara** (author)
- [profnandaa](https://github.com/profnandaa) - **Anthony Nandaa**
- [ezkemboi](https://github.com/ezkemboi) - **Ezrqn Kemboi**
- [tux-tn](https://github.com/tux-tn) - **Sarhan Aissi**
## Reading
Remember, validating can be troublesome sometimes. See [A list of articles about programming assumptions commonly made that aren't true](https://github.com/jameslk/awesome-falsehoods).
## License (MIT)
```
Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
[downloads-image]: http://img.shields.io/npm/dm/validator.svg
[npm-url]: https://npmjs.org/package/validator
[npm-image]: http://img.shields.io/npm/v/validator.svg
[codecov-url]: https://codecov.io/gh/validatorjs/validator.js
[codecov-image]: https://codecov.io/gh/validatorjs/validator.js/branch/master/graph/badge.svg
[ci-url]: https://github.com/validatorjs/validator.js/actions?query=workflow%3ACI
[ci-image]: https://github.com/validatorjs/validator.js/workflows/CI/badge.svg?branch=master
[gitter-url]: https://gitter.im/validatorjs/community
[gitter-image]: https://badges.gitter.im/validatorjs/community.svg
[huntr-url]: https://huntr.dev/bounties/disclose/?target=https://github.com/validatorjs/validator.js
[huntr-image]: https://cdn.huntr.dev/huntr_security_badge_mono.svg
[amd]: http://requirejs.org/docs/whyamd.html
[bower]: http://bower.io/
[Crockford Base32]: http://www.crockford.com/base32.html
[Base64 URL Safe]: https://base64.guru/standards/base64url
[Data URI Format]: https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs
[European Article Number]: https://en.wikipedia.org/wiki/International_Article_Number
[Ethereum]: https://ethereum.org/
[CSS Colors Level 4 Specification]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
[IMEI]: https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity
[ISBN]: https://en.wikipedia.org/wiki/ISBN
[ISIN]: https://en.wikipedia.org/wiki/International_Securities_Identification_Number
[ISO 639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
[ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
[ISO 3166-1 alpha-2]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
[ISO 3166-1 alpha-3]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
[ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
[ISRC]: https://en.wikipedia.org/wiki/International_Standard_Recording_Code
[ISSN]: https://en.wikipedia.org/wiki/International_Standard_Serial_Number
[Luhn Check]: https://en.wikipedia.org/wiki/Luhn_algorithm
[Magnet URI Format]: https://en.wikipedia.org/wiki/Magnet_URI_scheme
[MIME Type]: https://en.wikipedia.org/wiki/Media_type
[mongoid]: http://docs.mongodb.org/manual/reference/object-id/
[RFC 3339]: https://tools.ietf.org/html/rfc3339
[VAT Number]: https://en.wikipedia.org/wiki/VAT_identification_number

View File

@@ -0,0 +1,43 @@
{
"name": "quick-lru",
"version": "5.1.1",
"description": "Simple “Least Recently Used” (LRU) cache",
"license": "MIT",
"repository": "sindresorhus/quick-lru",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && nyc ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"lru",
"quick",
"cache",
"caching",
"least",
"recently",
"used",
"fast",
"map",
"hash",
"buffer"
],
"devDependencies": {
"ava": "^2.0.0",
"coveralls": "^3.0.3",
"nyc": "^15.0.0",
"tsd": "^0.11.0",
"xo": "^0.26.0"
}
}

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isBase64;
var _assertString = _interopRequireDefault(require("./util/assertString"));
var _merge = _interopRequireDefault(require("./util/merge"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var notBase64 = /[^A-Z0-9+\/=]/i;
var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
var defaultBase64Options = {
urlSafe: false
};
function isBase64(str, options) {
(0, _assertString.default)(str);
options = (0, _merge.default)(options, defaultBase64Options);
var len = str.length;
if (options.urlSafe) {
return urlSafeBase64.test(str);
}
if (len % 4 !== 0 || notBase64.test(str)) {
return false;
}
var firstPaddingChar = str.indexOf('=');
return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
}
module.exports = exports.default;
module.exports.default = exports.default;

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
const fsStat = require("@nodelib/fs.stat");
const fsWalk = require("@nodelib/fs.walk");
const reader_1 = require("./reader");
class ReaderStream extends reader_1.default {
constructor() {
super(...arguments);
this._walkStream = fsWalk.walkStream;
this._stat = fsStat.stat;
}
dynamic(root, options) {
return this._walkStream(root, options);
}
static(patterns, options) {
const filepaths = patterns.map(this._getFullEntryPath, this);
const stream = new stream_1.PassThrough({ objectMode: true });
stream._write = (index, _enc, done) => {
return this._getEntry(filepaths[index], patterns[index], options)
.then((entry) => {
if (entry !== null && options.entryFilter(entry)) {
stream.push(entry);
}
if (index === filepaths.length - 1) {
stream.end();
}
done();
})
.catch(done);
};
for (let i = 0; i < filepaths.length; i++) {
stream.write(i);
}
return stream;
}
_getEntry(filepath, pattern, options) {
return this._getStat(filepath)
.then((stats) => this._makeEntry(stats, pattern))
.catch((error) => {
if (options.errorFilter(error)) {
return null;
}
throw error;
});
}
_getStat(filepath) {
return new Promise((resolve, reject) => {
this._stat(filepath, this._fsStatSettings, (error, stats) => {
return error === null ? resolve(stats) : reject(error);
});
});
}
}
exports.default = ReaderStream;

View File

@@ -0,0 +1,5 @@
# Documentation
- [API Reference](https://github.com/JoshGlazebrook/socks#api-reference)
- [Code Examples](./examples/index.md)

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"2":"C K L G M N O","132":"P Q R S T U V W X","260":"Y Z a b c d e i j k l m n o p q r s t u f H"},C:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB EC FC","132":"DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB","260":"aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB"},D:{"2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB","132":"dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X","194":"YB uB ZB vB aB bB cB","260":"Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC"},E:{"2":"I v J D E F A B HC zB IC JC KC LC 0B","132":"C K L G qB rB 1B MC NC 2B 3B 4B 5B","516":"6B 7B 8B 9B OC","772":"sB"},F:{"2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB PC QC RC SC qB AC TC rB","132":"SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB","260":"nB oB pB P Q R wB S T U V W X Y Z a b c d e"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC","132":"eC fC gC hC iC jC","260":"kC lC mC nC 2B 3B 4B 5B","772":"sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"2":"tB I pC qC rC sC BC tC uC","260":"f"},J:{"2":"D A"},K:{"2":"A B C qB AC rB","260":"h"},L:{"260":"H"},M:{"260":"H"},N:{"2":"A B"},O:{"132":"vC"},P:{"2":"I wC xC yC zC","132":"0C 0B 1C 2C 3C 4C","260":"g 5C sB 6C 7C 8C"},Q:{"132":"1B"},R:{"260":"9C"},S:{"132":"AD","260":"BD"}},B:4,C:"CSS display: contents"};

View File

@@ -0,0 +1,145 @@
### A `FormData` polyfill for the browser ...and a module for NodeJS (`New!`)
```bash
npm install formdata-polyfill
```
The browser polyfill will likely have done its part already, and i hope you stop supporting old browsers c",)<br>
But NodeJS still laks a proper FormData<br>The good old form-data package is a very old and isn't spec compatible and dose some abnormal stuff to construct and read FormData instances that other http libraries are not happy about when it comes to follow the spec.
### The NodeJS / ESM version
- The modular (~2.3 KiB minified uncompressed) version of this package is independent of any browser stuff and don't patch anything
- It's as pure/spec compatible as it possible gets the test are run by WPT.
- It's compatible with [node-fetch](https://github.com/node-fetch/node-fetch).
- It have higher platform dependencies as it uses classes, symbols, ESM & private fields
- Only dependency it has is [fetch-blob](https://github.com/node-fetch/fetch-blob)
```js
// Node example
import fetch from 'node-fetch'
import File from 'fetch-blob/file.js'
import { fileFromSync } from 'fetch-blob/from.js'
import { FormData } from 'formdata-polyfill/esm.min.js'
const file = fileFromSync('./README.md')
const fd = new FormData()
fd.append('file-upload', new File(['abc'], 'hello-world.txt'))
fd.append('file-upload', file)
// it's also possible to append file/blob look-a-like items
// if you have streams coming from other destinations
fd.append('file-upload', {
size: 123,
type: '',
name: 'cat-video.mp4',
stream() { return stream },
[Symbol.toStringTag]: 'File'
})
fetch('https://httpbin.org/post', { method: 'POST', body: fd })
```
----
It also comes with way to convert FormData into Blobs - it's not something that every developer should have to deal with.
It's mainly for [node-fetch](https://github.com/node-fetch/node-fetch) and other http library to ease the process of serializing a FormData into a blob and just wish to deal with Blobs instead (Both Deno and Undici adapted a version of this [formDataToBlob](https://github.com/jimmywarting/FormData/blob/5ddea9e0de2fc5e246ab1b2f9d404dee0c319c02/formdata-to-blob.js) to the core and passes all WPT tests run by the browser itself)
```js
import { Readable } from 'node:stream'
import { FormData, formDataToBlob } from 'formdata-polyfill/esm.min.js'
const blob = formDataToBlob(new FormData())
fetch('https://httpbin.org/post', { method: 'POST', body: blob })
// node built in http and other similar http library have to do:
const stream = Readable.from(blob.stream())
const req = http.request('http://httpbin.org/post', {
method: 'post',
headers: {
'Content-Length': blob.size,
'Content-Type': blob.type
}
})
stream.pipe(req)
```
PS: blob & file that are appended to the FormData will not be read until any of the serialized blob read-methods gets called
...so uploading very large files is no biggie
### Browser polyfill
usage:
```js
import 'formdata-polyfill' // that's it
```
The browser polyfill conditionally replaces the native implementation rather than fixing the missing functions,
since otherwise there is no way to get or delete existing values in the FormData object.
Therefore this also patches `XMLHttpRequest.prototype.send` and `fetch` to send the `FormData` as a blob,
and `navigator.sendBeacon` to send native `FormData`.
I was unable to patch the Response/Request constructor
so if you are constructing them with FormData then you need to call `fd._blob()` manually.
```js
new Request(url, {
method: 'post',
body: fd._blob ? fd._blob() : fd
})
```
Dependencies
---
If you need to support IE <= 9 then I recommend you to include eligrey's [blob.js]
(which i hope you don't - since IE is now dead)
<details>
<summary>Updating from 2.x to 3.x</summary>
Previously you had to import the polyfill and use that,
since it didn't replace the global (existing) FormData implementation.
But now it transparently calls `_blob()` for you when you are sending something with fetch or XHR,
by way of monkey-patching the `XMLHttpRequest.prototype.send` and `fetch` functions.
So you maybe had something like this:
```javascript
var FormData = require('formdata-polyfill')
var fd = new FormData(form)
xhr.send(fd._blob())
```
There is no longer anything exported from the module
(though you of course still need to import it to install the polyfill),
so you can now use the FormData object as normal:
```javascript
require('formdata-polyfill')
var fd = new FormData(form)
xhr.send(fd)
```
</details>
Native Browser compatibility (as of 2021-05-08)
---
Based on this you can decide for yourself if you need this polyfill.
[![screenshot](https://user-images.githubusercontent.com/1148376/117550329-0993aa80-b040-11eb-976c-14e31f1a3ba4.png)](https://developer.mozilla.org/en-US/docs/Web/API/FormData#Browser_compatibility)
This normalizes support for the FormData API:
- `append` with filename
- `delete()`, `get()`, `getAll()`, `has()`, `set()`
- `entries()`, `keys()`, `values()`, and support for `for...of`
- Available in web workers (just include the polyfill)
[npm-image]: https://img.shields.io/npm/v/formdata-polyfill.svg
[npm-url]: https://www.npmjs.com/package/formdata-polyfill
[blob.js]: https://github.com/eligrey/Blob.js

View File

@@ -0,0 +1,135 @@
# ci-info
Get details about the current Continuous Integration environment.
Please [open an
issue](https://github.com/watson/ci-info/issues/new?template=ci-server-not-detected.md)
if your CI server isn't properly detected :)
[![npm](https://img.shields.io/npm/v/ci-info.svg)](https://www.npmjs.com/package/ci-info)
[![Tests](https://github.com/watson/ci-info/workflows/Tests/badge.svg)](https://github.com/watson/ci-info/actions)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
## Installation
```bash
npm install ci-info --save
```
## Usage
```js
var ci = require('ci-info')
if (ci.isCI) {
console.log('The name of the CI server is:', ci.name)
} else {
console.log('This program is not running on a CI server')
}
```
## Supported CI tools
Officially supported CI servers:
| Name | Constant | isPR |
| ------------------------------------------------------------------------------- | ----------------------- | ---- |
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | 🚫 |
| [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` | ✅ |
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `ci.AZURE_PIPELINES` | ✅ |
| [Appcircle](https://appcircle.io/) | `ci.APPCIRCLE` | 🚫 |
| [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 |
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` | ✅ |
| [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` | ✅ |
| [Buddy](https://buddy.works/) | `ci.BUDDY` | ✅ |
| [Buildkite](https://buildkite.com) | `ci.BUILDKITE` | ✅ |
| [CircleCI](http://circleci.com) | `ci.CIRCLE` | ✅ |
| [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` | ✅ |
| [Codefresh](https://codefresh.io/) | `ci.CODEFRESH` | ✅ |
| [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 |
| [Drone](https://drone.io) | `ci.DRONE` | ✅ |
| [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 |
| [Expo Application Services](https://expo.dev/eas) | `ci.EAS` | 🚫 |
| [Gerrit CI](https://www.gerritcodereview.com) | `ci.GERRIT` | 🚫 |
| [GitHub Actions](https://github.com/features/actions/) | `ci.GITHUB_ACTIONS` | ✅ |
| [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | ✅ |
| [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 |
| [Google Cloud Build](https://cloud.google.com/build) | `ci.GOOGLE_CLOUD_BUILD` | 🚫 |
| [Harness CI](https://www.harness.io/products/continuous-integration) | `ci.HARNESS` | 🚫 |
| [Heroku](https://www.heroku.com) | `ci.HEROKU` | 🚫 |
| [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 |
| [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ |
| [LayerCI](https://layerci.com/) | `ci.LAYERCI` | ✅ |
| [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 |
| [Netlify CI](https://www.netlify.com/) | `ci.NETLIFY` | ✅ |
| [Nevercode](http://nevercode.io/) | `ci.NEVERCODE` | ✅ |
| [ReleaseHub](https://releasehub.com/) | `ci.RELEASEHUB` | 🚫 |
| [Render](https://render.com/) | `ci.RENDER` | ✅ |
| [Sail CI](https://sail.ci/) | `ci.SAIL` | ✅ |
| [Screwdriver](https://screwdriver.cd/) | `ci.SCREWDRIVER` | ✅ |
| [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` | ✅ |
| [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` | ✅ |
| [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` | ✅ |
| [Sourcehut](https://sourcehut.org/) | `ci.SOURCEHUT` | 🚫 |
| [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` | 🚫 |
| [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` | 🚫 |
| [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` | 🚫 |
| [Travis CI](http://travis-ci.org) | `ci.TRAVIS` | ✅ |
| [Vercel](https://vercel.com/) | `ci.VERCEL` | 🚫 |
| [Visual Studio App Center](https://appcenter.ms/) | `ci.APPCENTER` | 🚫 |
| [Woodpecker](https://woodpecker-ci.org/) | `ci.WOODPECKER` | ✅ |
## API
### `ci.name`
Returns a string containing name of the CI server the code is running on.
If CI server is not detected, it returns `null`.
Don't depend on the value of this string not to change for a specific
vendor. If you find your self writing `ci.name === 'Travis CI'`, you
most likely want to use `ci.TRAVIS` instead.
### `ci.isCI`
Returns a boolean. Will be `true` if the code is running on a CI server,
otherwise `false`.
Some CI servers not listed here might still trigger the `ci.isCI`
boolean to be set to `true` if they use certain vendor neutral
environment variables. In those cases `ci.name` will be `null` and no
vendor specific boolean will be set to `true`.
### `ci.isPR`
Returns a boolean if PR detection is supported for the current CI server. Will
be `true` if a PR is being tested, otherwise `false`. If PR detection is
not supported for the current CI server, the value will be `null`.
### `ci.<VENDOR-CONSTANT>`
A vendor specific boolean constant is exposed for each support CI
vendor. A constant will be `true` if the code is determined to run on
the given CI server, otherwise `false`.
Examples of vendor constants are `ci.TRAVIS` or `ci.APPVEYOR`. For a
complete list, see the support table above.
Deprecated vendor constants that will be removed in the next major
release:
- `ci.TDDIUM` (Solano CI) This have been renamed `ci.SOLANO`
## Ports
ci-info has been ported to the following languages
| Language | Repository |
|----------|------------|
| Go | https://github.com/hofstadter-io/cinful |
| Rust | https://github.com/sagiegurari/ci_info |
| Kotlin | https://github.com/cloudflightio/ci-info |
## License
[MIT](LICENSE)

View File

@@ -0,0 +1,384 @@
export as namespace preact;
import { JSXInternal } from './jsx';
export import JSX = JSXInternal;
//
// Preact Virtual DOM
// -----------------------------------
export interface VNode<P = {}> {
type: ComponentType<P> | string;
props: P & { children: ComponentChildren };
key: Key;
/**
* ref is not guaranteed by React.ReactElement, for compatibility reasons
* with popular react libs we define it as optional too
*/
ref?: Ref<any> | null;
/**
* The time this `vnode` started rendering. Will only be set when
* the devtools are attached.
* Default value: `0`
*/
startTime?: number;
/**
* The time that the rendering of this `vnode` was completed. Will only be
* set when the devtools are attached.
* Default value: `-1`
*/
endTime?: number;
}
//
// Preact Component interface
// -----------------------------------
export type Key = string | number | any;
export type RefObject<T> = { current: T | null };
export type RefCallback<T> = (instance: T | null) => void;
export type Ref<T> = RefObject<T> | RefCallback<T> | null;
export type ComponentChild =
| VNode<any>
| object
| string
| number
| bigint
| boolean
| null
| undefined;
export type ComponentChildren = ComponentChild[] | ComponentChild;
export interface Attributes {
key?: Key | undefined;
jsx?: boolean | undefined;
}
export interface ClassAttributes<T> extends Attributes {
ref?: Ref<T>;
}
export interface PreactDOMAttributes {
children?: ComponentChildren;
dangerouslySetInnerHTML?: {
__html: string;
};
}
export interface ErrorInfo {
componentStack?: string;
}
export type RenderableProps<P, RefType = any> = P &
Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<RefType> }>;
export type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
export type ComponentFactory<P = {}> = ComponentType<P>;
export type ComponentProps<
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
> = C extends ComponentType<infer P>
? P
: C extends keyof JSXInternal.IntrinsicElements
? JSXInternal.IntrinsicElements[C]
: never;
export interface FunctionComponent<P = {}> {
(props: RenderableProps<P>, context?: any): VNode<any> | null;
displayName?: string;
defaultProps?: Partial<P>;
}
export interface FunctionalComponent<P = {}> extends FunctionComponent<P> {}
export interface ComponentClass<P = {}, S = {}> {
new (props: P, context?: any): Component<P, S>;
displayName?: string;
defaultProps?: Partial<P>;
contextType?: Context<any>;
getDerivedStateFromProps?(
props: Readonly<P>,
state: Readonly<S>
): Partial<S> | null;
getDerivedStateFromError?(error: any): Partial<S> | null;
}
export interface ComponentConstructor<P = {}, S = {}>
extends ComponentClass<P, S> {}
// Type alias for a component instance considered generally, whether stateless or stateful.
export type AnyComponent<P = {}, S = {}> =
| FunctionComponent<P>
| Component<P, S>;
export interface Component<P = {}, S = {}> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillUnmount?(): void;
getChildContext?(): object;
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
shouldComponentUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
nextContext: any
): boolean;
componentWillUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
nextContext: any
): void;
getSnapshotBeforeUpdate?(oldProps: Readonly<P>, oldState: Readonly<S>): any;
componentDidUpdate?(
previousProps: Readonly<P>,
previousState: Readonly<S>,
snapshot: any
): void;
componentDidCatch?(error: any, errorInfo: ErrorInfo): void;
}
export abstract class Component<P, S> {
constructor(props?: P, context?: any);
static displayName?: string;
static defaultProps?: any;
static contextType?: Context<any>;
// Static members cannot reference class type parameters. This is not
// supported in TypeScript. Reusing the same type arguments from `Component`
// will lead to an impossible state where one cannot satisfy the type
// constraint under no circumstances, see #1356.In general type arguments
// seem to be a bit buggy and not supported well at the time of this
// writing with TS 3.3.3333.
static getDerivedStateFromProps?(
props: Readonly<object>,
state: Readonly<object>
): object | null;
static getDerivedStateFromError?(error: any): object | null;
state: Readonly<S>;
props: RenderableProps<P>;
context: any;
base?: Element | Text;
// From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e836acc75a78cf0655b5dfdbe81d69fdd4d8a252/types/react/index.d.ts#L402
// // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
// // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
setState<K extends keyof S>(
state:
| ((
prevState: Readonly<S>,
props: Readonly<P>
) => Pick<S, K> | Partial<S> | null)
| (Pick<S, K> | Partial<S> | null),
callback?: () => void
): void;
forceUpdate(callback?: () => void): void;
abstract render(
props?: RenderableProps<P>,
state?: Readonly<S>,
context?: any
): ComponentChild;
}
//
// Preact createElement
// -----------------------------------
export function createElement(
type: 'input',
props:
| (JSXInternal.DOMAttributes<HTMLInputElement> &
ClassAttributes<HTMLInputElement>)
| null,
...children: ComponentChildren[]
): VNode<any>;
export function createElement<
P extends JSXInternal.HTMLAttributes<T>,
T extends HTMLElement
>(
type: keyof JSXInternal.IntrinsicElements,
props: (ClassAttributes<T> & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export function createElement<
P extends JSXInternal.SVGAttributes<T>,
T extends HTMLElement
>(
type: keyof JSXInternal.IntrinsicElements,
props: (ClassAttributes<T> & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export function createElement<T extends HTMLElement>(
type: string,
props:
| (ClassAttributes<T> &
JSXInternal.HTMLAttributes &
JSXInternal.SVGAttributes)
| null,
...children: ComponentChildren[]
): VNode<any>;
export function createElement<P>(
type: ComponentType<P>,
props: (Attributes & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export namespace createElement {
export import JSX = JSXInternal;
}
export function h(
type: 'input',
props:
| (JSXInternal.DOMAttributes<HTMLInputElement> &
ClassAttributes<HTMLInputElement>)
| null,
...children: ComponentChildren[]
): VNode<any>;
export function h<
P extends JSXInternal.HTMLAttributes<T>,
T extends HTMLElement
>(
type: keyof JSXInternal.IntrinsicElements,
props: (ClassAttributes<T> & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export function h<
P extends JSXInternal.SVGAttributes<T>,
T extends HTMLElement
>(
type: keyof JSXInternal.IntrinsicElements,
props: (ClassAttributes<T> & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export function h<T extends HTMLElement>(
type: string,
props:
| (ClassAttributes<T> &
JSXInternal.HTMLAttributes &
JSXInternal.SVGAttributes)
| null,
...children: ComponentChildren[]
): VNode<any>;
export function h<P>(
type: ComponentType<P>,
props: (Attributes & P) | null,
...children: ComponentChildren[]
): VNode<any>;
export namespace h {
export import JSX = JSXInternal;
}
//
// Preact render
// -----------------------------------
interface ContainerNode {
nodeType: Node['nodeType'];
parentNode: Node['parentNode'];
firstChild: Node['firstChild'];
insertBefore: Node['insertBefore'];
appendChild: Node['appendChild'];
removeChild: Node['removeChild'];
childNodes: ArrayLike<Node>
}
export function render(
vnode: ComponentChild,
parent: ContainerNode
): void;
/**
* @deprecated Will be removed in v11.
*
* Replacement Preact 10+ implementation can be found here: https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
*/
export function render(
vnode: ComponentChild,
parent: ContainerNode,
replaceNode?: Element | Text
): void;
export function hydrate(
vnode: ComponentChild,
parent: ContainerNode
): void;
export function cloneElement(
vnode: VNode<any>,
props?: any,
...children: ComponentChildren[]
): VNode<any>;
export function cloneElement<P>(
vnode: VNode<P>,
props?: any,
...children: ComponentChildren[]
): VNode<P>;
//
// Preact Built-in Components
// -----------------------------------
// TODO: Revisit what the public type of this is...
export const Fragment: FunctionComponent<{}>;
//
// Preact options
// -----------------------------------
/**
* Global options for preact
*/
export interface Options {
/** Attach a hook that is invoked whenever a VNode is created. */
vnode?(vnode: VNode): void;
/** Attach a hook that is invoked immediately before a vnode is unmounted. */
unmount?(vnode: VNode): void;
/** Attach a hook that is invoked after a vnode has rendered. */
diffed?(vnode: VNode): void;
event?(e: Event): any;
requestAnimationFrame?(callback: () => void): void;
debounceRendering?(cb: () => void): void;
useDebugValue?(value: string | number): void;
_addHookName?(name: string | number): void;
__suspenseDidResolve?(vnode: VNode, cb: () => void): void;
// __canSuspenseResolve?(vnode: VNode, cb: () => void): void;
}
export const options: Options;
//
// Preact helpers
// -----------------------------------
export function createRef<T = any>(): RefObject<T>;
export function toChildArray(
children: ComponentChildren
): Array<VNode | string | number>;
export function isValidElement(vnode: any): vnode is VNode;
//
// Context
// -----------------------------------
export interface Consumer<T>
extends FunctionComponent<{
children: (value: T) => ComponentChildren;
}> {}
export interface PreactConsumer<T> extends Consumer<T> {}
export interface Provider<T>
extends FunctionComponent<{
value: T;
children: ComponentChildren;
}> {}
export interface PreactProvider<T> extends Provider<T> {}
export type ContextType<C extends Context<any>> = C extends Context<infer T>
? T
: never;
export interface Context<T> {
Consumer: Consumer<T>;
Provider: Provider<T>;
displayName?: string;
}
export interface PreactContext<T> extends Context<T> {}
export function createContext<T>(defaultValue: T): Context<T>;