@invisi-labs/protocol 1.1.1 → 1.1.2
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/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -87,7 +87,7 @@ declare const word: (v: bigint | string) => Hex;
|
|
|
87
87
|
declare function dense<T>(v: readonly T[], name: string): readonly T[];
|
|
88
88
|
declare function known(v: object, keys: readonly string[], name?: string): void;
|
|
89
89
|
declare function notes(v: readonly Hex[], name: string): `0x${string}`[];
|
|
90
|
-
declare function envelope(v: Hex, length: number, version?: number): Hex;
|
|
90
|
+
declare function envelope(v: Hex, length: number, version?: number, maximum?: number): Hex;
|
|
91
91
|
declare function normalizeContext(c: TransactionContext): {
|
|
92
92
|
chainId: bigint;
|
|
93
93
|
protocolAddress: Hex;
|
package/dist/index.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ declare const word: (v: bigint | string) => Hex;
|
|
|
87
87
|
declare function dense<T>(v: readonly T[], name: string): readonly T[];
|
|
88
88
|
declare function known(v: object, keys: readonly string[], name?: string): void;
|
|
89
89
|
declare function notes(v: readonly Hex[], name: string): `0x${string}`[];
|
|
90
|
-
declare function envelope(v: Hex, length: number, version?: number): Hex;
|
|
90
|
+
declare function envelope(v: Hex, length: number, version?: number, maximum?: number): Hex;
|
|
91
91
|
declare function normalizeContext(c: TransactionContext): {
|
|
92
92
|
chainId: bigint;
|
|
93
93
|
protocolAddress: Hex;
|
package/dist/index.js
CHANGED
|
@@ -572,8 +572,8 @@ function notes(v, name) {
|
|
|
572
572
|
throw new Error(`duplicate or zero ${name}`);
|
|
573
573
|
return r;
|
|
574
574
|
}
|
|
575
|
-
function envelope(v, length, version) {
|
|
576
|
-
if (!isHexString2(v) || !/^0x(?:[a-fA-F0-9]{2})*$/.test(v) || dataLength(v)
|
|
575
|
+
function envelope(v, length, version, maximum = length) {
|
|
576
|
+
if (!isHexString2(v) || !/^0x(?:[a-fA-F0-9]{2})*$/.test(v) || dataLength(v) < length || dataLength(v) > maximum)
|
|
577
577
|
throw new Error(`ciphertext must be ${length} bytes`);
|
|
578
578
|
if (version !== void 0 && Number.parseInt(v.slice(2, 4), 16) !== version)
|
|
579
579
|
throw new Error("unsupported ciphertext envelope version");
|
|
@@ -619,8 +619,9 @@ function normalizeDelivery(value, options = {}) {
|
|
|
619
619
|
}
|
|
620
620
|
const ciphertext = envelope(
|
|
621
621
|
value.ciphertext,
|
|
622
|
-
options.credit ?
|
|
623
|
-
options.credit ?
|
|
622
|
+
options.credit ? 402 : 160,
|
|
623
|
+
options.credit ? 4 : 2,
|
|
624
|
+
options.credit ? 658 : 416
|
|
624
625
|
);
|
|
625
626
|
const clue = envelope(value.clue, 68);
|
|
626
627
|
if (clue.slice(130, 132).toLowerCase() !== "18") throw new Error("clue precision must be 24");
|