@outis-wallet/agent-cli 0.1.0 → 0.1.1
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/outis.mjs +449 -1913
- package/dist/{wallet_core_bg.wasm → typed_data_bg.wasm} +0 -0
- package/package.json +16 -13
package/dist/outis.mjs
CHANGED
|
@@ -1,191 +1,203 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res, err) => function __init() {
|
|
5
|
-
if (err) throw err[0];
|
|
6
|
-
try {
|
|
7
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
-
} catch (e) {
|
|
9
|
-
throw err = [e], e;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
3
|
var __export = (target, all) => {
|
|
13
4
|
for (var name in all)
|
|
14
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
6
|
};
|
|
16
7
|
|
|
17
|
-
// ../../packages/core/src/stakingValidators.ts
|
|
18
|
-
var init_stakingValidators = __esm({
|
|
19
|
-
"../../packages/core/src/stakingValidators.ts"() {
|
|
20
|
-
"use strict";
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
8
|
// src/main.ts
|
|
25
9
|
import { parseArgs } from "node:util";
|
|
26
10
|
|
|
27
|
-
//
|
|
11
|
+
// ../typed-data/node/index.ts
|
|
28
12
|
import { readFileSync } from "node:fs";
|
|
29
13
|
import { fileURLToPath } from "node:url";
|
|
30
14
|
|
|
31
|
-
//
|
|
15
|
+
// ../typed-data/pkg/typed_data.js
|
|
16
|
+
var typed_data_exports = {};
|
|
17
|
+
__export(typed_data_exports, {
|
|
18
|
+
default: () => __wbg_init,
|
|
19
|
+
encode_value: () => encode_value,
|
|
20
|
+
initSync: () => initSync,
|
|
21
|
+
scalar: () => scalar,
|
|
22
|
+
struct_hash: () => struct_hash,
|
|
23
|
+
struct_values: () => struct_values,
|
|
24
|
+
type_hash: () => type_hash,
|
|
25
|
+
typed_data_hash: () => typed_data_hash,
|
|
26
|
+
typed_data_revision: () => typed_data_revision
|
|
27
|
+
});
|
|
32
28
|
function encode_value(types, kind, json2, revision) {
|
|
33
29
|
let deferred6_0;
|
|
34
30
|
let deferred6_1;
|
|
35
31
|
try {
|
|
36
|
-
const
|
|
37
|
-
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
32
|
+
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
33
|
const len0 = WASM_VECTOR_LEN;
|
|
39
|
-
const ptr1 = passStringToWasm0(kind, wasm.
|
|
34
|
+
const ptr1 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
35
|
const len1 = WASM_VECTOR_LEN;
|
|
41
|
-
const ptr2 = passStringToWasm0(json2, wasm.
|
|
36
|
+
const ptr2 = passStringToWasm0(json2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
37
|
const len2 = WASM_VECTOR_LEN;
|
|
43
|
-
const ptr3 = passStringToWasm0(revision, wasm.
|
|
38
|
+
const ptr3 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
44
39
|
const len3 = WASM_VECTOR_LEN;
|
|
45
|
-
wasm.encode_value(
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
50
|
-
var ptr5 = r0;
|
|
51
|
-
var len5 = r1;
|
|
52
|
-
if (r3) {
|
|
40
|
+
const ret = wasm.encode_value(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
41
|
+
var ptr5 = ret[0];
|
|
42
|
+
var len5 = ret[1];
|
|
43
|
+
if (ret[3]) {
|
|
53
44
|
ptr5 = 0;
|
|
54
45
|
len5 = 0;
|
|
55
|
-
throw
|
|
46
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
56
47
|
}
|
|
57
48
|
deferred6_0 = ptr5;
|
|
58
49
|
deferred6_1 = len5;
|
|
59
50
|
return getStringFromWasm0(ptr5, len5);
|
|
60
51
|
} finally {
|
|
61
|
-
wasm.
|
|
62
|
-
|
|
52
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function scalar(json2, kind, revision) {
|
|
56
|
+
let deferred5_0;
|
|
57
|
+
let deferred5_1;
|
|
58
|
+
try {
|
|
59
|
+
const ptr0 = passStringToWasm0(json2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ptr1 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
62
|
+
const len1 = WASM_VECTOR_LEN;
|
|
63
|
+
const ptr2 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
64
|
+
const len2 = WASM_VECTOR_LEN;
|
|
65
|
+
const ret = wasm.scalar(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
66
|
+
var ptr4 = ret[0];
|
|
67
|
+
var len4 = ret[1];
|
|
68
|
+
if (ret[3]) {
|
|
69
|
+
ptr4 = 0;
|
|
70
|
+
len4 = 0;
|
|
71
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
72
|
+
}
|
|
73
|
+
deferred5_0 = ptr4;
|
|
74
|
+
deferred5_1 = len4;
|
|
75
|
+
return getStringFromWasm0(ptr4, len4);
|
|
76
|
+
} finally {
|
|
77
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
80
|
function struct_hash(types, name, data, revision) {
|
|
66
81
|
let deferred6_0;
|
|
67
82
|
let deferred6_1;
|
|
68
83
|
try {
|
|
69
|
-
const
|
|
70
|
-
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
84
|
+
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
85
|
const len0 = WASM_VECTOR_LEN;
|
|
72
|
-
const ptr1 = passStringToWasm0(name, wasm.
|
|
86
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
73
87
|
const len1 = WASM_VECTOR_LEN;
|
|
74
|
-
const ptr2 = passStringToWasm0(data, wasm.
|
|
88
|
+
const ptr2 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
89
|
const len2 = WASM_VECTOR_LEN;
|
|
76
|
-
const ptr3 = passStringToWasm0(revision, wasm.
|
|
90
|
+
const ptr3 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
77
91
|
const len3 = WASM_VECTOR_LEN;
|
|
78
|
-
wasm.struct_hash(
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
83
|
-
var ptr5 = r0;
|
|
84
|
-
var len5 = r1;
|
|
85
|
-
if (r3) {
|
|
92
|
+
const ret = wasm.struct_hash(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
93
|
+
var ptr5 = ret[0];
|
|
94
|
+
var len5 = ret[1];
|
|
95
|
+
if (ret[3]) {
|
|
86
96
|
ptr5 = 0;
|
|
87
97
|
len5 = 0;
|
|
88
|
-
throw
|
|
98
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
89
99
|
}
|
|
90
100
|
deferred6_0 = ptr5;
|
|
91
101
|
deferred6_1 = len5;
|
|
92
102
|
return getStringFromWasm0(ptr5, len5);
|
|
93
103
|
} finally {
|
|
94
|
-
wasm.
|
|
95
|
-
wasm.__wbindgen_export3(deferred6_0, deferred6_1, 1);
|
|
104
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
107
|
function struct_values(types, name, data, revision) {
|
|
99
108
|
let deferred6_0;
|
|
100
109
|
let deferred6_1;
|
|
101
110
|
try {
|
|
102
|
-
const
|
|
103
|
-
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
111
|
+
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
104
112
|
const len0 = WASM_VECTOR_LEN;
|
|
105
|
-
const ptr1 = passStringToWasm0(name, wasm.
|
|
113
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
114
|
const len1 = WASM_VECTOR_LEN;
|
|
107
|
-
const ptr2 = passStringToWasm0(data, wasm.
|
|
115
|
+
const ptr2 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
108
116
|
const len2 = WASM_VECTOR_LEN;
|
|
109
|
-
const ptr3 = passStringToWasm0(revision, wasm.
|
|
117
|
+
const ptr3 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
110
118
|
const len3 = WASM_VECTOR_LEN;
|
|
111
|
-
wasm.struct_values(
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
116
|
-
var ptr5 = r0;
|
|
117
|
-
var len5 = r1;
|
|
118
|
-
if (r3) {
|
|
119
|
+
const ret = wasm.struct_values(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
120
|
+
var ptr5 = ret[0];
|
|
121
|
+
var len5 = ret[1];
|
|
122
|
+
if (ret[3]) {
|
|
119
123
|
ptr5 = 0;
|
|
120
124
|
len5 = 0;
|
|
121
|
-
throw
|
|
125
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
122
126
|
}
|
|
123
127
|
deferred6_0 = ptr5;
|
|
124
128
|
deferred6_1 = len5;
|
|
125
129
|
return getStringFromWasm0(ptr5, len5);
|
|
126
130
|
} finally {
|
|
127
|
-
wasm.
|
|
128
|
-
wasm.__wbindgen_export3(deferred6_0, deferred6_1, 1);
|
|
131
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
function type_hash(types, name, revision) {
|
|
132
135
|
let deferred5_0;
|
|
133
136
|
let deferred5_1;
|
|
134
137
|
try {
|
|
135
|
-
const
|
|
136
|
-
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
138
|
+
const ptr0 = passStringToWasm0(types, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
139
|
const len0 = WASM_VECTOR_LEN;
|
|
138
|
-
const ptr1 = passStringToWasm0(name, wasm.
|
|
140
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
139
141
|
const len1 = WASM_VECTOR_LEN;
|
|
140
|
-
const ptr2 = passStringToWasm0(revision, wasm.
|
|
142
|
+
const ptr2 = passStringToWasm0(revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
143
|
const len2 = WASM_VECTOR_LEN;
|
|
142
|
-
wasm.type_hash(
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
147
|
-
var ptr4 = r0;
|
|
148
|
-
var len4 = r1;
|
|
149
|
-
if (r3) {
|
|
144
|
+
const ret = wasm.type_hash(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
145
|
+
var ptr4 = ret[0];
|
|
146
|
+
var len4 = ret[1];
|
|
147
|
+
if (ret[3]) {
|
|
150
148
|
ptr4 = 0;
|
|
151
149
|
len4 = 0;
|
|
152
|
-
throw
|
|
150
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
153
151
|
}
|
|
154
152
|
deferred5_0 = ptr4;
|
|
155
153
|
deferred5_1 = len4;
|
|
156
154
|
return getStringFromWasm0(ptr4, len4);
|
|
157
155
|
} finally {
|
|
158
|
-
wasm.
|
|
159
|
-
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
156
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
159
|
function typed_data_hash(json2, account) {
|
|
163
160
|
let deferred4_0;
|
|
164
161
|
let deferred4_1;
|
|
165
162
|
try {
|
|
166
|
-
const
|
|
167
|
-
const ptr0 = passStringToWasm0(json2, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
163
|
+
const ptr0 = passStringToWasm0(json2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
168
164
|
const len0 = WASM_VECTOR_LEN;
|
|
169
|
-
const ptr1 = passStringToWasm0(account, wasm.
|
|
165
|
+
const ptr1 = passStringToWasm0(account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
166
|
const len1 = WASM_VECTOR_LEN;
|
|
171
|
-
wasm.typed_data_hash(
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
176
|
-
var ptr3 = r0;
|
|
177
|
-
var len3 = r1;
|
|
178
|
-
if (r3) {
|
|
167
|
+
const ret = wasm.typed_data_hash(ptr0, len0, ptr1, len1);
|
|
168
|
+
var ptr3 = ret[0];
|
|
169
|
+
var len3 = ret[1];
|
|
170
|
+
if (ret[3]) {
|
|
179
171
|
ptr3 = 0;
|
|
180
172
|
len3 = 0;
|
|
181
|
-
throw
|
|
173
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
182
174
|
}
|
|
183
175
|
deferred4_0 = ptr3;
|
|
184
176
|
deferred4_1 = len3;
|
|
185
177
|
return getStringFromWasm0(ptr3, len3);
|
|
186
178
|
} finally {
|
|
187
|
-
wasm.
|
|
188
|
-
|
|
179
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function typed_data_revision(json2) {
|
|
183
|
+
let deferred3_0;
|
|
184
|
+
let deferred3_1;
|
|
185
|
+
try {
|
|
186
|
+
const ptr0 = passStringToWasm0(json2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
+
const len0 = WASM_VECTOR_LEN;
|
|
188
|
+
const ret = wasm.typed_data_revision(ptr0, len0);
|
|
189
|
+
var ptr2 = ret[0];
|
|
190
|
+
var len2 = ret[1];
|
|
191
|
+
if (ret[3]) {
|
|
192
|
+
ptr2 = 0;
|
|
193
|
+
len2 = 0;
|
|
194
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
195
|
+
}
|
|
196
|
+
deferred3_0 = ptr2;
|
|
197
|
+
deferred3_1 = len2;
|
|
198
|
+
return getStringFromWasm0(ptr2, len2);
|
|
199
|
+
} finally {
|
|
200
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
function __wbg_get_imports() {
|
|
@@ -193,40 +205,26 @@ function __wbg_get_imports() {
|
|
|
193
205
|
__proto__: null,
|
|
194
206
|
__wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
|
|
195
207
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
196
|
-
return
|
|
208
|
+
return ret;
|
|
197
209
|
},
|
|
198
|
-
|
|
199
|
-
|
|
210
|
+
__wbindgen_init_externref_table: function() {
|
|
211
|
+
const table = wasm.__wbindgen_externrefs;
|
|
212
|
+
const offset = table.grow(4);
|
|
213
|
+
table.set(0, void 0);
|
|
214
|
+
table.set(offset + 0, void 0);
|
|
215
|
+
table.set(offset + 1, null);
|
|
216
|
+
table.set(offset + 2, true);
|
|
217
|
+
table.set(offset + 3, false);
|
|
200
218
|
}
|
|
201
219
|
};
|
|
202
220
|
return {
|
|
203
221
|
__proto__: null,
|
|
204
|
-
"./
|
|
222
|
+
"./typed_data_bg.js": import0
|
|
205
223
|
};
|
|
206
224
|
}
|
|
207
|
-
function addHeapObject(obj) {
|
|
208
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
209
|
-
const idx = heap_next;
|
|
210
|
-
heap_next = heap[idx];
|
|
211
|
-
heap[idx] = obj;
|
|
212
|
-
return idx;
|
|
213
|
-
}
|
|
214
|
-
function dropObject(idx) {
|
|
215
|
-
if (idx < 1028) return;
|
|
216
|
-
heap[idx] = heap_next;
|
|
217
|
-
heap_next = idx;
|
|
218
|
-
}
|
|
219
|
-
var cachedDataViewMemory0 = null;
|
|
220
|
-
function getDataViewMemory0() {
|
|
221
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
222
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
223
|
-
}
|
|
224
|
-
return cachedDataViewMemory0;
|
|
225
|
-
}
|
|
226
225
|
function getStringFromWasm0(ptr, len) {
|
|
227
226
|
return decodeText(ptr >>> 0, len);
|
|
228
227
|
}
|
|
229
|
-
var cachedUint32ArrayMemory0 = null;
|
|
230
228
|
var cachedUint8ArrayMemory0 = null;
|
|
231
229
|
function getUint8ArrayMemory0() {
|
|
232
230
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
@@ -234,12 +232,6 @@ function getUint8ArrayMemory0() {
|
|
|
234
232
|
}
|
|
235
233
|
return cachedUint8ArrayMemory0;
|
|
236
234
|
}
|
|
237
|
-
function getObject(idx) {
|
|
238
|
-
return heap[idx];
|
|
239
|
-
}
|
|
240
|
-
var heap = new Array(1024).fill(void 0);
|
|
241
|
-
heap.push(void 0, null, true, false);
|
|
242
|
-
var heap_next = heap.length;
|
|
243
235
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
244
236
|
if (realloc === void 0) {
|
|
245
237
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -270,10 +262,10 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
270
262
|
WASM_VECTOR_LEN = offset;
|
|
271
263
|
return ptr;
|
|
272
264
|
}
|
|
273
|
-
function
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
return
|
|
265
|
+
function takeFromExternrefTable0(idx) {
|
|
266
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
267
|
+
wasm.__externref_table_dealloc(idx);
|
|
268
|
+
return value;
|
|
277
269
|
}
|
|
278
270
|
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
279
271
|
cachedTextDecoder.decode();
|
|
@@ -307,9 +299,8 @@ function __wbg_finalize_init(instance, module) {
|
|
|
307
299
|
wasmInstance = instance;
|
|
308
300
|
wasm = instance.exports;
|
|
309
301
|
wasmModule = module;
|
|
310
|
-
cachedDataViewMemory0 = null;
|
|
311
|
-
cachedUint32ArrayMemory0 = null;
|
|
312
302
|
cachedUint8ArrayMemory0 = null;
|
|
303
|
+
wasm.__wbindgen_start();
|
|
313
304
|
return wasm;
|
|
314
305
|
}
|
|
315
306
|
async function __wbg_load(module, imports) {
|
|
@@ -349,6 +340,22 @@ async function __wbg_load(module, imports) {
|
|
|
349
340
|
return false;
|
|
350
341
|
}
|
|
351
342
|
}
|
|
343
|
+
function initSync(module) {
|
|
344
|
+
if (wasm !== void 0) return wasm;
|
|
345
|
+
if (module !== void 0) {
|
|
346
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
347
|
+
({ module } = module);
|
|
348
|
+
} else {
|
|
349
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const imports = __wbg_get_imports();
|
|
353
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
354
|
+
module = new WebAssembly.Module(module);
|
|
355
|
+
}
|
|
356
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
357
|
+
return __wbg_finalize_init(instance, module);
|
|
358
|
+
}
|
|
352
359
|
async function __wbg_init(module_or_path) {
|
|
353
360
|
if (wasm !== void 0) return wasm;
|
|
354
361
|
if (module_or_path !== void 0) {
|
|
@@ -359,7 +366,7 @@ async function __wbg_init(module_or_path) {
|
|
|
359
366
|
}
|
|
360
367
|
}
|
|
361
368
|
if (module_or_path === void 0) {
|
|
362
|
-
module_or_path = new URL("
|
|
369
|
+
module_or_path = new URL("typed_data_bg.wasm", import.meta.url);
|
|
363
370
|
}
|
|
364
371
|
const imports = __wbg_get_imports();
|
|
365
372
|
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
@@ -369,52 +376,90 @@ async function __wbg_init(module_or_path) {
|
|
|
369
376
|
return __wbg_finalize_init(instance, module);
|
|
370
377
|
}
|
|
371
378
|
|
|
372
|
-
//
|
|
379
|
+
// ../typed-data/src/reader.ts
|
|
380
|
+
var hex = (value) => `0x${value.toString(16)}`;
|
|
381
|
+
var json = (data) => JSON.stringify(data, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
382
|
+
function typedDataReader(module) {
|
|
383
|
+
return {
|
|
384
|
+
/**
|
|
385
|
+
* The hash `account` signs for the typed data `data` (SNIP-12, revisions 0 and 1, as starknet.js
|
|
386
|
+
* hashes it). Throws for what starknet.js couldn't hash, and for what it would hash though it can
|
|
387
|
+
* be read two ways: a type or field name with a separator in it.
|
|
388
|
+
*/
|
|
389
|
+
typedDataHash(account, data) {
|
|
390
|
+
return BigInt(module().typed_data_hash(json(data), hex(account)));
|
|
391
|
+
},
|
|
392
|
+
/**
|
|
393
|
+
* The revision `data` is hashed under, as starknet.js decides it: "1" where the types have a
|
|
394
|
+
* StarknetDomain and the domain's revision reads "1" (as text or as a number), "0" where they have
|
|
395
|
+
* a StarkNetDomain and the domain no revision or the text "0", and none otherwise: starknet.js
|
|
396
|
+
* won't hash such a message at all.
|
|
397
|
+
*/
|
|
398
|
+
typedDataRevision(data) {
|
|
399
|
+
const core = module();
|
|
400
|
+
try {
|
|
401
|
+
return core.typed_data_revision(json(data));
|
|
402
|
+
} catch {
|
|
403
|
+
return void 0;
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* The felt `value` is hashed as where a scalar `kind` goes (felt, shortstring, u128, i128,
|
|
408
|
+
* ContractAddress, ClassHash, timestamp, bool, selector) under `revision`: what a message's field
|
|
409
|
+
* is shown as, by the hash's own reading of it (a string that reads as a number is that number,
|
|
410
|
+
* other text a short string where the kind takes one). Throws where starknet.js wouldn't hash it.
|
|
411
|
+
*/
|
|
412
|
+
scalarFelt(value, kind, revision) {
|
|
413
|
+
return BigInt(module().scalar(json(value), kind, revision));
|
|
414
|
+
},
|
|
415
|
+
/**
|
|
416
|
+
* starknet.js's getStructHash: `data` hashed as the struct `type` among `types` under `revision`.
|
|
417
|
+
* The types are read as a message's are, so a name with a separator in it throws, as a message of
|
|
418
|
+
* those types would.
|
|
419
|
+
*/
|
|
420
|
+
structHash(types, type, data, revision) {
|
|
421
|
+
return BigInt(module().struct_hash(json(types), type, json(data), revision));
|
|
422
|
+
},
|
|
423
|
+
/** starknet.js's getTypeHash: the hash of `type`'s encoding among `types` under `revision`; the types read as structHash reads them. */
|
|
424
|
+
typeHash(types, type, revision) {
|
|
425
|
+
return BigInt(module().type_hash(json(types), type, revision));
|
|
426
|
+
},
|
|
427
|
+
/** starknet.js's encodeData's values: the type hash of `type`, then each of its fields of `data` encoded, under `revision`. */
|
|
428
|
+
structValues(types, type, data, revision) {
|
|
429
|
+
return JSON.parse(module().struct_values(json(types), type, json(data), revision)).map(BigInt);
|
|
430
|
+
},
|
|
431
|
+
/** starknet.js's encodeValue, outside any struct: `value` encoded as `kind` among `types` (a struct of theirs, a list, a string, a scalar) under `revision`. */
|
|
432
|
+
encodeValue(types, kind, value, revision) {
|
|
433
|
+
return BigInt(module().encode_value(json(types), kind, json(value), revision));
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// ../typed-data/src/index.ts
|
|
373
439
|
var loading;
|
|
374
440
|
var loaded = false;
|
|
375
|
-
function
|
|
376
|
-
loading ??= __wbg_init({ module_or_path: source ?? new URL("../pkg/
|
|
441
|
+
function loadTypedData(source) {
|
|
442
|
+
loading ??= __wbg_init({ module_or_path: source ?? new URL("../pkg/typed_data_bg.wasm", import.meta.url) }).then(() => {
|
|
377
443
|
loaded = true;
|
|
378
444
|
});
|
|
379
445
|
return loading;
|
|
380
446
|
}
|
|
381
|
-
|
|
382
|
-
if (!loaded) throw new Error("The
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
var json = (data) => JSON.stringify(data, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
386
|
-
function typedDataHash(account, data) {
|
|
387
|
-
core();
|
|
388
|
-
return BigInt(typed_data_hash(json(data), hex(account)));
|
|
389
|
-
}
|
|
390
|
-
function structHash(types, type, data, revision) {
|
|
391
|
-
core();
|
|
392
|
-
return BigInt(struct_hash(json(types), type, json(data), revision));
|
|
393
|
-
}
|
|
394
|
-
function typeHash(types, type, revision) {
|
|
395
|
-
core();
|
|
396
|
-
return BigInt(type_hash(json(types), type, revision));
|
|
397
|
-
}
|
|
398
|
-
function structValues(types, type, data, revision) {
|
|
399
|
-
core();
|
|
400
|
-
return JSON.parse(struct_values(json(types), type, json(data), revision)).map(BigInt);
|
|
401
|
-
}
|
|
402
|
-
function encodeValue(types, kind, value, revision) {
|
|
403
|
-
core();
|
|
404
|
-
return BigInt(encode_value(json(types), kind, json(value), revision));
|
|
405
|
-
}
|
|
447
|
+
var { typedDataHash, typedDataRevision, scalarFelt, structHash, typeHash, structValues, encodeValue } = typedDataReader(() => {
|
|
448
|
+
if (!loaded) throw new Error("The typed-data module isn't loaded: await loadTypedData() first");
|
|
449
|
+
return typed_data_exports;
|
|
450
|
+
});
|
|
406
451
|
|
|
407
|
-
//
|
|
408
|
-
var
|
|
409
|
-
function
|
|
452
|
+
// ../typed-data/node/index.ts
|
|
453
|
+
var TYPED_DATA_MODULE = new URL("../pkg/typed_data_bg.wasm", import.meta.url);
|
|
454
|
+
function loadTypedDataFromFile(module = TYPED_DATA_MODULE) {
|
|
410
455
|
const path = module instanceof URL ? fileURLToPath(module) : module;
|
|
411
456
|
let bytes;
|
|
412
457
|
try {
|
|
413
458
|
bytes = readFileSync(path);
|
|
414
459
|
} catch {
|
|
415
|
-
throw new Error(`No
|
|
460
|
+
throw new Error(`No typed-data module at ${path}: run \`pnpm --filter @outis-wallet/typed-data build:wasm\` first`);
|
|
416
461
|
}
|
|
417
|
-
return
|
|
462
|
+
return loadTypedData(bytes);
|
|
418
463
|
}
|
|
419
464
|
|
|
420
465
|
// ../../node_modules/.pnpm/@starknet-io+types-js@0.9.2/node_modules/@starknet-io/types-js/dist/esm/index.js
|
|
@@ -964,9 +1009,9 @@ function anumArr(label, input) {
|
|
|
964
1009
|
function chain(...args) {
|
|
965
1010
|
const id = (a) => a;
|
|
966
1011
|
const wrap = (a, b) => (c) => a(b(c));
|
|
967
|
-
const
|
|
1012
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
968
1013
|
const decode = args.map((x) => x.decode).reduce(wrap, id);
|
|
969
|
-
return { encode
|
|
1014
|
+
return { encode, decode };
|
|
970
1015
|
}
|
|
971
1016
|
// @__NO_SIDE_EFFECTS__
|
|
972
1017
|
function alphabet(letters) {
|
|
@@ -1119,7 +1164,7 @@ var base64 = hasBase64Builtin ? {
|
|
|
1119
1164
|
}
|
|
1120
1165
|
} : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */ join(""));
|
|
1121
1166
|
|
|
1122
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1167
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/utils.js
|
|
1123
1168
|
function isInteger(value) {
|
|
1124
1169
|
return INTEGER_REGEX.test(value);
|
|
1125
1170
|
}
|
|
@@ -1133,6 +1178,9 @@ function isSafeNumber(value, config3) {
|
|
|
1133
1178
|
return Number.isSafeInteger(Number.parseInt(value, 10));
|
|
1134
1179
|
}
|
|
1135
1180
|
const num = Number.parseFloat(value);
|
|
1181
|
+
if (Number.isInteger(num) && !Number.isSafeInteger(num)) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1136
1184
|
const parsed = String(num);
|
|
1137
1185
|
if (value === parsed) {
|
|
1138
1186
|
return true;
|
|
@@ -1144,7 +1192,7 @@ function isSafeNumber(value, config3) {
|
|
|
1144
1192
|
}
|
|
1145
1193
|
if (config3?.approx === true) {
|
|
1146
1194
|
const requiredDigits = 14;
|
|
1147
|
-
if (
|
|
1195
|
+
if (parsedDigits.length >= requiredDigits && valueDigits.startsWith(parsedDigits.substring(0, requiredDigits))) {
|
|
1148
1196
|
return true;
|
|
1149
1197
|
}
|
|
1150
1198
|
}
|
|
@@ -1211,11 +1259,21 @@ function getSignificantDigitRange(value) {
|
|
|
1211
1259
|
};
|
|
1212
1260
|
}
|
|
1213
1261
|
|
|
1214
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1262
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/LosslessNumber.js
|
|
1263
|
+
var losslessNumberMarker = /* @__PURE__ */ Symbol.for("lossless-json.LosslessNumber");
|
|
1215
1264
|
var LosslessNumber = class {
|
|
1216
1265
|
// numeric value as string
|
|
1217
|
-
|
|
1266
|
+
value;
|
|
1267
|
+
/**
|
|
1268
|
+
* @deprecated Use the isLosslessNumber(value) function instead.
|
|
1269
|
+
*
|
|
1270
|
+
* Ordinary objects may also have an isLosslessNumber property, so this
|
|
1271
|
+
* field cannot reliably identify lossless numbers.
|
|
1272
|
+
*/
|
|
1218
1273
|
isLosslessNumber = true;
|
|
1274
|
+
get [losslessNumberMarker]() {
|
|
1275
|
+
return true;
|
|
1276
|
+
}
|
|
1219
1277
|
constructor(value) {
|
|
1220
1278
|
if (!isNumber(value)) {
|
|
1221
1279
|
throw new Error(`Invalid number (value: "${value}")`);
|
|
@@ -1254,10 +1312,10 @@ var LosslessNumber = class {
|
|
|
1254
1312
|
// stringified JSON since it has to be parsed into a number first.
|
|
1255
1313
|
};
|
|
1256
1314
|
function isLosslessNumber(value) {
|
|
1257
|
-
return value && typeof value === "object" && value
|
|
1315
|
+
return value !== null && typeof value === "object" && value[losslessNumberMarker] === true;
|
|
1258
1316
|
}
|
|
1259
1317
|
|
|
1260
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1318
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/numberParsers.js
|
|
1261
1319
|
function parseLosslessNumber(value) {
|
|
1262
1320
|
return new LosslessNumber(value);
|
|
1263
1321
|
}
|
|
@@ -1265,7 +1323,7 @@ function parseNumberAndBigInt(value) {
|
|
|
1265
1323
|
return isInteger(value) ? BigInt(value) : Number.parseFloat(value);
|
|
1266
1324
|
}
|
|
1267
1325
|
|
|
1268
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1326
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/revive.js
|
|
1269
1327
|
function revive(json2, reviver) {
|
|
1270
1328
|
return reviveValue({
|
|
1271
1329
|
"": json2
|
|
@@ -1293,12 +1351,17 @@ function reviveObject(object, reviver) {
|
|
|
1293
1351
|
}
|
|
1294
1352
|
function reviveArray(array, reviver) {
|
|
1295
1353
|
for (let i = 0; i < array.length; i++) {
|
|
1296
|
-
|
|
1354
|
+
const value = reviveValue(array, String(i), array[i], reviver);
|
|
1355
|
+
if (value === void 0) {
|
|
1356
|
+
delete array[i];
|
|
1357
|
+
} else {
|
|
1358
|
+
array[i] = value;
|
|
1359
|
+
}
|
|
1297
1360
|
}
|
|
1298
1361
|
return array;
|
|
1299
1362
|
}
|
|
1300
1363
|
|
|
1301
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1364
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/parse.js
|
|
1302
1365
|
function parse(text, reviver, options) {
|
|
1303
1366
|
const optionsObj = typeof options === "function" ? {
|
|
1304
1367
|
parseNumber: options
|
|
@@ -1344,10 +1407,10 @@ function parse(text, reviver, options) {
|
|
|
1344
1407
|
newValue: value2
|
|
1345
1408
|
});
|
|
1346
1409
|
if (returnedValue !== void 0) {
|
|
1347
|
-
object
|
|
1410
|
+
setObjectKey(object, key, returnedValue);
|
|
1348
1411
|
}
|
|
1349
1412
|
} else {
|
|
1350
|
-
object
|
|
1413
|
+
setObjectKey(object, key, value2);
|
|
1351
1414
|
}
|
|
1352
1415
|
}
|
|
1353
1416
|
if (text.charCodeAt(i) !== codeClosingBrace) {
|
|
@@ -1445,6 +1508,8 @@ function parse(text, reviver, options) {
|
|
|
1445
1508
|
while (isDigit(text.charCodeAt(i))) {
|
|
1446
1509
|
i++;
|
|
1447
1510
|
}
|
|
1511
|
+
} else {
|
|
1512
|
+
return void 0;
|
|
1448
1513
|
}
|
|
1449
1514
|
if (text.charCodeAt(i) === codeDot) {
|
|
1450
1515
|
i++;
|
|
@@ -1508,11 +1573,10 @@ function parse(text, reviver, options) {
|
|
|
1508
1573
|
function throwObjectKeyExpected() {
|
|
1509
1574
|
throw new SyntaxError(`Quoted object key expected ${gotAt()}`);
|
|
1510
1575
|
}
|
|
1511
|
-
function throwDuplicateKey(
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
} = _ref;
|
|
1576
|
+
function throwDuplicateKey({
|
|
1577
|
+
key,
|
|
1578
|
+
position
|
|
1579
|
+
}) {
|
|
1516
1580
|
throw new SyntaxError(`Duplicate key '${key}' encountered at position ${position}`);
|
|
1517
1581
|
}
|
|
1518
1582
|
function throwObjectKeyOrEndExpected() {
|
|
@@ -1545,6 +1609,18 @@ function parse(text, reviver, options) {
|
|
|
1545
1609
|
return `${got()} ${pos()}`;
|
|
1546
1610
|
}
|
|
1547
1611
|
}
|
|
1612
|
+
function setObjectKey(object, key, value) {
|
|
1613
|
+
if (key === "__proto__") {
|
|
1614
|
+
Object.defineProperty(object, key, {
|
|
1615
|
+
value,
|
|
1616
|
+
writable: true,
|
|
1617
|
+
enumerable: true,
|
|
1618
|
+
configurable: true
|
|
1619
|
+
});
|
|
1620
|
+
} else {
|
|
1621
|
+
object[key] = value;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1548
1624
|
function isWhitespace(code) {
|
|
1549
1625
|
return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
|
|
1550
1626
|
}
|
|
@@ -1612,7 +1688,7 @@ var codeLowercaseE = 101;
|
|
|
1612
1688
|
var codeUppercaseF = 70;
|
|
1613
1689
|
var codeLowercaseF = 102;
|
|
1614
1690
|
|
|
1615
|
-
// ../../node_modules/.pnpm/lossless-json@4.3.
|
|
1691
|
+
// ../../node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/stringify.js
|
|
1616
1692
|
function stringify(value, replacer, space, numberStringifiers) {
|
|
1617
1693
|
const resolvedSpace = resolveSpace(space);
|
|
1618
1694
|
const replacedValue = typeof replacer === "function" ? replacer.call({
|
|
@@ -1633,7 +1709,7 @@ function stringify(value, replacer, space, numberStringifiers) {
|
|
|
1633
1709
|
if (typeof value2 === "boolean" || typeof value2 === "number" || typeof value2 === "string" || value2 === null || value2 instanceof Date || value2 instanceof Boolean || value2 instanceof Number || value2 instanceof String) {
|
|
1634
1710
|
return JSON.stringify(value2);
|
|
1635
1711
|
}
|
|
1636
|
-
if (value2
|
|
1712
|
+
if (isLosslessNumber(value2)) {
|
|
1637
1713
|
return value2.toString();
|
|
1638
1714
|
}
|
|
1639
1715
|
if (typeof value2 === "bigint") {
|
|
@@ -1659,7 +1735,8 @@ function stringify(value, replacer, space, numberStringifiers) {
|
|
|
1659
1735
|
str += childIndent;
|
|
1660
1736
|
}
|
|
1661
1737
|
if (typeof item !== "undefined" && typeof item !== "function") {
|
|
1662
|
-
|
|
1738
|
+
const serialized = stringifyValue(item, childIndent);
|
|
1739
|
+
str += serialized === void 0 ? "null" : serialized;
|
|
1663
1740
|
} else {
|
|
1664
1741
|
str += "null";
|
|
1665
1742
|
}
|
|
@@ -1673,9 +1750,9 @@ ${indent}]` : "]";
|
|
|
1673
1750
|
}
|
|
1674
1751
|
function stringifyObject(object, indent) {
|
|
1675
1752
|
if (typeof object.toJSON === "function") {
|
|
1676
|
-
return
|
|
1753
|
+
return stringifyValue(object.toJSON(), indent);
|
|
1677
1754
|
}
|
|
1678
|
-
const keys = Array.isArray(replacer) ? replacer.map(String) : Object.keys(object);
|
|
1755
|
+
const keys = Array.isArray(replacer) ? [...new Set(replacer.map(String))] : Object.keys(object);
|
|
1679
1756
|
if (keys.length === 0) {
|
|
1680
1757
|
return "{}";
|
|
1681
1758
|
}
|
|
@@ -1685,6 +1762,10 @@ ${indent}]` : "]";
|
|
|
1685
1762
|
for (const key of keys) {
|
|
1686
1763
|
const value2 = typeof replacer === "function" ? replacer.call(object, key, object[key]) : object[key];
|
|
1687
1764
|
if (includeProperty(key, value2)) {
|
|
1765
|
+
const serialized = stringifyValue(value2, childIndent);
|
|
1766
|
+
if (serialized === void 0) {
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1688
1769
|
if (first) {
|
|
1689
1770
|
first = false;
|
|
1690
1771
|
} else {
|
|
@@ -1692,7 +1773,7 @@ ${indent}]` : "]";
|
|
|
1692
1773
|
}
|
|
1693
1774
|
const keyStr = JSON.stringify(key);
|
|
1694
1775
|
str += resolvedSpace ? `${childIndent + keyStr}: ` : `${keyStr}:`;
|
|
1695
|
-
str +=
|
|
1776
|
+
str += serialized;
|
|
1696
1777
|
}
|
|
1697
1778
|
}
|
|
1698
1779
|
str += resolvedSpace ? `
|
|
@@ -1703,12 +1784,14 @@ ${indent}}` : "}";
|
|
|
1703
1784
|
return typeof value2 !== "undefined" && typeof value2 !== "function" && typeof value2 !== "symbol";
|
|
1704
1785
|
}
|
|
1705
1786
|
}
|
|
1787
|
+
var MAX_SPACE_LENGTH = 10;
|
|
1706
1788
|
function resolveSpace(space) {
|
|
1707
1789
|
if (typeof space === "number") {
|
|
1708
|
-
|
|
1790
|
+
const count = Math.min(Math.trunc(space), MAX_SPACE_LENGTH);
|
|
1791
|
+
return count >= 1 ? " ".repeat(count) : void 0;
|
|
1709
1792
|
}
|
|
1710
1793
|
if (typeof space === "string" && space !== "") {
|
|
1711
|
-
return space;
|
|
1794
|
+
return space.slice(0, MAX_SPACE_LENGTH);
|
|
1712
1795
|
}
|
|
1713
1796
|
return void 0;
|
|
1714
1797
|
}
|
|
@@ -3888,7 +3971,7 @@ function weierstrass(curveDef) {
|
|
|
3888
3971
|
return point;
|
|
3889
3972
|
}
|
|
3890
3973
|
};
|
|
3891
|
-
function
|
|
3974
|
+
function getPublicKey2(privateKey, isCompressed = true) {
|
|
3892
3975
|
return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
|
3893
3976
|
}
|
|
3894
3977
|
function isProbPub(item) {
|
|
@@ -4030,7 +4113,7 @@ function weierstrass(curveDef) {
|
|
|
4030
4113
|
}
|
|
4031
4114
|
return {
|
|
4032
4115
|
CURVE: CURVE2,
|
|
4033
|
-
getPublicKey:
|
|
4116
|
+
getPublicKey: getPublicKey2,
|
|
4034
4117
|
getSharedSecret: getSharedSecret3,
|
|
4035
4118
|
sign: sign3,
|
|
4036
4119
|
verify: verify2,
|
|
@@ -4175,7 +4258,7 @@ function aoutput2(out, instance) {
|
|
|
4175
4258
|
|
|
4176
4259
|
// ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
4177
4260
|
import * as nc from "node:crypto";
|
|
4178
|
-
var
|
|
4261
|
+
var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
4179
4262
|
|
|
4180
4263
|
// ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/utils.js
|
|
4181
4264
|
var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
@@ -4221,11 +4304,11 @@ function wrapConstructor2(hashCons) {
|
|
|
4221
4304
|
return hashC;
|
|
4222
4305
|
}
|
|
4223
4306
|
function randomBytes(bytesLength = 32) {
|
|
4224
|
-
if (
|
|
4225
|
-
return
|
|
4307
|
+
if (crypto && typeof crypto.getRandomValues === "function") {
|
|
4308
|
+
return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
4226
4309
|
}
|
|
4227
|
-
if (
|
|
4228
|
-
return
|
|
4310
|
+
if (crypto && typeof crypto.randomBytes === "function") {
|
|
4311
|
+
return crypto.randomBytes(bytesLength);
|
|
4229
4312
|
}
|
|
4230
4313
|
throw new Error("crypto.getRandomValues must be defined");
|
|
4231
4314
|
}
|
|
@@ -5405,10 +5488,10 @@ var ETransactionVersion33 = {
|
|
|
5405
5488
|
F3: ETransactionVersion5.F3
|
|
5406
5489
|
};
|
|
5407
5490
|
|
|
5408
|
-
// ../../node_modules/.pnpm/starknet@10.8.0_typescript@7.0.2_zod@4.6.
|
|
5491
|
+
// ../../node_modules/.pnpm/starknet@10.8.0_typescript@7.0.2_zod@4.6.7/node_modules/starknet/dist/index.mjs
|
|
5409
5492
|
var __defProp2 = Object.defineProperty;
|
|
5410
5493
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5411
|
-
var
|
|
5494
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5412
5495
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5413
5496
|
var __export2 = (target, all) => {
|
|
5414
5497
|
for (var name in all)
|
|
@@ -5416,7 +5499,7 @@ var __export2 = (target, all) => {
|
|
|
5416
5499
|
};
|
|
5417
5500
|
var __copyProps = (to, from, except, desc) => {
|
|
5418
5501
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
5419
|
-
for (let key of
|
|
5502
|
+
for (let key of __getOwnPropNames(from))
|
|
5420
5503
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
5421
5504
|
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
5422
5505
|
}
|
|
@@ -10162,8 +10245,8 @@ function calculateDeclareTransactionHash2(classHash, senderAddress, version, max
|
|
|
10162
10245
|
[nonce, ...compiledClassHash ? [compiledClassHash] : []]
|
|
10163
10246
|
);
|
|
10164
10247
|
}
|
|
10165
|
-
function calculateDeployAccountTransactionHash2(contractAddress, classHash,
|
|
10166
|
-
const calldata = [classHash, salt, ...
|
|
10248
|
+
function calculateDeployAccountTransactionHash2(contractAddress, classHash, constructorCalldata, salt, version, maxFee2, chainId, nonce) {
|
|
10249
|
+
const calldata = [classHash, salt, ...constructorCalldata];
|
|
10167
10250
|
return calculateTransactionHashCommon2(
|
|
10168
10251
|
_TransactionHashPrefix.DEPLOY_ACCOUNT,
|
|
10169
10252
|
version,
|
|
@@ -10301,8 +10384,8 @@ function flattenEntryPointData(data, encodedBuiltinsArray) {
|
|
|
10301
10384
|
...encodedBuiltinsArray[index]
|
|
10302
10385
|
]);
|
|
10303
10386
|
}
|
|
10304
|
-
function calculateContractAddressFromHash(salt, classHash,
|
|
10305
|
-
const compiledCalldata = CallData.compile(
|
|
10387
|
+
function calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress) {
|
|
10388
|
+
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
10306
10389
|
const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
|
|
10307
10390
|
const CONTRACT_ADDRESS_PREFIX = felt("0x535441524b4e45545f434f4e54524143545f41444452455353");
|
|
10308
10391
|
const hash = computeHashOnElements2([
|
|
@@ -10367,8 +10450,8 @@ function hashByteCodeSegments(casm) {
|
|
|
10367
10450
|
const bytecodeSegmentLengths = casm.bytecode_segment_lengths ?? [];
|
|
10368
10451
|
let segmentStart = 0;
|
|
10369
10452
|
const hashLeaves = bytecodeSegmentLengths.flatMap((len) => {
|
|
10370
|
-
const
|
|
10371
|
-
return [BigInt(len), poseidonHashMany(
|
|
10453
|
+
const segment = byteCode.slice(segmentStart, segmentStart += len);
|
|
10454
|
+
return [BigInt(len), poseidonHashMany(segment)];
|
|
10372
10455
|
});
|
|
10373
10456
|
return 1n + poseidonHashMany(hashLeaves);
|
|
10374
10457
|
}
|
|
@@ -12646,7 +12729,7 @@ function encodeData(types, type, data, revision = api_exports3.TypedDataRevision
|
|
|
12646
12729
|
function getStructHash(types, type, data, revision = api_exports3.TypedDataRevision.LEGACY) {
|
|
12647
12730
|
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
12648
12731
|
}
|
|
12649
|
-
function getMessageHash(typedData,
|
|
12732
|
+
function getMessageHash(typedData, accountAddress) {
|
|
12650
12733
|
if (!validateTypedData(typedData)) {
|
|
12651
12734
|
throw new Error("Typed data does not match JSON schema");
|
|
12652
12735
|
}
|
|
@@ -12655,25 +12738,25 @@ function getMessageHash(typedData, accountAddress2) {
|
|
|
12655
12738
|
const message = [
|
|
12656
12739
|
encodeShortString("StarkNet Message"),
|
|
12657
12740
|
getStructHash(typedData.types, domain, typedData.domain, revision),
|
|
12658
|
-
|
|
12741
|
+
accountAddress,
|
|
12659
12742
|
getStructHash(typedData.types, typedData.primaryType, typedData.message, revision)
|
|
12660
12743
|
];
|
|
12661
12744
|
return hashMethod(message);
|
|
12662
12745
|
}
|
|
12663
|
-
function verifyMessage(message, signature, fullPublicKey,
|
|
12746
|
+
function verifyMessage(message, signature, fullPublicKey, accountAddress) {
|
|
12664
12747
|
const isTypedData = validateTypedData(message);
|
|
12665
12748
|
if (!isBigNumberish(message) && !isTypedData) {
|
|
12666
12749
|
throw new Error("message has a wrong format.");
|
|
12667
12750
|
}
|
|
12668
|
-
if (isTypedData &&
|
|
12751
|
+
if (isTypedData && accountAddress === void 0) {
|
|
12669
12752
|
throw new Error(
|
|
12670
12753
|
"When providing a TypedData in message parameter, the accountAddress parameter has to be provided."
|
|
12671
12754
|
);
|
|
12672
12755
|
}
|
|
12673
|
-
if (isTypedData && !isBigNumberish(
|
|
12756
|
+
if (isTypedData && !isBigNumberish(accountAddress)) {
|
|
12674
12757
|
throw new Error("accountAddress shall be a BigNumberish");
|
|
12675
12758
|
}
|
|
12676
|
-
const messageHash = isTypedData ? getMessageHash(message,
|
|
12759
|
+
const messageHash = isTypedData ? getMessageHash(message, accountAddress) : toHex(message);
|
|
12677
12760
|
const sign3 = Array.isArray(signature) ? new Signature(BigInt(signature[0]), BigInt(signature[1])) : signature;
|
|
12678
12761
|
const fullPubKey = toHex(fullPublicKey);
|
|
12679
12762
|
const isValid = verify(sign3, messageHash, fullPubKey);
|
|
@@ -13602,18 +13685,18 @@ var Deployer = class {
|
|
|
13602
13685
|
salt,
|
|
13603
13686
|
unique = true,
|
|
13604
13687
|
// not_from_zero on v.2.0.0 but same function. When false v.1 address != v.2 address
|
|
13605
|
-
constructorCalldata
|
|
13688
|
+
constructorCalldata = [],
|
|
13606
13689
|
abi
|
|
13607
13690
|
} = it;
|
|
13608
|
-
const compiledConstructorCallData = getCompiledCalldata(
|
|
13691
|
+
const compiledConstructorCallData = getCompiledCalldata(constructorCalldata, () => {
|
|
13609
13692
|
if (abi) {
|
|
13610
13693
|
const calldataClass = new CallData(abi);
|
|
13611
|
-
if (Array.isArray(
|
|
13612
|
-
calldataClass.validate(ValidateType.DEPLOY, "constructor",
|
|
13694
|
+
if (Array.isArray(constructorCalldata)) {
|
|
13695
|
+
calldataClass.validate(ValidateType.DEPLOY, "constructor", constructorCalldata);
|
|
13613
13696
|
}
|
|
13614
|
-
return calldataClass.compile("constructor",
|
|
13697
|
+
return calldataClass.compile("constructor", constructorCalldata);
|
|
13615
13698
|
}
|
|
13616
|
-
return CallData.compile(
|
|
13699
|
+
return CallData.compile(constructorCalldata);
|
|
13617
13700
|
});
|
|
13618
13701
|
const deploySalt = salt ?? randomAddress();
|
|
13619
13702
|
return {
|
|
@@ -14072,17 +14155,7 @@ function filterEventsByAddress(events, contractAddress) {
|
|
|
14072
14155
|
}
|
|
14073
14156
|
var export_TypedDataRevision = api_exports3.TypedDataRevision;
|
|
14074
14157
|
|
|
14075
|
-
//
|
|
14076
|
-
var STARKNET_SIGNER_TYPE = BigInt(shortString_exports.encodeShortString("Starknet Signer"));
|
|
14077
|
-
function assertValidSigner(signer) {
|
|
14078
|
-
if (signer.pubkey === 0n) throw new Error("Signer public key cannot be zero");
|
|
14079
|
-
}
|
|
14080
|
-
function signerGuid(signer) {
|
|
14081
|
-
assertValidSigner(signer);
|
|
14082
|
-
return BigInt(hash_exports.computePoseidonHash(STARKNET_SIGNER_TYPE, signer.pubkey));
|
|
14083
|
-
}
|
|
14084
|
-
|
|
14085
|
-
// ../../packages/core/src/account.ts
|
|
14158
|
+
// ../agent/src/core/account.ts
|
|
14086
14159
|
function selector(name) {
|
|
14087
14160
|
return BigInt(hash_exports.getSelectorFromName(name));
|
|
14088
14161
|
}
|
|
@@ -14090,496 +14163,103 @@ function executeCalldata(calls) {
|
|
|
14090
14163
|
return [BigInt(calls.length), ...calls.flatMap((call2) => [call2.to, call2.selector, BigInt(call2.calldata.length), ...call2.calldata])];
|
|
14091
14164
|
}
|
|
14092
14165
|
|
|
14093
|
-
//
|
|
14094
|
-
var
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
const l = fromNumL(n);
|
|
14099
|
-
view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
|
|
14100
|
-
view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
|
|
14101
|
-
}
|
|
14102
|
-
|
|
14103
|
-
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js
|
|
14104
|
-
function isBytes5(a) {
|
|
14105
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
14106
|
-
}
|
|
14107
|
-
var atitle = (title) => title ? `"${title}" ` : "";
|
|
14108
|
-
function anumber4(n, title = "") {
|
|
14109
|
-
if (typeof n !== "number")
|
|
14110
|
-
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
14111
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
14112
|
-
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
14113
|
-
return n;
|
|
14114
|
-
}
|
|
14115
|
-
function abytes5(value, length, title = "") {
|
|
14116
|
-
if (isBytes5(value) && (length === void 0 || value.length === length))
|
|
14117
|
-
return value;
|
|
14118
|
-
if (length !== void 0)
|
|
14119
|
-
anumber4(length, "length");
|
|
14120
|
-
const bytes = isBytes5(value);
|
|
14121
|
-
const ofLen = length !== void 0 ? ` of length ${length}` : "";
|
|
14122
|
-
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
14123
|
-
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
14124
|
-
if (!bytes)
|
|
14125
|
-
throw new TypeError(message);
|
|
14126
|
-
throw new RangeError(message);
|
|
14127
|
-
}
|
|
14128
|
-
var aobject = (value, label) => {
|
|
14129
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
14130
|
-
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
14131
|
-
};
|
|
14132
|
-
var aopts = (value, label) => {
|
|
14133
|
-
aobject(value, label);
|
|
14134
|
-
const proto = Object.getPrototypeOf(value);
|
|
14135
|
-
if (proto !== Object.prototype && proto !== null)
|
|
14136
|
-
throw new TypeError(`"${label}" expected plain object`);
|
|
14137
|
-
if (Object.hasOwn(value, "__proto__"))
|
|
14138
|
-
throw new TypeError(`"${label}.__proto__" is not allowed`);
|
|
14139
|
-
};
|
|
14140
|
-
function aexists3(instance, checkFinished = true) {
|
|
14141
|
-
if (instance.destroyed)
|
|
14142
|
-
throw new Error("hash was destroyed");
|
|
14143
|
-
if (checkFinished && instance.finished)
|
|
14144
|
-
throw new Error("digest() was already called");
|
|
14166
|
+
// ../agent/src/core/bytes.ts
|
|
14167
|
+
var MASK_128 = (1n << 128n) - 1n;
|
|
14168
|
+
function u256ToFelts(value) {
|
|
14169
|
+
if (value < 0n || value >> 256n !== 0n) throw new RangeError("u256 out of range");
|
|
14170
|
+
return [value & MASK_128, value >> 128n];
|
|
14145
14171
|
}
|
|
14146
|
-
function
|
|
14147
|
-
|
|
14148
|
-
const
|
|
14149
|
-
|
|
14150
|
-
throw new RangeError('"output" expected length >= ' + min);
|
|
14151
|
-
}
|
|
14172
|
+
function bytesToBigInt(bytes) {
|
|
14173
|
+
let value = 0n;
|
|
14174
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
14175
|
+
return value;
|
|
14152
14176
|
}
|
|
14153
|
-
function
|
|
14154
|
-
|
|
14155
|
-
arrays[i].fill(0);
|
|
14156
|
-
}
|
|
14177
|
+
function utf8(text) {
|
|
14178
|
+
return new TextEncoder().encode(text);
|
|
14157
14179
|
}
|
|
14158
|
-
function
|
|
14159
|
-
|
|
14180
|
+
function base64UrlEncode(bytes) {
|
|
14181
|
+
let binary = "";
|
|
14182
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
14183
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
14160
14184
|
}
|
|
14161
|
-
function
|
|
14162
|
-
return
|
|
14185
|
+
function toHex2(value) {
|
|
14186
|
+
return `0x${value.toString(16)}`;
|
|
14163
14187
|
}
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14188
|
+
|
|
14189
|
+
// ../agent/src/core/keys.ts
|
|
14190
|
+
var SN_SEPOLIA = 0x534e5f5345504f4c4941n;
|
|
14191
|
+
|
|
14192
|
+
// ../agent/src/core/rpc.ts
|
|
14193
|
+
var RpcError2 = class extends Error {
|
|
14194
|
+
constructor(code, message, data, method) {
|
|
14195
|
+
super(message);
|
|
14196
|
+
this.code = code;
|
|
14197
|
+
this.data = data;
|
|
14198
|
+
this.method = method;
|
|
14199
|
+
this.name = "RpcError";
|
|
14200
|
+
}
|
|
14201
|
+
code;
|
|
14202
|
+
data;
|
|
14203
|
+
method;
|
|
14204
|
+
};
|
|
14205
|
+
var CONTRACT_NOT_FOUND = 20;
|
|
14206
|
+
function contractNotFound(error) {
|
|
14207
|
+
return error instanceof RpcError2 && error.code === CONTRACT_NOT_FOUND;
|
|
14170
14208
|
}
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
return
|
|
14209
|
+
var ENTRYPOINT_NOT_FOUND = 21;
|
|
14210
|
+
var CONTRACT_ERROR = 40;
|
|
14211
|
+
function noSuchFunction(error, contract, selector2) {
|
|
14212
|
+
if (!(error instanceof RpcError2)) return false;
|
|
14213
|
+
if (error.code === ENTRYPOINT_NOT_FOUND) return true;
|
|
14214
|
+
if (error.code !== CONTRACT_ERROR) return false;
|
|
14215
|
+
const named = (text) => {
|
|
14216
|
+
const said = /Entry point EntryPointSelector\((0x[0-9a-fA-F]{1,64})\) not found in contract/.exec(text);
|
|
14217
|
+
return said !== null && BigInt(said[1]) === selector2;
|
|
14218
|
+
};
|
|
14219
|
+
const reverted = typeof error.data === "object" && error.data !== null ? error.data.revert_error : error.data;
|
|
14220
|
+
if (typeof reverted === "string") return named(reverted);
|
|
14221
|
+
if (typeof reverted !== "object" || reverted === null) return false;
|
|
14222
|
+
const frame = reverted;
|
|
14223
|
+
const is = (written, value) => typeof written === "string" && /^0x[0-9a-fA-F]{1,64}$/.test(written) && BigInt(written) === value;
|
|
14224
|
+
if (!is(frame.contract_address, contract) || !is(frame.selector, selector2) || typeof frame.error !== "string") return false;
|
|
14225
|
+
return named(frame.error) || /'ENTRYPOINT_NOT_FOUND'/.test(frame.error) && !/ENTRYPOINT_FAILED/.test(frame.error);
|
|
14183
14226
|
}
|
|
14184
|
-
var
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
return a & b ^ ~a & c;
|
|
14193
|
-
}
|
|
14194
|
-
function Maj3(a, b, c) {
|
|
14195
|
-
return a & b ^ a & c ^ b & c;
|
|
14196
|
-
}
|
|
14197
|
-
var HashMD3 = class {
|
|
14198
|
-
blockLen;
|
|
14199
|
-
outputLen;
|
|
14200
|
-
canXOF = false;
|
|
14201
|
-
padOffset;
|
|
14202
|
-
isLE;
|
|
14203
|
-
// For partial updates less than block size
|
|
14204
|
-
buffer;
|
|
14205
|
-
view;
|
|
14206
|
-
finished = false;
|
|
14207
|
-
length = 0;
|
|
14208
|
-
pos = 0;
|
|
14209
|
-
destroyed = false;
|
|
14210
|
-
constructor(blockLen, outputLen, padOffset, isLE2) {
|
|
14211
|
-
this.blockLen = blockLen;
|
|
14212
|
-
this.outputLen = outputLen;
|
|
14213
|
-
this.padOffset = padOffset;
|
|
14214
|
-
this.isLE = isLE2;
|
|
14215
|
-
this.buffer = new Uint8Array(blockLen);
|
|
14216
|
-
this.view = createView3(this.buffer);
|
|
14227
|
+
var TXN_HASH_NOT_FOUND = 29;
|
|
14228
|
+
var BATCH_SIZE = 50;
|
|
14229
|
+
var BLOCK = "pre_confirmed";
|
|
14230
|
+
var TransactionRevertedError = class extends Error {
|
|
14231
|
+
constructor(receipt) {
|
|
14232
|
+
super(`Transaction reverted: ${receipt.revert_reason ?? "no reason given"}`);
|
|
14233
|
+
this.receipt = receipt;
|
|
14234
|
+
this.name = "TransactionRevertedError";
|
|
14217
14235
|
}
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
let processed = false;
|
|
14224
|
-
for (let pos = 0; pos < len; ) {
|
|
14225
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
14226
|
-
if (take === blockLen) {
|
|
14227
|
-
const dataView = createView3(data);
|
|
14228
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
14229
|
-
this.process(dataView, pos);
|
|
14230
|
-
processed = true;
|
|
14231
|
-
continue;
|
|
14232
|
-
}
|
|
14233
|
-
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
14234
|
-
this.pos += take;
|
|
14235
|
-
pos += take;
|
|
14236
|
-
if (this.pos === blockLen) {
|
|
14237
|
-
this.process(view, 0);
|
|
14238
|
-
this.pos = 0;
|
|
14239
|
-
processed = true;
|
|
14240
|
-
}
|
|
14241
|
-
}
|
|
14242
|
-
this.length += data.length;
|
|
14243
|
-
if (processed)
|
|
14244
|
-
this.roundClean();
|
|
14245
|
-
return this;
|
|
14236
|
+
receipt;
|
|
14237
|
+
};
|
|
14238
|
+
var Rpc = class {
|
|
14239
|
+
constructor(url) {
|
|
14240
|
+
this.url = url;
|
|
14246
14241
|
}
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
const
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14242
|
+
url;
|
|
14243
|
+
nextId = 1;
|
|
14244
|
+
async request(method, params, signal) {
|
|
14245
|
+
signal?.throwIfAborted();
|
|
14246
|
+
const response = await fetch(this.url, {
|
|
14247
|
+
method: "POST",
|
|
14248
|
+
headers: { "content-type": "application/json" },
|
|
14249
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: this.nextId++, method, params }),
|
|
14250
|
+
signal
|
|
14251
|
+
});
|
|
14252
|
+
const text = await response.text();
|
|
14253
|
+
let body;
|
|
14254
|
+
try {
|
|
14255
|
+
body = JSON.parse(text);
|
|
14256
|
+
} catch {
|
|
14257
|
+
body = void 0;
|
|
14258
14258
|
}
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
const len = this.outputLen;
|
|
14264
|
-
const outLen = len / 4;
|
|
14265
|
-
const state = this.get();
|
|
14266
|
-
if (len % 4 || outLen > state.length)
|
|
14267
|
-
throw new Error("invalid outputLen");
|
|
14268
|
-
for (let i = 0; i < outLen; i++)
|
|
14269
|
-
oview.setUint32(4 * i, state[i], isLE2);
|
|
14270
|
-
}
|
|
14271
|
-
digest() {
|
|
14272
|
-
const { buffer, outputLen } = this;
|
|
14273
|
-
this.digestInto(buffer);
|
|
14274
|
-
const res = buffer.slice(0, outputLen);
|
|
14275
|
-
this.destroy();
|
|
14276
|
-
return res;
|
|
14277
|
-
}
|
|
14278
|
-
_cloneIntoMeta(to) {
|
|
14279
|
-
const { buffer, length, finished, destroyed, pos } = this;
|
|
14280
|
-
to.destroyed = destroyed;
|
|
14281
|
-
to.finished = finished;
|
|
14282
|
-
to.length = length;
|
|
14283
|
-
to.pos = pos;
|
|
14284
|
-
if (pos)
|
|
14285
|
-
to.buffer.set(buffer);
|
|
14286
|
-
return to;
|
|
14287
|
-
}
|
|
14288
|
-
clone() {
|
|
14289
|
-
return this._cloneInto();
|
|
14290
|
-
}
|
|
14291
|
-
};
|
|
14292
|
-
var SHA256_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
14293
|
-
1779033703,
|
|
14294
|
-
3144134277,
|
|
14295
|
-
1013904242,
|
|
14296
|
-
2773480762,
|
|
14297
|
-
1359893119,
|
|
14298
|
-
2600822924,
|
|
14299
|
-
528734635,
|
|
14300
|
-
1541459225
|
|
14301
|
-
]);
|
|
14302
|
-
|
|
14303
|
-
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha2.js
|
|
14304
|
-
var SHA256_K3 = /* @__PURE__ */ Uint32Array.from([
|
|
14305
|
-
1116352408,
|
|
14306
|
-
1899447441,
|
|
14307
|
-
3049323471,
|
|
14308
|
-
3921009573,
|
|
14309
|
-
961987163,
|
|
14310
|
-
1508970993,
|
|
14311
|
-
2453635748,
|
|
14312
|
-
2870763221,
|
|
14313
|
-
3624381080,
|
|
14314
|
-
310598401,
|
|
14315
|
-
607225278,
|
|
14316
|
-
1426881987,
|
|
14317
|
-
1925078388,
|
|
14318
|
-
2162078206,
|
|
14319
|
-
2614888103,
|
|
14320
|
-
3248222580,
|
|
14321
|
-
3835390401,
|
|
14322
|
-
4022224774,
|
|
14323
|
-
264347078,
|
|
14324
|
-
604807628,
|
|
14325
|
-
770255983,
|
|
14326
|
-
1249150122,
|
|
14327
|
-
1555081692,
|
|
14328
|
-
1996064986,
|
|
14329
|
-
2554220882,
|
|
14330
|
-
2821834349,
|
|
14331
|
-
2952996808,
|
|
14332
|
-
3210313671,
|
|
14333
|
-
3336571891,
|
|
14334
|
-
3584528711,
|
|
14335
|
-
113926993,
|
|
14336
|
-
338241895,
|
|
14337
|
-
666307205,
|
|
14338
|
-
773529912,
|
|
14339
|
-
1294757372,
|
|
14340
|
-
1396182291,
|
|
14341
|
-
1695183700,
|
|
14342
|
-
1986661051,
|
|
14343
|
-
2177026350,
|
|
14344
|
-
2456956037,
|
|
14345
|
-
2730485921,
|
|
14346
|
-
2820302411,
|
|
14347
|
-
3259730800,
|
|
14348
|
-
3345764771,
|
|
14349
|
-
3516065817,
|
|
14350
|
-
3600352804,
|
|
14351
|
-
4094571909,
|
|
14352
|
-
275423344,
|
|
14353
|
-
430227734,
|
|
14354
|
-
506948616,
|
|
14355
|
-
659060556,
|
|
14356
|
-
883997877,
|
|
14357
|
-
958139571,
|
|
14358
|
-
1322822218,
|
|
14359
|
-
1537002063,
|
|
14360
|
-
1747873779,
|
|
14361
|
-
1955562222,
|
|
14362
|
-
2024104815,
|
|
14363
|
-
2227730452,
|
|
14364
|
-
2361852424,
|
|
14365
|
-
2428436474,
|
|
14366
|
-
2756734187,
|
|
14367
|
-
3204031479,
|
|
14368
|
-
3329325298
|
|
14369
|
-
]);
|
|
14370
|
-
var SHA256_W3 = /* @__PURE__ */ new Uint32Array(64);
|
|
14371
|
-
var SHA2_32B = class extends HashMD3 {
|
|
14372
|
-
// We cannot use array here since array allows indexing by variable
|
|
14373
|
-
// which means optimizer/compiler cannot use registers.
|
|
14374
|
-
// Numeric initializers matter: starting the fields as `undefined` changes
|
|
14375
|
-
// V8's field representation and makes sha256 3x slower (measured).
|
|
14376
|
-
A = 0;
|
|
14377
|
-
B = 0;
|
|
14378
|
-
C = 0;
|
|
14379
|
-
D = 0;
|
|
14380
|
-
E = 0;
|
|
14381
|
-
F = 0;
|
|
14382
|
-
G = 0;
|
|
14383
|
-
H = 0;
|
|
14384
|
-
constructor(outputLen, IV) {
|
|
14385
|
-
super(64, outputLen, 8, false);
|
|
14386
|
-
this.A = IV[0] | 0;
|
|
14387
|
-
this.B = IV[1] | 0;
|
|
14388
|
-
this.C = IV[2] | 0;
|
|
14389
|
-
this.D = IV[3] | 0;
|
|
14390
|
-
this.E = IV[4] | 0;
|
|
14391
|
-
this.F = IV[5] | 0;
|
|
14392
|
-
this.G = IV[6] | 0;
|
|
14393
|
-
this.H = IV[7] | 0;
|
|
14394
|
-
}
|
|
14395
|
-
get() {
|
|
14396
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
14397
|
-
return [A, B, C, D, E, F, G, H];
|
|
14398
|
-
}
|
|
14399
|
-
// prettier-ignore
|
|
14400
|
-
set(A, B, C, D, E, F, G, H) {
|
|
14401
|
-
this.A = A | 0;
|
|
14402
|
-
this.B = B | 0;
|
|
14403
|
-
this.C = C | 0;
|
|
14404
|
-
this.D = D | 0;
|
|
14405
|
-
this.E = E | 0;
|
|
14406
|
-
this.F = F | 0;
|
|
14407
|
-
this.G = G | 0;
|
|
14408
|
-
this.H = H | 0;
|
|
14409
|
-
}
|
|
14410
|
-
_cloneInto(to) {
|
|
14411
|
-
(to ||= new this.constructor()).set(...this.get());
|
|
14412
|
-
return this._cloneIntoMeta(to);
|
|
14413
|
-
}
|
|
14414
|
-
process(view, offset) {
|
|
14415
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
14416
|
-
SHA256_W3[i] = view.getUint32(offset, false);
|
|
14417
|
-
for (let i = 16; i < 64; i++) {
|
|
14418
|
-
const W15 = SHA256_W3[i - 15];
|
|
14419
|
-
const W2 = SHA256_W3[i - 2];
|
|
14420
|
-
const s0 = rotr3(W15, 7) ^ rotr3(W15, 18) ^ W15 >>> 3;
|
|
14421
|
-
const s1 = rotr3(W2, 17) ^ rotr3(W2, 19) ^ W2 >>> 10;
|
|
14422
|
-
SHA256_W3[i] = s1 + SHA256_W3[i - 7] + s0 + SHA256_W3[i - 16] | 0;
|
|
14423
|
-
}
|
|
14424
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
14425
|
-
for (let i = 0; i < 64; i++) {
|
|
14426
|
-
const sigma1 = rotr3(E, 6) ^ rotr3(E, 11) ^ rotr3(E, 25);
|
|
14427
|
-
const T1 = H + sigma1 + Chi3(E, F, G) + SHA256_K3[i] + SHA256_W3[i] | 0;
|
|
14428
|
-
const sigma0 = rotr3(A, 2) ^ rotr3(A, 13) ^ rotr3(A, 22);
|
|
14429
|
-
const T2 = sigma0 + Maj3(A, B, C) | 0;
|
|
14430
|
-
H = G;
|
|
14431
|
-
G = F;
|
|
14432
|
-
F = E;
|
|
14433
|
-
E = D + T1 | 0;
|
|
14434
|
-
D = C;
|
|
14435
|
-
C = B;
|
|
14436
|
-
B = A;
|
|
14437
|
-
A = T1 + T2 | 0;
|
|
14438
|
-
}
|
|
14439
|
-
A = A + this.A | 0;
|
|
14440
|
-
B = B + this.B | 0;
|
|
14441
|
-
C = C + this.C | 0;
|
|
14442
|
-
D = D + this.D | 0;
|
|
14443
|
-
E = E + this.E | 0;
|
|
14444
|
-
F = F + this.F | 0;
|
|
14445
|
-
G = G + this.G | 0;
|
|
14446
|
-
H = H + this.H | 0;
|
|
14447
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
14448
|
-
}
|
|
14449
|
-
roundClean() {
|
|
14450
|
-
clean(SHA256_W3);
|
|
14451
|
-
}
|
|
14452
|
-
destroy() {
|
|
14453
|
-
this.destroyed = true;
|
|
14454
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
14455
|
-
clean(this.buffer);
|
|
14456
|
-
}
|
|
14457
|
-
};
|
|
14458
|
-
var _SHA256 = class extends SHA2_32B {
|
|
14459
|
-
constructor() {
|
|
14460
|
-
super(32, SHA256_IV3);
|
|
14461
|
-
}
|
|
14462
|
-
};
|
|
14463
|
-
var sha2563 = /* @__PURE__ */ createHasher(
|
|
14464
|
-
() => new _SHA256(),
|
|
14465
|
-
/* @__PURE__ */ oidNist(1)
|
|
14466
|
-
);
|
|
14467
|
-
|
|
14468
|
-
// ../../packages/core/src/bytes.ts
|
|
14469
|
-
var MASK_128 = (1n << 128n) - 1n;
|
|
14470
|
-
function u256ToFelts(value) {
|
|
14471
|
-
if (value < 0n || value >> 256n !== 0n) throw new RangeError("u256 out of range");
|
|
14472
|
-
return [value & MASK_128, value >> 128n];
|
|
14473
|
-
}
|
|
14474
|
-
function bytesToBigInt(bytes) {
|
|
14475
|
-
let value = 0n;
|
|
14476
|
-
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
14477
|
-
return value;
|
|
14478
|
-
}
|
|
14479
|
-
function utf8(text) {
|
|
14480
|
-
return new TextEncoder().encode(text);
|
|
14481
|
-
}
|
|
14482
|
-
function concatBytes3(...parts) {
|
|
14483
|
-
const out = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
|
|
14484
|
-
let offset = 0;
|
|
14485
|
-
for (const part of parts) {
|
|
14486
|
-
out.set(part, offset);
|
|
14487
|
-
offset += part.length;
|
|
14488
|
-
}
|
|
14489
|
-
return out;
|
|
14490
|
-
}
|
|
14491
|
-
function base64UrlEncode(bytes) {
|
|
14492
|
-
let binary = "";
|
|
14493
|
-
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
14494
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
14495
|
-
}
|
|
14496
|
-
function toHex2(value) {
|
|
14497
|
-
return `0x${value.toString(16)}`;
|
|
14498
|
-
}
|
|
14499
|
-
|
|
14500
|
-
// ../../packages/core/src/accountsFilter.ts
|
|
14501
|
-
var TAG = utf8("outis/accounts-filter/v1");
|
|
14502
|
-
var MAX_BITS = 2 ** 32;
|
|
14503
|
-
|
|
14504
|
-
// ../../packages/core/src/requests.ts
|
|
14505
|
-
var FELT_MAX = 2n ** 251n + 17n * 2n ** 192n;
|
|
14506
|
-
|
|
14507
|
-
// ../../packages/core/src/private.ts
|
|
14508
|
-
var MAX_AMOUNT = 2n ** 128n - 1n;
|
|
14509
|
-
var OUTIS_DAPP_NAME = BigInt(shortString_exports.encodeShortString("outis"));
|
|
14510
|
-
var SHADOW_NONCE_LIMIT = 2n ** 64n - 1n;
|
|
14511
|
-
|
|
14512
|
-
// ../../packages/core/src/rpc.ts
|
|
14513
|
-
var RpcError2 = class extends Error {
|
|
14514
|
-
constructor(code, message, data, method) {
|
|
14515
|
-
super(message);
|
|
14516
|
-
this.code = code;
|
|
14517
|
-
this.data = data;
|
|
14518
|
-
this.method = method;
|
|
14519
|
-
this.name = "RpcError";
|
|
14520
|
-
}
|
|
14521
|
-
code;
|
|
14522
|
-
data;
|
|
14523
|
-
method;
|
|
14524
|
-
};
|
|
14525
|
-
var CONTRACT_NOT_FOUND = 20;
|
|
14526
|
-
function contractNotFound(error) {
|
|
14527
|
-
return error instanceof RpcError2 && error.code === CONTRACT_NOT_FOUND;
|
|
14528
|
-
}
|
|
14529
|
-
var ENTRYPOINT_NOT_FOUND = 21;
|
|
14530
|
-
var CONTRACT_ERROR = 40;
|
|
14531
|
-
function noSuchFunction(error, contract, selector2) {
|
|
14532
|
-
if (!(error instanceof RpcError2)) return false;
|
|
14533
|
-
if (error.code === ENTRYPOINT_NOT_FOUND) return true;
|
|
14534
|
-
if (error.code !== CONTRACT_ERROR) return false;
|
|
14535
|
-
const named = (text) => {
|
|
14536
|
-
const said = /Entry point EntryPointSelector\((0x[0-9a-fA-F]{1,64})\) not found in contract/.exec(text);
|
|
14537
|
-
return said !== null && BigInt(said[1]) === selector2;
|
|
14538
|
-
};
|
|
14539
|
-
const reverted = typeof error.data === "object" && error.data !== null ? error.data.revert_error : error.data;
|
|
14540
|
-
if (typeof reverted === "string") return named(reverted);
|
|
14541
|
-
if (typeof reverted !== "object" || reverted === null) return false;
|
|
14542
|
-
const frame = reverted;
|
|
14543
|
-
const is = (written, value) => typeof written === "string" && /^0x[0-9a-fA-F]{1,64}$/.test(written) && BigInt(written) === value;
|
|
14544
|
-
if (!is(frame.contract_address, contract) || !is(frame.selector, selector2) || typeof frame.error !== "string") return false;
|
|
14545
|
-
return named(frame.error) || /'ENTRYPOINT_NOT_FOUND'/.test(frame.error) && !/ENTRYPOINT_FAILED/.test(frame.error);
|
|
14546
|
-
}
|
|
14547
|
-
var TXN_HASH_NOT_FOUND = 29;
|
|
14548
|
-
var BATCH_SIZE = 50;
|
|
14549
|
-
var BLOCK = "pre_confirmed";
|
|
14550
|
-
var TransactionRevertedError = class extends Error {
|
|
14551
|
-
constructor(receipt) {
|
|
14552
|
-
super(`Transaction reverted: ${receipt.revert_reason ?? "no reason given"}`);
|
|
14553
|
-
this.receipt = receipt;
|
|
14554
|
-
this.name = "TransactionRevertedError";
|
|
14555
|
-
}
|
|
14556
|
-
receipt;
|
|
14557
|
-
};
|
|
14558
|
-
var Rpc = class {
|
|
14559
|
-
constructor(url) {
|
|
14560
|
-
this.url = url;
|
|
14561
|
-
}
|
|
14562
|
-
url;
|
|
14563
|
-
nextId = 1;
|
|
14564
|
-
async request(method, params, signal) {
|
|
14565
|
-
signal?.throwIfAborted();
|
|
14566
|
-
const response = await fetch(this.url, {
|
|
14567
|
-
method: "POST",
|
|
14568
|
-
headers: { "content-type": "application/json" },
|
|
14569
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: this.nextId++, method, params }),
|
|
14570
|
-
signal
|
|
14571
|
-
});
|
|
14572
|
-
const text = await response.text();
|
|
14573
|
-
let body;
|
|
14574
|
-
try {
|
|
14575
|
-
body = JSON.parse(text);
|
|
14576
|
-
} catch {
|
|
14577
|
-
body = void 0;
|
|
14578
|
-
}
|
|
14579
|
-
if (body?.error) throw new RpcError2(body.error.code, body.error.message, body.error.data, method);
|
|
14580
|
-
if (!response.ok || !body) throw new RpcError2(response.status, `RPC endpoint answered HTTP ${response.status}`, text.slice(0, 500), method);
|
|
14581
|
-
if (typeof body !== "object" || !("result" in body)) throw new RpcError2(-1, "The RPC endpoint answered with neither a result nor an error", text.slice(0, 500), method);
|
|
14582
|
-
return body.result;
|
|
14259
|
+
if (body?.error) throw new RpcError2(body.error.code, body.error.message, body.error.data, method);
|
|
14260
|
+
if (!response.ok || !body) throw new RpcError2(response.status, `RPC endpoint answered HTTP ${response.status}`, text.slice(0, 500), method);
|
|
14261
|
+
if (typeof body !== "object" || !("result" in body)) throw new RpcError2(-1, "The RPC endpoint answered with neither a result nor an error", text.slice(0, 500), method);
|
|
14262
|
+
return body.result;
|
|
14583
14263
|
}
|
|
14584
14264
|
/**
|
|
14585
14265
|
* Requests sent BATCH_SIZE to an HTTP request, the batches side by side, answered in the order
|
|
@@ -14749,74 +14429,17 @@ var Rpc = class {
|
|
|
14749
14429
|
}
|
|
14750
14430
|
};
|
|
14751
14431
|
|
|
14752
|
-
//
|
|
14753
|
-
var
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
var DIGITS_DOMAIN = new TextEncoder().encode("outis/2fa/digits");
|
|
14757
|
-
var OWNER_ALONE = /* @__PURE__ */ new Set([selector("trigger_escape_guardian"), selector("escape_guardian")]);
|
|
14758
|
-
|
|
14759
|
-
// ../../packages/core/src/transactions.ts
|
|
14760
|
-
var VERSION = "0x3";
|
|
14761
|
-
function hashBounds(bounds) {
|
|
14762
|
-
const bound = ({ maxAmount, maxPricePerUnit }) => ({ max_amount: maxAmount, max_price_per_unit: maxPricePerUnit });
|
|
14763
|
-
return { l1_gas: bound(bounds.l1Gas), l2_gas: bound(bounds.l2Gas), l1_data_gas: bound(bounds.l1DataGas) };
|
|
14432
|
+
// ../agent/src/core/signers.ts
|
|
14433
|
+
var STARKNET_SIGNER_TYPE = BigInt(shortString_exports.encodeShortString("Starknet Signer"));
|
|
14434
|
+
function assertValidSigner(signer) {
|
|
14435
|
+
if (signer.pubkey === 0n) throw new Error("Signer public key cannot be zero");
|
|
14764
14436
|
}
|
|
14765
|
-
function
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
max_price_per_unit: toHex2(maxPricePerUnit)
|
|
14769
|
-
});
|
|
14770
|
-
return { l1_gas: bound(bounds.l1Gas), l2_gas: bound(bounds.l2Gas), l1_data_gas: bound(bounds.l1DataGas) };
|
|
14437
|
+
function signerGuid(signer) {
|
|
14438
|
+
assertValidSigner(signer);
|
|
14439
|
+
return BigInt(hash_exports.computePoseidonHash(STARKNET_SIGNER_TYPE, signer.pubkey));
|
|
14771
14440
|
}
|
|
14772
|
-
var COMMON_FIELDS = {
|
|
14773
|
-
tip: "0x0",
|
|
14774
|
-
paymaster_data: [],
|
|
14775
|
-
nonce_data_availability_mode: "L1",
|
|
14776
|
-
fee_data_availability_mode: "L1"
|
|
14777
|
-
};
|
|
14778
|
-
function invokeTransaction(tx, version, signature) {
|
|
14779
|
-
return {
|
|
14780
|
-
type: "INVOKE",
|
|
14781
|
-
version,
|
|
14782
|
-
sender_address: toHex2(tx.sender),
|
|
14783
|
-
calldata: executeCalldata(tx.calls).map(toHex2),
|
|
14784
|
-
signature: signature.map(toHex2),
|
|
14785
|
-
nonce: toHex2(tx.nonce),
|
|
14786
|
-
resource_bounds: rpcBounds(tx.bounds),
|
|
14787
|
-
account_deployment_data: [],
|
|
14788
|
-
...COMMON_FIELDS,
|
|
14789
|
-
// Without facts there is no proof to carry, and empty proof fields make the transaction invalid.
|
|
14790
|
-
...tx.proof?.facts.length && { proof: tx.proof.data, proof_facts: tx.proof.facts.map(toHex2) }
|
|
14791
|
-
};
|
|
14792
|
-
}
|
|
14793
|
-
function invokeTransactionHash(tx) {
|
|
14794
|
-
return BigInt(
|
|
14795
|
-
hash_exports.calculateInvokeTransactionHash({
|
|
14796
|
-
senderAddress: tx.sender,
|
|
14797
|
-
version: VERSION,
|
|
14798
|
-
compiledCalldata: executeCalldata(tx.calls).map(toHex2),
|
|
14799
|
-
chainId: toHex2(tx.chainId),
|
|
14800
|
-
nonce: tx.nonce,
|
|
14801
|
-
accountDeploymentData: [],
|
|
14802
|
-
nonceDataAvailabilityMode: 0,
|
|
14803
|
-
feeDataAvailabilityMode: 0,
|
|
14804
|
-
resourceBounds: hashBounds(tx.bounds),
|
|
14805
|
-
tip: 0n,
|
|
14806
|
-
paymasterData: [],
|
|
14807
|
-
proofFacts: tx.proof?.facts.map(toHex2)
|
|
14808
|
-
})
|
|
14809
|
-
);
|
|
14810
|
-
}
|
|
14811
|
-
|
|
14812
|
-
// ../../packages/core/src/keys.ts
|
|
14813
|
-
var SN_MAIN = 0x534e5f4d41494en;
|
|
14814
|
-
var SN_SEPOLIA = 0x534e5f5345504f4c4941n;
|
|
14815
|
-
var STARK_ORDER = ec_exports.starkCurve.CURVE.n;
|
|
14816
|
-
var VIEWING_KEY_DOMAIN = utf8("STRK20_ACCOUNT_LEAF_V1");
|
|
14817
|
-
var UNBIASED_LIMIT = 2n ** 256n - 2n ** 256n % STARK_ORDER;
|
|
14818
14441
|
|
|
14819
|
-
//
|
|
14442
|
+
// ../agent/src/core/tokens.ts
|
|
14820
14443
|
var STRK = {
|
|
14821
14444
|
symbol: "STRK",
|
|
14822
14445
|
address: 0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938dn,
|
|
@@ -14857,22 +14480,6 @@ var TBTC = { symbol: "tBTC", address: 0x04daa17763b286d1e59b97c283c0b8c949994c36
|
|
|
14857
14480
|
var SOLVBTC = { symbol: "SolvBTC", address: 0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68n, decimals: 18 };
|
|
14858
14481
|
var STRKBTC = { symbol: "strkBTC", address: 0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135n, decimals: 8 };
|
|
14859
14482
|
var NAMED_TOKENS = [STRK, ETH, USDC, USDC_SEPOLIA, USDC_BRIDGED, USDT, WBTC, ZEC, SOL, XSTRK, EKUBO, LORDS, DREAMS, CASH, DAI, WSTETH, TBTC, SOLVBTC, STRKBTC];
|
|
14860
|
-
var NAMES = /* @__PURE__ */ new Map([
|
|
14861
|
-
[STRK.address, "Starknet"],
|
|
14862
|
-
[ETH.address, "Ether"],
|
|
14863
|
-
[USDC_BRIDGED.address, "USDC (Bridged)"],
|
|
14864
|
-
[USDT.address, "Tether"],
|
|
14865
|
-
[WBTC.address, "Wrapped Bitcoin"],
|
|
14866
|
-
[ZEC.address, "Zcash"],
|
|
14867
|
-
[SOL.address, "Solana"],
|
|
14868
|
-
[XSTRK.address, "Endur Staked STRK"],
|
|
14869
|
-
[EKUBO.address, "Ekubo"],
|
|
14870
|
-
[DREAMS.address, "Daydreams"],
|
|
14871
|
-
[CASH.address, "Opus CASH"],
|
|
14872
|
-
[DAI.address, "Dai"],
|
|
14873
|
-
[WSTETH.address, "Wrapped Staked Ether"],
|
|
14874
|
-
[SOLVBTC.address, "Solv BTC"]
|
|
14875
|
-
]);
|
|
14876
14483
|
function decodeSymbol(felts) {
|
|
14877
14484
|
const text = (value, length) => {
|
|
14878
14485
|
const hex2 = value.toString(16);
|
|
@@ -14962,1135 +14569,64 @@ function formatAmount(amount, decimals, maxFractionDigits = 6) {
|
|
|
14962
14569
|
return fraction ? `${whole}.${fraction}` : whole.toString();
|
|
14963
14570
|
}
|
|
14964
14571
|
|
|
14965
|
-
//
|
|
14966
|
-
var
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
var TRANSFER = selector("Transfer");
|
|
14971
|
-
var TRANSFER_CALL = selector("transfer");
|
|
14972
|
-
var CONTRACT_DEPLOYED = selector("ContractDeployed");
|
|
14973
|
-
var NFT_TRANSFER_CALLS = new Set(["transfer_from", "transferFrom", "safe_transfer_from", "safeTransferFrom"].map(selector));
|
|
14974
|
-
var APPROVE_CALL = selector("approve");
|
|
14975
|
-
var INCREASE_CALLS = new Set(["increase_allowance", "increaseAllowance"].map(selector));
|
|
14976
|
-
var SWAP_CALLS = new Set(["swap", "multihop_swap", "multi_multihop_swap"].map(selector));
|
|
14977
|
-
var VIEWING_KEY_SET = selector("ViewingKeySet");
|
|
14978
|
-
var ENC_NOTE_CREATED = selector("EncNoteCreated");
|
|
14979
|
-
var POSITION_UPDATED = selector("PositionUpdated");
|
|
14980
|
-
var FEES_COLLECTED = selector("PositionFeesCollected");
|
|
14981
|
-
var ORDER_UPDATED = selector("OrderUpdated");
|
|
14982
|
-
var PROCEEDS_WITHDRAWN = selector("OrderProceedsWithdrawn");
|
|
14983
|
-
var ORDER_PLACED = selector("OrderPlaced");
|
|
14984
|
-
var ORDER_CLOSED = selector("OrderClosed");
|
|
14985
|
-
var TRANSFER_SINGLE = selector("TransferSingle");
|
|
14986
|
-
var TRANSFER_BATCH = selector("TransferBatch");
|
|
14987
|
-
var ACCOUNT_CHANGES = new Map(
|
|
14988
|
-
[
|
|
14989
|
-
["set_escape_security_period", "removalDelayChanged"],
|
|
14990
|
-
["cancel_escape", "escapeCancelled"],
|
|
14991
|
-
["trigger_escape_guardian", "twoFactorRemovalStarted"],
|
|
14992
|
-
["escape_guardian", "twoFactorRemovedWithoutPhone"],
|
|
14993
|
-
["trigger_escape_owner", "ownerReplacementStarted"],
|
|
14994
|
-
["escape_owner", "ownerReplaced"],
|
|
14995
|
-
["change_owners", "ownersChanged"],
|
|
14996
|
-
["upgrade", "upgraded"],
|
|
14997
|
-
["revoke_session", "sessionRevoked"]
|
|
14998
|
-
].map(([name, change]) => [selector(name), change])
|
|
14999
|
-
);
|
|
15000
|
-
var CHANGE_GUARDIANS = selector("change_guardians");
|
|
15001
|
-
var TRIGGER_ESCAPE_GUARDIAN = selector("trigger_escape_guardian");
|
|
15002
|
-
|
|
15003
|
-
// ../../packages/core/src/imported.ts
|
|
15004
|
-
var STARK_ORDER2 = ec_exports.starkCurve.CURVE.n;
|
|
15005
|
-
var NOT_ONE_OWNER = 2n ** 64n;
|
|
15006
|
-
|
|
15007
|
-
// ../../packages/core/src/music.ts
|
|
15008
|
-
var MAX_MIDI = 64 * 1024;
|
|
15009
|
-
var MAX_SETTINGS = 16 * 1024;
|
|
15010
|
-
|
|
15011
|
-
// ../../packages/core/src/nfts.ts
|
|
15012
|
-
var U256 = 1n << 256n;
|
|
15013
|
-
var KNOWN = {
|
|
15014
|
-
[toHex2(SN_MAIN)]: [
|
|
15015
|
-
{ address: 0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9afn, name: "Starknet ID" },
|
|
15016
|
-
{ address: 0x00539f522b29ae9251dbf7443c7a950cf260372e69efab3710a11bf17a9599f1n, name: "Blobert" },
|
|
15017
|
-
{ address: 0x07ae27a31bb6526e3de9cf02f081f6ce0615ac12a6d7b85ee58b8ad7947a2809n, name: "Realms" },
|
|
15018
|
-
{ address: 0x07280a807c8b79379bec87919433b7b836b93a92e6d71b24ee99f4ffe33dd337n, name: "Influence Crews" },
|
|
15019
|
-
{ address: 0x0603cf837055c64d026a3c5a9e3a83036cea6c4a3f68a9e19f7a687d726fe817n, name: "Influence Asteroids" },
|
|
15020
|
-
{ address: 0x0241b9c4ce12c06f49fee2ec7c16337386fa5185168f538a7631aacecdf3df74n, name: "Influence Crewmates" },
|
|
15021
|
-
{ address: 0x04369e47e647ab5fc4d36cee26590276b99a89a83fc3306462d21d366611fde3n, name: "Influence Ships" }
|
|
15022
|
-
]
|
|
15023
|
-
};
|
|
15024
|
-
var DEFI = {
|
|
15025
|
-
[toHex2(SN_MAIN)]: [
|
|
15026
|
-
EKUBO_POSITIONS_NFT,
|
|
15027
|
-
0x5502bd98af66c3d1227aa4ac7107eb6867b1686c02a62e2edbda91a686be1e3n,
|
|
15028
|
-
0x669d0af171fb4b5d93a2e51f897ae3a2526b0011120fd30e20922de6aa204a1n,
|
|
15029
|
-
0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095n,
|
|
15030
|
-
0x46902423bd632c428376b84fcee9cac5dbe016214e93a8103bcbde6e1de656bn,
|
|
15031
|
-
0x4fec59a12f8424281c1e65a80b5de51b4e754625c60cddfcd00d46941ec37b2n,
|
|
15032
|
-
0x906d03590010868cbf7590ad47043959d7af8e782089a605d9b22567b64fdan,
|
|
15033
|
-
0x2e6cd71e5060a254d4db00655e420db7bf89da7755bb0d5f922e2f00c76ac49n,
|
|
15034
|
-
0x429e8ee8bc7ecd1ade72630d350a2e0f10f9a2507c45f188ba17fe8f2ab4cf3n,
|
|
15035
|
-
0x7a5dc288325456f05e70e9616e16bc02ffbe448f4b89f80b47c0970b989c7cn,
|
|
15036
|
-
0x5ee66a39af9aef3d0d48982b4a63e8bd2a5bad021916bd87fb0eae3a26800b8n,
|
|
15037
|
-
0xeac9032f02057779816e38a6cb9185d12d86b3aacc9949b96b36de359c1e3n,
|
|
15038
|
-
0x5af0c2a657eaa8e23ed78e855dac0c51e4f69e2cf91a18c472041a1f75bb41fn
|
|
15039
|
-
]
|
|
15040
|
-
};
|
|
15041
|
-
var MAX_IMAGE = 10 * 1024 * 1024;
|
|
15042
|
-
var MAX_METADATA_BODY = 128 * 1024;
|
|
15043
|
-
var MAX_MUSIC_BODY = 512 * 1024;
|
|
15044
|
-
|
|
15045
|
-
// ../../packages/core/src/ledger.ts
|
|
15046
|
-
var HARDENED = 2147483648;
|
|
15047
|
-
function segment(name) {
|
|
15048
|
-
const digest = sha2563(utf8(name));
|
|
15049
|
-
return (digest[28] << 24 | digest[29] << 16 | digest[30] << 8 | digest[31]) >>> 0 & 2147483647;
|
|
15050
|
-
}
|
|
15051
|
-
var EIP2645 = 2645;
|
|
15052
|
-
var STARKNET_LAYER = segment("starknet");
|
|
15053
|
-
var OUTIS_APPLICATION = segment("outis");
|
|
15054
|
-
var UNLOCK_PURPOSE = 1;
|
|
15055
|
-
var ANY_NETWORK = 0;
|
|
15056
|
-
function hardened(steps) {
|
|
15057
|
-
if (steps.length !== 6 || steps.some((step) => !Number.isInteger(step) || step < 0 || step >= HARDENED)) throw new Error("Not an EIP-2645 path");
|
|
15058
|
-
return steps.map((step) => (step | HARDENED) >>> 0);
|
|
15059
|
-
}
|
|
15060
|
-
var OWNER_NETWORK = segment("SN_MAIN");
|
|
15061
|
-
var LEDGER_UNLOCK_PATH = hardened([EIP2645, STARKNET_LAYER, OUTIS_APPLICATION, ANY_NETWORK, UNLOCK_PURPOSE, 0]);
|
|
15062
|
-
var LEDGER_UNLOCK_MESSAGE = BigInt(shortString_exports.encodeShortString("outis/ledger/unlock/v1"));
|
|
15063
|
-
var ROOT_INFO = utf8("outis/ledger/root/v1");
|
|
15064
|
-
|
|
15065
|
-
// ../../packages/core/src/password.ts
|
|
15066
|
-
var PURPOSE = new TextEncoder().encode("outis password-sealed seed v1");
|
|
15067
|
-
|
|
15068
|
-
// ../../packages/core/src/email.ts
|
|
15069
|
-
var EMAIL_KDF = { m: 65536, t: 12 };
|
|
15070
|
-
var KDF_WORK_MAX = EMAIL_KDF.m * EMAIL_KDF.t * 2;
|
|
15071
|
-
var SALT_LABEL = utf8("outis/email/salt/v1");
|
|
15072
|
-
var SEAL_LABEL = utf8("outis/email/seal/v1");
|
|
15073
|
-
var LOGIN_LABEL = utf8("outis/email/login/v1");
|
|
15074
|
-
var PURPOSE2 = utf8("outis email-sealed seed v1");
|
|
15075
|
-
var ZERO2 = new Uint8Array([0]);
|
|
15076
|
-
var SIGN_KEY_PURPOSE = utf8("outis email-sealed sign key v1");
|
|
15077
|
-
var MESSAGE_DOMAIN = utf8("outis/vault/v1");
|
|
15078
|
-
|
|
15079
|
-
// ../../packages/core/src/shadows.ts
|
|
15080
|
-
var APPLY_ACTIONS = selector("apply_actions");
|
|
15081
|
-
var TRANSFER2 = selector("Transfer");
|
|
15082
|
-
var POSITION_UPDATED2 = selector("PositionUpdated");
|
|
15083
|
-
var ORDER_UPDATED2 = selector("OrderUpdated");
|
|
15084
|
-
var ORDER_PLACED2 = selector("OrderPlaced");
|
|
15085
|
-
var MODIFY_POSITION = selector("modify_position");
|
|
15086
|
-
var POSITION = selector("position");
|
|
15087
|
-
var ENTER_DELEGATION_POOL = selector("enter_delegation_pool");
|
|
15088
|
-
var ADD_TO_DELEGATION_POOL = selector("add_to_delegation_pool");
|
|
15089
|
-
|
|
15090
|
-
// ../../packages/core/src/qr.ts
|
|
15091
|
-
var CODE_LIFETIME_S = 5 * 60;
|
|
15092
|
-
var MAX_SEALED_PUSH = 1 + 32 + 512 + 16;
|
|
15093
|
-
|
|
15094
|
-
// ../../node_modules/.pnpm/hpke@1.1.2/node_modules/hpke/index.js
|
|
15095
|
-
function ComputeNonce(base_nonce, seq, Nn) {
|
|
15096
|
-
const nonce = new Uint8Array(Nn);
|
|
15097
|
-
nonce.set(base_nonce);
|
|
15098
|
-
let s = seq;
|
|
15099
|
-
for (let i = Nn - 1; i >= 0 && s > 0; i--) {
|
|
15100
|
-
nonce[i] = nonce[i] ^ s & 255;
|
|
15101
|
-
s = Math.floor(s / 256);
|
|
15102
|
-
}
|
|
15103
|
-
return nonce;
|
|
15104
|
-
}
|
|
15105
|
-
function IncrementSeq(seq) {
|
|
15106
|
-
if (seq >= Number.MAX_SAFE_INTEGER) {
|
|
15107
|
-
throw new MessageLimitReachedError("Sequence number overflow");
|
|
15108
|
-
}
|
|
15109
|
-
return ++seq;
|
|
15110
|
-
}
|
|
15111
|
-
async function ContextExport(suite2, exporterSecret, exporterContext, L) {
|
|
15112
|
-
checkUint8Array(exporterContext, "exporterContext");
|
|
15113
|
-
const stages = KDFStages(suite2.KDF);
|
|
15114
|
-
if (!Number.isInteger(L) || L <= 0 || L > 65535) {
|
|
15115
|
-
throw new TypeError('"L" must be a positive integer not exceeding 65535');
|
|
15116
|
-
}
|
|
15117
|
-
if (stages === 2 && L > 255 * suite2.KDF.Nh) {
|
|
15118
|
-
throw new TypeError('"L" must not exceed 255*Nh of the cipher suite KDF');
|
|
15119
|
-
}
|
|
15120
|
-
const Export = stages === 1 ? Export_OneStage : Export_TwoStage;
|
|
15121
|
-
return await Export(suite2.KDF, suite2.id, exporterSecret, exporterContext, L);
|
|
15122
|
-
}
|
|
15123
|
-
var Mutex = class {
|
|
15124
|
-
#locked = Promise.resolve();
|
|
15125
|
-
async lock() {
|
|
15126
|
-
let releaseLock;
|
|
15127
|
-
const nextLock = new Promise((resolve) => {
|
|
15128
|
-
releaseLock = resolve;
|
|
15129
|
-
});
|
|
15130
|
-
const previousLock = this.#locked;
|
|
15131
|
-
this.#locked = nextLock;
|
|
15132
|
-
await previousLock;
|
|
15133
|
-
return releaseLock;
|
|
15134
|
-
}
|
|
15135
|
-
};
|
|
15136
|
-
var SenderContext = class {
|
|
15137
|
-
#suite;
|
|
15138
|
-
#key;
|
|
15139
|
-
#base_nonce;
|
|
15140
|
-
#exporter_secret;
|
|
15141
|
-
#mode;
|
|
15142
|
-
#seq = 0;
|
|
15143
|
-
#mutex;
|
|
15144
|
-
constructor(suite2, mode, key, base_nonce, exporter_secret) {
|
|
15145
|
-
this.#suite = suite2;
|
|
15146
|
-
this.#mode = mode;
|
|
15147
|
-
this.#key = key;
|
|
15148
|
-
this.#base_nonce = base_nonce;
|
|
15149
|
-
this.#exporter_secret = exporter_secret;
|
|
15150
|
-
}
|
|
15151
|
-
get mode() {
|
|
15152
|
-
return this.#mode;
|
|
15153
|
-
}
|
|
15154
|
-
get seq() {
|
|
15155
|
-
return this.#seq;
|
|
15156
|
-
}
|
|
15157
|
-
async Seal(plaintext, aad) {
|
|
15158
|
-
checkUint8Array(plaintext, "plaintext");
|
|
15159
|
-
aad ??= new Uint8Array();
|
|
15160
|
-
checkUint8Array(aad, "aad");
|
|
15161
|
-
if (this.#suite.AEAD.id === EXPORT_ONLY) {
|
|
15162
|
-
throw new TypeError("Export-only AEAD cannot be used with Seal");
|
|
15163
|
-
}
|
|
15164
|
-
this.#mutex ??= new Mutex();
|
|
15165
|
-
const release = await this.#mutex.lock();
|
|
15166
|
-
let ct;
|
|
15167
|
-
try {
|
|
15168
|
-
ct = await this.#suite.AEAD.Seal(
|
|
15169
|
-
this.#key,
|
|
15170
|
-
ComputeNonce(this.#base_nonce, this.#seq, this.#suite.AEAD.Nn),
|
|
15171
|
-
aad,
|
|
15172
|
-
plaintext
|
|
15173
|
-
);
|
|
15174
|
-
this.#seq = IncrementSeq(this.#seq);
|
|
15175
|
-
return ct;
|
|
15176
|
-
} finally {
|
|
15177
|
-
release();
|
|
15178
|
-
}
|
|
15179
|
-
}
|
|
15180
|
-
async Export(exporterContext, length) {
|
|
15181
|
-
return await ContextExport(this.#suite, this.#exporter_secret, exporterContext, length);
|
|
15182
|
-
}
|
|
15183
|
-
get Nt() {
|
|
15184
|
-
return this.#suite.AEAD.Nt;
|
|
15185
|
-
}
|
|
15186
|
-
};
|
|
15187
|
-
var RecipientContext = class {
|
|
15188
|
-
#suite;
|
|
15189
|
-
#key;
|
|
15190
|
-
#base_nonce;
|
|
15191
|
-
#exporter_secret;
|
|
15192
|
-
#mode;
|
|
15193
|
-
#seq = 0;
|
|
15194
|
-
#mutex;
|
|
15195
|
-
constructor(suite2, mode, key, base_nonce, exporter_secret) {
|
|
15196
|
-
this.#suite = suite2;
|
|
15197
|
-
this.#mode = mode;
|
|
15198
|
-
this.#key = key;
|
|
15199
|
-
this.#base_nonce = base_nonce;
|
|
15200
|
-
this.#exporter_secret = exporter_secret;
|
|
15201
|
-
}
|
|
15202
|
-
get mode() {
|
|
15203
|
-
return this.#mode;
|
|
15204
|
-
}
|
|
15205
|
-
get seq() {
|
|
15206
|
-
return this.#seq;
|
|
15207
|
-
}
|
|
15208
|
-
async Open(ciphertext, aad) {
|
|
15209
|
-
checkUint8Array(ciphertext, "ciphertext");
|
|
15210
|
-
aad ??= new Uint8Array();
|
|
15211
|
-
checkUint8Array(aad, "aad");
|
|
15212
|
-
if (this.#suite.AEAD.id === EXPORT_ONLY) {
|
|
15213
|
-
throw new TypeError("Export-only AEAD cannot be used with Open");
|
|
15214
|
-
}
|
|
15215
|
-
this.#mutex ??= new Mutex();
|
|
15216
|
-
const release = await this.#mutex.lock();
|
|
15217
|
-
try {
|
|
15218
|
-
let pt;
|
|
15219
|
-
try {
|
|
15220
|
-
pt = await this.#suite.AEAD.Open(
|
|
15221
|
-
this.#key,
|
|
15222
|
-
ComputeNonce(this.#base_nonce, this.#seq, this.#suite.AEAD.Nn),
|
|
15223
|
-
aad,
|
|
15224
|
-
ciphertext
|
|
15225
|
-
);
|
|
15226
|
-
} catch (cause) {
|
|
15227
|
-
if (cause instanceof MessageLimitReachedError || cause instanceof NotSupportedError) {
|
|
15228
|
-
throw cause;
|
|
15229
|
-
}
|
|
15230
|
-
throw new OpenError("AEAD decryption failed", { cause });
|
|
15231
|
-
}
|
|
15232
|
-
this.#seq = IncrementSeq(this.#seq);
|
|
15233
|
-
return pt;
|
|
15234
|
-
} finally {
|
|
15235
|
-
release();
|
|
15236
|
-
}
|
|
15237
|
-
}
|
|
15238
|
-
async Export(exporterContext, length) {
|
|
15239
|
-
return await ContextExport(this.#suite, this.#exporter_secret, exporterContext, length);
|
|
15240
|
-
}
|
|
15241
|
-
};
|
|
15242
|
-
var validate = (factory, type) => {
|
|
15243
|
-
try {
|
|
15244
|
-
const result = factory();
|
|
15245
|
-
if (result.type !== type) {
|
|
15246
|
-
throw new Error(`Invalid "${type}" return discriminator`);
|
|
15247
|
-
}
|
|
15248
|
-
return result;
|
|
15249
|
-
} catch (cause) {
|
|
15250
|
-
throw new TypeError(`Invalid "${type}"`, { cause });
|
|
15251
|
-
}
|
|
15252
|
-
};
|
|
15253
|
-
var CipherSuite = class {
|
|
15254
|
-
#suite;
|
|
15255
|
-
constructor(KEM, KDF, AEAD) {
|
|
15256
|
-
const kem = validate(KEM, "KEM");
|
|
15257
|
-
const kdf = validate(KDF, "KDF");
|
|
15258
|
-
const aead = validate(AEAD, "AEAD");
|
|
15259
|
-
this.#suite = {
|
|
15260
|
-
KEM: kem,
|
|
15261
|
-
KDF: kdf,
|
|
15262
|
-
AEAD: aead,
|
|
15263
|
-
id: concat(L_HPKE, I2OSP(kem.id, 2), I2OSP(kdf.id, 2), I2OSP(aead.id, 2))
|
|
15264
|
-
};
|
|
15265
|
-
}
|
|
15266
|
-
get KEM() {
|
|
15267
|
-
return {
|
|
15268
|
-
id: this.#suite.KEM.id,
|
|
15269
|
-
name: this.#suite.KEM.name,
|
|
15270
|
-
Nsecret: this.#suite.KEM.Nsecret,
|
|
15271
|
-
Nenc: this.#suite.KEM.Nenc,
|
|
15272
|
-
Npk: this.#suite.KEM.Npk,
|
|
15273
|
-
Nsk: this.#suite.KEM.Nsk
|
|
15274
|
-
};
|
|
15275
|
-
}
|
|
15276
|
-
get KDF() {
|
|
15277
|
-
return {
|
|
15278
|
-
id: this.#suite.KDF.id,
|
|
15279
|
-
name: this.#suite.KDF.name,
|
|
15280
|
-
stages: this.#suite.KDF.stages,
|
|
15281
|
-
Nh: this.#suite.KDF.Nh
|
|
15282
|
-
};
|
|
15283
|
-
}
|
|
15284
|
-
get AEAD() {
|
|
15285
|
-
return {
|
|
15286
|
-
id: this.#suite.AEAD.id,
|
|
15287
|
-
name: this.#suite.AEAD.name,
|
|
15288
|
-
Nk: this.#suite.AEAD.Nk,
|
|
15289
|
-
Nn: this.#suite.AEAD.Nn,
|
|
15290
|
-
Nt: this.#suite.AEAD.Nt
|
|
15291
|
-
};
|
|
15292
|
-
}
|
|
15293
|
-
async GenerateKeyPair(extractable) {
|
|
15294
|
-
extractable ??= false;
|
|
15295
|
-
checkExtractable(extractable);
|
|
15296
|
-
return await this.#suite.KEM.GenerateKeyPair(extractable);
|
|
15297
|
-
}
|
|
15298
|
-
async DeriveKeyPair(ikm, extractable) {
|
|
15299
|
-
extractable ??= false;
|
|
15300
|
-
checkExtractable(extractable);
|
|
15301
|
-
checkUint8Array(ikm, "ikm");
|
|
15302
|
-
if (ikm.byteLength < this.#suite.KEM.Nsk) {
|
|
15303
|
-
throw new DeriveKeyPairError('Insufficient "ikm" length');
|
|
15304
|
-
}
|
|
15305
|
-
try {
|
|
15306
|
-
return await this.#suite.KEM.DeriveKeyPair(ikm, extractable);
|
|
15307
|
-
} catch (cause) {
|
|
15308
|
-
if (cause instanceof NotSupportedError) {
|
|
15309
|
-
throw cause;
|
|
15310
|
-
}
|
|
15311
|
-
throw new DeriveKeyPairError("Key derivation failed", { cause });
|
|
15312
|
-
}
|
|
15313
|
-
}
|
|
15314
|
-
async SerializePrivateKey(privateKey) {
|
|
15315
|
-
isKey(privateKey, "private", true);
|
|
15316
|
-
return await this.#suite.KEM.SerializePrivateKey(privateKey);
|
|
15317
|
-
}
|
|
15318
|
-
async SerializePublicKey(publicKey) {
|
|
15319
|
-
isKey(publicKey, "public", true);
|
|
15320
|
-
return await this.#suite.KEM.SerializePublicKey(publicKey);
|
|
15321
|
-
}
|
|
15322
|
-
async DeserializePrivateKey(privateKey, extractable) {
|
|
15323
|
-
extractable ??= false;
|
|
15324
|
-
checkExtractable(extractable);
|
|
15325
|
-
checkUint8Array(privateKey, "privateKey");
|
|
15326
|
-
try {
|
|
15327
|
-
if (privateKey.byteLength !== this.#suite.KEM.Nsk) {
|
|
15328
|
-
throw new Error('Invalid "privateKey" length');
|
|
15329
|
-
}
|
|
15330
|
-
return await this.#suite.KEM.DeserializePrivateKey(privateKey, extractable);
|
|
15331
|
-
} catch (cause) {
|
|
15332
|
-
if (cause instanceof NotSupportedError) {
|
|
15333
|
-
throw cause;
|
|
15334
|
-
}
|
|
15335
|
-
throw new DeserializeError("Private key deserialization failed", { cause });
|
|
15336
|
-
}
|
|
15337
|
-
}
|
|
15338
|
-
async DeserializePublicKey(publicKey) {
|
|
15339
|
-
checkUint8Array(publicKey, "publicKey");
|
|
15340
|
-
try {
|
|
15341
|
-
if (publicKey.byteLength !== this.#suite.KEM.Npk) {
|
|
15342
|
-
throw new Error('Invalid "publicKey" length');
|
|
15343
|
-
}
|
|
15344
|
-
return await this.#suite.KEM.DeserializePublicKey(publicKey);
|
|
15345
|
-
} catch (cause) {
|
|
15346
|
-
if (cause instanceof NotSupportedError) {
|
|
15347
|
-
throw cause;
|
|
15348
|
-
}
|
|
15349
|
-
throw new DeserializeError("Public key deserialization failed", { cause });
|
|
15350
|
-
}
|
|
15351
|
-
}
|
|
15352
|
-
async Seal(publicKey, plaintext, options) {
|
|
15353
|
-
if (this.#suite.AEAD.id === EXPORT_ONLY) {
|
|
15354
|
-
throw new TypeError("Export-only AEAD cannot be used with Seal");
|
|
15355
|
-
}
|
|
15356
|
-
const { encapsulatedSecret, ctx } = await this.SetupSender(publicKey, options);
|
|
15357
|
-
const ciphertext = await ctx.Seal(plaintext, options?.aad);
|
|
15358
|
-
return { encapsulatedSecret, ciphertext };
|
|
15359
|
-
}
|
|
15360
|
-
async Open(privateKey, encapsulatedSecret, ciphertext, options) {
|
|
15361
|
-
if (this.#suite.AEAD.id === EXPORT_ONLY) {
|
|
15362
|
-
throw new TypeError("Export-only AEAD cannot be used with Open");
|
|
15363
|
-
}
|
|
15364
|
-
const ctx = await this.SetupRecipient(privateKey, encapsulatedSecret, options);
|
|
15365
|
-
return await ctx.Open(ciphertext, options?.aad);
|
|
15366
|
-
}
|
|
15367
|
-
async SendExport(publicKey, exporterContext, length, options) {
|
|
15368
|
-
const { encapsulatedSecret, ctx } = await this.SetupSender(publicKey, options);
|
|
15369
|
-
const exportedSecret = await ctx.Export(exporterContext, length);
|
|
15370
|
-
return { encapsulatedSecret, exportedSecret };
|
|
15371
|
-
}
|
|
15372
|
-
async ReceiveExport(privateKey, encapsulatedSecret, exporterContext, length, options) {
|
|
15373
|
-
const ctx = await this.SetupRecipient(privateKey, encapsulatedSecret, options);
|
|
15374
|
-
return await ctx.Export(exporterContext, length);
|
|
15375
|
-
}
|
|
15376
|
-
async SetupSender(publicKey, options) {
|
|
15377
|
-
isKey(publicKey, "public");
|
|
15378
|
-
let shared_secret;
|
|
15379
|
-
let enc;
|
|
15380
|
-
try {
|
|
15381
|
-
const result = await this.#suite.KEM.Encap(publicKey);
|
|
15382
|
-
shared_secret = result.shared_secret;
|
|
15383
|
-
enc = result.enc;
|
|
15384
|
-
} catch (cause) {
|
|
15385
|
-
if (cause instanceof ValidationError || cause instanceof NotSupportedError) {
|
|
15386
|
-
throw cause;
|
|
15387
|
-
}
|
|
15388
|
-
throw new EncapError("Encapsulation failed", { cause });
|
|
15389
|
-
}
|
|
15390
|
-
const mode = options?.psk?.byteLength ? MODE_PSK : MODE_BASE;
|
|
15391
|
-
const { key, base_nonce, exporter_secret } = await KeySchedule(
|
|
15392
|
-
this.#suite,
|
|
15393
|
-
mode,
|
|
15394
|
-
shared_secret,
|
|
15395
|
-
options?.info,
|
|
15396
|
-
options?.psk,
|
|
15397
|
-
options?.pskId
|
|
15398
|
-
);
|
|
15399
|
-
const ctx = new SenderContext(this.#suite, mode, key, base_nonce, exporter_secret);
|
|
15400
|
-
return { encapsulatedSecret: enc, ctx };
|
|
15401
|
-
}
|
|
15402
|
-
async SetupRecipient(privateKey, encapsulatedSecret, options) {
|
|
15403
|
-
const { skR, pkR } = this.#extractRecipientKeys(privateKey);
|
|
15404
|
-
checkUint8Array(encapsulatedSecret, "encapsulatedSecret");
|
|
15405
|
-
if (encapsulatedSecret.byteLength !== this.#suite.KEM.Nenc) {
|
|
15406
|
-
throw new DecapError("Invalid encapsulated secret length");
|
|
15407
|
-
}
|
|
15408
|
-
let shared_secret;
|
|
15409
|
-
try {
|
|
15410
|
-
shared_secret = await this.#suite.KEM.Decap(encapsulatedSecret, skR, pkR);
|
|
15411
|
-
} catch (cause) {
|
|
15412
|
-
if (cause instanceof ValidationError || cause instanceof NotSupportedError) {
|
|
15413
|
-
throw cause;
|
|
15414
|
-
}
|
|
15415
|
-
throw new DecapError("Decapsulation failed", { cause });
|
|
15416
|
-
}
|
|
15417
|
-
const mode = options?.psk?.byteLength ? MODE_PSK : MODE_BASE;
|
|
15418
|
-
const { key, base_nonce, exporter_secret } = await KeySchedule(
|
|
15419
|
-
this.#suite,
|
|
15420
|
-
mode,
|
|
15421
|
-
shared_secret,
|
|
15422
|
-
options?.info,
|
|
15423
|
-
options?.psk,
|
|
15424
|
-
options?.pskId
|
|
15425
|
-
);
|
|
15426
|
-
return new RecipientContext(this.#suite, mode, key, base_nonce, exporter_secret);
|
|
15427
|
-
}
|
|
15428
|
-
#extractRecipientKeys(skR) {
|
|
15429
|
-
if (isKeyPair(skR)) {
|
|
15430
|
-
return { skR: skR.privateKey, pkR: skR.publicKey };
|
|
15431
|
-
}
|
|
15432
|
-
isKey(skR, "private");
|
|
15433
|
-
return { skR, pkR: void 0 };
|
|
15434
|
-
}
|
|
15435
|
-
};
|
|
15436
|
-
var ValidationError = class _ValidationError extends Error {
|
|
15437
|
-
constructor(message, options) {
|
|
15438
|
-
super(message, options);
|
|
15439
|
-
this.name = "ValidationError";
|
|
15440
|
-
Error.captureStackTrace?.(this, _ValidationError);
|
|
15441
|
-
}
|
|
15442
|
-
};
|
|
15443
|
-
var DeserializeError = class _DeserializeError extends Error {
|
|
15444
|
-
constructor(message, options) {
|
|
15445
|
-
super(message, options);
|
|
15446
|
-
this.name = "DeserializeError";
|
|
15447
|
-
Error.captureStackTrace?.(this, _DeserializeError);
|
|
15448
|
-
}
|
|
15449
|
-
};
|
|
15450
|
-
var EncapError = class _EncapError extends Error {
|
|
15451
|
-
constructor(message, options) {
|
|
15452
|
-
super(message, options);
|
|
15453
|
-
this.name = "EncapError";
|
|
15454
|
-
Error.captureStackTrace?.(this, _EncapError);
|
|
15455
|
-
}
|
|
15456
|
-
};
|
|
15457
|
-
var DecapError = class _DecapError extends Error {
|
|
15458
|
-
constructor(message, options) {
|
|
15459
|
-
super(message, options);
|
|
15460
|
-
this.name = "DecapError";
|
|
15461
|
-
Error.captureStackTrace?.(this, _DecapError);
|
|
15462
|
-
}
|
|
15463
|
-
};
|
|
15464
|
-
var OpenError = class _OpenError extends Error {
|
|
15465
|
-
constructor(message, options) {
|
|
15466
|
-
super(message, options);
|
|
15467
|
-
this.name = "OpenError";
|
|
15468
|
-
Error.captureStackTrace?.(this, _OpenError);
|
|
15469
|
-
}
|
|
15470
|
-
};
|
|
15471
|
-
var MessageLimitReachedError = class _MessageLimitReachedError extends Error {
|
|
15472
|
-
constructor(message, options) {
|
|
15473
|
-
super(message, options);
|
|
15474
|
-
this.name = "MessageLimitReachedError";
|
|
15475
|
-
Error.captureStackTrace?.(this, _MessageLimitReachedError);
|
|
15476
|
-
}
|
|
15477
|
-
};
|
|
15478
|
-
var DeriveKeyPairError = class _DeriveKeyPairError extends Error {
|
|
15479
|
-
constructor(message, options) {
|
|
15480
|
-
super(message, options);
|
|
15481
|
-
this.name = "DeriveKeyPairError";
|
|
15482
|
-
Error.captureStackTrace?.(this, _DeriveKeyPairError);
|
|
15483
|
-
}
|
|
15484
|
-
};
|
|
15485
|
-
var NotSupportedError = class _NotSupportedError extends Error {
|
|
15486
|
-
constructor(message, options) {
|
|
15487
|
-
super(message, options);
|
|
15488
|
-
this.name = "NotSupportedError";
|
|
15489
|
-
Error.captureStackTrace?.(this, _NotSupportedError);
|
|
15490
|
-
}
|
|
15491
|
-
};
|
|
15492
|
-
var MODE_BASE = 0;
|
|
15493
|
-
var MODE_PSK = 1;
|
|
15494
|
-
function concat(...buffers) {
|
|
15495
|
-
const size = buffers.reduce((acc, { length }) => acc + length, 0);
|
|
15496
|
-
const buf = new Uint8Array(size);
|
|
15497
|
-
let i = 0;
|
|
15498
|
-
for (const buffer of buffers) {
|
|
15499
|
-
buf.set(buffer, i);
|
|
15500
|
-
i += buffer.length;
|
|
15501
|
-
}
|
|
15502
|
-
return buf;
|
|
15503
|
-
}
|
|
15504
|
-
function slice(buffer, start, end) {
|
|
15505
|
-
return Uint8Array.prototype.slice.call(buffer, start, end);
|
|
15506
|
-
}
|
|
15507
|
-
function encode(string) {
|
|
15508
|
-
const bytes = new Uint8Array(string.length);
|
|
15509
|
-
for (let i = 0; i < string.length; i++) {
|
|
15510
|
-
const code = string.charCodeAt(i);
|
|
15511
|
-
if (code > 127) {
|
|
15512
|
-
throw new TypeError("Input string must contain only ASCII characters");
|
|
15513
|
-
}
|
|
15514
|
-
bytes[i] = code;
|
|
15515
|
-
}
|
|
15516
|
-
return bytes;
|
|
15517
|
-
}
|
|
15518
|
-
var L_HPKE_v1 = encode("HPKE-v1");
|
|
15519
|
-
var L_HPKE = encode("HPKE");
|
|
15520
|
-
var L_KEM = encode("KEM");
|
|
15521
|
-
var L_sec = encode("sec");
|
|
15522
|
-
var L_secret = encode("secret");
|
|
15523
|
-
var L_key = encode("key");
|
|
15524
|
-
var L_base_nonce = encode("base_nonce");
|
|
15525
|
-
var L_exp = encode("exp");
|
|
15526
|
-
var L_psk_id_hash = encode("psk_id_hash");
|
|
15527
|
-
var L_info_hash = encode("info_hash");
|
|
15528
|
-
var L_dkp_prk = encode("dkp_prk");
|
|
15529
|
-
var L_candidate = encode("candidate");
|
|
15530
|
-
var L_eae_prk = encode("eae_prk");
|
|
15531
|
-
var L_shared_secret = encode("shared_secret");
|
|
15532
|
-
var L_sk = encode("sk");
|
|
15533
|
-
var L_DeriveKeyPair = encode("DeriveKeyPair");
|
|
15534
|
-
function lengthPrefixed(x) {
|
|
15535
|
-
return concat(I2OSP(x.byteLength, 2), x);
|
|
15536
|
-
}
|
|
15537
|
-
async function LabeledDerive(KDF, suite_id, ikm, label, context2, L) {
|
|
15538
|
-
const labeled_ikm = concat(ikm, L_HPKE_v1, suite_id, lengthPrefixed(label), I2OSP(L, 2), context2);
|
|
15539
|
-
return await KDF.Derive(labeled_ikm, L);
|
|
15540
|
-
}
|
|
15541
|
-
async function Export_OneStage(KDF, suite_id, exporter_secret, exporter_context, L) {
|
|
15542
|
-
checkLength(exporter_context, "Exporter context", MAX_LENGTH_ONE_STAGE);
|
|
15543
|
-
return await LabeledDerive(KDF, suite_id, exporter_secret, L_sec, exporter_context, L);
|
|
15544
|
-
}
|
|
15545
|
-
async function CombineSecrets_OneStage(suite2, mode, shared_secret, info, psk, psk_id) {
|
|
15546
|
-
checkLength(psk, "PSK", MAX_LENGTH_ONE_STAGE);
|
|
15547
|
-
checkLength(psk_id, "PSK ID", MAX_LENGTH_ONE_STAGE);
|
|
15548
|
-
checkLength(info, "Info", MAX_LENGTH_ONE_STAGE);
|
|
15549
|
-
const secrets = concat(lengthPrefixed(psk), lengthPrefixed(shared_secret));
|
|
15550
|
-
const context2 = concat(I2OSP(mode, 1), lengthPrefixed(psk_id), lengthPrefixed(info));
|
|
15551
|
-
const secret = await LabeledDerive(
|
|
15552
|
-
suite2.KDF,
|
|
15553
|
-
suite2.id,
|
|
15554
|
-
secrets,
|
|
15555
|
-
L_secret,
|
|
15556
|
-
context2,
|
|
15557
|
-
suite2.AEAD.Nk + suite2.AEAD.Nn + suite2.KDF.Nh
|
|
15558
|
-
);
|
|
15559
|
-
const key = slice(secret, 0, suite2.AEAD.Nk);
|
|
15560
|
-
const base_nonce = slice(secret, suite2.AEAD.Nk, suite2.AEAD.Nk + suite2.AEAD.Nn);
|
|
15561
|
-
const exporter_secret = slice(secret, suite2.AEAD.Nk + suite2.AEAD.Nn);
|
|
15562
|
-
return { key, base_nonce, exporter_secret };
|
|
15563
|
-
}
|
|
15564
|
-
var MAX_LENGTH_TWO_STAGE = 65535;
|
|
15565
|
-
var MAX_LENGTH_ONE_STAGE = 65535;
|
|
15566
|
-
function checkLength(data, name, maxLength) {
|
|
15567
|
-
if (data.byteLength > maxLength) {
|
|
15568
|
-
throw new TypeError(`${name} length must not exceed ${maxLength} bytes`);
|
|
15569
|
-
}
|
|
15570
|
-
}
|
|
15571
|
-
function checkUint8Array(input, name) {
|
|
15572
|
-
if (!(input instanceof Uint8Array)) {
|
|
15573
|
-
throw new TypeError(`"${name}" must be Uint8Array`);
|
|
15574
|
-
}
|
|
15575
|
-
if (typeof SharedArrayBuffer !== "undefined" && input.buffer instanceof SharedArrayBuffer) {
|
|
15576
|
-
throw new TypeError(`"${name}" must not be backed by a SharedArrayBuffer`);
|
|
15577
|
-
}
|
|
15578
|
-
}
|
|
15579
|
-
function checkExtractable(extractable) {
|
|
15580
|
-
if (typeof extractable !== "boolean") {
|
|
15581
|
-
throw new TypeError('"extractable" must be boolean');
|
|
15582
|
-
}
|
|
15583
|
-
}
|
|
15584
|
-
async function CombineSecrets_TwoStage(suite2, mode, shared_secret, info, psk, psk_id) {
|
|
15585
|
-
checkLength(psk, "PSK", MAX_LENGTH_TWO_STAGE);
|
|
15586
|
-
checkLength(psk_id, "PSK ID", MAX_LENGTH_TWO_STAGE);
|
|
15587
|
-
checkLength(info, "Info", MAX_LENGTH_TWO_STAGE);
|
|
15588
|
-
const [psk_id_hash, info_hash] = await Promise.all([
|
|
15589
|
-
LabeledExtract(suite2.KDF, suite2.id, new Uint8Array(), L_psk_id_hash, psk_id),
|
|
15590
|
-
LabeledExtract(suite2.KDF, suite2.id, new Uint8Array(), L_info_hash, info)
|
|
15591
|
-
]);
|
|
15592
|
-
const key_schedule_context = concat(I2OSP(mode, 1), psk_id_hash, info_hash);
|
|
15593
|
-
const secret = await LabeledExtract(suite2.KDF, suite2.id, shared_secret, L_secret, psk);
|
|
15594
|
-
if (suite2.AEAD.id === EXPORT_ONLY) {
|
|
15595
|
-
const exporter_secret2 = await LabeledExpand(
|
|
15596
|
-
suite2.KDF,
|
|
15597
|
-
suite2.id,
|
|
15598
|
-
secret,
|
|
15599
|
-
L_exp,
|
|
15600
|
-
key_schedule_context,
|
|
15601
|
-
suite2.KDF.Nh
|
|
15602
|
-
);
|
|
15603
|
-
return { key: new Uint8Array(), base_nonce: new Uint8Array(), exporter_secret: exporter_secret2 };
|
|
15604
|
-
}
|
|
15605
|
-
const [key, base_nonce, exporter_secret] = await Promise.all([
|
|
15606
|
-
LabeledExpand(suite2.KDF, suite2.id, secret, L_key, key_schedule_context, suite2.AEAD.Nk),
|
|
15607
|
-
LabeledExpand(suite2.KDF, suite2.id, secret, L_base_nonce, key_schedule_context, suite2.AEAD.Nn),
|
|
15608
|
-
LabeledExpand(suite2.KDF, suite2.id, secret, L_exp, key_schedule_context, suite2.KDF.Nh)
|
|
15609
|
-
]);
|
|
15610
|
-
return { key, base_nonce, exporter_secret };
|
|
15611
|
-
}
|
|
15612
|
-
async function Export_TwoStage(KDF, suite_id, exporter_secret, exporter_context, L) {
|
|
15613
|
-
checkLength(exporter_context, "Exporter context", MAX_LENGTH_TWO_STAGE);
|
|
15614
|
-
return await LabeledExpand(KDF, suite_id, exporter_secret, L_sec, exporter_context, L);
|
|
15615
|
-
}
|
|
15616
|
-
async function LabeledExtract(KDF, suite_id, salt, label, ikm) {
|
|
15617
|
-
const labeled_ikm = concat(L_HPKE_v1, suite_id, label, ikm);
|
|
15618
|
-
return await KDF.Extract(salt, labeled_ikm);
|
|
15619
|
-
}
|
|
15620
|
-
async function LabeledExpand(KDF, suite_id, prk, label, info, L) {
|
|
15621
|
-
const labeled_info = concat(I2OSP(L, 2), L_HPKE_v1, suite_id, label, info);
|
|
15622
|
-
return await KDF.Expand(prk, labeled_info, L);
|
|
15623
|
-
}
|
|
15624
|
-
function isKeyPair(skR) {
|
|
15625
|
-
if (!skR || typeof skR !== "object") return false;
|
|
15626
|
-
if ("publicKey" in skR && "privateKey" in skR) {
|
|
15627
|
-
const pkR = skR.publicKey;
|
|
15628
|
-
skR = skR.privateKey;
|
|
15629
|
-
try {
|
|
15630
|
-
isKey(pkR, "public");
|
|
15631
|
-
isKey(skR, "private");
|
|
15632
|
-
if (pkR.algorithm.name !== skR.algorithm.name) {
|
|
15633
|
-
throw new TypeError("key pair algorithms do not match");
|
|
15634
|
-
}
|
|
15635
|
-
} catch (cause) {
|
|
15636
|
-
throw new TypeError('Invalid "privateKey"', { cause });
|
|
15637
|
-
}
|
|
15638
|
-
return true;
|
|
15639
|
-
}
|
|
15640
|
-
return false;
|
|
15641
|
-
}
|
|
15642
|
-
function isKey(key, type, extractable) {
|
|
15643
|
-
const k = key;
|
|
15644
|
-
if (typeof k.algorithm !== "object" || typeof k.algorithm.name !== "string" || typeof k.extractable !== "boolean" || typeof k.type !== "string" || k.type !== type) {
|
|
15645
|
-
throw new TypeError(`Invalid "${type}Key"`);
|
|
15646
|
-
}
|
|
15647
|
-
if (extractable && k.extractable !== true) {
|
|
15648
|
-
throw new TypeError(`"${type}Key" must be extractable`);
|
|
15649
|
-
}
|
|
15650
|
-
}
|
|
15651
|
-
function I2OSP(n, w) {
|
|
15652
|
-
if (!Number.isSafeInteger(w) || w <= 0) {
|
|
15653
|
-
throw new Error("w must be a positive safe integer");
|
|
15654
|
-
}
|
|
15655
|
-
if (!Number.isSafeInteger(n) || n < 0) {
|
|
15656
|
-
throw new Error("n must be a non-negative safe integer");
|
|
15657
|
-
}
|
|
15658
|
-
const max = Math.pow(256, w);
|
|
15659
|
-
if (n >= max) {
|
|
15660
|
-
throw new Error("n too large to fit in w-length byte string");
|
|
15661
|
-
}
|
|
15662
|
-
const ret = new Uint8Array(w);
|
|
15663
|
-
let num = n;
|
|
15664
|
-
for (let i = 0; i < w && num; i++) {
|
|
15665
|
-
ret[w - (i + 1)] = num % 256;
|
|
15666
|
-
num = Math.floor(num / 256);
|
|
15667
|
-
}
|
|
15668
|
-
return ret;
|
|
15669
|
-
}
|
|
15670
|
-
function KDFStages(KDF) {
|
|
15671
|
-
if (KDF.stages === 1 || KDF.stages === 2) {
|
|
15672
|
-
return KDF.stages;
|
|
15673
|
-
}
|
|
15674
|
-
throw new Error("unreachable");
|
|
15675
|
-
}
|
|
15676
|
-
async function KeySchedule(suite2, mode, shared_secret, info, psk, pskId) {
|
|
15677
|
-
info ??= new Uint8Array();
|
|
15678
|
-
checkUint8Array(info, "info");
|
|
15679
|
-
psk ??= new Uint8Array();
|
|
15680
|
-
checkUint8Array(psk, "psk");
|
|
15681
|
-
pskId ??= new Uint8Array();
|
|
15682
|
-
checkUint8Array(pskId, "pskId");
|
|
15683
|
-
const stages = KDFStages(suite2.KDF);
|
|
15684
|
-
const CombineSecrets = stages === 1 ? CombineSecrets_OneStage : CombineSecrets_TwoStage;
|
|
15685
|
-
VerifyPSKInputs(psk, pskId);
|
|
15686
|
-
return await CombineSecrets(suite2, mode, shared_secret, info, psk, pskId);
|
|
15687
|
-
}
|
|
15688
|
-
function VerifyPSKInputs(psk, psk_id) {
|
|
15689
|
-
if (psk.byteLength && psk_id.byteLength) {
|
|
15690
|
-
if (psk.byteLength < 32) {
|
|
15691
|
-
throw new TypeError("Insufficient PSK length");
|
|
15692
|
-
}
|
|
15693
|
-
return;
|
|
15694
|
-
}
|
|
15695
|
-
if (!psk.byteLength && !psk_id.byteLength) {
|
|
15696
|
-
return;
|
|
15697
|
-
}
|
|
15698
|
-
throw new TypeError("Inconsistent PSK inputs");
|
|
15699
|
-
}
|
|
15700
|
-
var NotApplicable = () => {
|
|
15701
|
-
throw new Error("unreachable");
|
|
15702
|
-
};
|
|
15703
|
-
var EXPORT_ONLY = 65535;
|
|
15704
|
-
async function subtle(promise, name) {
|
|
15705
|
-
try {
|
|
15706
|
-
return await promise(crypto.subtle);
|
|
15707
|
-
} catch (cause) {
|
|
15708
|
-
if (cause instanceof TypeError || cause instanceof DOMException && cause.name === "NotSupportedError") {
|
|
15709
|
-
throw new NotSupportedError(`${name} is unsupported in this runtime`, { cause });
|
|
15710
|
-
}
|
|
15711
|
-
throw cause;
|
|
15712
|
-
}
|
|
15713
|
-
}
|
|
15714
|
-
async function cacheValue(cache, key, init) {
|
|
15715
|
-
const result = await init();
|
|
15716
|
-
cache.set(key, result);
|
|
15717
|
-
return result;
|
|
14572
|
+
// ../agent/src/core/transactions.ts
|
|
14573
|
+
var VERSION = "0x3";
|
|
14574
|
+
function hashBounds(bounds) {
|
|
14575
|
+
const bound = ({ maxAmount, maxPricePerUnit }) => ({ max_amount: maxAmount, max_price_per_unit: maxPricePerUnit });
|
|
14576
|
+
return { l1_gas: bound(bounds.l1Gas), l2_gas: bound(bounds.l2Gas), l1_data_gas: bound(bounds.l1DataGas) };
|
|
15718
14577
|
}
|
|
15719
|
-
function
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
|
|
15725
|
-
);
|
|
15726
|
-
}
|
|
15727
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
15728
|
-
function importPrk(prk) {
|
|
15729
|
-
const key = importKey.call(this, prk);
|
|
15730
|
-
cache.set(prk, key);
|
|
15731
|
-
return key;
|
|
15732
|
-
}
|
|
15733
|
-
return {
|
|
15734
|
-
stages: 2,
|
|
15735
|
-
Derive: NotApplicable,
|
|
15736
|
-
async Extract(salt, ikm) {
|
|
15737
|
-
const key = salt.byteLength === 0 ? emptySalt ??= await importKey.call(this, new ArrayBuffer(this.Nh)) : await importKey.call(this, salt);
|
|
15738
|
-
return new Uint8Array(
|
|
15739
|
-
await subtle((c) => c.sign("HMAC", key, ikm), this.name)
|
|
15740
|
-
);
|
|
15741
|
-
},
|
|
15742
|
-
async Expand(prk, info, L) {
|
|
15743
|
-
if (prk.byteLength < this.Nh) {
|
|
15744
|
-
throw new Error("prk.byteLength < this.Nh");
|
|
15745
|
-
}
|
|
15746
|
-
if (L > 255 * this.Nh) {
|
|
15747
|
-
throw new Error("L must be <= 255*Nh");
|
|
15748
|
-
}
|
|
15749
|
-
const N = Math.ceil(L / this.Nh);
|
|
15750
|
-
const key = await (cache.get(prk) ?? importPrk.call(this, prk));
|
|
15751
|
-
const T = new Uint8Array(N * this.Nh);
|
|
15752
|
-
let T_prev = new Uint8Array();
|
|
15753
|
-
for (let i = 0; i < N; i++) {
|
|
15754
|
-
const input = new Uint8Array(T_prev.byteLength + info.byteLength + 1);
|
|
15755
|
-
input.set(T_prev);
|
|
15756
|
-
input.set(info, T_prev.byteLength);
|
|
15757
|
-
input[T_prev.byteLength + info.byteLength] = i + 1;
|
|
15758
|
-
const T_i = new Uint8Array(await subtle((c) => c.sign("HMAC", key, input), this.name));
|
|
15759
|
-
T.set(T_i, i * this.Nh);
|
|
15760
|
-
T_prev = T_i;
|
|
15761
|
-
}
|
|
15762
|
-
return slice(T, 0, L);
|
|
15763
|
-
}
|
|
15764
|
-
};
|
|
14578
|
+
function rpcBounds(bounds) {
|
|
14579
|
+
const bound = ({ maxAmount, maxPricePerUnit }) => ({
|
|
14580
|
+
max_amount: toHex2(maxAmount),
|
|
14581
|
+
max_price_per_unit: toHex2(maxPricePerUnit)
|
|
14582
|
+
});
|
|
14583
|
+
return { l1_gas: bound(bounds.l1Gas), l2_gas: bound(bounds.l2Gas), l1_data_gas: bound(bounds.l1DataGas) };
|
|
15765
14584
|
}
|
|
15766
|
-
var
|
|
15767
|
-
|
|
14585
|
+
var COMMON_FIELDS = {
|
|
14586
|
+
tip: "0x0",
|
|
14587
|
+
paymaster_data: [],
|
|
14588
|
+
nonce_data_availability_mode: "L1",
|
|
14589
|
+
fee_data_availability_mode: "L1"
|
|
15768
14590
|
};
|
|
15769
|
-
|
|
15770
|
-
if (!key.extractable) {
|
|
15771
|
-
throw new TypeError(
|
|
15772
|
-
'"privateKey" must be extractable or a Key Pair must be used in this runtime'
|
|
15773
|
-
);
|
|
15774
|
-
}
|
|
15775
|
-
return await subtle(async (c) => {
|
|
15776
|
-
const jwk = await c.exportKey("jwk", key);
|
|
15777
|
-
return c.importKey(
|
|
15778
|
-
"jwk",
|
|
15779
|
-
{ kty: jwk.kty, crv: jwk.crv, x: jwk.x, y: jwk.y },
|
|
15780
|
-
key.algorithm,
|
|
15781
|
-
true,
|
|
15782
|
-
usages
|
|
15783
|
-
);
|
|
15784
|
-
}, name);
|
|
15785
|
-
}
|
|
15786
|
-
async function getPublicKey2(name, key, usages) {
|
|
15787
|
-
return await subtle((c) => c.getPublicKey?.(key, usages), name) || await getPublicKeyByExport(name, key, usages);
|
|
15788
|
-
}
|
|
15789
|
-
function checkNotAllZeros(buffer) {
|
|
15790
|
-
let or = 0;
|
|
15791
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
15792
|
-
or |= buffer[i];
|
|
15793
|
-
}
|
|
15794
|
-
if (or === 0) {
|
|
15795
|
-
throw new ValidationError("DH shared secret is an all-zero value");
|
|
15796
|
-
}
|
|
15797
|
-
}
|
|
15798
|
-
function fromBase64(input) {
|
|
15799
|
-
input = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
15800
|
-
const binary = atob(input);
|
|
15801
|
-
const bytes = new Uint8Array(binary.length);
|
|
15802
|
-
for (let i = 0; i < binary.length; i++) {
|
|
15803
|
-
bytes[i] = binary.charCodeAt(i);
|
|
15804
|
-
}
|
|
15805
|
-
return bytes;
|
|
15806
|
-
}
|
|
15807
|
-
function b64u(input) {
|
|
15808
|
-
return Uint8Array.fromBase64?.(input, { alphabet: "base64url" }) || fromBase64(input);
|
|
15809
|
-
}
|
|
15810
|
-
function assertKeyAlgorithm(key, expectedAlgorithm) {
|
|
15811
|
-
if (key.algorithm.name !== expectedAlgorithm.name) {
|
|
15812
|
-
throw new TypeError(`key algorithm must be ${expectedAlgorithm.name}`);
|
|
15813
|
-
}
|
|
15814
|
-
if (key.algorithm.namedCurve !== expectedAlgorithm.namedCurve) {
|
|
15815
|
-
throw new TypeError(
|
|
15816
|
-
`key namedCurve must be ${expectedAlgorithm.namedCurve}`
|
|
15817
|
-
);
|
|
15818
|
-
}
|
|
15819
|
-
}
|
|
15820
|
-
function assertCryptoKey(key) {
|
|
15821
|
-
if (key[Symbol.toStringTag] !== "CryptoKey") {
|
|
15822
|
-
if (key instanceof CryptoKey) return;
|
|
15823
|
-
throw new TypeError("unexpected key constructor");
|
|
15824
|
-
}
|
|
15825
|
-
}
|
|
15826
|
-
async function ExtractAndExpand_TwoStage(DHKEM, dh, kem_context) {
|
|
15827
|
-
const eae_prk = await LabeledExtract(DHKEM.kdf, DHKEM.suite_id, new Uint8Array(), L_eae_prk, dh);
|
|
15828
|
-
return await LabeledExpand(
|
|
15829
|
-
DHKEM.kdf,
|
|
15830
|
-
DHKEM.suite_id,
|
|
15831
|
-
eae_prk,
|
|
15832
|
-
L_shared_secret,
|
|
15833
|
-
kem_context,
|
|
15834
|
-
DHKEM.Nsecret
|
|
15835
|
-
);
|
|
15836
|
-
}
|
|
15837
|
-
function DHKEM_SHARED() {
|
|
14591
|
+
function invokeTransaction(tx, version, signature) {
|
|
15838
14592
|
return {
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
}
|
|
15850
|
-
async DeserializePublicKey(key) {
|
|
15851
|
-
return await subtle(
|
|
15852
|
-
(c) => c.importKey("raw", key, this.algorithm, true, []),
|
|
15853
|
-
this.name
|
|
15854
|
-
);
|
|
15855
|
-
},
|
|
15856
|
-
async SerializePrivateKey(key) {
|
|
15857
|
-
assertKeyAlgorithm(key, this.algorithm);
|
|
15858
|
-
assertCryptoKey(key);
|
|
15859
|
-
const { d } = await subtle((c) => c.exportKey("jwk", key), this.name);
|
|
15860
|
-
return b64u(d);
|
|
15861
|
-
},
|
|
15862
|
-
async Encap(pkR) {
|
|
15863
|
-
assertKeyAlgorithm(pkR, this.algorithm);
|
|
15864
|
-
assertCryptoKey(pkR);
|
|
15865
|
-
const ekp = await this.GenerateKeyPair(false);
|
|
15866
|
-
const skE = ekp.privateKey;
|
|
15867
|
-
const pkE = ekp.publicKey;
|
|
15868
|
-
const dh = new Uint8Array(
|
|
15869
|
-
await subtle(
|
|
15870
|
-
(c) => c.deriveBits({ name: skE.algorithm.name, public: pkR }, skE, this.Ndh << 3),
|
|
15871
|
-
this.name
|
|
15872
|
-
)
|
|
15873
|
-
);
|
|
15874
|
-
checkNotAllZeros(dh);
|
|
15875
|
-
const enc = await this.SerializePublicKey(pkE);
|
|
15876
|
-
const pkRm = await this.SerializePublicKey(pkR);
|
|
15877
|
-
const kem_context = concat(enc, pkRm);
|
|
15878
|
-
const shared_secret = await ExtractAndExpand_TwoStage(this, dh, kem_context);
|
|
15879
|
-
return { shared_secret, enc };
|
|
15880
|
-
},
|
|
15881
|
-
async Decap(enc, skR, pkR) {
|
|
15882
|
-
assertKeyAlgorithm(skR, this.algorithm);
|
|
15883
|
-
assertCryptoKey(skR);
|
|
15884
|
-
if (pkR) {
|
|
15885
|
-
assertKeyAlgorithm(pkR, this.algorithm);
|
|
15886
|
-
assertCryptoKey(pkR);
|
|
15887
|
-
} else {
|
|
15888
|
-
pkR = await getPublicKey2(this.name, skR, []);
|
|
15889
|
-
}
|
|
15890
|
-
const pkE = await this.DeserializePublicKey(enc);
|
|
15891
|
-
const dh = new Uint8Array(
|
|
15892
|
-
await subtle(
|
|
15893
|
-
(c) => c.deriveBits({ name: skR.algorithm.name, public: pkE }, skR, this.Ndh << 3),
|
|
15894
|
-
this.name
|
|
15895
|
-
)
|
|
15896
|
-
);
|
|
15897
|
-
checkNotAllZeros(dh);
|
|
15898
|
-
const pkRm = await this.SerializePublicKey(pkR);
|
|
15899
|
-
const kem_context = concat(enc, pkRm);
|
|
15900
|
-
const shared_secret = await ExtractAndExpand_TwoStage(this, dh, kem_context);
|
|
15901
|
-
return shared_secret;
|
|
15902
|
-
}
|
|
14593
|
+
type: "INVOKE",
|
|
14594
|
+
version,
|
|
14595
|
+
sender_address: toHex2(tx.sender),
|
|
14596
|
+
calldata: executeCalldata(tx.calls).map(toHex2),
|
|
14597
|
+
signature: signature.map(toHex2),
|
|
14598
|
+
nonce: toHex2(tx.nonce),
|
|
14599
|
+
resource_bounds: rpcBounds(tx.bounds),
|
|
14600
|
+
account_deployment_data: [],
|
|
14601
|
+
...COMMON_FIELDS,
|
|
14602
|
+
// Without facts there is no proof to carry, and empty proof fields make the transaction invalid.
|
|
14603
|
+
...tx.proof?.facts.length && { proof: tx.proof.data, proof_facts: tx.proof.facts.map(toHex2) }
|
|
15903
14604
|
};
|
|
15904
14605
|
}
|
|
15905
|
-
|
|
15906
|
-
|
|
15907
|
-
|
|
15908
|
-
|
|
15909
|
-
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
pkcs8.set(tmpl);
|
|
15922
|
-
pkcs8.set(key, tmpl.byteLength);
|
|
15923
|
-
return await subtle(
|
|
15924
|
-
(c) => c.importKey("pkcs8", pkcs8, algorithm, extractable, ["deriveBits"]),
|
|
15925
|
-
name
|
|
14606
|
+
function invokeTransactionHash(tx) {
|
|
14607
|
+
return BigInt(
|
|
14608
|
+
hash_exports.calculateInvokeTransactionHash({
|
|
14609
|
+
senderAddress: tx.sender,
|
|
14610
|
+
version: VERSION,
|
|
14611
|
+
compiledCalldata: executeCalldata(tx.calls).map(toHex2),
|
|
14612
|
+
chainId: toHex2(tx.chainId),
|
|
14613
|
+
nonce: tx.nonce,
|
|
14614
|
+
accountDeploymentData: [],
|
|
14615
|
+
nonceDataAvailabilityMode: 0,
|
|
14616
|
+
feeDataAvailabilityMode: 0,
|
|
14617
|
+
resourceBounds: hashBounds(tx.bounds),
|
|
14618
|
+
tip: 0n,
|
|
14619
|
+
paymasterData: [],
|
|
14620
|
+
proofFacts: tx.proof?.facts.map(toHex2)
|
|
14621
|
+
})
|
|
15926
14622
|
);
|
|
15927
14623
|
}
|
|
15928
|
-
async function DeriveKeyPairX(ikm, extractable) {
|
|
15929
|
-
const dkp_prk = await LabeledExtract(this.kdf, this.suite_id, new Uint8Array(), L_dkp_prk, ikm);
|
|
15930
|
-
const sk = await LabeledExpand(this.kdf, this.suite_id, dkp_prk, L_sk, new Uint8Array(), this.Nsk);
|
|
15931
|
-
return await createKeyPairFromPrivateKey(this, sk, extractable);
|
|
15932
|
-
}
|
|
15933
|
-
var KEM_DHKEM_X25519_HKDF_SHA256 = function() {
|
|
15934
|
-
const id = 32;
|
|
15935
|
-
const name = "DHKEM(X25519, HKDF-SHA256)";
|
|
15936
|
-
const kdf = KDF_HKDF_SHA256();
|
|
15937
|
-
kdf.name = name;
|
|
15938
|
-
return {
|
|
15939
|
-
id,
|
|
15940
|
-
suite_id: concat(L_KEM, I2OSP(id, 2)),
|
|
15941
|
-
type: "KEM",
|
|
15942
|
-
name,
|
|
15943
|
-
kdf,
|
|
15944
|
-
Nsecret: 32,
|
|
15945
|
-
Nenc: 32,
|
|
15946
|
-
Npk: 32,
|
|
15947
|
-
Nsk: 32,
|
|
15948
|
-
Ndh: 32,
|
|
15949
|
-
algorithm: { name: "X25519" },
|
|
15950
|
-
pkcs8: Uint8Array.of(48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32),
|
|
15951
|
-
DeriveKeyPair: DeriveKeyPairX,
|
|
15952
|
-
async DeserializePrivateKey(key, extractable) {
|
|
15953
|
-
return await CurveKeyFromD(name, this.Nsk, this.pkcs8, this.algorithm, key, extractable);
|
|
15954
|
-
},
|
|
15955
|
-
...DHKEM_SHARED()
|
|
15956
|
-
};
|
|
15957
|
-
};
|
|
15958
|
-
function AEAD_SHARED() {
|
|
15959
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
15960
|
-
async function importKey(key) {
|
|
15961
|
-
return await subtle(
|
|
15962
|
-
(c) => c.importKey(this.keyFormat, key, this.algorithm, false, [
|
|
15963
|
-
"encrypt",
|
|
15964
|
-
"decrypt"
|
|
15965
|
-
]),
|
|
15966
|
-
this.name
|
|
15967
|
-
);
|
|
15968
|
-
}
|
|
15969
|
-
return {
|
|
15970
|
-
async Seal(key, nonce, aad, pt) {
|
|
15971
|
-
const cryptoKey = cache.get(key) ?? await cacheValue(cache, key, () => importKey.call(this, key));
|
|
15972
|
-
return new Uint8Array(
|
|
15973
|
-
await subtle(
|
|
15974
|
-
(c) => c.encrypt(
|
|
15975
|
-
{
|
|
15976
|
-
name: this.algorithm,
|
|
15977
|
-
iv: nonce,
|
|
15978
|
-
additionalData: aad
|
|
15979
|
-
},
|
|
15980
|
-
cryptoKey,
|
|
15981
|
-
pt
|
|
15982
|
-
),
|
|
15983
|
-
this.name
|
|
15984
|
-
)
|
|
15985
|
-
);
|
|
15986
|
-
},
|
|
15987
|
-
async Open(key, nonce, aad, ct) {
|
|
15988
|
-
const cryptoKey = cache.get(key) ?? await cacheValue(cache, key, () => importKey.call(this, key));
|
|
15989
|
-
return new Uint8Array(
|
|
15990
|
-
await subtle(
|
|
15991
|
-
(c) => c.decrypt(
|
|
15992
|
-
{
|
|
15993
|
-
name: this.algorithm,
|
|
15994
|
-
iv: nonce,
|
|
15995
|
-
additionalData: aad
|
|
15996
|
-
},
|
|
15997
|
-
cryptoKey,
|
|
15998
|
-
ct
|
|
15999
|
-
),
|
|
16000
|
-
this.name
|
|
16001
|
-
)
|
|
16002
|
-
);
|
|
16003
|
-
}
|
|
16004
|
-
};
|
|
16005
|
-
}
|
|
16006
|
-
var AEAD_AES_128_GCM = function() {
|
|
16007
|
-
return {
|
|
16008
|
-
id: 1,
|
|
16009
|
-
type: "AEAD",
|
|
16010
|
-
name: "AES-128-GCM",
|
|
16011
|
-
Nk: 16,
|
|
16012
|
-
Nn: 12,
|
|
16013
|
-
Nt: 16,
|
|
16014
|
-
algorithm: "AES-GCM",
|
|
16015
|
-
keyFormat: "raw",
|
|
16016
|
-
...AEAD_SHARED()
|
|
16017
|
-
};
|
|
16018
|
-
};
|
|
16019
|
-
|
|
16020
|
-
// ../../packages/core/src/push.ts
|
|
16021
|
-
var PUSH_INFO = new TextEncoder().encode("outis/push/v1");
|
|
16022
|
-
var suite = new CipherSuite(KEM_DHKEM_X25519_HKDF_SHA256, KDF_HKDF_SHA256, AEAD_AES_128_GCM);
|
|
16023
|
-
|
|
16024
|
-
// ../../packages/core/src/recent.ts
|
|
16025
|
-
var TRANSFER3 = selector("Transfer");
|
|
16026
|
-
var TRANSACTION_EXECUTED = selector("TransactionExecuted");
|
|
16027
|
-
|
|
16028
|
-
// ../../packages/core/src/vault.ts
|
|
16029
|
-
var PASSKEY_SEAL_INPUT = utf8("outis/vault/v1");
|
|
16030
|
-
var SEALING_KEY_LABEL = utf8("outis/vault/seal/v1");
|
|
16031
|
-
var PURPOSE3 = utf8("outis passkey-sealed seed v1");
|
|
16032
|
-
var WALLET_KEY_LABEL = utf8("outis/vault/wallet/v1");
|
|
16033
|
-
var MESSAGE_DOMAIN2 = utf8("outis/vault/v1");
|
|
16034
|
-
|
|
16035
|
-
// ../../packages/core/src/vaultNames.ts
|
|
16036
|
-
var NAMES_KEY_LABEL = utf8("outis/vault/names/v1");
|
|
16037
|
-
var NAMES_SEAL_LABEL = utf8("outis/vault/names/seal/v1");
|
|
16038
|
-
var NAMES_PURPOSE = utf8("outis vault names v1");
|
|
16039
|
-
var MESSAGE_PREFIX = concatBytes3(utf8("outis/vault/v1"), new Uint8Array([0]), utf8("names"), new Uint8Array([0]));
|
|
16040
|
-
var IV_BYTES = 12;
|
|
16041
|
-
var TAG_BYTES = 16;
|
|
16042
|
-
var PADDED_SIZES = [1024, 2048, 4096, 8192];
|
|
16043
|
-
var NAMES_BLOB_MAX = 1 + IV_BYTES + PADDED_SIZES[PADDED_SIZES.length - 1] + TAG_BYTES;
|
|
16044
|
-
var NAMES_VERSION_MAX = Number.MAX_SAFE_INTEGER;
|
|
16045
|
-
|
|
16046
|
-
// ../../packages/core/src/webauthn.ts
|
|
16047
|
-
var P256_SPKI = Uint8Array.from([
|
|
16048
|
-
48,
|
|
16049
|
-
89,
|
|
16050
|
-
48,
|
|
16051
|
-
19,
|
|
16052
|
-
6,
|
|
16053
|
-
7,
|
|
16054
|
-
42,
|
|
16055
|
-
134,
|
|
16056
|
-
72,
|
|
16057
|
-
206,
|
|
16058
|
-
61,
|
|
16059
|
-
2,
|
|
16060
|
-
1,
|
|
16061
|
-
6,
|
|
16062
|
-
8,
|
|
16063
|
-
42,
|
|
16064
|
-
134,
|
|
16065
|
-
72,
|
|
16066
|
-
206,
|
|
16067
|
-
61,
|
|
16068
|
-
3,
|
|
16069
|
-
1,
|
|
16070
|
-
7,
|
|
16071
|
-
3,
|
|
16072
|
-
66,
|
|
16073
|
-
0
|
|
16074
|
-
]);
|
|
16075
|
-
var ED25519_SPKI = Uint8Array.from([48, 42, 48, 5, 6, 3, 43, 101, 112, 3, 33, 0]);
|
|
16076
|
-
var RSA_ALGORITHM = Uint8Array.from([48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0]);
|
|
16077
|
-
|
|
16078
|
-
// ../../packages/core/src/opus.ts
|
|
16079
|
-
var PROVIDE = selector("provide");
|
|
16080
|
-
var U128 = 2n ** 128n;
|
|
16081
14624
|
|
|
16082
|
-
//
|
|
16083
|
-
init_stakingValidators();
|
|
16084
|
-
init_stakingValidators();
|
|
16085
|
-
|
|
16086
|
-
// ../../packages/agent/src/account.ts
|
|
14625
|
+
// ../agent/src/account.ts
|
|
16087
14626
|
var AGENT_ACCOUNT_CLASS_HASH = 0x072cbe983c9c56c99c8753faf70557fef9c6b23f677ed18642aa8902b43daf42n;
|
|
16088
14627
|
var AGENT_ACCOUNT_SALT = BigInt(shortString_exports.encodeShortString("outis/agent"));
|
|
16089
14628
|
|
|
16090
|
-
//
|
|
16091
|
-
var ANY_CALLER = BigInt(shortString_exports.encodeShortString("ANY_CALLER"));
|
|
16092
|
-
|
|
16093
|
-
// ../../packages/agent/src/session.ts
|
|
14629
|
+
// ../agent/src/session.ts
|
|
16094
14630
|
var SESSION_MAGIC = BigInt(shortString_exports.encodeShortString("session-token"));
|
|
16095
14631
|
var SESSION_MESSAGE_MAGIC = BigInt(shortString_exports.encodeShortString("session-message"));
|
|
16096
14632
|
var MAX_U64 = (1n << 64n) - 1n;
|
|
@@ -16315,7 +14851,7 @@ var SessionKey = class _SessionKey {
|
|
|
16315
14851
|
}
|
|
16316
14852
|
};
|
|
16317
14853
|
|
|
16318
|
-
//
|
|
14854
|
+
// ../agent/src/registry.ts
|
|
16319
14855
|
var REGISTERED = selector("SessionRegistered");
|
|
16320
14856
|
function decodeRegistration(event, metadata, sessionKeyGuid, chainId) {
|
|
16321
14857
|
try {
|
|
@@ -16391,7 +14927,7 @@ async function findRegisteredSessions(rpc, args) {
|
|
|
16391
14927
|
return registrations;
|
|
16392
14928
|
}
|
|
16393
14929
|
|
|
16394
|
-
//
|
|
14930
|
+
// ../agent/src/request.ts
|
|
16395
14931
|
var AGENT_REQUEST_FRAGMENT = "#agent=";
|
|
16396
14932
|
function fingerprint(guid) {
|
|
16397
14933
|
const hex2 = guid.toString(16).padStart(16, "0").slice(-16).toUpperCase();
|
|
@@ -16403,7 +14939,7 @@ function agentRequestLink(keychainUrl, request) {
|
|
|
16403
14939
|
return `${page.href}${AGENT_REQUEST_FRAGMENT}${base64UrlEncode(utf8(JSON.stringify(request)))}`;
|
|
16404
14940
|
}
|
|
16405
14941
|
|
|
16406
|
-
//
|
|
14942
|
+
// ../agent/src/transactions.ts
|
|
16407
14943
|
var VERSION2 = "0x3";
|
|
16408
14944
|
var QUERY_VERSION = "0x100000000000000000000000000000003";
|
|
16409
14945
|
var ZERO_BOUNDS = {
|
|
@@ -16467,7 +15003,7 @@ async function submitSessionInvoke(rpc, prepared, key) {
|
|
|
16467
15003
|
import { homedir } from "node:os";
|
|
16468
15004
|
import { join as join2 } from "node:path";
|
|
16469
15005
|
var NETWORKS = {
|
|
16470
|
-
//
|
|
15006
|
+
// Outis's node answers requests that name no origin on Sepolia.
|
|
16471
15007
|
sepolia: { name: "sepolia", rpcUrl: "https://rpc.outis.xyz/sepolia/rpc/v0_10", keychainUrl: "https://outis.xyz/agent" },
|
|
16472
15008
|
devnet: { name: "devnet", rpcUrl: "http://127.0.0.1:5050/rpc", keychainUrl: "http://localhost:5173" }
|
|
16473
15009
|
};
|
|
@@ -17108,7 +15644,7 @@ async function main(argv) {
|
|
|
17108
15644
|
return 0;
|
|
17109
15645
|
}
|
|
17110
15646
|
try {
|
|
17111
|
-
await
|
|
15647
|
+
await loadTypedDataFromFile(true ? new URL("./typed_data_bg.wasm", import.meta.url) : void 0);
|
|
17112
15648
|
const ctx = context(values.network);
|
|
17113
15649
|
switch (command) {
|
|
17114
15650
|
case "connect":
|