Skip to content

Commit e4fe954

Browse files
Use request identity verification from shared core (#438)
* Update shared core * Use request identity from shared core
1 parent 1b13f15 commit e4fe954

18 files changed

+899
-672
lines changed

packages/restate-sdk-cloudflare-workers/patches/vm/sdk_shared_core_wasm_bindings.d.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ export class WasmHeader {
5757
}
5858
/**
5959
*/
60+
export class WasmIdentityVerifier {
61+
free(): void;
62+
/**
63+
* @param {(string)[]} keys
64+
*/
65+
constructor(keys: (string)[]);
66+
/**
67+
* @param {string} path
68+
* @param {(WasmHeader)[]} headers
69+
*/
70+
verify_identity(path: string, headers: (WasmHeader)[]): void;
71+
}
72+
/**
73+
*/
6074
export class WasmInput {
6175
free(): void;
6276
/**
@@ -103,10 +117,10 @@ export class WasmVM {
103117
*/
104118
notify_input_closed(): void;
105119
/**
106-
* @param {string} error
107-
* @param {string | undefined} [description]
120+
* @param {string} error_message
121+
* @param {string | undefined} [error_description]
108122
*/
109-
notify_error(error: string, description?: string): void;
123+
notify_error(error_message: string, error_description?: string): void;
110124
/**
111125
* @returns {any}
112126
*/
@@ -222,12 +236,13 @@ export class WasmVM {
222236
*/
223237
sys_run_exit_failure(value: WasmFailure): number;
224238
/**
225-
* @param {WasmFailure} value
239+
* @param {string} error_message
240+
* @param {string | undefined} error_description
226241
* @param {bigint} attempt_duration
227242
* @param {WasmExponentialRetryConfig} config
228243
* @returns {number}
229244
*/
230-
sys_run_exit_failure_transient(value: WasmFailure, attempt_duration: bigint, config: WasmExponentialRetryConfig): number;
245+
sys_run_exit_failure_transient(error_message: string, error_description: string | undefined, attempt_duration: bigint, config: WasmExponentialRetryConfig): number;
231246
/**
232247
* @param {Uint8Array} buffer
233248
*/

packages/restate-sdk-cloudflare-workers/patches/vm/sdk_shared_core_wasm_bindings_bg.js

Lines changed: 204 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ function addHeapObject(obj) {
4848
return idx;
4949
}
5050

51-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
52-
53-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
54-
55-
cachedTextDecoder.decode();
51+
let WASM_VECTOR_LEN = 0;
5652

5753
let cachedUint8ArrayMemory0 = null;
5854

@@ -63,13 +59,6 @@ function getUint8ArrayMemory0() {
6359
return cachedUint8ArrayMemory0;
6460
}
6561

66-
function getStringFromWasm0(ptr, len) {
67-
ptr = ptr >>> 0;
68-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
69-
}
70-
71-
let WASM_VECTOR_LEN = 0;
72-
7362
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
7463

7564
let cachedTextEncoder = new lTextEncoder('utf-8');
@@ -126,6 +115,17 @@ function passStringToWasm0(arg, malloc, realloc) {
126115
return ptr;
127116
}
128117

118+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
119+
120+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
121+
122+
cachedTextDecoder.decode();
123+
124+
function getStringFromWasm0(ptr, len) {
125+
ptr = ptr >>> 0;
126+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
127+
}
128+
129129
function debugString(val) {
130130
// primitive types
131131
const type = typeof val;
@@ -246,6 +246,14 @@ function passArray32ToWasm0(arg, malloc) {
246246
WASM_VECTOR_LEN = arg.length;
247247
return ptr;
248248
}
249+
250+
function handleError(f, args) {
251+
try {
252+
return f.apply(this, args);
253+
} catch (e) {
254+
wasm.__wbindgen_exn_store(addHeapObject(e));
255+
}
256+
}
249257
/**
250258
*/
251259
export const LogLevel = Object.freeze({ TRACE:0,"0":"TRACE",DEBUG:1,"1":"DEBUG",INFO:2,"2":"INFO",WARN:3,"3":"WARN",ERROR:4,"4":"ERROR", });
@@ -337,6 +345,69 @@ export class WasmHeader {
337345
}
338346
}
339347

348+
const WasmIdentityVerifierFinalization = (typeof FinalizationRegistry === 'undefined')
349+
? { register: () => {}, unregister: () => {} }
350+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmidentityverifier_free(ptr >>> 0, 1));
351+
/**
352+
*/
353+
export class WasmIdentityVerifier {
354+
355+
__destroy_into_raw() {
356+
const ptr = this.__wbg_ptr;
357+
this.__wbg_ptr = 0;
358+
WasmIdentityVerifierFinalization.unregister(this);
359+
return ptr;
360+
}
361+
362+
free() {
363+
const ptr = this.__destroy_into_raw();
364+
wasm.__wbg_wasmidentityverifier_free(ptr, 0);
365+
}
366+
/**
367+
* @param {(string)[]} keys
368+
*/
369+
constructor(keys) {
370+
try {
371+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
372+
const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_malloc);
373+
const len0 = WASM_VECTOR_LEN;
374+
wasm.wasmidentityverifier_new(retptr, ptr0, len0);
375+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
376+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
377+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
378+
if (r2) {
379+
throw takeObject(r1);
380+
}
381+
this.__wbg_ptr = r0 >>> 0;
382+
WasmIdentityVerifierFinalization.register(this, this.__wbg_ptr, this);
383+
return this;
384+
} finally {
385+
wasm.__wbindgen_add_to_stack_pointer(16);
386+
}
387+
}
388+
/**
389+
* @param {string} path
390+
* @param {(WasmHeader)[]} headers
391+
*/
392+
verify_identity(path, headers) {
393+
try {
394+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
395+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396+
const len0 = WASM_VECTOR_LEN;
397+
const ptr1 = passArrayJsValueToWasm0(headers, wasm.__wbindgen_malloc);
398+
const len1 = WASM_VECTOR_LEN;
399+
wasm.wasmidentityverifier_verify_identity(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
400+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
401+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
402+
if (r1) {
403+
throw takeObject(r0);
404+
}
405+
} finally {
406+
wasm.__wbindgen_add_to_stack_pointer(16);
407+
}
408+
}
409+
}
410+
340411
const WasmInputFinalization = (typeof FinalizationRegistry === 'undefined')
341412
? { register: () => {}, unregister: () => {} }
342413
: new FinalizationRegistry(ptr => wasm.__wbg_wasminput_free(ptr >>> 0, 1));
@@ -538,13 +609,13 @@ export class WasmVM {
538609
wasm.wasmvm_notify_input_closed(this.__wbg_ptr);
539610
}
540611
/**
541-
* @param {string} error
542-
* @param {string | undefined} [description]
612+
* @param {string} error_message
613+
* @param {string | undefined} [error_description]
543614
*/
544-
notify_error(error, description) {
545-
const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
615+
notify_error(error_message, error_description) {
616+
const ptr0 = passStringToWasm0(error_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
546617
const len0 = WASM_VECTOR_LEN;
547-
var ptr1 = isLikeNone(description) ? 0 : passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
618+
var ptr1 = isLikeNone(error_description) ? 0 : passStringToWasm0(error_description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548619
var len1 = WASM_VECTOR_LEN;
549620
wasm.wasmvm_notify_error(this.__wbg_ptr, ptr0, len0, ptr1, len1);
550621
}
@@ -982,15 +1053,20 @@ export class WasmVM {
9821053
}
9831054
}
9841055
/**
985-
* @param {WasmFailure} value
1056+
* @param {string} error_message
1057+
* @param {string | undefined} error_description
9861058
* @param {bigint} attempt_duration
9871059
* @param {WasmExponentialRetryConfig} config
9881060
* @returns {number}
9891061
*/
990-
sys_run_exit_failure_transient(value, attempt_duration, config) {
1062+
sys_run_exit_failure_transient(error_message, error_description, attempt_duration, config) {
9911063
try {
9921064
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
993-
wasm.wasmvm_sys_run_exit_failure_transient(retptr, this.__wbg_ptr, addHeapObject(value), attempt_duration, addHeapObject(config));
1065+
const ptr0 = passStringToWasm0(error_message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1066+
const len0 = WASM_VECTOR_LEN;
1067+
var ptr1 = isLikeNone(error_description) ? 0 : passStringToWasm0(error_description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1068+
var len1 = WASM_VECTOR_LEN;
1069+
wasm.wasmvm_sys_run_exit_failure_transient(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, attempt_duration, addHeapObject(config));
9941070
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
9951071
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
9961072
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1188,11 +1264,6 @@ export function __wbg_wasmheader_new(arg0) {
11881264
return addHeapObject(ret);
11891265
};
11901266

1191-
export function __wbindgen_error_new(arg0, arg1) {
1192-
const ret = new Error(getStringFromWasm0(arg0, arg1));
1193-
return addHeapObject(ret);
1194-
};
1195-
11961267
export function __wbindgen_is_undefined(arg0) {
11971268
const ret = getObject(arg0) === undefined;
11981269
return ret;
@@ -1233,6 +1304,11 @@ export function __wbindgen_is_object(arg0) {
12331304
return ret;
12341305
};
12351306

1307+
export function __wbindgen_error_new(arg0, arg1) {
1308+
const ret = new Error(getStringFromWasm0(arg0, arg1));
1309+
return addHeapObject(ret);
1310+
};
1311+
12361312
export function __wbg_new_abda76e883ba8a5f() {
12371313
const ret = new Error();
12381314
return addHeapObject(ret);
@@ -1291,16 +1367,94 @@ export function __wbg_set_841ac57cff3d672b(arg0, arg1, arg2) {
12911367
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
12921368
};
12931369

1370+
export function __wbg_crypto_1d1f22824a6a080c(arg0) {
1371+
const ret = getObject(arg0).crypto;
1372+
return addHeapObject(ret);
1373+
};
1374+
1375+
export function __wbg_process_4a72847cc503995b(arg0) {
1376+
const ret = getObject(arg0).process;
1377+
return addHeapObject(ret);
1378+
};
1379+
1380+
export function __wbg_versions_f686565e586dd935(arg0) {
1381+
const ret = getObject(arg0).versions;
1382+
return addHeapObject(ret);
1383+
};
1384+
1385+
export function __wbg_node_104a2ff8d6ea03a2(arg0) {
1386+
const ret = getObject(arg0).node;
1387+
return addHeapObject(ret);
1388+
};
1389+
1390+
export function __wbindgen_is_string(arg0) {
1391+
const ret = typeof(getObject(arg0)) === 'string';
1392+
return ret;
1393+
};
1394+
1395+
export function __wbg_require_cca90b1a94a0255b() { return handleError(function () {
1396+
const ret = module.require;
1397+
return addHeapObject(ret);
1398+
}, arguments) };
1399+
1400+
export function __wbg_msCrypto_eb05e62b530a1508(arg0) {
1401+
const ret = getObject(arg0).msCrypto;
1402+
return addHeapObject(ret);
1403+
};
1404+
1405+
export function __wbg_randomFillSync_5c9c955aa56b6049() { return handleError(function (arg0, arg1) {
1406+
getObject(arg0).randomFillSync(takeObject(arg1));
1407+
}, arguments) };
1408+
1409+
export function __wbg_getRandomValues_3aa56aa6edec874c() { return handleError(function (arg0, arg1) {
1410+
getObject(arg0).getRandomValues(getObject(arg1));
1411+
}, arguments) };
1412+
12941413
export function __wbg_new_a220cf903aa02ca2() {
12951414
const ret = new Array();
12961415
return addHeapObject(ret);
12971416
};
12981417

1418+
export function __wbindgen_is_function(arg0) {
1419+
const ret = typeof(getObject(arg0)) === 'function';
1420+
return ret;
1421+
};
1422+
1423+
export function __wbg_newnoargs_76313bd6ff35d0f2(arg0, arg1) {
1424+
const ret = new Function(getStringFromWasm0(arg0, arg1));
1425+
return addHeapObject(ret);
1426+
};
1427+
1428+
export function __wbg_call_1084a111329e68ce() { return handleError(function (arg0, arg1) {
1429+
const ret = getObject(arg0).call(getObject(arg1));
1430+
return addHeapObject(ret);
1431+
}, arguments) };
1432+
12991433
export function __wbg_new_525245e2b9901204() {
13001434
const ret = new Object();
13011435
return addHeapObject(ret);
13021436
};
13031437

1438+
export function __wbg_self_3093d5d1f7bcb682() { return handleError(function () {
1439+
const ret = self.self;
1440+
return addHeapObject(ret);
1441+
}, arguments) };
1442+
1443+
export function __wbg_window_3bcfc4d31bc012f8() { return handleError(function () {
1444+
const ret = window.window;
1445+
return addHeapObject(ret);
1446+
}, arguments) };
1447+
1448+
export function __wbg_globalThis_86b222e13bdf32ed() { return handleError(function () {
1449+
const ret = globalThis.globalThis;
1450+
return addHeapObject(ret);
1451+
}, arguments) };
1452+
1453+
export function __wbg_global_e5a3fe56f8be9485() { return handleError(function () {
1454+
const ret = global.global;
1455+
return addHeapObject(ret);
1456+
}, arguments) };
1457+
13041458
export function __wbg_set_673dda6c73d19609(arg0, arg1, arg2) {
13051459
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
13061460
};
@@ -1321,11 +1475,26 @@ export function __wbg_instanceof_ArrayBuffer_61dfc3198373c902(arg0) {
13211475
return ret;
13221476
};
13231477

1478+
export function __wbg_call_89af060b4e1523f2() { return handleError(function (arg0, arg1, arg2) {
1479+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1480+
return addHeapObject(ret);
1481+
}, arguments) };
1482+
13241483
export function __wbg_isSafeInteger_7f1ed56200d90674(arg0) {
13251484
const ret = Number.isSafeInteger(getObject(arg0));
13261485
return ret;
13271486
};
13281487

1488+
export function __wbg_getTime_91058879093a1589(arg0) {
1489+
const ret = getObject(arg0).getTime();
1490+
return ret;
1491+
};
1492+
1493+
export function __wbg_new0_65387337a95cf44d() {
1494+
const ret = new Date();
1495+
return addHeapObject(ret);
1496+
};
1497+
13291498
export function __wbg_now_b7a162010a9e75b4() {
13301499
const ret = Date.now();
13311500
return ret;
@@ -1366,6 +1535,16 @@ export function __wbg_instanceof_Uint8Array_247a91427532499e(arg0) {
13661535
return ret;
13671536
};
13681537

1538+
export function __wbg_newwithlength_ec548f448387c968(arg0) {
1539+
const ret = new Uint8Array(arg0 >>> 0);
1540+
return addHeapObject(ret);
1541+
};
1542+
1543+
export function __wbg_subarray_7c2e3576afe181d1(arg0, arg1, arg2) {
1544+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1545+
return addHeapObject(ret);
1546+
};
1547+
13691548
export function __wbindgen_bigint_get_as_i64(arg0, arg1) {
13701549
const v = getObject(arg1);
13711550
const ret = typeof(v) === 'bigint' ? v : undefined;

0 commit comments

Comments
 (0)