WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/checker/types.go. DO NOT EDIT.
|
||||
export var TypePredicateKind;
|
||||
(function (TypePredicateKind) {
|
||||
TypePredicateKind[TypePredicateKind["This"] = 0] = "This";
|
||||
TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier";
|
||||
TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis";
|
||||
TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier";
|
||||
})(TypePredicateKind || (TypePredicateKind = {}));
|
||||
//# sourceMappingURL=typePredicateKind.enum.js.map
|
||||
@@ -0,0 +1,346 @@
|
||||
"use strict";
|
||||
|
||||
/* @minVersion 7.24.0 */
|
||||
|
||||
function toPrimitive(input, hint) {
|
||||
if (typeof input !== "object" || input === null) {
|
||||
return input;
|
||||
}
|
||||
|
||||
var prim = input[Symbol.toPrimitive];
|
||||
if (prim !== undefined) {
|
||||
var res = prim.call(input, hint || "default");
|
||||
if (typeof res !== "object") {
|
||||
return res;
|
||||
}
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
|
||||
return (hint === "string" ? String : Number)(input);
|
||||
}
|
||||
|
||||
function toPropertyKey(arg) {
|
||||
var key = toPrimitive(arg, "string");
|
||||
return typeof key === "symbol" ? key : String(key);
|
||||
}
|
||||
|
||||
function checkInRHS(value) {
|
||||
if (Object(value) !== value) {
|
||||
throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null"));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function setFunctionName(fn, name, prefix) {
|
||||
if (typeof name === "symbol") {
|
||||
name = name.description;
|
||||
name = name ? "[" + name + "]" : "";
|
||||
}
|
||||
|
||||
try {
|
||||
Object.defineProperty(fn, "name", { configurable: true, value: prefix ? prefix + " " + name : name });
|
||||
} catch (_) {}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
kind bit layout
|
||||
|
||||
FIELD = 0
|
||||
ACCESSOR = 1
|
||||
METHOD = 2
|
||||
GETTER = 3
|
||||
SETTER = 4
|
||||
CLASS = 5
|
||||
|
||||
STATIC = 8
|
||||
DECORATORS_HAVE_THIS = 16
|
||||
*/
|
||||
function _apply_decs_2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) {
|
||||
var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
|
||||
var defineProperty = Object.defineProperty;
|
||||
var create = Object.create;
|
||||
var metadata;
|
||||
var existingNonFields = [create(null), create(null)];
|
||||
var hasClassDecs = classDecs.length;
|
||||
var _;
|
||||
|
||||
function createRunInitializers(initializers, useStaticThis, hasValue) {
|
||||
return function(thisArg, value) {
|
||||
if (useStaticThis) {
|
||||
value = thisArg;
|
||||
thisArg = targetClass;
|
||||
}
|
||||
|
||||
for (var i = 0; i < initializers.length; i++) value = initializers[i].apply(thisArg, hasValue ? [value] : []);
|
||||
|
||||
return hasValue ? value : thisArg;
|
||||
};
|
||||
}
|
||||
|
||||
function assertCallable(fn, hint1, hint2, throwUndefined) {
|
||||
if (typeof fn !== "function") {
|
||||
if (throwUndefined || fn !== void 0) {
|
||||
throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
|
||||
}
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) {
|
||||
function assertInstanceIfPrivate(target) {
|
||||
if (!hasPrivateBrand(target)) {
|
||||
throw new TypeError("Attempted to access private element on non-instance");
|
||||
}
|
||||
}
|
||||
|
||||
var decs = [].concat(decInfo[0]);
|
||||
var decVal = decInfo[3];
|
||||
var isClass = !ret;
|
||||
|
||||
var isAccessor = kind === 1;
|
||||
var isGetter = kind === 3;
|
||||
var isSetter = kind === 4;
|
||||
var isMethod = kind === 2;
|
||||
|
||||
function bindPropCall(name, useStaticThis, before) {
|
||||
return function(_this, value) {
|
||||
if (useStaticThis) {
|
||||
value = _this;
|
||||
_this = Class;
|
||||
}
|
||||
|
||||
if (before) {
|
||||
before(_this);
|
||||
}
|
||||
|
||||
return desc[name].call(_this, value);
|
||||
};
|
||||
}
|
||||
|
||||
var desc = {};
|
||||
var init = [];
|
||||
var key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value";
|
||||
|
||||
if (!isClass) {
|
||||
if (isPrivate) {
|
||||
if (isField || isAccessor) {
|
||||
desc = {
|
||||
get: setFunctionName(
|
||||
function() {
|
||||
return decVal(this);
|
||||
},
|
||||
name,
|
||||
"get"
|
||||
),
|
||||
set: function(value) {
|
||||
decInfo[4](this, value);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
desc[key] = decVal;
|
||||
}
|
||||
|
||||
if (!isField) {
|
||||
setFunctionName(desc[key], name, isMethod ? "" : key);
|
||||
}
|
||||
} else if (!isField) {
|
||||
desc = Object.getOwnPropertyDescriptor(Class, name);
|
||||
}
|
||||
|
||||
if (!isField && !isPrivate) {
|
||||
_ = existingNonFields[+isStatic][name];
|
||||
if (_ && (_ ^ kind) !== 7) {
|
||||
throw new Error("Decorating two elements with the same name (" + desc[key].name + ") is not supported yet");
|
||||
}
|
||||
|
||||
existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind;
|
||||
}
|
||||
}
|
||||
|
||||
var newValue = Class;
|
||||
|
||||
for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
|
||||
var dec = assertCallable(decs[i], "A decorator", "be", true);
|
||||
var decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
|
||||
|
||||
var decoratorFinishedRef = {};
|
||||
var ctx = {
|
||||
kind: ["field", "accessor", "method", "getter", "setter", "class"][kind],
|
||||
name: name,
|
||||
metadata: metadata,
|
||||
addInitializer: function(decoratorFinishedRef, initializer) {
|
||||
if (decoratorFinishedRef.v) {
|
||||
throw new TypeError("attempted to call addInitializer after decoration was finished");
|
||||
}
|
||||
assertCallable(initializer, "An initializer", "be", true);
|
||||
initializers.push(initializer);
|
||||
}
|
||||
.bind(null, decoratorFinishedRef)
|
||||
};
|
||||
|
||||
if (isClass) {
|
||||
_ = dec.call(decThis, newValue, ctx);
|
||||
decoratorFinishedRef.v = 1;
|
||||
|
||||
if (assertCallable(_, "class decorators", "return")) {
|
||||
newValue = _;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
ctx.static = isStatic;
|
||||
ctx.private = isPrivate;
|
||||
_ = ctx.access = {
|
||||
has: isPrivate ? hasPrivateBrand.bind() : function(target) {
|
||||
return name in target;
|
||||
}
|
||||
};
|
||||
|
||||
if (!isSetter) {
|
||||
_.get = isPrivate
|
||||
? isMethod
|
||||
? function(_this) {
|
||||
assertInstanceIfPrivate(_this);
|
||||
return desc.value;
|
||||
}
|
||||
: bindPropCall("get", 0, assertInstanceIfPrivate)
|
||||
: function(target) {
|
||||
return target[name];
|
||||
};
|
||||
}
|
||||
|
||||
if (!isMethod && !isGetter) {
|
||||
_.set = isPrivate ? bindPropCall("set", 0, assertInstanceIfPrivate) : function(target, value) {
|
||||
target[name] = value;
|
||||
};
|
||||
}
|
||||
|
||||
newValue = dec.call(decThis, isAccessor ? { get: desc.get, set: desc.set } : desc[key], ctx);
|
||||
|
||||
decoratorFinishedRef.v = 1;
|
||||
|
||||
if (isAccessor) {
|
||||
if (typeof newValue === "object" && newValue) {
|
||||
if ((_ = assertCallable(newValue.get, "accessor.get"))) {
|
||||
desc.get = _;
|
||||
}
|
||||
if ((_ = assertCallable(newValue.set, "accessor.set"))) {
|
||||
desc.set = _;
|
||||
}
|
||||
if ((_ = assertCallable(newValue.init, "accessor.init"))) {
|
||||
init.unshift(_);
|
||||
}
|
||||
} else if (newValue !== void 0) {
|
||||
throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
|
||||
}
|
||||
} else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) {
|
||||
if (isField) {
|
||||
init.unshift(newValue);
|
||||
} else {
|
||||
desc[key] = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kind < 2) {
|
||||
ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0));
|
||||
}
|
||||
|
||||
if (!isField && !isClass) {
|
||||
if (isPrivate) {
|
||||
if (isAccessor) {
|
||||
ret.splice(-1, 0, bindPropCall("get", isStatic), bindPropCall("set", isStatic));
|
||||
} else {
|
||||
ret.push(isMethod ? desc[key] : assertCallable.call.bind(desc[key]));
|
||||
}
|
||||
} else {
|
||||
defineProperty(Class, name, desc);
|
||||
}
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
function applyMemberDecs() {
|
||||
var ret = [];
|
||||
var protoInitializers;
|
||||
var staticInitializers;
|
||||
|
||||
var pushInitializers = function(initializers) {
|
||||
if (initializers) {
|
||||
ret.push(createRunInitializers(initializers));
|
||||
}
|
||||
};
|
||||
|
||||
var applyMemberDecsOfKind = function(isStatic, isField) {
|
||||
for (var i = 0; i < memberDecs.length; i++) {
|
||||
var decInfo = memberDecs[i];
|
||||
var kind = decInfo[1];
|
||||
var kindOnly = kind & 7;
|
||||
|
||||
if ((kind & 8) == isStatic && !kindOnly == isField) {
|
||||
var name = decInfo[2];
|
||||
var isPrivate = !!decInfo[3];
|
||||
var decoratorsHaveThis = kind & 16;
|
||||
|
||||
applyDec(
|
||||
isStatic ? targetClass : targetClass.prototype,
|
||||
decInfo,
|
||||
decoratorsHaveThis,
|
||||
isPrivate ? "#" + name : toPropertyKey(name),
|
||||
kindOnly,
|
||||
kindOnly < 2 ? [] : isStatic ? (staticInitializers = staticInitializers || []) : (protoInitializers = protoInitializers || []),
|
||||
ret,
|
||||
!!isStatic,
|
||||
isPrivate,
|
||||
isField,
|
||||
isStatic && isPrivate
|
||||
? function(_) {
|
||||
return checkInRHS(_) === targetClass;
|
||||
}
|
||||
: instanceBrand
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
applyMemberDecsOfKind(8, 0);
|
||||
applyMemberDecsOfKind(0, 0);
|
||||
applyMemberDecsOfKind(8, 1);
|
||||
applyMemberDecsOfKind(0, 1);
|
||||
|
||||
pushInitializers(protoInitializers);
|
||||
pushInitializers(staticInitializers);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function defineMetadata(Class) {
|
||||
return defineProperty(Class, symbolMetadata, { configurable: true, enumerable: true, value: metadata });
|
||||
}
|
||||
|
||||
if (parentClass !== undefined) {
|
||||
metadata = parentClass[symbolMetadata];
|
||||
}
|
||||
metadata = create(metadata == null ? null : metadata);
|
||||
|
||||
_ = applyMemberDecs();
|
||||
|
||||
if (!hasClassDecs) {
|
||||
defineMetadata(targetClass);
|
||||
}
|
||||
|
||||
return {
|
||||
e: _,
|
||||
get c() {
|
||||
var initializers = [];
|
||||
return (hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports._ = _apply_decs_2311;
|
||||
@@ -0,0 +1,60 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse.js')
|
||||
|
||||
const diff = (version1, version2) => {
|
||||
const v1 = parse(version1, null, true)
|
||||
const v2 = parse(version2, null, true)
|
||||
const comparison = v1.compare(v2)
|
||||
|
||||
if (comparison === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const v1Higher = comparison > 0
|
||||
const highVersion = v1Higher ? v1 : v2
|
||||
const lowVersion = v1Higher ? v2 : v1
|
||||
const highHasPre = !!highVersion.prerelease.length
|
||||
const lowHasPre = !!lowVersion.prerelease.length
|
||||
|
||||
if (lowHasPre && !highHasPre) {
|
||||
// Going from prerelease -> no prerelease requires some special casing
|
||||
|
||||
// If the low version has only a major, then it will always be a major
|
||||
// Some examples:
|
||||
// 1.0.0-1 -> 1.0.0
|
||||
// 1.0.0-1 -> 1.1.1
|
||||
// 1.0.0-1 -> 2.0.0
|
||||
if (!lowVersion.patch && !lowVersion.minor) {
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// If the main part has no difference
|
||||
if (lowVersion.compareMain(highVersion) === 0) {
|
||||
if (lowVersion.minor && !lowVersion.patch) {
|
||||
return 'minor'
|
||||
}
|
||||
return 'patch'
|
||||
}
|
||||
}
|
||||
|
||||
// add the `pre` prefix if we are going to a prerelease version
|
||||
const prefix = highHasPre ? 'pre' : ''
|
||||
|
||||
if (v1.major !== v2.major) {
|
||||
return prefix + 'major'
|
||||
}
|
||||
|
||||
if (v1.minor !== v2.minor) {
|
||||
return prefix + 'minor'
|
||||
}
|
||||
|
||||
if (v1.patch !== v2.patch) {
|
||||
return prefix + 'patch'
|
||||
}
|
||||
|
||||
// high and low are prereleases
|
||||
return 'prerelease'
|
||||
}
|
||||
|
||||
module.exports = diff
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha512.d.ts","sourceRoot":"","sources":["src/sha512.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EAClB,MAAM,WAAW,CAAC;AACnB,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAO,OAAiB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC;AAC1D,6DAA6D;AAC7D,eAAO,MAAM,UAAU,EAAE,OAAO,WAAyB,CAAC"}
|
||||
@@ -0,0 +1,64 @@
|
||||
"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ZodMiniISODuration = exports.ZodMiniISOTime = exports.ZodMiniISODate = exports.ZodMiniISODateTime = void 0;
|
||||
exports.datetime = datetime;
|
||||
exports.date = date;
|
||||
exports.time = time;
|
||||
exports.duration = duration;
|
||||
const core = __importStar(require("../core/index.cjs"));
|
||||
const schemas = __importStar(require("./schemas.cjs"));
|
||||
exports.ZodMiniISODateTime = core.$constructor("ZodMiniISODateTime", (inst, def) => {
|
||||
core.$ZodISODateTime.init(inst, def);
|
||||
schemas.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function datetime(params) {
|
||||
return core._isoDateTime(exports.ZodMiniISODateTime, params);
|
||||
}
|
||||
exports.ZodMiniISODate = core.$constructor("ZodMiniISODate", (inst, def) => {
|
||||
core.$ZodISODate.init(inst, def);
|
||||
schemas.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function date(params) {
|
||||
return core._isoDate(exports.ZodMiniISODate, params);
|
||||
}
|
||||
exports.ZodMiniISOTime = core.$constructor("ZodMiniISOTime", (inst, def) => {
|
||||
core.$ZodISOTime.init(inst, def);
|
||||
schemas.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function time(params) {
|
||||
return core._isoTime(exports.ZodMiniISOTime, params);
|
||||
}
|
||||
exports.ZodMiniISODuration = core.$constructor("ZodMiniISODuration", (inst, def) => {
|
||||
core.$ZodISODuration.init(inst, def);
|
||||
schemas.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function duration(params) {
|
||||
return core._isoDuration(exports.ZodMiniISODuration, params);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.esnext_float16 = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
const es2015_iterable_1 = require("./es2015.iterable");
|
||||
const es2015_symbol_1 = require("./es2015.symbol");
|
||||
exports.esnext_float16 = {
|
||||
libs: [es2015_symbol_1.es2015_symbol, es2015_iterable_1.es2015_iterable],
|
||||
variables: [
|
||||
['Float16Array', base_config_1.TYPE_VALUE],
|
||||
['Float16ArrayConstructor', base_config_1.TYPE],
|
||||
['Math', base_config_1.TYPE],
|
||||
['DataView', base_config_1.TYPE],
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "is-extglob",
|
||||
"description": "Returns true if a string has an extglob.",
|
||||
"version": "2.1.1",
|
||||
"homepage": "https://github.com/jonschlinkert/is-extglob",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/is-extglob",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-extglob/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^0.1.10",
|
||||
"mocha": "^3.0.2"
|
||||
},
|
||||
"keywords": [
|
||||
"bash",
|
||||
"braces",
|
||||
"check",
|
||||
"exec",
|
||||
"expression",
|
||||
"extglob",
|
||||
"glob",
|
||||
"globbing",
|
||||
"globstar",
|
||||
"is",
|
||||
"match",
|
||||
"matches",
|
||||
"pattern",
|
||||
"regex",
|
||||
"regular",
|
||||
"string",
|
||||
"test"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"has-glob",
|
||||
"is-glob",
|
||||
"micromatch"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.clearProgramCache = clearProgramCache;
|
||||
exports.clearDefaultProjectMatchedFiles = clearDefaultProjectMatchedFiles;
|
||||
exports.parse = parse;
|
||||
exports.clearParseAndGenerateServicesCalls = clearParseAndGenerateServicesCalls;
|
||||
exports.parseAndGenerateServices = parseAndGenerateServices;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const ast_converter_1 = require("./ast-converter");
|
||||
const convert_1 = require("./convert");
|
||||
const createIsolatedProgram_1 = require("./create-program/createIsolatedProgram");
|
||||
const createProjectProgram_1 = require("./create-program/createProjectProgram");
|
||||
const createSourceFile_1 = require("./create-program/createSourceFile");
|
||||
const getWatchProgramsForProjects_1 = require("./create-program/getWatchProgramsForProjects");
|
||||
const useProvidedPrograms_1 = require("./create-program/useProvidedPrograms");
|
||||
const createParserServices_1 = require("./createParserServices");
|
||||
const createParseSettings_1 = require("./parseSettings/createParseSettings");
|
||||
const semantic_or_syntactic_errors_1 = require("./semantic-or-syntactic-errors");
|
||||
const useProgramFromProjectService_1 = require("./useProgramFromProjectService");
|
||||
const log = (0, debug_1.default)('typescript-eslint:typescript-estree:parser');
|
||||
/**
|
||||
* Cache existing programs for the single run use-case.
|
||||
*
|
||||
* clearProgramCache() is only intended to be used in testing to ensure the parser is clean between tests.
|
||||
*/
|
||||
const existingPrograms = new Map();
|
||||
function clearProgramCache() {
|
||||
existingPrograms.clear();
|
||||
}
|
||||
const defaultProjectMatchedFiles = new Set();
|
||||
function clearDefaultProjectMatchedFiles() {
|
||||
defaultProjectMatchedFiles.clear();
|
||||
}
|
||||
/**
|
||||
* @param parseSettings Internal settings for parsing the file
|
||||
* @param hasFullTypeInformation True if the program should be attempted to be calculated from provided tsconfig files
|
||||
* @returns Returns a source file and program corresponding to the linted code
|
||||
*/
|
||||
function getProgramAndAST(parseSettings, hasFullTypeInformation) {
|
||||
if (parseSettings.projectService) {
|
||||
const fromProjectService = (0, useProgramFromProjectService_1.useProgramFromProjectService)(parseSettings.projectService, parseSettings, hasFullTypeInformation, defaultProjectMatchedFiles);
|
||||
if (fromProjectService) {
|
||||
return fromProjectService;
|
||||
}
|
||||
}
|
||||
if (parseSettings.programs) {
|
||||
return (0, useProvidedPrograms_1.useProvidedPrograms)(parseSettings.programs, parseSettings);
|
||||
}
|
||||
// no need to waste time creating a program as the caller didn't want parser services
|
||||
// so we can save time and just create a lonesome source file
|
||||
if (!hasFullTypeInformation) {
|
||||
return (0, createSourceFile_1.createNoProgram)(parseSettings);
|
||||
}
|
||||
return (0, createProjectProgram_1.createProjectProgram)(parseSettings, (0, getWatchProgramsForProjects_1.getWatchProgramsForProjects)(parseSettings));
|
||||
}
|
||||
function parse(code, options) {
|
||||
const { ast } = parseWithNodeMapsInternal(code, options, false);
|
||||
return ast;
|
||||
}
|
||||
function parseWithNodeMapsInternal(code, options, shouldPreserveNodeMaps) {
|
||||
/**
|
||||
* Reset the parse configuration
|
||||
*/
|
||||
const parseSettings = (0, createParseSettings_1.createParseSettings)(code, options);
|
||||
/**
|
||||
* Ensure users do not attempt to use parse() when they need parseAndGenerateServices()
|
||||
*/
|
||||
if (options?.errorOnTypeScriptSyntacticAndSemanticIssues) {
|
||||
throw new Error(`"errorOnTypeScriptSyntacticAndSemanticIssues" is only supported for parseAndGenerateServices()`);
|
||||
}
|
||||
/**
|
||||
* Create a ts.SourceFile directly, no ts.Program is needed for a simple parse
|
||||
*/
|
||||
const ast = (0, createSourceFile_1.createSourceFile)(parseSettings);
|
||||
/**
|
||||
* Convert the TypeScript AST to an ESTree-compatible one
|
||||
*/
|
||||
const { astMaps, estree } = (0, ast_converter_1.astConverter)(ast, parseSettings, shouldPreserveNodeMaps);
|
||||
return {
|
||||
ast: estree,
|
||||
esTreeNodeToTSNodeMap: astMaps.esTreeNodeToTSNodeMap,
|
||||
tsNodeToESTreeNodeMap: astMaps.tsNodeToESTreeNodeMap,
|
||||
};
|
||||
}
|
||||
let parseAndGenerateServicesCalls = {};
|
||||
// Privately exported utility intended for use in typescript-eslint unit tests only
|
||||
function clearParseAndGenerateServicesCalls() {
|
||||
parseAndGenerateServicesCalls = {};
|
||||
}
|
||||
function parseAndGenerateServices(code, tsestreeOptions) {
|
||||
/**
|
||||
* Reset the parse configuration
|
||||
*/
|
||||
const parseSettings = (0, createParseSettings_1.createParseSettings)(code, tsestreeOptions);
|
||||
/**
|
||||
* If this is a single run in which the user has not provided any existing programs but there
|
||||
* are programs which need to be created from the provided "project" option,
|
||||
* create an Iterable which will lazily create the programs as needed by the iteration logic
|
||||
*/
|
||||
if (parseSettings.singleRun &&
|
||||
!parseSettings.programs &&
|
||||
parseSettings.projects.size > 0) {
|
||||
parseSettings.programs = {
|
||||
*[Symbol.iterator]() {
|
||||
for (const configFile of parseSettings.projects) {
|
||||
const existingProgram = existingPrograms.get(configFile[0]);
|
||||
if (existingProgram) {
|
||||
yield existingProgram;
|
||||
}
|
||||
else {
|
||||
log('Detected single-run/CLI usage, creating Program once ahead of time for project: %s', configFile);
|
||||
const newProgram = (0, useProvidedPrograms_1.createProgramFromConfigFile)(configFile[1]);
|
||||
existingPrograms.set(configFile[0], newProgram);
|
||||
yield newProgram;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
const hasFullTypeInformation = parseSettings.programs != null ||
|
||||
parseSettings.projects.size > 0 ||
|
||||
!!parseSettings.projectService;
|
||||
if (typeof tsestreeOptions.errorOnTypeScriptSyntacticAndSemanticIssues ===
|
||||
'boolean' &&
|
||||
tsestreeOptions.errorOnTypeScriptSyntacticAndSemanticIssues) {
|
||||
parseSettings.errorOnTypeScriptSyntacticAndSemanticIssues = true;
|
||||
}
|
||||
if (parseSettings.errorOnTypeScriptSyntacticAndSemanticIssues &&
|
||||
!hasFullTypeInformation) {
|
||||
throw new Error('Cannot calculate TypeScript semantic issues without a valid project.');
|
||||
}
|
||||
/**
|
||||
* If we are in singleRun mode but the parseAndGenerateServices() function has been called more than once for the current file,
|
||||
* it must mean that we are in the middle of an ESLint automated fix cycle (in which parsing can be performed up to an additional
|
||||
* 10 times in order to apply all possible fixes for the file).
|
||||
*
|
||||
* In this scenario we cannot rely upon the singleRun AOT compiled programs because the SourceFiles will not contain the source
|
||||
* with the latest fixes applied. Therefore we fallback to creating the quickest possible isolated program from the updated source.
|
||||
*
|
||||
* Note: This fallback is only needed for the legacy `project` option which uses AOT compiled programs.
|
||||
* When `projectService` is used, the TypeScript language service always provides up-to-date programs,
|
||||
* so no fallback is necessary. Additionally, external parsers like vue-eslint-parser may call
|
||||
* parseAndGenerateServices() multiple times for the same file in a single lint pass, which would
|
||||
* incorrectly trigger this fallback.
|
||||
*/
|
||||
if (parseSettings.singleRun && tsestreeOptions.filePath) {
|
||||
parseAndGenerateServicesCalls[tsestreeOptions.filePath] =
|
||||
(parseAndGenerateServicesCalls[tsestreeOptions.filePath] || 0) + 1;
|
||||
}
|
||||
const { ast, program } = parseSettings.singleRun &&
|
||||
tsestreeOptions.filePath &&
|
||||
parseAndGenerateServicesCalls[tsestreeOptions.filePath] > 1 &&
|
||||
!parseSettings.projectService
|
||||
? (0, createIsolatedProgram_1.createIsolatedProgram)(parseSettings)
|
||||
: getProgramAndAST(parseSettings, hasFullTypeInformation);
|
||||
/**
|
||||
* Convert the TypeScript AST to an ESTree-compatible one, and optionally preserve
|
||||
* mappings between converted and original AST nodes
|
||||
*/
|
||||
const shouldPreserveNodeMaps = typeof parseSettings.preserveNodeMaps === 'boolean'
|
||||
? parseSettings.preserveNodeMaps
|
||||
: true;
|
||||
const { astMaps, estree } = (0, ast_converter_1.astConverter)(ast, parseSettings, shouldPreserveNodeMaps);
|
||||
/**
|
||||
* Even if TypeScript parsed the source code ok, and we had no problems converting the AST,
|
||||
* there may be other syntactic or semantic issues in the code that we can optionally report on.
|
||||
*/
|
||||
if (program && parseSettings.errorOnTypeScriptSyntacticAndSemanticIssues) {
|
||||
const error = (0, semantic_or_syntactic_errors_1.getFirstSemanticOrSyntacticError)(program, ast);
|
||||
if (error) {
|
||||
throw (0, convert_1.convertError)(error);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return the converted AST and additional parser services
|
||||
*/
|
||||
return {
|
||||
ast: estree,
|
||||
services: (0, createParserServices_1.createParserServices)(astMaps, program),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_to_primitive.cjs",
|
||||
"module": "../../esm/_to_primitive.js"
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import type {Buffer} from 'buffer';
|
||||
|
||||
import {
|
||||
BlockheightBasedTransactionConfirmationStrategy,
|
||||
Connection,
|
||||
DurableNonceTransactionConfirmationStrategy,
|
||||
TransactionConfirmationStrategy,
|
||||
} from '../connection';
|
||||
import type {TransactionSignature} from '../transaction';
|
||||
import type {ConfirmOptions} from '../connection';
|
||||
import {SendTransactionError} from '../errors';
|
||||
|
||||
/**
|
||||
* Send and confirm a raw transaction
|
||||
*
|
||||
* If `commitment` option is not specified, defaults to 'max' commitment.
|
||||
*
|
||||
* @param {Connection} connection
|
||||
* @param {Buffer} rawTransaction
|
||||
* @param {TransactionConfirmationStrategy} confirmationStrategy
|
||||
* @param {ConfirmOptions} [options]
|
||||
* @returns {Promise<TransactionSignature>}
|
||||
*/
|
||||
export async function sendAndConfirmRawTransaction(
|
||||
connection: Connection,
|
||||
rawTransaction: Buffer,
|
||||
confirmationStrategy: TransactionConfirmationStrategy,
|
||||
options?: ConfirmOptions,
|
||||
): Promise<TransactionSignature>;
|
||||
|
||||
/**
|
||||
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
||||
* is no longer supported and will be removed in a future version.
|
||||
*/
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export async function sendAndConfirmRawTransaction(
|
||||
connection: Connection,
|
||||
rawTransaction: Buffer,
|
||||
options?: ConfirmOptions,
|
||||
): Promise<TransactionSignature>;
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export async function sendAndConfirmRawTransaction(
|
||||
connection: Connection,
|
||||
rawTransaction: Buffer,
|
||||
confirmationStrategyOrConfirmOptions:
|
||||
| TransactionConfirmationStrategy
|
||||
| ConfirmOptions
|
||||
| undefined,
|
||||
maybeConfirmOptions?: ConfirmOptions,
|
||||
): Promise<TransactionSignature> {
|
||||
let confirmationStrategy: TransactionConfirmationStrategy | undefined;
|
||||
let options: ConfirmOptions | undefined;
|
||||
if (
|
||||
confirmationStrategyOrConfirmOptions &&
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
confirmationStrategyOrConfirmOptions,
|
||||
'lastValidBlockHeight',
|
||||
)
|
||||
) {
|
||||
confirmationStrategy =
|
||||
confirmationStrategyOrConfirmOptions as BlockheightBasedTransactionConfirmationStrategy;
|
||||
options = maybeConfirmOptions;
|
||||
} else if (
|
||||
confirmationStrategyOrConfirmOptions &&
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
confirmationStrategyOrConfirmOptions,
|
||||
'nonceValue',
|
||||
)
|
||||
) {
|
||||
confirmationStrategy =
|
||||
confirmationStrategyOrConfirmOptions as DurableNonceTransactionConfirmationStrategy;
|
||||
options = maybeConfirmOptions;
|
||||
} else {
|
||||
options = confirmationStrategyOrConfirmOptions as
|
||||
| ConfirmOptions
|
||||
| undefined;
|
||||
}
|
||||
const sendOptions = options && {
|
||||
skipPreflight: options.skipPreflight,
|
||||
preflightCommitment: options.preflightCommitment || options.commitment,
|
||||
minContextSlot: options.minContextSlot,
|
||||
};
|
||||
|
||||
const signature = await connection.sendRawTransaction(
|
||||
rawTransaction,
|
||||
sendOptions,
|
||||
);
|
||||
|
||||
const commitment = options && options.commitment;
|
||||
const confirmationPromise = confirmationStrategy
|
||||
? connection.confirmTransaction(confirmationStrategy, commitment)
|
||||
: connection.confirmTransaction(signature, commitment);
|
||||
const status = (await confirmationPromise).value;
|
||||
|
||||
if (status.err) {
|
||||
if (signature != null) {
|
||||
throw new SendTransactionError({
|
||||
action: sendOptions?.skipPreflight ? 'send' : 'simulate',
|
||||
signature: signature,
|
||||
transactionMessage: `Status: (${JSON.stringify(status)})`,
|
||||
});
|
||||
}
|
||||
throw new Error(
|
||||
`Raw transaction ${signature} failed (${JSON.stringify(status)})`,
|
||||
);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = pretty
|
||||
|
||||
const sjs = require('secure-json-parse')
|
||||
|
||||
const isObject = require('./utils/is-object')
|
||||
const prettifyErrorLog = require('./utils/prettify-error-log')
|
||||
const prettifyLevel = require('./utils/prettify-level')
|
||||
const prettifyMessage = require('./utils/prettify-message')
|
||||
const prettifyMetadata = require('./utils/prettify-metadata')
|
||||
const prettifyObject = require('./utils/prettify-object')
|
||||
const prettifyTime = require('./utils/prettify-time')
|
||||
const filterLog = require('./utils/filter-log')
|
||||
|
||||
const {
|
||||
LEVELS,
|
||||
LEVEL_KEY,
|
||||
LEVEL_NAMES
|
||||
} = require('./constants')
|
||||
|
||||
const jsonParser = input => {
|
||||
try {
|
||||
return { value: sjs.parse(input, { protoAction: 'remove' }) }
|
||||
} catch (err) {
|
||||
return { err }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Orchestrates processing the received log data according to the provided
|
||||
* configuration and returns a prettified log string.
|
||||
*
|
||||
* @typedef {function} LogPrettifierFunc
|
||||
* @param {string|object} inputData A log string or a log-like object.
|
||||
* @returns {string} A string that represents the prettified log data.
|
||||
*/
|
||||
function pretty (inputData) {
|
||||
let log
|
||||
if (!isObject(inputData)) {
|
||||
const parsed = jsonParser(inputData)
|
||||
if (parsed.err || !isObject(parsed.value)) {
|
||||
// pass through
|
||||
return inputData + this.EOL
|
||||
}
|
||||
log = parsed.value
|
||||
} else {
|
||||
log = inputData
|
||||
}
|
||||
|
||||
if (this.minimumLevel) {
|
||||
// We need to figure out if the custom levels has the desired minimum
|
||||
// level & use that one if found. If not, determine if the level exists
|
||||
// in the standard levels. In both cases, make sure we have the level
|
||||
// number instead of the level name.
|
||||
let condition
|
||||
if (this.useOnlyCustomProps) {
|
||||
condition = this.customLevels
|
||||
} else {
|
||||
condition = this.customLevelNames[this.minimumLevel] !== undefined
|
||||
}
|
||||
let minimum
|
||||
if (condition) {
|
||||
minimum = this.customLevelNames[this.minimumLevel]
|
||||
} else {
|
||||
minimum = LEVEL_NAMES[this.minimumLevel]
|
||||
}
|
||||
if (!minimum) {
|
||||
minimum = typeof this.minimumLevel === 'string'
|
||||
? LEVEL_NAMES[this.minimumLevel]
|
||||
: LEVEL_NAMES[LEVELS[this.minimumLevel].toLowerCase()]
|
||||
}
|
||||
|
||||
const level = log[this.levelKey === undefined ? LEVEL_KEY : this.levelKey]
|
||||
if (level < minimum) return
|
||||
}
|
||||
|
||||
const prettifiedMessage = prettifyMessage({ log, context: this.context })
|
||||
|
||||
if (this.ignoreKeys || this.includeKeys) {
|
||||
log = filterLog({ log, context: this.context })
|
||||
}
|
||||
|
||||
const prettifiedLevel = prettifyLevel({
|
||||
log,
|
||||
context: {
|
||||
...this.context,
|
||||
// This is odd. The colorizer ends up relying on the value of
|
||||
// `customProperties` instead of the original `customLevels` and
|
||||
// `customLevelNames`.
|
||||
...this.context.customProperties
|
||||
}
|
||||
})
|
||||
const prettifiedMetadata = prettifyMetadata({ log, context: this.context })
|
||||
const prettifiedTime = prettifyTime({ log, context: this.context })
|
||||
|
||||
let line = ''
|
||||
if (this.levelFirst && prettifiedLevel) {
|
||||
line = `${prettifiedLevel}`
|
||||
}
|
||||
|
||||
if (prettifiedTime && line === '') {
|
||||
line = `${prettifiedTime}`
|
||||
} else if (prettifiedTime) {
|
||||
line = `${line} ${prettifiedTime}`
|
||||
}
|
||||
|
||||
if (!this.levelFirst && prettifiedLevel) {
|
||||
if (line.length > 0) {
|
||||
line = `${line} ${prettifiedLevel}`
|
||||
} else {
|
||||
line = prettifiedLevel
|
||||
}
|
||||
}
|
||||
|
||||
if (prettifiedMetadata) {
|
||||
if (line.length > 0) {
|
||||
line = `${line} ${prettifiedMetadata}:`
|
||||
} else {
|
||||
line = prettifiedMetadata
|
||||
}
|
||||
}
|
||||
|
||||
if (line.endsWith(':') === false && line !== '') {
|
||||
line += ':'
|
||||
}
|
||||
|
||||
if (prettifiedMessage !== undefined) {
|
||||
if (line.length > 0) {
|
||||
line = `${line} ${prettifiedMessage}`
|
||||
} else {
|
||||
line = prettifiedMessage
|
||||
}
|
||||
}
|
||||
|
||||
if (line.length > 0 && !this.singleLine) {
|
||||
line += this.EOL
|
||||
}
|
||||
|
||||
// pino@7+ does not log this anymore
|
||||
if (log.type === 'Error' && typeof log.stack === 'string') {
|
||||
const prettifiedErrorLog = prettifyErrorLog({ log, context: this.context })
|
||||
if (this.singleLine) line += this.EOL
|
||||
line += prettifiedErrorLog
|
||||
} else if (this.hideObject === false) {
|
||||
const skipKeys = [
|
||||
this.messageKey,
|
||||
this.levelKey,
|
||||
this.timestampKey
|
||||
]
|
||||
.map((key) => key.replaceAll(/\\/g, ''))
|
||||
.filter(key => {
|
||||
return typeof log[key] === 'string' ||
|
||||
typeof log[key] === 'number' ||
|
||||
typeof log[key] === 'boolean'
|
||||
})
|
||||
const prettifiedObject = prettifyObject({
|
||||
log,
|
||||
skipKeys,
|
||||
context: this.context
|
||||
})
|
||||
|
||||
// In single line mode, include a space only if prettified version isn't empty
|
||||
if (this.singleLine && !/^\s$/.test(prettifiedObject)) {
|
||||
line += ' '
|
||||
}
|
||||
line += prettifiedObject
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import OverloadYield from "./OverloadYield.js";
|
||||
function _asyncGeneratorDelegate(t) {
|
||||
var e = {},
|
||||
n = !1;
|
||||
function pump(e, r) {
|
||||
return n = !0, r = new Promise(function (n) {
|
||||
n(t[e](r));
|
||||
}), {
|
||||
done: !1,
|
||||
value: new OverloadYield(r, 1)
|
||||
};
|
||||
}
|
||||
return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () {
|
||||
return this;
|
||||
}, e.next = function (t) {
|
||||
return n ? (n = !1, t) : pump("next", t);
|
||||
}, "function" == typeof t["throw"] && (e["throw"] = function (t) {
|
||||
if (n) throw n = !1, t;
|
||||
return pump("throw", t);
|
||||
}), "function" == typeof t["return"] && (e["return"] = function (t) {
|
||||
return n ? (n = !1, t) : pump("return", t);
|
||||
}), e;
|
||||
}
|
||||
export { _asyncGeneratorDelegate as default };
|
||||
@@ -0,0 +1,11 @@
|
||||
var equal = require('../');
|
||||
console.dir([
|
||||
equal(
|
||||
{ a : [ 2, 3 ], b : [ 4 ] },
|
||||
{ a : [ 2, 3 ], b : [ 4 ] }
|
||||
),
|
||||
equal(
|
||||
{ x : 5, y : [6] },
|
||||
{ x : 5, y : 6 }
|
||||
)
|
||||
]);
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unnecessaryAssign", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,106 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "memiliki" },
|
||||
file: { unit: "byte", verb: "memiliki" },
|
||||
array: { unit: "item", verb: "memiliki" },
|
||||
set: { unit: "item", verb: "memiliki" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "alamat email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "tanggal dan waktu format ISO",
|
||||
date: "tanggal format ISO",
|
||||
time: "jam format ISO",
|
||||
duration: "durasi format ISO",
|
||||
ipv4: "alamat IPv4",
|
||||
ipv6: "alamat IPv6",
|
||||
cidrv4: "rentang alamat IPv4",
|
||||
cidrv6: "rentang alamat IPv6",
|
||||
base64: "string dengan enkode base64",
|
||||
base64url: "string dengan enkode base64url",
|
||||
json_string: "string JSON",
|
||||
e164: "angka E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Input tidak valid: diharapkan instanceof ${issue.expected}, diterima ${received}`;
|
||||
}
|
||||
return `Input tidak valid: diharapkan ${expected}, diterima ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Input tidak valid: diharapkan ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Pilihan tidak valid: diharapkan salah satu dari ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} memiliki ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemen"}`;
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} menjadi ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} memiliki ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} menjadi ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `String tidak valid: harus dimulai dengan "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `String tidak valid: harus berakhir dengan "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `String tidak valid: harus menyertakan "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `String tidak valid: harus sesuai pola ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} tidak valid`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Angka tidak valid: harus kelipatan dari ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Kunci tidak dikenali ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Kunci tidak valid di ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Input tidak valid";
|
||||
case "invalid_element":
|
||||
return `Nilai tidak valid di ${issue.origin}`;
|
||||
default:
|
||||
return `Input tidak valid`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "module",
|
||||
"sideEffects": false
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
|
||||
const util_js_1 = require("./helpers/util.cjs");
|
||||
exports.ZodIssueCode = util_js_1.util.arrayToEnum([
|
||||
"invalid_type",
|
||||
"invalid_literal",
|
||||
"custom",
|
||||
"invalid_union",
|
||||
"invalid_union_discriminator",
|
||||
"invalid_enum_value",
|
||||
"unrecognized_keys",
|
||||
"invalid_arguments",
|
||||
"invalid_return_type",
|
||||
"invalid_date",
|
||||
"invalid_string",
|
||||
"too_small",
|
||||
"too_big",
|
||||
"invalid_intersection_types",
|
||||
"not_multiple_of",
|
||||
"not_finite",
|
||||
]);
|
||||
const quotelessJson = (obj) => {
|
||||
const json = JSON.stringify(obj, null, 2);
|
||||
return json.replace(/"([^"]+)":/g, "$1:");
|
||||
};
|
||||
exports.quotelessJson = quotelessJson;
|
||||
class ZodError extends Error {
|
||||
get errors() {
|
||||
return this.issues;
|
||||
}
|
||||
constructor(issues) {
|
||||
super();
|
||||
this.issues = [];
|
||||
this.addIssue = (sub) => {
|
||||
this.issues = [...this.issues, sub];
|
||||
};
|
||||
this.addIssues = (subs = []) => {
|
||||
this.issues = [...this.issues, ...subs];
|
||||
};
|
||||
const actualProto = new.target.prototype;
|
||||
if (Object.setPrototypeOf) {
|
||||
// eslint-disable-next-line ban/ban
|
||||
Object.setPrototypeOf(this, actualProto);
|
||||
}
|
||||
else {
|
||||
this.__proto__ = actualProto;
|
||||
}
|
||||
this.name = "ZodError";
|
||||
this.issues = issues;
|
||||
}
|
||||
format(_mapper) {
|
||||
const mapper = _mapper ||
|
||||
function (issue) {
|
||||
return issue.message;
|
||||
};
|
||||
const fieldErrors = { _errors: [] };
|
||||
const processError = (error) => {
|
||||
for (const issue of error.issues) {
|
||||
if (issue.code === "invalid_union") {
|
||||
issue.unionErrors.map(processError);
|
||||
}
|
||||
else if (issue.code === "invalid_return_type") {
|
||||
processError(issue.returnTypeError);
|
||||
}
|
||||
else if (issue.code === "invalid_arguments") {
|
||||
processError(issue.argumentsError);
|
||||
}
|
||||
else if (issue.path.length === 0) {
|
||||
fieldErrors._errors.push(mapper(issue));
|
||||
}
|
||||
else {
|
||||
let curr = fieldErrors;
|
||||
let i = 0;
|
||||
while (i < issue.path.length) {
|
||||
const el = issue.path[i];
|
||||
const terminal = i === issue.path.length - 1;
|
||||
if (!terminal) {
|
||||
curr[el] = curr[el] || { _errors: [] };
|
||||
// if (typeof el === "string") {
|
||||
// curr[el] = curr[el] || { _errors: [] };
|
||||
// } else if (typeof el === "number") {
|
||||
// const errorArray: any = [];
|
||||
// errorArray._errors = [];
|
||||
// curr[el] = curr[el] || errorArray;
|
||||
// }
|
||||
}
|
||||
else {
|
||||
curr[el] = curr[el] || { _errors: [] };
|
||||
curr[el]._errors.push(mapper(issue));
|
||||
}
|
||||
curr = curr[el];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
processError(this);
|
||||
return fieldErrors;
|
||||
}
|
||||
static assert(value) {
|
||||
if (!(value instanceof ZodError)) {
|
||||
throw new Error(`Not a ZodError: ${value}`);
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
return this.message;
|
||||
}
|
||||
get message() {
|
||||
return JSON.stringify(this.issues, util_js_1.util.jsonStringifyReplacer, 2);
|
||||
}
|
||||
get isEmpty() {
|
||||
return this.issues.length === 0;
|
||||
}
|
||||
flatten(mapper = (issue) => issue.message) {
|
||||
const fieldErrors = Object.create(null);
|
||||
const formErrors = [];
|
||||
for (const sub of this.issues) {
|
||||
if (sub.path.length > 0) {
|
||||
const firstEl = sub.path[0];
|
||||
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
||||
fieldErrors[firstEl].push(mapper(sub));
|
||||
}
|
||||
else {
|
||||
formErrors.push(mapper(sub));
|
||||
}
|
||||
}
|
||||
return { formErrors, fieldErrors };
|
||||
}
|
||||
get formErrors() {
|
||||
return this.flatten();
|
||||
}
|
||||
}
|
||||
exports.ZodError = ZodError;
|
||||
ZodError.create = (issues) => {
|
||||
const error = new ZodError(issues);
|
||||
return error;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export const errors = [];
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"internalSymbolName.enum.d.ts","sourceRoot":"","sources":["../../src/enums/internalSymbolName.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,kBAAkB;IAC1B,IAAI,WAAW;IACf,WAAW,kBAAkB;IAC7B,GAAG,UAAU;IACb,KAAK,YAAY;IACjB,UAAU,aAAa;IACvB,MAAM,aAAa;IACnB,OAAO,cAAc;IACrB,IAAI,WAAW;IACf,MAAM,aAAa;IACnB,aAAa,oBAAoB;IACjC,KAAK,YAAY;IACjB,QAAQ,eAAe;IACvB,QAAQ,eAAe;IACvB,qBAAqB,iBAAiB;IACtC,uBAAuB,8BAA8B;IACrD,gBAAgB,uBAAuB;IACvC,YAAY,YAAY;IACxB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,aAAa,mBAAmB;CACnC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i8.d.ts","sourceRoot":"","sources":["../../src/i8.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvG;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,QAAO,gBAAgB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAM7D,CAAC;AAEP;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,QAAO,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAKpD,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,UAAU,QAAO,cAAc,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CACvB,CAAC"}
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const commist = require('commist')()
|
||||
const help = require('./')({
|
||||
dir: path.join(path.dirname(require.main.filename), 'doc')
|
||||
})
|
||||
|
||||
commist.register('help', help.toStdout)
|
||||
commist.register('start', function () {
|
||||
console.log('Starting the script!')
|
||||
})
|
||||
|
||||
const res = commist.parse(process.argv.splice(2))
|
||||
|
||||
if (res) {
|
||||
help.toStdout()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
function sha1(bytes) {
|
||||
if (Array.isArray(bytes)) {
|
||||
bytes = Buffer.from(bytes);
|
||||
}
|
||||
else if (typeof bytes === 'string') {
|
||||
bytes = Buffer.from(bytes, 'utf8');
|
||||
}
|
||||
return createHash('sha1').update(bytes).digest();
|
||||
}
|
||||
export default sha1;
|
||||
@@ -0,0 +1,29 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
function v4(options, buf, offset) {
|
||||
if (!buf && !options && crypto.randomUUID) {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
return _v4(options, buf, offset);
|
||||
}
|
||||
function _v4(options, buf, offset) {
|
||||
options = options || {};
|
||||
const rnds = options.random ?? options.rng?.() ?? rng();
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = rnds[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
return unsafeStringify(rnds);
|
||||
}
|
||||
export default v4;
|
||||
@@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"regexps-iri.js","sourceRoot":"","sources":["../../src/regexps-iri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,eAAe,SAAS,CAAC,IAAI,CAAC,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tokenFlags.enum.js","sourceRoot":"","sources":["../../src/enums/tokenFlags.enum.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,MAAM,CAAN,IAAY,UA4BX;AA5BD,WAAY,UAAU;IAClB,2CAAQ,CAAA;IACR,uEAA2B,CAAA;IAC3B,6EAA8B,CAAA;IAC9B,2DAAqB,CAAA;IACrB,6EAA8B,CAAA;IAC9B,wDAAmB,CAAA;IACnB,8CAAc,CAAA;IACd,4DAAqB,CAAA;IACrB,mEAAwB,CAAA;IACxB,iEAAuB,CAAA;IACvB,uEAA0B,CAAA;IAC1B,gEAAuB,CAAA;IACvB,gFAA+B,CAAA;IAC/B,wDAAmB,CAAA;IACnB,4EAA6B,CAAA;IAC7B,uFAAkC,CAAA;IAClC,mGAAwC,CAAA;IACxC,6DAAqB,CAAA;IACrB,gGAAsC,CAAA;IACtC,8FAAqC,CAAA;IACrC,iFAAyD,CAAA;IACzD,+DAAqD,CAAA;IACrD,2EAA2H,CAAA;IAC3H,6EAA6H,CAAA;IAC7H,sFAAmH,CAAA;IACnH,6FAA4C,CAAA;IAC5C,yDAA0F,CAAA;AAC9F,CAAC,EA5BW,UAAU,KAAV,UAAU,QA4BrB"}
|
||||
@@ -0,0 +1,5 @@
|
||||
const file13 = require("./file13.js")
|
||||
|
||||
module.exports = function () {
|
||||
file13()
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
export function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
export var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return __assign.apply(this, arguments);
|
||||
}
|
||||
|
||||
export function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
export function __decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
|
||||
export function __param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
}
|
||||
|
||||
export function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
|
||||
export function __runInitializers(thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
|
||||
export function __propKey(x) {
|
||||
return typeof x === "symbol" ? x : "".concat(x);
|
||||
};
|
||||
|
||||
export function __setFunctionName(f, name, prefix) {
|
||||
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
||||
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
||||
};
|
||||
|
||||
export function __metadata(metadataKey, metadataValue) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
export function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
export function __generator(thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
}
|
||||
|
||||
export var __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];
|
||||
});
|
||||
|
||||
export function __exportStar(m, o) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
||||
}
|
||||
|
||||
export function __values(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
}
|
||||
|
||||
export function __read(o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export function __spread() {
|
||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
||||
ar = ar.concat(__read(arguments[i]));
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export function __spreadArrays() {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
}
|
||||
|
||||
export function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
export function __await(v) {
|
||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
||||
}
|
||||
|
||||
export function __asyncGenerator(thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
||||
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
}
|
||||
|
||||
export function __asyncDelegator(o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
||||
}
|
||||
|
||||
export function __asyncValues(o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
}
|
||||
|
||||
export function __makeTemplateObject(cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
|
||||
var __setModuleDefault = Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
};
|
||||
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
|
||||
export function __importStar(mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function __importDefault(mod) {
|
||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
||||
}
|
||||
|
||||
export function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
}
|
||||
|
||||
export function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
}
|
||||
|
||||
export function __classPrivateFieldIn(state, receiver) {
|
||||
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
|
||||
return typeof state === "function" ? receiver === state : state.has(receiver);
|
||||
}
|
||||
|
||||
export function __addDisposableResource(env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
export function __disposeResources(env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
export function __rewriteRelativeImportExtension(path, preserveJsx) {
|
||||
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
||||
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
||||
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
||||
});
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
export default {
|
||||
__extends,
|
||||
__assign,
|
||||
__rest,
|
||||
__decorate,
|
||||
__param,
|
||||
__esDecorate,
|
||||
__runInitializers,
|
||||
__propKey,
|
||||
__setFunctionName,
|
||||
__metadata,
|
||||
__awaiter,
|
||||
__generator,
|
||||
__createBinding,
|
||||
__exportStar,
|
||||
__values,
|
||||
__read,
|
||||
__spread,
|
||||
__spreadArrays,
|
||||
__spreadArray,
|
||||
__await,
|
||||
__asyncGenerator,
|
||||
__asyncDelegator,
|
||||
__asyncValues,
|
||||
__makeTemplateObject,
|
||||
__importStar,
|
||||
__importDefault,
|
||||
__classPrivateFieldGet,
|
||||
__classPrivateFieldSet,
|
||||
__classPrivateFieldIn,
|
||||
__addDisposableResource,
|
||||
__disposeResources,
|
||||
__rewriteRelativeImportExtension,
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.es2015_symbol_wellknown = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
const es2015_symbol_1 = require("./es2015.symbol");
|
||||
exports.es2015_symbol_wellknown = {
|
||||
libs: [es2015_symbol_1.es2015_symbol],
|
||||
variables: [
|
||||
['SymbolConstructor', base_config_1.TYPE],
|
||||
['Symbol', base_config_1.TYPE],
|
||||
['Array', base_config_1.TYPE],
|
||||
['ReadonlyArray', base_config_1.TYPE],
|
||||
['Date', base_config_1.TYPE],
|
||||
['Map', base_config_1.TYPE],
|
||||
['WeakMap', base_config_1.TYPE],
|
||||
['Set', base_config_1.TYPE],
|
||||
['WeakSet', base_config_1.TYPE],
|
||||
['JSON', base_config_1.TYPE],
|
||||
['Function', base_config_1.TYPE],
|
||||
['GeneratorFunction', base_config_1.TYPE],
|
||||
['Math', base_config_1.TYPE],
|
||||
['Promise', base_config_1.TYPE],
|
||||
['PromiseConstructor', base_config_1.TYPE],
|
||||
['RegExp', base_config_1.TYPE],
|
||||
['RegExpConstructor', base_config_1.TYPE],
|
||||
['String', base_config_1.TYPE],
|
||||
['ArrayBuffer', base_config_1.TYPE],
|
||||
['DataView', base_config_1.TYPE],
|
||||
['Int8Array', base_config_1.TYPE],
|
||||
['Uint8Array', base_config_1.TYPE],
|
||||
['Uint8ClampedArray', base_config_1.TYPE],
|
||||
['Int16Array', base_config_1.TYPE],
|
||||
['Uint16Array', base_config_1.TYPE],
|
||||
['Int32Array', base_config_1.TYPE],
|
||||
['Uint32Array', base_config_1.TYPE],
|
||||
['Float32Array', base_config_1.TYPE],
|
||||
['Float64Array', base_config_1.TYPE],
|
||||
['ArrayConstructor', base_config_1.TYPE],
|
||||
['MapConstructor', base_config_1.TYPE],
|
||||
['SetConstructor', base_config_1.TYPE],
|
||||
['ArrayBufferConstructor', base_config_1.TYPE],
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* Montgomery curve methods. It's not really whole montgomery curve,
|
||||
* just bunch of very specific methods for X25519 / X448 from
|
||||
* [RFC 7748](https://www.rfc-editor.org/rfc/rfc7748)
|
||||
* @module
|
||||
*/
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
import {
|
||||
_validateObject,
|
||||
abytes,
|
||||
aInRange,
|
||||
bytesToNumberLE,
|
||||
ensureBytes,
|
||||
numberToBytesLE,
|
||||
randomBytes,
|
||||
} from '../utils.ts';
|
||||
import type { CurveLengths } from './curve.ts';
|
||||
import { mod } from './modular.ts';
|
||||
|
||||
const _0n = BigInt(0);
|
||||
const _1n = BigInt(1);
|
||||
const _2n = BigInt(2);
|
||||
type Hex = string | Uint8Array;
|
||||
|
||||
export type CurveType = {
|
||||
P: bigint; // finite field prime
|
||||
type: 'x25519' | 'x448';
|
||||
adjustScalarBytes: (bytes: Uint8Array) => Uint8Array;
|
||||
powPminus2: (x: bigint) => bigint;
|
||||
randomBytes?: (bytesLength?: number) => Uint8Array;
|
||||
};
|
||||
|
||||
export type MontgomeryECDH = {
|
||||
scalarMult: (scalar: Hex, u: Hex) => Uint8Array;
|
||||
scalarMultBase: (scalar: Hex) => Uint8Array;
|
||||
getSharedSecret: (secretKeyA: Hex, publicKeyB: Hex) => Uint8Array;
|
||||
getPublicKey: (secretKey: Hex) => Uint8Array;
|
||||
utils: {
|
||||
randomSecretKey: () => Uint8Array;
|
||||
/** @deprecated use `randomSecretKey` */
|
||||
randomPrivateKey: () => Uint8Array;
|
||||
};
|
||||
GuBytes: Uint8Array;
|
||||
lengths: CurveLengths;
|
||||
keygen: (seed?: Uint8Array) => { secretKey: Uint8Array; publicKey: Uint8Array };
|
||||
};
|
||||
export type CurveFn = MontgomeryECDH;
|
||||
|
||||
function validateOpts(curve: CurveType) {
|
||||
_validateObject(curve, {
|
||||
adjustScalarBytes: 'function',
|
||||
powPminus2: 'function',
|
||||
});
|
||||
return Object.freeze({ ...curve } as const);
|
||||
}
|
||||
|
||||
export function montgomery(curveDef: CurveType): MontgomeryECDH {
|
||||
const CURVE = validateOpts(curveDef);
|
||||
const { P, type, adjustScalarBytes, powPminus2, randomBytes: rand } = CURVE;
|
||||
const is25519 = type === 'x25519';
|
||||
if (!is25519 && type !== 'x448') throw new Error('invalid type');
|
||||
const randomBytes_ = rand || randomBytes;
|
||||
|
||||
const montgomeryBits = is25519 ? 255 : 448;
|
||||
const fieldLen = is25519 ? 32 : 56;
|
||||
const Gu = is25519 ? BigInt(9) : BigInt(5);
|
||||
// RFC 7748 #5:
|
||||
// The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519 and
|
||||
// (156326 - 2) / 4 = 39081 for curve448/X448
|
||||
// const a = is25519 ? 156326n : 486662n;
|
||||
const a24 = is25519 ? BigInt(121665) : BigInt(39081);
|
||||
// RFC: x25519 "the resulting integer is of the form 2^254 plus
|
||||
// eight times a value between 0 and 2^251 - 1 (inclusive)"
|
||||
// x448: "2^447 plus four times a value between 0 and 2^445 - 1 (inclusive)"
|
||||
const minScalar = is25519 ? _2n ** BigInt(254) : _2n ** BigInt(447);
|
||||
const maxAdded = is25519
|
||||
? BigInt(8) * _2n ** BigInt(251) - _1n
|
||||
: BigInt(4) * _2n ** BigInt(445) - _1n;
|
||||
const maxScalar = minScalar + maxAdded + _1n; // (inclusive)
|
||||
const modP = (n: bigint) => mod(n, P);
|
||||
const GuBytes = encodeU(Gu);
|
||||
function encodeU(u: bigint): Uint8Array {
|
||||
return numberToBytesLE(modP(u), fieldLen);
|
||||
}
|
||||
function decodeU(u: Hex): bigint {
|
||||
const _u = ensureBytes('u coordinate', u, fieldLen);
|
||||
// RFC: When receiving such an array, implementations of X25519
|
||||
// (but not X448) MUST mask the most significant bit in the final byte.
|
||||
if (is25519) _u[31] &= 127; // 0b0111_1111
|
||||
// RFC: Implementations MUST accept non-canonical values and process them as
|
||||
// if they had been reduced modulo the field prime. The non-canonical
|
||||
// values are 2^255 - 19 through 2^255 - 1 for X25519 and 2^448 - 2^224
|
||||
// - 1 through 2^448 - 1 for X448.
|
||||
return modP(bytesToNumberLE(_u));
|
||||
}
|
||||
function decodeScalar(scalar: Hex): bigint {
|
||||
return bytesToNumberLE(adjustScalarBytes(ensureBytes('scalar', scalar, fieldLen)));
|
||||
}
|
||||
function scalarMult(scalar: Hex, u: Hex): Uint8Array {
|
||||
const pu = montgomeryLadder(decodeU(u), decodeScalar(scalar));
|
||||
// Some public keys are useless, of low-order. Curve author doesn't think
|
||||
// it needs to be validated, but we do it nonetheless.
|
||||
// https://cr.yp.to/ecdh.html#validate
|
||||
if (pu === _0n) throw new Error('invalid private or public key received');
|
||||
return encodeU(pu);
|
||||
}
|
||||
// Computes public key from private. By doing scalar multiplication of base point.
|
||||
function scalarMultBase(scalar: Hex): Uint8Array {
|
||||
return scalarMult(scalar, GuBytes);
|
||||
}
|
||||
|
||||
// cswap from RFC7748 "example code"
|
||||
function cswap(swap: bigint, x_2: bigint, x_3: bigint): { x_2: bigint; x_3: bigint } {
|
||||
// dummy = mask(swap) AND (x_2 XOR x_3)
|
||||
// Where mask(swap) is the all-1 or all-0 word of the same length as x_2
|
||||
// and x_3, computed, e.g., as mask(swap) = 0 - swap.
|
||||
const dummy = modP(swap * (x_2 - x_3));
|
||||
x_2 = modP(x_2 - dummy); // x_2 = x_2 XOR dummy
|
||||
x_3 = modP(x_3 + dummy); // x_3 = x_3 XOR dummy
|
||||
return { x_2, x_3 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Montgomery x-only multiplication ladder.
|
||||
* @param pointU u coordinate (x) on Montgomery Curve 25519
|
||||
* @param scalar by which the point would be multiplied
|
||||
* @returns new Point on Montgomery curve
|
||||
*/
|
||||
function montgomeryLadder(u: bigint, scalar: bigint): bigint {
|
||||
aInRange('u', u, _0n, P);
|
||||
aInRange('scalar', scalar, minScalar, maxScalar);
|
||||
const k = scalar;
|
||||
const x_1 = u;
|
||||
let x_2 = _1n;
|
||||
let z_2 = _0n;
|
||||
let x_3 = u;
|
||||
let z_3 = _1n;
|
||||
let swap = _0n;
|
||||
for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) {
|
||||
const k_t = (k >> t) & _1n;
|
||||
swap ^= k_t;
|
||||
({ x_2, x_3 } = cswap(swap, x_2, x_3));
|
||||
({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
|
||||
swap = k_t;
|
||||
|
||||
const A = x_2 + z_2;
|
||||
const AA = modP(A * A);
|
||||
const B = x_2 - z_2;
|
||||
const BB = modP(B * B);
|
||||
const E = AA - BB;
|
||||
const C = x_3 + z_3;
|
||||
const D = x_3 - z_3;
|
||||
const DA = modP(D * A);
|
||||
const CB = modP(C * B);
|
||||
const dacb = DA + CB;
|
||||
const da_cb = DA - CB;
|
||||
x_3 = modP(dacb * dacb);
|
||||
z_3 = modP(x_1 * modP(da_cb * da_cb));
|
||||
x_2 = modP(AA * BB);
|
||||
z_2 = modP(E * (AA + modP(a24 * E)));
|
||||
}
|
||||
({ x_2, x_3 } = cswap(swap, x_2, x_3));
|
||||
({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
|
||||
const z2 = powPminus2(z_2); // `Fp.pow(x, P - _2n)` is much slower equivalent
|
||||
return modP(x_2 * z2); // Return x_2 * (z_2^(p - 2))
|
||||
}
|
||||
const lengths = {
|
||||
secretKey: fieldLen,
|
||||
publicKey: fieldLen,
|
||||
seed: fieldLen,
|
||||
};
|
||||
const randomSecretKey = (seed = randomBytes_(fieldLen)) => {
|
||||
abytes(seed, lengths.seed);
|
||||
return seed;
|
||||
};
|
||||
function keygen(seed?: Uint8Array) {
|
||||
const secretKey = randomSecretKey(seed);
|
||||
return { secretKey, publicKey: scalarMultBase(secretKey) };
|
||||
}
|
||||
const utils = {
|
||||
randomSecretKey,
|
||||
randomPrivateKey: randomSecretKey,
|
||||
};
|
||||
return {
|
||||
keygen,
|
||||
getSharedSecret: (secretKey: Hex, publicKey: Hex) => scalarMult(secretKey, publicKey),
|
||||
getPublicKey: (secretKey: Hex): Uint8Array => scalarMultBase(secretKey),
|
||||
scalarMult,
|
||||
scalarMultBase,
|
||||
utils,
|
||||
GuBytes: GuBytes.slice(),
|
||||
lengths,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.es2025_collection = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
const es2024_collection_1 = require("./es2024.collection");
|
||||
exports.es2025_collection = {
|
||||
libs: [es2024_collection_1.es2024_collection],
|
||||
variables: [
|
||||
['ReadonlySetLike', base_config_1.TYPE],
|
||||
['Set', base_config_1.TYPE],
|
||||
['ReadonlySet', base_config_1.TYPE],
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "tekens", verb: "heeft" },
|
||||
file: { unit: "bytes", verb: "heeft" },
|
||||
array: { unit: "elementen", verb: "heeft" },
|
||||
set: { unit: "elementen", verb: "heeft" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "invoer",
|
||||
email: "emailadres",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datum en tijd",
|
||||
date: "ISO datum",
|
||||
time: "ISO tijd",
|
||||
duration: "ISO duur",
|
||||
ipv4: "IPv4-adres",
|
||||
ipv6: "IPv6-adres",
|
||||
cidrv4: "IPv4-bereik",
|
||||
cidrv6: "IPv6-bereik",
|
||||
base64: "base64-gecodeerde tekst",
|
||||
base64url: "base64 URL-gecodeerde tekst",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164-nummer",
|
||||
jwt: "JWT",
|
||||
template_literal: "invoer",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "getal",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ongeldige invoer: verwacht instanceof ${issue.expected}, ontving ${received}`;
|
||||
}
|
||||
return `Ongeldige invoer: verwacht ${expected}, ontving ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ongeldige invoer: verwacht ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ongeldige optie: verwacht één van ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const longName = issue.origin === "date" ? "laat" : issue.origin === "string" ? "lang" : "groot";
|
||||
if (sizing)
|
||||
return `Te ${longName}: verwacht dat ${issue.origin ?? "waarde"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementen"} ${sizing.verb}`;
|
||||
return `Te ${longName}: verwacht dat ${issue.origin ?? "waarde"} ${adj}${issue.maximum.toString()} is`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const shortName = issue.origin === "date" ? "vroeg" : issue.origin === "string" ? "kort" : "klein";
|
||||
if (sizing) {
|
||||
return `Te ${shortName}: verwacht dat ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
}
|
||||
return `Te ${shortName}: verwacht dat ${issue.origin} ${adj}${issue.minimum.toString()} is`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Ongeldige tekst: moet met "${_issue.prefix}" beginnen`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ongeldige tekst: moet op "${_issue.suffix}" eindigen`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ongeldige tekst: moet "${_issue.includes}" bevatten`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ongeldige tekst: moet overeenkomen met patroon ${_issue.pattern}`;
|
||||
return `Ongeldig: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ongeldig getal: moet een veelvoud van ${issue.divisor} zijn`;
|
||||
case "unrecognized_keys":
|
||||
return `Onbekende key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ongeldige key in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ongeldige invoer";
|
||||
case "invalid_element":
|
||||
return `Ongeldige waarde in ${issue.origin}`;
|
||||
default:
|
||||
return `Ongeldige invoer`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
Reference in New Issue
Block a user