@poe-platform/safe-js 0.1.362 → 0.1.363
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-js/chunks/{chunk-EF6FLPF6.js → chunk-ADA4LH5C.js} +2 -2
- package/dist/safe-js/chunks/{chunk-QMF5YOGC.js → chunk-OTFEHCGJ.js} +190 -8
- package/dist/safe-js/chunks/chunk-OTFEHCGJ.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/typed-array.d.ts +1 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-QMF5YOGC.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-EF6FLPF6.js.map → chunk-ADA4LH5C.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OTFEHCGJ.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-ADA4LH5C.js.map
|
|
@@ -6995,6 +6995,11 @@ function copyTypedArrayStorage(value, state) {
|
|
|
6995
6995
|
}
|
|
6996
6996
|
return new storage.Native(buffer, storage.byteOffset, storage.length);
|
|
6997
6997
|
}
|
|
6998
|
+
function requireUint8Array(value) {
|
|
6999
|
+
if (!isNumericTypedArray(value) || typedArrayStorage(value).Native !== Uint8Array)
|
|
7000
|
+
throw new TypeError("Conversion requires a Uint8Array receiver.");
|
|
7001
|
+
return value;
|
|
7002
|
+
}
|
|
6998
7003
|
|
|
6999
7004
|
// packages/safe-js/src/interp/date.ts
|
|
7000
7005
|
import { types as types3 } from "node:util";
|
|
@@ -14672,7 +14677,7 @@ function installUint8Hex(budget, constructor, prototype) {
|
|
|
14672
14677
|
name: "toHex",
|
|
14673
14678
|
length: 0,
|
|
14674
14679
|
call: (_args, context) => {
|
|
14675
|
-
const value =
|
|
14680
|
+
const value = requireUint8Array(context?.thisValue);
|
|
14676
14681
|
const { length } = typedArrayStorage(value, true);
|
|
14677
14682
|
budget.provisionDataUsage(length * 2)();
|
|
14678
14683
|
let result = "";
|
|
@@ -14694,7 +14699,7 @@ function installUint8Hex(budget, constructor, prototype) {
|
|
|
14694
14699
|
name: "setFromHex",
|
|
14695
14700
|
length: 1,
|
|
14696
14701
|
call: ([text], context) => {
|
|
14697
|
-
const value =
|
|
14702
|
+
const value = requireUint8Array(context?.thisValue);
|
|
14698
14703
|
if (typeof text !== "string") throw new TypeError("Hex input must be a string.");
|
|
14699
14704
|
typedArrayStorage(value, true);
|
|
14700
14705
|
const written = decodeHexInto(text, value, budget);
|
|
@@ -14704,11 +14709,6 @@ function installUint8Hex(budget, constructor, prototype) {
|
|
|
14704
14709
|
}
|
|
14705
14710
|
});
|
|
14706
14711
|
}
|
|
14707
|
-
function uint8Receiver(value) {
|
|
14708
|
-
if (!isNumericTypedArray(value) || typedArrayStorage(value).Native !== Uint8Array)
|
|
14709
|
-
throw new TypeError("Hex conversion requires a Uint8Array receiver.");
|
|
14710
|
-
return value;
|
|
14711
|
-
}
|
|
14712
14712
|
function decodeHexInto(text, value, budget) {
|
|
14713
14713
|
if (text.length % 2 !== 0) throw new SyntaxError("Hex input must have an even length.");
|
|
14714
14714
|
const length = Math.min(text.length / 2, typedArrayStorage(value).length);
|
|
@@ -14728,6 +14728,187 @@ function hexNibble(code) {
|
|
|
14728
14728
|
return -1;
|
|
14729
14729
|
}
|
|
14730
14730
|
|
|
14731
|
+
// packages/safe-js/src/interp/globals/uint8-base64.ts
|
|
14732
|
+
var alphabets = {
|
|
14733
|
+
base64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
14734
|
+
base64url: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
|
14735
|
+
};
|
|
14736
|
+
function installUint8Base64(budget, constructor, prototype) {
|
|
14737
|
+
const fromBase64 = createSandboxClosure({
|
|
14738
|
+
guest: true,
|
|
14739
|
+
sandbox: true,
|
|
14740
|
+
name: "fromBase64",
|
|
14741
|
+
length: 1,
|
|
14742
|
+
call: async ([text, options], context) => {
|
|
14743
|
+
if (typeof text !== "string") throw new TypeError("Base64 input must be a string.");
|
|
14744
|
+
const release = retainValues(budget, () => [text, options]);
|
|
14745
|
+
try {
|
|
14746
|
+
const { alphabet, mode } = await base64Options(options, false, budget, context);
|
|
14747
|
+
const result = decodeBase64(text, alphabet, mode, budget);
|
|
14748
|
+
if (result.error !== void 0) throw result.error;
|
|
14749
|
+
budget.provisionDataUsage(result.bytes.length * 2 + 3)();
|
|
14750
|
+
const value = new Uint8Array(result.bytes);
|
|
14751
|
+
setSandboxPrototype(value, prototype, budget);
|
|
14752
|
+
return value;
|
|
14753
|
+
} finally {
|
|
14754
|
+
release();
|
|
14755
|
+
}
|
|
14756
|
+
}
|
|
14757
|
+
});
|
|
14758
|
+
Object.defineProperty(materializeFunctionProperties(constructor), "fromBase64", {
|
|
14759
|
+
value: fromBase64,
|
|
14760
|
+
writable: true,
|
|
14761
|
+
configurable: true
|
|
14762
|
+
});
|
|
14763
|
+
registerIntrinsicFunction(budget, fromBase64);
|
|
14764
|
+
Object.defineProperties(prototype, {
|
|
14765
|
+
toBase64: {
|
|
14766
|
+
writable: true,
|
|
14767
|
+
configurable: true,
|
|
14768
|
+
value: createSandboxClosure({
|
|
14769
|
+
guest: true,
|
|
14770
|
+
sandbox: true,
|
|
14771
|
+
name: "toBase64",
|
|
14772
|
+
length: 0,
|
|
14773
|
+
call: async ([options], context) => {
|
|
14774
|
+
const value = requireUint8Array(context?.thisValue);
|
|
14775
|
+
const release = retainValues(budget, () => [value, options]);
|
|
14776
|
+
try {
|
|
14777
|
+
const { alphabet, omitPadding } = await base64Options(options, true, budget, context);
|
|
14778
|
+
const { length } = typedArrayStorage(value, true);
|
|
14779
|
+
budget.provisionDataUsage(omitPadding ? Math.ceil(length * 4 / 3) : Math.ceil(length / 3) * 4)();
|
|
14780
|
+
let result = "";
|
|
14781
|
+
for (let index = 0; index < length; index += 3) {
|
|
14782
|
+
budget.visitNode();
|
|
14783
|
+
const a = value[index], b = value[index + 1] ?? 0, c = value[index + 2] ?? 0;
|
|
14784
|
+
const chunk = alphabet[a >> 2] + alphabet[(a & 3) << 4 | b >> 4] + (index + 1 < length ? alphabet[(b & 15) << 2 | c >> 6] : omitPadding ? "" : "=") + (index + 2 < length ? alphabet[c & 63] : omitPadding ? "" : "=");
|
|
14785
|
+
result = budget.allocateString(result + chunk);
|
|
14786
|
+
}
|
|
14787
|
+
return result;
|
|
14788
|
+
} finally {
|
|
14789
|
+
release();
|
|
14790
|
+
}
|
|
14791
|
+
}
|
|
14792
|
+
})
|
|
14793
|
+
},
|
|
14794
|
+
setFromBase64: {
|
|
14795
|
+
writable: true,
|
|
14796
|
+
configurable: true,
|
|
14797
|
+
value: createSandboxClosure({
|
|
14798
|
+
guest: true,
|
|
14799
|
+
sandbox: true,
|
|
14800
|
+
name: "setFromBase64",
|
|
14801
|
+
length: 1,
|
|
14802
|
+
call: async ([text, options], context) => {
|
|
14803
|
+
const value = requireUint8Array(context?.thisValue);
|
|
14804
|
+
if (typeof text !== "string") throw new TypeError("Base64 input must be a string.");
|
|
14805
|
+
const release = retainValues(budget, () => [value, text, options]);
|
|
14806
|
+
try {
|
|
14807
|
+
const { alphabet, mode } = await base64Options(options, false, budget, context);
|
|
14808
|
+
const { length } = typedArrayStorage(value, true);
|
|
14809
|
+
const result = decodeBase64(text, alphabet, mode, budget, length);
|
|
14810
|
+
for (let index = 0; index < result.bytes.length; index++) value[index] = result.bytes[index];
|
|
14811
|
+
if (result.error !== void 0) throw result.error;
|
|
14812
|
+
return { read: result.read, written: result.bytes.length };
|
|
14813
|
+
} finally {
|
|
14814
|
+
release();
|
|
14815
|
+
}
|
|
14816
|
+
}
|
|
14817
|
+
})
|
|
14818
|
+
}
|
|
14819
|
+
});
|
|
14820
|
+
}
|
|
14821
|
+
async function base64Options(options, encode, budget, context) {
|
|
14822
|
+
if (options !== void 0 && (options === null || typeof options !== "object"))
|
|
14823
|
+
throw new TypeError("Base64 options must be an object.");
|
|
14824
|
+
const read = (key) => {
|
|
14825
|
+
if (options === void 0) return void 0;
|
|
14826
|
+
if (context?.getProperty !== void 0) return context.getProperty(options, key);
|
|
14827
|
+
const descriptor = getSandboxPropertyDescriptor(options, key, budget);
|
|
14828
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, options, context);
|
|
14829
|
+
};
|
|
14830
|
+
const alphabet = await read("alphabet");
|
|
14831
|
+
if (alphabet !== void 0 && alphabet !== "base64" && alphabet !== "base64url")
|
|
14832
|
+
throw new TypeError("Invalid base64 alphabet.");
|
|
14833
|
+
const digits = alphabets[alphabet ?? "base64"];
|
|
14834
|
+
if (encode) return { alphabet: digits, omitPadding: Boolean(await read("omitPadding")), mode: "loose" };
|
|
14835
|
+
const mode = await read("lastChunkHandling");
|
|
14836
|
+
if (mode !== void 0 && mode !== "loose" && mode !== "strict" && mode !== "stop-before-partial")
|
|
14837
|
+
throw new TypeError("Invalid base64 lastChunkHandling.");
|
|
14838
|
+
return { alphabet: digits, omitPadding: false, mode: mode ?? "loose" };
|
|
14839
|
+
}
|
|
14840
|
+
function decodeBase64(text, alphabet, mode, budget, maxLength = Number.MAX_SAFE_INTEGER) {
|
|
14841
|
+
const bytes = [];
|
|
14842
|
+
const chunk = [];
|
|
14843
|
+
let read = 0, index = 0;
|
|
14844
|
+
const skipWhitespace2 = () => {
|
|
14845
|
+
while (index < text.length) {
|
|
14846
|
+
const code = text.charCodeAt(index);
|
|
14847
|
+
if (code !== 9 && code !== 10 && code !== 12 && code !== 13 && code !== 32) break;
|
|
14848
|
+
budget.visitNode();
|
|
14849
|
+
index++;
|
|
14850
|
+
}
|
|
14851
|
+
};
|
|
14852
|
+
const append = (strict) => {
|
|
14853
|
+
if (strict && (chunk.length === 2 && (chunk[1] & 15) !== 0 || chunk.length === 3 && (chunk[2] & 3) !== 0))
|
|
14854
|
+
throw new SyntaxError("Nonzero unused base64 bits.");
|
|
14855
|
+
const length = bytes.length + chunk.length - 1;
|
|
14856
|
+
budget.allocateArrayLength(length);
|
|
14857
|
+
budget.provisionDataUsage(length + 1)();
|
|
14858
|
+
bytes.push(chunk[0] << 2 | chunk[1] >> 4);
|
|
14859
|
+
if (chunk.length > 2) bytes.push((chunk[1] & 15) << 4 | chunk[2] >> 2);
|
|
14860
|
+
if (chunk.length > 3) bytes.push((chunk[2] & 3) << 6 | chunk[3]);
|
|
14861
|
+
};
|
|
14862
|
+
try {
|
|
14863
|
+
if (maxLength === 0) return { read, bytes };
|
|
14864
|
+
for (; ; ) {
|
|
14865
|
+
skipWhitespace2();
|
|
14866
|
+
if (index === text.length) {
|
|
14867
|
+
if (chunk.length > 0) {
|
|
14868
|
+
if (mode === "stop-before-partial") return { read, bytes };
|
|
14869
|
+
if (mode === "strict" || chunk.length === 1) throw new SyntaxError("Incomplete base64 chunk.");
|
|
14870
|
+
append(false);
|
|
14871
|
+
}
|
|
14872
|
+
return { read: index, bytes };
|
|
14873
|
+
}
|
|
14874
|
+
budget.visitNode();
|
|
14875
|
+
const char = text[index++];
|
|
14876
|
+
if (char === "=") {
|
|
14877
|
+
if (chunk.length < 2) throw new SyntaxError("Invalid base64 padding.");
|
|
14878
|
+
skipWhitespace2();
|
|
14879
|
+
if (chunk.length === 2) {
|
|
14880
|
+
if (index === text.length) {
|
|
14881
|
+
if (mode === "stop-before-partial") return { read, bytes };
|
|
14882
|
+
throw new SyntaxError("Incomplete base64 padding.");
|
|
14883
|
+
}
|
|
14884
|
+
if (text[index] === "=") {
|
|
14885
|
+
budget.visitNode();
|
|
14886
|
+
index++;
|
|
14887
|
+
skipWhitespace2();
|
|
14888
|
+
}
|
|
14889
|
+
}
|
|
14890
|
+
if (index < text.length) throw new SyntaxError("Unexpected input after base64 padding.");
|
|
14891
|
+
append(mode === "strict");
|
|
14892
|
+
return { read: index, bytes };
|
|
14893
|
+
}
|
|
14894
|
+
const digit = alphabet.indexOf(char);
|
|
14895
|
+
if (digit < 0) throw new SyntaxError("Invalid base64 character.");
|
|
14896
|
+
const remaining = maxLength - bytes.length;
|
|
14897
|
+
if (remaining === 1 && chunk.length === 2 || remaining === 2 && chunk.length === 3) return { read, bytes };
|
|
14898
|
+
chunk.push(digit);
|
|
14899
|
+
if (chunk.length === 4) {
|
|
14900
|
+
append(false);
|
|
14901
|
+
chunk.length = 0;
|
|
14902
|
+
read = index;
|
|
14903
|
+
if (bytes.length === maxLength) return { read, bytes };
|
|
14904
|
+
}
|
|
14905
|
+
}
|
|
14906
|
+
} catch (error) {
|
|
14907
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
14908
|
+
return { read, bytes, error };
|
|
14909
|
+
}
|
|
14910
|
+
}
|
|
14911
|
+
|
|
14731
14912
|
// packages/safe-js/src/interp/globals/numeric-typed-array.ts
|
|
14732
14913
|
var constructors = /* @__PURE__ */ new WeakMap();
|
|
14733
14914
|
function createNumericTypedArrayGlobal(budget, nativePrototype = false, Native = Float32Array) {
|
|
@@ -14995,6 +15176,7 @@ function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
|
14995
15176
|
prototypes2.set(Native, prototype);
|
|
14996
15177
|
}
|
|
14997
15178
|
installUint8Hex(budget, bindings.Uint8Array, prototypes2.get(Uint8Array));
|
|
15179
|
+
installUint8Base64(budget, bindings.Uint8Array, prototypes2.get(Uint8Array));
|
|
14998
15180
|
for (const [name, Native] of Object.entries(numericTypedArrayConstructors)) {
|
|
14999
15181
|
registerIntrinsicFunction(budget, bindings[name]);
|
|
15000
15182
|
registerIntrinsicObject(budget, prototypes2.get(Native));
|
|
@@ -42921,4 +43103,4 @@ export {
|
|
|
42921
43103
|
FileSnapshotBackend,
|
|
42922
43104
|
run
|
|
42923
43105
|
};
|
|
42924
|
-
//# sourceMappingURL=chunk-
|
|
43106
|
+
//# sourceMappingURL=chunk-OTFEHCGJ.js.map
|