@turnkey/sdk-browser 5.13.6 → 5.14.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.
@@ -10,8 +10,8 @@ var utils = require('../utils.js');
10
10
  class TurnkeySDKClientBase {
11
11
  constructor(config) {
12
12
  this.getActivity = async (input) => {
13
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
14
- session = utils.parseSession(session);
13
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
14
+ const session = sessionData ? utils.parseSession(sessionData) : null;
15
15
  return this.request("/public/v1/query/get_activity", {
16
16
  ...input,
17
17
  organizationId: input.organizationId ??
@@ -23,18 +23,26 @@ class TurnkeySDKClientBase {
23
23
  if (!this.stamper) {
24
24
  return undefined;
25
25
  }
26
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
27
+ const session = sessionData ? utils.parseSession(sessionData) : null;
26
28
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_activity";
27
- const body = JSON.stringify(input);
28
- const stamp = await this.stamper.stamp(body);
29
+ const body = {
30
+ ...input,
31
+ organizationId: input.organizationId ??
32
+ session?.organizationId ??
33
+ this.config.organizationId,
34
+ };
35
+ const stringifiedBody = JSON.stringify(body);
36
+ const stamp = await this.stamper.stamp(stringifiedBody);
29
37
  return {
30
- body: body,
38
+ body: stringifiedBody,
31
39
  stamp: stamp,
32
40
  url: fullUrl,
33
41
  };
34
42
  };
35
43
  this.getApiKey = async (input) => {
36
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
37
- session = utils.parseSession(session);
44
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
45
+ const session = sessionData ? utils.parseSession(sessionData) : null;
38
46
  return this.request("/public/v1/query/get_api_key", {
39
47
  ...input,
40
48
  organizationId: input.organizationId ??
@@ -46,18 +54,26 @@ class TurnkeySDKClientBase {
46
54
  if (!this.stamper) {
47
55
  return undefined;
48
56
  }
57
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
58
+ const session = sessionData ? utils.parseSession(sessionData) : null;
49
59
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_api_key";
50
- const body = JSON.stringify(input);
51
- const stamp = await this.stamper.stamp(body);
60
+ const body = {
61
+ ...input,
62
+ organizationId: input.organizationId ??
63
+ session?.organizationId ??
64
+ this.config.organizationId,
65
+ };
66
+ const stringifiedBody = JSON.stringify(body);
67
+ const stamp = await this.stamper.stamp(stringifiedBody);
52
68
  return {
53
- body: body,
69
+ body: stringifiedBody,
54
70
  stamp: stamp,
55
71
  url: fullUrl,
56
72
  };
57
73
  };
58
74
  this.getApiKeys = async (input = {}) => {
59
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
60
- session = utils.parseSession(session);
75
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
76
+ const session = sessionData ? utils.parseSession(sessionData) : null;
61
77
  return this.request("/public/v1/query/get_api_keys", {
62
78
  ...input,
63
79
  organizationId: input.organizationId ??
@@ -69,18 +85,26 @@ class TurnkeySDKClientBase {
69
85
  if (!this.stamper) {
70
86
  return undefined;
71
87
  }
88
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
89
+ const session = sessionData ? utils.parseSession(sessionData) : null;
72
90
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_api_keys";
73
- const body = JSON.stringify(input);
74
- const stamp = await this.stamper.stamp(body);
91
+ const body = {
92
+ ...input,
93
+ organizationId: input.organizationId ??
94
+ session?.organizationId ??
95
+ this.config.organizationId,
96
+ };
97
+ const stringifiedBody = JSON.stringify(body);
98
+ const stamp = await this.stamper.stamp(stringifiedBody);
75
99
  return {
76
- body: body,
100
+ body: stringifiedBody,
77
101
  stamp: stamp,
78
102
  url: fullUrl,
79
103
  };
80
104
  };
81
105
  this.getAttestationDocument = async (input) => {
82
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
83
- session = utils.parseSession(session);
106
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
107
+ const session = sessionData ? utils.parseSession(sessionData) : null;
84
108
  return this.request("/public/v1/query/get_attestation", {
85
109
  ...input,
86
110
  organizationId: input.organizationId ??
@@ -92,18 +116,26 @@ class TurnkeySDKClientBase {
92
116
  if (!this.stamper) {
93
117
  return undefined;
94
118
  }
119
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
120
+ const session = sessionData ? utils.parseSession(sessionData) : null;
95
121
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_attestation";
96
- const body = JSON.stringify(input);
97
- const stamp = await this.stamper.stamp(body);
122
+ const body = {
123
+ ...input,
124
+ organizationId: input.organizationId ??
125
+ session?.organizationId ??
126
+ this.config.organizationId,
127
+ };
128
+ const stringifiedBody = JSON.stringify(body);
129
+ const stamp = await this.stamper.stamp(stringifiedBody);
98
130
  return {
99
- body: body,
131
+ body: stringifiedBody,
100
132
  stamp: stamp,
101
133
  url: fullUrl,
102
134
  };
103
135
  };
104
136
  this.getAuthenticator = async (input) => {
105
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
106
- session = utils.parseSession(session);
137
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
138
+ const session = sessionData ? utils.parseSession(sessionData) : null;
107
139
  return this.request("/public/v1/query/get_authenticator", {
108
140
  ...input,
109
141
  organizationId: input.organizationId ??
@@ -115,18 +147,26 @@ class TurnkeySDKClientBase {
115
147
  if (!this.stamper) {
116
148
  return undefined;
117
149
  }
150
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
151
+ const session = sessionData ? utils.parseSession(sessionData) : null;
118
152
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_authenticator";
119
- const body = JSON.stringify(input);
120
- const stamp = await this.stamper.stamp(body);
153
+ const body = {
154
+ ...input,
155
+ organizationId: input.organizationId ??
156
+ session?.organizationId ??
157
+ this.config.organizationId,
158
+ };
159
+ const stringifiedBody = JSON.stringify(body);
160
+ const stamp = await this.stamper.stamp(stringifiedBody);
121
161
  return {
122
- body: body,
162
+ body: stringifiedBody,
123
163
  stamp: stamp,
124
164
  url: fullUrl,
125
165
  };
126
166
  };
127
167
  this.getAuthenticators = async (input) => {
128
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
129
- session = utils.parseSession(session);
168
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
169
+ const session = sessionData ? utils.parseSession(sessionData) : null;
130
170
  return this.request("/public/v1/query/get_authenticators", {
131
171
  ...input,
132
172
  organizationId: input.organizationId ??
@@ -138,18 +178,26 @@ class TurnkeySDKClientBase {
138
178
  if (!this.stamper) {
139
179
  return undefined;
140
180
  }
181
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
182
+ const session = sessionData ? utils.parseSession(sessionData) : null;
141
183
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_authenticators";
142
- const body = JSON.stringify(input);
143
- const stamp = await this.stamper.stamp(body);
184
+ const body = {
185
+ ...input,
186
+ organizationId: input.organizationId ??
187
+ session?.organizationId ??
188
+ this.config.organizationId,
189
+ };
190
+ const stringifiedBody = JSON.stringify(body);
191
+ const stamp = await this.stamper.stamp(stringifiedBody);
144
192
  return {
145
- body: body,
193
+ body: stringifiedBody,
146
194
  stamp: stamp,
147
195
  url: fullUrl,
148
196
  };
149
197
  };
150
198
  this.getBootProof = async (input) => {
151
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
152
- session = utils.parseSession(session);
199
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
200
+ const session = sessionData ? utils.parseSession(sessionData) : null;
153
201
  return this.request("/public/v1/query/get_boot_proof", {
154
202
  ...input,
155
203
  organizationId: input.organizationId ??
@@ -161,18 +209,57 @@ class TurnkeySDKClientBase {
161
209
  if (!this.stamper) {
162
210
  return undefined;
163
211
  }
212
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
213
+ const session = sessionData ? utils.parseSession(sessionData) : null;
164
214
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_boot_proof";
165
- const body = JSON.stringify(input);
166
- const stamp = await this.stamper.stamp(body);
215
+ const body = {
216
+ ...input,
217
+ organizationId: input.organizationId ??
218
+ session?.organizationId ??
219
+ this.config.organizationId,
220
+ };
221
+ const stringifiedBody = JSON.stringify(body);
222
+ const stamp = await this.stamper.stamp(stringifiedBody);
223
+ return {
224
+ body: stringifiedBody,
225
+ stamp: stamp,
226
+ url: fullUrl,
227
+ };
228
+ };
229
+ this.getGasUsage = async (input) => {
230
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
231
+ const session = sessionData ? utils.parseSession(sessionData) : null;
232
+ return this.request("/public/v1/query/get_gas_usage", {
233
+ ...input,
234
+ organizationId: input.organizationId ??
235
+ session?.organizationId ??
236
+ this.config.organizationId,
237
+ });
238
+ };
239
+ this.stampGetGasUsage = async (input) => {
240
+ if (!this.stamper) {
241
+ return undefined;
242
+ }
243
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
244
+ const session = sessionData ? utils.parseSession(sessionData) : null;
245
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_gas_usage";
246
+ const body = {
247
+ ...input,
248
+ organizationId: input.organizationId ??
249
+ session?.organizationId ??
250
+ this.config.organizationId,
251
+ };
252
+ const stringifiedBody = JSON.stringify(body);
253
+ const stamp = await this.stamper.stamp(stringifiedBody);
167
254
  return {
168
- body: body,
255
+ body: stringifiedBody,
169
256
  stamp: stamp,
170
257
  url: fullUrl,
171
258
  };
172
259
  };
173
260
  this.getLatestBootProof = async (input) => {
174
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
175
- session = utils.parseSession(session);
261
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
262
+ const session = sessionData ? utils.parseSession(sessionData) : null;
176
263
  return this.request("/public/v1/query/get_latest_boot_proof", {
177
264
  ...input,
178
265
  organizationId: input.organizationId ??
@@ -184,18 +271,57 @@ class TurnkeySDKClientBase {
184
271
  if (!this.stamper) {
185
272
  return undefined;
186
273
  }
274
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
275
+ const session = sessionData ? utils.parseSession(sessionData) : null;
187
276
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_latest_boot_proof";
188
- const body = JSON.stringify(input);
189
- const stamp = await this.stamper.stamp(body);
277
+ const body = {
278
+ ...input,
279
+ organizationId: input.organizationId ??
280
+ session?.organizationId ??
281
+ this.config.organizationId,
282
+ };
283
+ const stringifiedBody = JSON.stringify(body);
284
+ const stamp = await this.stamper.stamp(stringifiedBody);
190
285
  return {
191
- body: body,
286
+ body: stringifiedBody,
287
+ stamp: stamp,
288
+ url: fullUrl,
289
+ };
290
+ };
291
+ this.getNonces = async (input) => {
292
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
293
+ const session = sessionData ? utils.parseSession(sessionData) : null;
294
+ return this.request("/public/v1/query/get_nonces", {
295
+ ...input,
296
+ organizationId: input.organizationId ??
297
+ session?.organizationId ??
298
+ this.config.organizationId,
299
+ });
300
+ };
301
+ this.stampGetNonces = async (input) => {
302
+ if (!this.stamper) {
303
+ return undefined;
304
+ }
305
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
306
+ const session = sessionData ? utils.parseSession(sessionData) : null;
307
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_nonces";
308
+ const body = {
309
+ ...input,
310
+ organizationId: input.organizationId ??
311
+ session?.organizationId ??
312
+ this.config.organizationId,
313
+ };
314
+ const stringifiedBody = JSON.stringify(body);
315
+ const stamp = await this.stamper.stamp(stringifiedBody);
316
+ return {
317
+ body: stringifiedBody,
192
318
  stamp: stamp,
193
319
  url: fullUrl,
194
320
  };
195
321
  };
196
322
  this.getOauth2Credential = async (input) => {
197
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
198
- session = utils.parseSession(session);
323
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
324
+ const session = sessionData ? utils.parseSession(sessionData) : null;
199
325
  return this.request("/public/v1/query/get_oauth2_credential", {
200
326
  ...input,
201
327
  organizationId: input.organizationId ??
@@ -207,18 +333,26 @@ class TurnkeySDKClientBase {
207
333
  if (!this.stamper) {
208
334
  return undefined;
209
335
  }
336
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
337
+ const session = sessionData ? utils.parseSession(sessionData) : null;
210
338
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_oauth2_credential";
211
- const body = JSON.stringify(input);
212
- const stamp = await this.stamper.stamp(body);
339
+ const body = {
340
+ ...input,
341
+ organizationId: input.organizationId ??
342
+ session?.organizationId ??
343
+ this.config.organizationId,
344
+ };
345
+ const stringifiedBody = JSON.stringify(body);
346
+ const stamp = await this.stamper.stamp(stringifiedBody);
213
347
  return {
214
- body: body,
348
+ body: stringifiedBody,
215
349
  stamp: stamp,
216
350
  url: fullUrl,
217
351
  };
218
352
  };
219
353
  this.getOauthProviders = async (input) => {
220
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
221
- session = utils.parseSession(session);
354
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
355
+ const session = sessionData ? utils.parseSession(sessionData) : null;
222
356
  return this.request("/public/v1/query/get_oauth_providers", {
223
357
  ...input,
224
358
  organizationId: input.organizationId ??
@@ -230,18 +364,26 @@ class TurnkeySDKClientBase {
230
364
  if (!this.stamper) {
231
365
  return undefined;
232
366
  }
367
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
368
+ const session = sessionData ? utils.parseSession(sessionData) : null;
233
369
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_oauth_providers";
234
- const body = JSON.stringify(input);
235
- const stamp = await this.stamper.stamp(body);
370
+ const body = {
371
+ ...input,
372
+ organizationId: input.organizationId ??
373
+ session?.organizationId ??
374
+ this.config.organizationId,
375
+ };
376
+ const stringifiedBody = JSON.stringify(body);
377
+ const stamp = await this.stamper.stamp(stringifiedBody);
236
378
  return {
237
- body: body,
379
+ body: stringifiedBody,
238
380
  stamp: stamp,
239
381
  url: fullUrl,
240
382
  };
241
383
  };
242
384
  this.getOnRampTransactionStatus = async (input) => {
243
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
244
- session = utils.parseSession(session);
385
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
386
+ const session = sessionData ? utils.parseSession(sessionData) : null;
245
387
  return this.request("/public/v1/query/get_onramp_transaction_status", {
246
388
  ...input,
247
389
  organizationId: input.organizationId ??
@@ -253,18 +395,26 @@ class TurnkeySDKClientBase {
253
395
  if (!this.stamper) {
254
396
  return undefined;
255
397
  }
398
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
399
+ const session = sessionData ? utils.parseSession(sessionData) : null;
256
400
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_onramp_transaction_status";
257
- const body = JSON.stringify(input);
258
- const stamp = await this.stamper.stamp(body);
401
+ const body = {
402
+ ...input,
403
+ organizationId: input.organizationId ??
404
+ session?.organizationId ??
405
+ this.config.organizationId,
406
+ };
407
+ const stringifiedBody = JSON.stringify(body);
408
+ const stamp = await this.stamper.stamp(stringifiedBody);
259
409
  return {
260
- body: body,
410
+ body: stringifiedBody,
261
411
  stamp: stamp,
262
412
  url: fullUrl,
263
413
  };
264
414
  };
265
415
  this.getOrganization = async (input = {}) => {
266
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
267
- session = utils.parseSession(session);
416
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
417
+ const session = sessionData ? utils.parseSession(sessionData) : null;
268
418
  return this.request("/public/v1/query/get_organization", {
269
419
  ...input,
270
420
  organizationId: input.organizationId ??
@@ -276,18 +426,26 @@ class TurnkeySDKClientBase {
276
426
  if (!this.stamper) {
277
427
  return undefined;
278
428
  }
429
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
430
+ const session = sessionData ? utils.parseSession(sessionData) : null;
279
431
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_organization";
280
- const body = JSON.stringify(input);
281
- const stamp = await this.stamper.stamp(body);
432
+ const body = {
433
+ ...input,
434
+ organizationId: input.organizationId ??
435
+ session?.organizationId ??
436
+ this.config.organizationId,
437
+ };
438
+ const stringifiedBody = JSON.stringify(body);
439
+ const stamp = await this.stamper.stamp(stringifiedBody);
282
440
  return {
283
- body: body,
441
+ body: stringifiedBody,
284
442
  stamp: stamp,
285
443
  url: fullUrl,
286
444
  };
287
445
  };
288
446
  this.getOrganizationConfigs = async (input) => {
289
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
290
- session = utils.parseSession(session);
447
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
448
+ const session = sessionData ? utils.parseSession(sessionData) : null;
291
449
  return this.request("/public/v1/query/get_organization_configs", {
292
450
  ...input,
293
451
  organizationId: input.organizationId ??
@@ -299,18 +457,26 @@ class TurnkeySDKClientBase {
299
457
  if (!this.stamper) {
300
458
  return undefined;
301
459
  }
460
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
461
+ const session = sessionData ? utils.parseSession(sessionData) : null;
302
462
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_organization_configs";
303
- const body = JSON.stringify(input);
304
- const stamp = await this.stamper.stamp(body);
463
+ const body = {
464
+ ...input,
465
+ organizationId: input.organizationId ??
466
+ session?.organizationId ??
467
+ this.config.organizationId,
468
+ };
469
+ const stringifiedBody = JSON.stringify(body);
470
+ const stamp = await this.stamper.stamp(stringifiedBody);
305
471
  return {
306
- body: body,
472
+ body: stringifiedBody,
307
473
  stamp: stamp,
308
474
  url: fullUrl,
309
475
  };
310
476
  };
311
477
  this.getPolicy = async (input) => {
312
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
313
- session = utils.parseSession(session);
478
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
479
+ const session = sessionData ? utils.parseSession(sessionData) : null;
314
480
  return this.request("/public/v1/query/get_policy", {
315
481
  ...input,
316
482
  organizationId: input.organizationId ??
@@ -322,18 +488,26 @@ class TurnkeySDKClientBase {
322
488
  if (!this.stamper) {
323
489
  return undefined;
324
490
  }
491
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
492
+ const session = sessionData ? utils.parseSession(sessionData) : null;
325
493
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_policy";
326
- const body = JSON.stringify(input);
327
- const stamp = await this.stamper.stamp(body);
494
+ const body = {
495
+ ...input,
496
+ organizationId: input.organizationId ??
497
+ session?.organizationId ??
498
+ this.config.organizationId,
499
+ };
500
+ const stringifiedBody = JSON.stringify(body);
501
+ const stamp = await this.stamper.stamp(stringifiedBody);
328
502
  return {
329
- body: body,
503
+ body: stringifiedBody,
330
504
  stamp: stamp,
331
505
  url: fullUrl,
332
506
  };
333
507
  };
334
508
  this.getPolicyEvaluations = async (input) => {
335
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
336
- session = utils.parseSession(session);
509
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
510
+ const session = sessionData ? utils.parseSession(sessionData) : null;
337
511
  return this.request("/public/v1/query/get_policy_evaluations", {
338
512
  ...input,
339
513
  organizationId: input.organizationId ??
@@ -345,18 +519,26 @@ class TurnkeySDKClientBase {
345
519
  if (!this.stamper) {
346
520
  return undefined;
347
521
  }
522
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
523
+ const session = sessionData ? utils.parseSession(sessionData) : null;
348
524
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_policy_evaluations";
349
- const body = JSON.stringify(input);
350
- const stamp = await this.stamper.stamp(body);
525
+ const body = {
526
+ ...input,
527
+ organizationId: input.organizationId ??
528
+ session?.organizationId ??
529
+ this.config.organizationId,
530
+ };
531
+ const stringifiedBody = JSON.stringify(body);
532
+ const stamp = await this.stamper.stamp(stringifiedBody);
351
533
  return {
352
- body: body,
534
+ body: stringifiedBody,
353
535
  stamp: stamp,
354
536
  url: fullUrl,
355
537
  };
356
538
  };
357
539
  this.getPrivateKey = async (input) => {
358
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
359
- session = utils.parseSession(session);
540
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
541
+ const session = sessionData ? utils.parseSession(sessionData) : null;
360
542
  return this.request("/public/v1/query/get_private_key", {
361
543
  ...input,
362
544
  organizationId: input.organizationId ??
@@ -368,18 +550,57 @@ class TurnkeySDKClientBase {
368
550
  if (!this.stamper) {
369
551
  return undefined;
370
552
  }
553
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
554
+ const session = sessionData ? utils.parseSession(sessionData) : null;
371
555
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_private_key";
372
- const body = JSON.stringify(input);
373
- const stamp = await this.stamper.stamp(body);
556
+ const body = {
557
+ ...input,
558
+ organizationId: input.organizationId ??
559
+ session?.organizationId ??
560
+ this.config.organizationId,
561
+ };
562
+ const stringifiedBody = JSON.stringify(body);
563
+ const stamp = await this.stamper.stamp(stringifiedBody);
564
+ return {
565
+ body: stringifiedBody,
566
+ stamp: stamp,
567
+ url: fullUrl,
568
+ };
569
+ };
570
+ this.getSendTransactionStatus = async (input) => {
571
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
572
+ const session = sessionData ? utils.parseSession(sessionData) : null;
573
+ return this.request("/public/v1/query/get_send_transaction_status", {
574
+ ...input,
575
+ organizationId: input.organizationId ??
576
+ session?.organizationId ??
577
+ this.config.organizationId,
578
+ });
579
+ };
580
+ this.stampGetSendTransactionStatus = async (input) => {
581
+ if (!this.stamper) {
582
+ return undefined;
583
+ }
584
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
585
+ const session = sessionData ? utils.parseSession(sessionData) : null;
586
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_send_transaction_status";
587
+ const body = {
588
+ ...input,
589
+ organizationId: input.organizationId ??
590
+ session?.organizationId ??
591
+ this.config.organizationId,
592
+ };
593
+ const stringifiedBody = JSON.stringify(body);
594
+ const stamp = await this.stamper.stamp(stringifiedBody);
374
595
  return {
375
- body: body,
596
+ body: stringifiedBody,
376
597
  stamp: stamp,
377
598
  url: fullUrl,
378
599
  };
379
600
  };
380
601
  this.getSmartContractInterface = async (input) => {
381
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
382
- session = utils.parseSession(session);
602
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
603
+ const session = sessionData ? utils.parseSession(sessionData) : null;
383
604
  return this.request("/public/v1/query/get_smart_contract_interface", {
384
605
  ...input,
385
606
  organizationId: input.organizationId ??
@@ -391,18 +612,26 @@ class TurnkeySDKClientBase {
391
612
  if (!this.stamper) {
392
613
  return undefined;
393
614
  }
615
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
616
+ const session = sessionData ? utils.parseSession(sessionData) : null;
394
617
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_smart_contract_interface";
395
- const body = JSON.stringify(input);
396
- const stamp = await this.stamper.stamp(body);
618
+ const body = {
619
+ ...input,
620
+ organizationId: input.organizationId ??
621
+ session?.organizationId ??
622
+ this.config.organizationId,
623
+ };
624
+ const stringifiedBody = JSON.stringify(body);
625
+ const stamp = await this.stamper.stamp(stringifiedBody);
397
626
  return {
398
- body: body,
627
+ body: stringifiedBody,
399
628
  stamp: stamp,
400
629
  url: fullUrl,
401
630
  };
402
631
  };
403
632
  this.getUser = async (input) => {
404
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
405
- session = utils.parseSession(session);
633
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
634
+ const session = sessionData ? utils.parseSession(sessionData) : null;
406
635
  return this.request("/public/v1/query/get_user", {
407
636
  ...input,
408
637
  organizationId: input.organizationId ??
@@ -414,18 +643,26 @@ class TurnkeySDKClientBase {
414
643
  if (!this.stamper) {
415
644
  return undefined;
416
645
  }
646
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
647
+ const session = sessionData ? utils.parseSession(sessionData) : null;
417
648
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_user";
418
- const body = JSON.stringify(input);
419
- const stamp = await this.stamper.stamp(body);
649
+ const body = {
650
+ ...input,
651
+ organizationId: input.organizationId ??
652
+ session?.organizationId ??
653
+ this.config.organizationId,
654
+ };
655
+ const stringifiedBody = JSON.stringify(body);
656
+ const stamp = await this.stamper.stamp(stringifiedBody);
420
657
  return {
421
- body: body,
658
+ body: stringifiedBody,
422
659
  stamp: stamp,
423
660
  url: fullUrl,
424
661
  };
425
662
  };
426
663
  this.getWallet = async (input) => {
427
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
428
- session = utils.parseSession(session);
664
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
665
+ const session = sessionData ? utils.parseSession(sessionData) : null;
429
666
  return this.request("/public/v1/query/get_wallet", {
430
667
  ...input,
431
668
  organizationId: input.organizationId ??
@@ -437,18 +674,26 @@ class TurnkeySDKClientBase {
437
674
  if (!this.stamper) {
438
675
  return undefined;
439
676
  }
677
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
678
+ const session = sessionData ? utils.parseSession(sessionData) : null;
440
679
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_wallet";
441
- const body = JSON.stringify(input);
442
- const stamp = await this.stamper.stamp(body);
680
+ const body = {
681
+ ...input,
682
+ organizationId: input.organizationId ??
683
+ session?.organizationId ??
684
+ this.config.organizationId,
685
+ };
686
+ const stringifiedBody = JSON.stringify(body);
687
+ const stamp = await this.stamper.stamp(stringifiedBody);
443
688
  return {
444
- body: body,
689
+ body: stringifiedBody,
445
690
  stamp: stamp,
446
691
  url: fullUrl,
447
692
  };
448
693
  };
449
694
  this.getWalletAccount = async (input) => {
450
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
451
- session = utils.parseSession(session);
695
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
696
+ const session = sessionData ? utils.parseSession(sessionData) : null;
452
697
  return this.request("/public/v1/query/get_wallet_account", {
453
698
  ...input,
454
699
  organizationId: input.organizationId ??
@@ -460,18 +705,26 @@ class TurnkeySDKClientBase {
460
705
  if (!this.stamper) {
461
706
  return undefined;
462
707
  }
708
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
709
+ const session = sessionData ? utils.parseSession(sessionData) : null;
463
710
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_wallet_account";
464
- const body = JSON.stringify(input);
465
- const stamp = await this.stamper.stamp(body);
711
+ const body = {
712
+ ...input,
713
+ organizationId: input.organizationId ??
714
+ session?.organizationId ??
715
+ this.config.organizationId,
716
+ };
717
+ const stringifiedBody = JSON.stringify(body);
718
+ const stamp = await this.stamper.stamp(stringifiedBody);
466
719
  return {
467
- body: body,
720
+ body: stringifiedBody,
468
721
  stamp: stamp,
469
722
  url: fullUrl,
470
723
  };
471
724
  };
472
725
  this.getActivities = async (input = {}) => {
473
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
474
- session = utils.parseSession(session);
726
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
727
+ const session = sessionData ? utils.parseSession(sessionData) : null;
475
728
  return this.request("/public/v1/query/list_activities", {
476
729
  ...input,
477
730
  organizationId: input.organizationId ??
@@ -483,18 +736,26 @@ class TurnkeySDKClientBase {
483
736
  if (!this.stamper) {
484
737
  return undefined;
485
738
  }
739
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
740
+ const session = sessionData ? utils.parseSession(sessionData) : null;
486
741
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_activities";
487
- const body = JSON.stringify(input);
488
- const stamp = await this.stamper.stamp(body);
742
+ const body = {
743
+ ...input,
744
+ organizationId: input.organizationId ??
745
+ session?.organizationId ??
746
+ this.config.organizationId,
747
+ };
748
+ const stringifiedBody = JSON.stringify(body);
749
+ const stamp = await this.stamper.stamp(stringifiedBody);
489
750
  return {
490
- body: body,
751
+ body: stringifiedBody,
491
752
  stamp: stamp,
492
753
  url: fullUrl,
493
754
  };
494
755
  };
495
756
  this.getAppProofs = async (input) => {
496
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
497
- session = utils.parseSession(session);
757
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
758
+ const session = sessionData ? utils.parseSession(sessionData) : null;
498
759
  return this.request("/public/v1/query/list_app_proofs", {
499
760
  ...input,
500
761
  organizationId: input.organizationId ??
@@ -506,18 +767,26 @@ class TurnkeySDKClientBase {
506
767
  if (!this.stamper) {
507
768
  return undefined;
508
769
  }
770
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
771
+ const session = sessionData ? utils.parseSession(sessionData) : null;
509
772
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_app_proofs";
510
- const body = JSON.stringify(input);
511
- const stamp = await this.stamper.stamp(body);
773
+ const body = {
774
+ ...input,
775
+ organizationId: input.organizationId ??
776
+ session?.organizationId ??
777
+ this.config.organizationId,
778
+ };
779
+ const stringifiedBody = JSON.stringify(body);
780
+ const stamp = await this.stamper.stamp(stringifiedBody);
512
781
  return {
513
- body: body,
782
+ body: stringifiedBody,
514
783
  stamp: stamp,
515
784
  url: fullUrl,
516
785
  };
517
786
  };
518
787
  this.listFiatOnRampCredentials = async (input) => {
519
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
520
- session = utils.parseSession(session);
788
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
789
+ const session = sessionData ? utils.parseSession(sessionData) : null;
521
790
  return this.request("/public/v1/query/list_fiat_on_ramp_credentials", {
522
791
  ...input,
523
792
  organizationId: input.organizationId ??
@@ -529,18 +798,26 @@ class TurnkeySDKClientBase {
529
798
  if (!this.stamper) {
530
799
  return undefined;
531
800
  }
801
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
802
+ const session = sessionData ? utils.parseSession(sessionData) : null;
532
803
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_fiat_on_ramp_credentials";
533
- const body = JSON.stringify(input);
534
- const stamp = await this.stamper.stamp(body);
804
+ const body = {
805
+ ...input,
806
+ organizationId: input.organizationId ??
807
+ session?.organizationId ??
808
+ this.config.organizationId,
809
+ };
810
+ const stringifiedBody = JSON.stringify(body);
811
+ const stamp = await this.stamper.stamp(stringifiedBody);
535
812
  return {
536
- body: body,
813
+ body: stringifiedBody,
537
814
  stamp: stamp,
538
815
  url: fullUrl,
539
816
  };
540
817
  };
541
818
  this.listOauth2Credentials = async (input) => {
542
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
543
- session = utils.parseSession(session);
819
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
820
+ const session = sessionData ? utils.parseSession(sessionData) : null;
544
821
  return this.request("/public/v1/query/list_oauth2_credentials", {
545
822
  ...input,
546
823
  organizationId: input.organizationId ??
@@ -552,18 +829,26 @@ class TurnkeySDKClientBase {
552
829
  if (!this.stamper) {
553
830
  return undefined;
554
831
  }
832
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
833
+ const session = sessionData ? utils.parseSession(sessionData) : null;
555
834
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_oauth2_credentials";
556
- const body = JSON.stringify(input);
557
- const stamp = await this.stamper.stamp(body);
835
+ const body = {
836
+ ...input,
837
+ organizationId: input.organizationId ??
838
+ session?.organizationId ??
839
+ this.config.organizationId,
840
+ };
841
+ const stringifiedBody = JSON.stringify(body);
842
+ const stamp = await this.stamper.stamp(stringifiedBody);
558
843
  return {
559
- body: body,
844
+ body: stringifiedBody,
560
845
  stamp: stamp,
561
846
  url: fullUrl,
562
847
  };
563
848
  };
564
849
  this.getPolicies = async (input = {}) => {
565
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
566
- session = utils.parseSession(session);
850
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
851
+ const session = sessionData ? utils.parseSession(sessionData) : null;
567
852
  return this.request("/public/v1/query/list_policies", {
568
853
  ...input,
569
854
  organizationId: input.organizationId ??
@@ -575,18 +860,26 @@ class TurnkeySDKClientBase {
575
860
  if (!this.stamper) {
576
861
  return undefined;
577
862
  }
863
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
864
+ const session = sessionData ? utils.parseSession(sessionData) : null;
578
865
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_policies";
579
- const body = JSON.stringify(input);
580
- const stamp = await this.stamper.stamp(body);
866
+ const body = {
867
+ ...input,
868
+ organizationId: input.organizationId ??
869
+ session?.organizationId ??
870
+ this.config.organizationId,
871
+ };
872
+ const stringifiedBody = JSON.stringify(body);
873
+ const stamp = await this.stamper.stamp(stringifiedBody);
581
874
  return {
582
- body: body,
875
+ body: stringifiedBody,
583
876
  stamp: stamp,
584
877
  url: fullUrl,
585
878
  };
586
879
  };
587
880
  this.listPrivateKeyTags = async (input) => {
588
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
589
- session = utils.parseSession(session);
881
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
882
+ const session = sessionData ? utils.parseSession(sessionData) : null;
590
883
  return this.request("/public/v1/query/list_private_key_tags", {
591
884
  ...input,
592
885
  organizationId: input.organizationId ??
@@ -598,18 +891,26 @@ class TurnkeySDKClientBase {
598
891
  if (!this.stamper) {
599
892
  return undefined;
600
893
  }
894
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
895
+ const session = sessionData ? utils.parseSession(sessionData) : null;
601
896
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_private_key_tags";
602
- const body = JSON.stringify(input);
603
- const stamp = await this.stamper.stamp(body);
897
+ const body = {
898
+ ...input,
899
+ organizationId: input.organizationId ??
900
+ session?.organizationId ??
901
+ this.config.organizationId,
902
+ };
903
+ const stringifiedBody = JSON.stringify(body);
904
+ const stamp = await this.stamper.stamp(stringifiedBody);
604
905
  return {
605
- body: body,
906
+ body: stringifiedBody,
606
907
  stamp: stamp,
607
908
  url: fullUrl,
608
909
  };
609
910
  };
610
911
  this.getPrivateKeys = async (input = {}) => {
611
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
612
- session = utils.parseSession(session);
912
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
913
+ const session = sessionData ? utils.parseSession(sessionData) : null;
613
914
  return this.request("/public/v1/query/list_private_keys", {
614
915
  ...input,
615
916
  organizationId: input.organizationId ??
@@ -621,18 +922,26 @@ class TurnkeySDKClientBase {
621
922
  if (!this.stamper) {
622
923
  return undefined;
623
924
  }
925
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
926
+ const session = sessionData ? utils.parseSession(sessionData) : null;
624
927
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_private_keys";
625
- const body = JSON.stringify(input);
626
- const stamp = await this.stamper.stamp(body);
928
+ const body = {
929
+ ...input,
930
+ organizationId: input.organizationId ??
931
+ session?.organizationId ??
932
+ this.config.organizationId,
933
+ };
934
+ const stringifiedBody = JSON.stringify(body);
935
+ const stamp = await this.stamper.stamp(stringifiedBody);
627
936
  return {
628
- body: body,
937
+ body: stringifiedBody,
629
938
  stamp: stamp,
630
939
  url: fullUrl,
631
940
  };
632
941
  };
633
942
  this.getSmartContractInterfaces = async (input) => {
634
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
635
- session = utils.parseSession(session);
943
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
944
+ const session = sessionData ? utils.parseSession(sessionData) : null;
636
945
  return this.request("/public/v1/query/list_smart_contract_interfaces", {
637
946
  ...input,
638
947
  organizationId: input.organizationId ??
@@ -644,19 +953,27 @@ class TurnkeySDKClientBase {
644
953
  if (!this.stamper) {
645
954
  return undefined;
646
955
  }
956
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
957
+ const session = sessionData ? utils.parseSession(sessionData) : null;
647
958
  const fullUrl = this.config.apiBaseUrl +
648
959
  "/public/v1/query/list_smart_contract_interfaces";
649
- const body = JSON.stringify(input);
650
- const stamp = await this.stamper.stamp(body);
960
+ const body = {
961
+ ...input,
962
+ organizationId: input.organizationId ??
963
+ session?.organizationId ??
964
+ this.config.organizationId,
965
+ };
966
+ const stringifiedBody = JSON.stringify(body);
967
+ const stamp = await this.stamper.stamp(stringifiedBody);
651
968
  return {
652
- body: body,
969
+ body: stringifiedBody,
653
970
  stamp: stamp,
654
971
  url: fullUrl,
655
972
  };
656
973
  };
657
974
  this.getSubOrgIds = async (input = {}) => {
658
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
659
- session = utils.parseSession(session);
975
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
976
+ const session = sessionData ? utils.parseSession(sessionData) : null;
660
977
  return this.request("/public/v1/query/list_suborgs", {
661
978
  ...input,
662
979
  organizationId: input.organizationId ??
@@ -668,18 +985,26 @@ class TurnkeySDKClientBase {
668
985
  if (!this.stamper) {
669
986
  return undefined;
670
987
  }
988
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
989
+ const session = sessionData ? utils.parseSession(sessionData) : null;
671
990
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_suborgs";
672
- const body = JSON.stringify(input);
673
- const stamp = await this.stamper.stamp(body);
991
+ const body = {
992
+ ...input,
993
+ organizationId: input.organizationId ??
994
+ session?.organizationId ??
995
+ this.config.organizationId,
996
+ };
997
+ const stringifiedBody = JSON.stringify(body);
998
+ const stamp = await this.stamper.stamp(stringifiedBody);
674
999
  return {
675
- body: body,
1000
+ body: stringifiedBody,
676
1001
  stamp: stamp,
677
1002
  url: fullUrl,
678
1003
  };
679
1004
  };
680
1005
  this.listUserTags = async (input = {}) => {
681
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
682
- session = utils.parseSession(session);
1006
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1007
+ const session = sessionData ? utils.parseSession(sessionData) : null;
683
1008
  return this.request("/public/v1/query/list_user_tags", {
684
1009
  ...input,
685
1010
  organizationId: input.organizationId ??
@@ -691,18 +1016,26 @@ class TurnkeySDKClientBase {
691
1016
  if (!this.stamper) {
692
1017
  return undefined;
693
1018
  }
1019
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1020
+ const session = sessionData ? utils.parseSession(sessionData) : null;
694
1021
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_user_tags";
695
- const body = JSON.stringify(input);
696
- const stamp = await this.stamper.stamp(body);
1022
+ const body = {
1023
+ ...input,
1024
+ organizationId: input.organizationId ??
1025
+ session?.organizationId ??
1026
+ this.config.organizationId,
1027
+ };
1028
+ const stringifiedBody = JSON.stringify(body);
1029
+ const stamp = await this.stamper.stamp(stringifiedBody);
697
1030
  return {
698
- body: body,
1031
+ body: stringifiedBody,
699
1032
  stamp: stamp,
700
1033
  url: fullUrl,
701
1034
  };
702
1035
  };
703
1036
  this.getUsers = async (input = {}) => {
704
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
705
- session = utils.parseSession(session);
1037
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1038
+ const session = sessionData ? utils.parseSession(sessionData) : null;
706
1039
  return this.request("/public/v1/query/list_users", {
707
1040
  ...input,
708
1041
  organizationId: input.organizationId ??
@@ -714,18 +1047,26 @@ class TurnkeySDKClientBase {
714
1047
  if (!this.stamper) {
715
1048
  return undefined;
716
1049
  }
1050
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1051
+ const session = sessionData ? utils.parseSession(sessionData) : null;
717
1052
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_users";
718
- const body = JSON.stringify(input);
719
- const stamp = await this.stamper.stamp(body);
1053
+ const body = {
1054
+ ...input,
1055
+ organizationId: input.organizationId ??
1056
+ session?.organizationId ??
1057
+ this.config.organizationId,
1058
+ };
1059
+ const stringifiedBody = JSON.stringify(body);
1060
+ const stamp = await this.stamper.stamp(stringifiedBody);
720
1061
  return {
721
- body: body,
1062
+ body: stringifiedBody,
722
1063
  stamp: stamp,
723
1064
  url: fullUrl,
724
1065
  };
725
1066
  };
726
1067
  this.getVerifiedSubOrgIds = async (input) => {
727
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
728
- session = utils.parseSession(session);
1068
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1069
+ const session = sessionData ? utils.parseSession(sessionData) : null;
729
1070
  return this.request("/public/v1/query/list_verified_suborgs", {
730
1071
  ...input,
731
1072
  organizationId: input.organizationId ??
@@ -737,18 +1078,26 @@ class TurnkeySDKClientBase {
737
1078
  if (!this.stamper) {
738
1079
  return undefined;
739
1080
  }
1081
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1082
+ const session = sessionData ? utils.parseSession(sessionData) : null;
740
1083
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_verified_suborgs";
741
- const body = JSON.stringify(input);
742
- const stamp = await this.stamper.stamp(body);
1084
+ const body = {
1085
+ ...input,
1086
+ organizationId: input.organizationId ??
1087
+ session?.organizationId ??
1088
+ this.config.organizationId,
1089
+ };
1090
+ const stringifiedBody = JSON.stringify(body);
1091
+ const stamp = await this.stamper.stamp(stringifiedBody);
743
1092
  return {
744
- body: body,
1093
+ body: stringifiedBody,
745
1094
  stamp: stamp,
746
1095
  url: fullUrl,
747
1096
  };
748
1097
  };
749
1098
  this.getWalletAccounts = async (input) => {
750
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
751
- session = utils.parseSession(session);
1099
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1100
+ const session = sessionData ? utils.parseSession(sessionData) : null;
752
1101
  return this.request("/public/v1/query/list_wallet_accounts", {
753
1102
  ...input,
754
1103
  organizationId: input.organizationId ??
@@ -760,18 +1109,26 @@ class TurnkeySDKClientBase {
760
1109
  if (!this.stamper) {
761
1110
  return undefined;
762
1111
  }
1112
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1113
+ const session = sessionData ? utils.parseSession(sessionData) : null;
763
1114
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_wallet_accounts";
764
- const body = JSON.stringify(input);
765
- const stamp = await this.stamper.stamp(body);
1115
+ const body = {
1116
+ ...input,
1117
+ organizationId: input.organizationId ??
1118
+ session?.organizationId ??
1119
+ this.config.organizationId,
1120
+ };
1121
+ const stringifiedBody = JSON.stringify(body);
1122
+ const stamp = await this.stamper.stamp(stringifiedBody);
766
1123
  return {
767
- body: body,
1124
+ body: stringifiedBody,
768
1125
  stamp: stamp,
769
1126
  url: fullUrl,
770
1127
  };
771
1128
  };
772
1129
  this.getWallets = async (input = {}) => {
773
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
774
- session = utils.parseSession(session);
1130
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1131
+ const session = sessionData ? utils.parseSession(sessionData) : null;
775
1132
  return this.request("/public/v1/query/list_wallets", {
776
1133
  ...input,
777
1134
  organizationId: input.organizationId ??
@@ -783,18 +1140,26 @@ class TurnkeySDKClientBase {
783
1140
  if (!this.stamper) {
784
1141
  return undefined;
785
1142
  }
1143
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1144
+ const session = sessionData ? utils.parseSession(sessionData) : null;
786
1145
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_wallets";
787
- const body = JSON.stringify(input);
788
- const stamp = await this.stamper.stamp(body);
1146
+ const body = {
1147
+ ...input,
1148
+ organizationId: input.organizationId ??
1149
+ session?.organizationId ??
1150
+ this.config.organizationId,
1151
+ };
1152
+ const stringifiedBody = JSON.stringify(body);
1153
+ const stamp = await this.stamper.stamp(stringifiedBody);
789
1154
  return {
790
- body: body,
1155
+ body: stringifiedBody,
791
1156
  stamp: stamp,
792
1157
  url: fullUrl,
793
1158
  };
794
1159
  };
795
1160
  this.getWhoami = async (input = {}) => {
796
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
797
- session = utils.parseSession(session);
1161
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1162
+ const session = sessionData ? utils.parseSession(sessionData) : null;
798
1163
  return this.request("/public/v1/query/whoami", {
799
1164
  ...input,
800
1165
  organizationId: input.organizationId ??
@@ -806,19 +1171,27 @@ class TurnkeySDKClientBase {
806
1171
  if (!this.stamper) {
807
1172
  return undefined;
808
1173
  }
1174
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1175
+ const session = sessionData ? utils.parseSession(sessionData) : null;
809
1176
  const fullUrl = this.config.apiBaseUrl + "/public/v1/query/whoami";
810
- const body = JSON.stringify(input);
811
- const stamp = await this.stamper.stamp(body);
1177
+ const body = {
1178
+ ...input,
1179
+ organizationId: input.organizationId ??
1180
+ session?.organizationId ??
1181
+ this.config.organizationId,
1182
+ };
1183
+ const stringifiedBody = JSON.stringify(body);
1184
+ const stamp = await this.stamper.stamp(stringifiedBody);
812
1185
  return {
813
- body: body,
1186
+ body: stringifiedBody,
814
1187
  stamp: stamp,
815
1188
  url: fullUrl,
816
1189
  };
817
1190
  };
818
1191
  this.approveActivity = async (input) => {
1192
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1193
+ const session = sessionData ? utils.parseSession(sessionData) : null;
819
1194
  const { organizationId, timestampMs, ...rest } = input;
820
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
821
- session = utils.parseSession(session);
822
1195
  return this.activityDecision("/public/v1/submit/approve_activity", {
823
1196
  parameters: rest,
824
1197
  organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
@@ -830,19 +1203,28 @@ class TurnkeySDKClientBase {
830
1203
  if (!this.stamper) {
831
1204
  return undefined;
832
1205
  }
1206
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1207
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1208
+ const { organizationId, timestampMs, ...parameters } = input;
833
1209
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/approve_activity";
834
- const body = JSON.stringify(input);
835
- const stamp = await this.stamper.stamp(body);
1210
+ const bodyWithType = {
1211
+ parameters,
1212
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1213
+ timestampMs: timestampMs ?? String(Date.now()),
1214
+ type: "ACTIVITY_TYPE_APPROVE_ACTIVITY",
1215
+ };
1216
+ const stringifiedBody = JSON.stringify(bodyWithType);
1217
+ const stamp = await this.stamper.stamp(stringifiedBody);
836
1218
  return {
837
- body: body,
1219
+ body: stringifiedBody,
838
1220
  stamp: stamp,
839
1221
  url: fullUrl,
840
1222
  };
841
1223
  };
842
1224
  this.createApiKeys = async (input) => {
1225
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1226
+ const session = sessionData ? utils.parseSession(sessionData) : null;
843
1227
  const { organizationId, timestampMs, ...rest } = input;
844
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
845
- session = utils.parseSession(session);
846
1228
  return this.command("/public/v1/submit/create_api_keys", {
847
1229
  parameters: rest,
848
1230
  organizationId: organizationId ??
@@ -856,19 +1238,28 @@ class TurnkeySDKClientBase {
856
1238
  if (!this.stamper) {
857
1239
  return undefined;
858
1240
  }
1241
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1242
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1243
+ const { organizationId, timestampMs, ...parameters } = input;
859
1244
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_api_keys";
860
- const body = JSON.stringify(input);
861
- const stamp = await this.stamper.stamp(body);
1245
+ const bodyWithType = {
1246
+ parameters,
1247
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1248
+ timestampMs: timestampMs ?? String(Date.now()),
1249
+ type: "ACTIVITY_TYPE_CREATE_API_KEYS_V2",
1250
+ };
1251
+ const stringifiedBody = JSON.stringify(bodyWithType);
1252
+ const stamp = await this.stamper.stamp(stringifiedBody);
862
1253
  return {
863
- body: body,
1254
+ body: stringifiedBody,
864
1255
  stamp: stamp,
865
1256
  url: fullUrl,
866
1257
  };
867
1258
  };
868
1259
  this.createApiOnlyUsers = async (input) => {
1260
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1261
+ const session = sessionData ? utils.parseSession(sessionData) : null;
869
1262
  const { organizationId, timestampMs, ...rest } = input;
870
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
871
- session = utils.parseSession(session);
872
1263
  return this.command("/public/v1/submit/create_api_only_users", {
873
1264
  parameters: rest,
874
1265
  organizationId: organizationId ??
@@ -882,19 +1273,28 @@ class TurnkeySDKClientBase {
882
1273
  if (!this.stamper) {
883
1274
  return undefined;
884
1275
  }
1276
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1277
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1278
+ const { organizationId, timestampMs, ...parameters } = input;
885
1279
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_api_only_users";
886
- const body = JSON.stringify(input);
887
- const stamp = await this.stamper.stamp(body);
1280
+ const bodyWithType = {
1281
+ parameters,
1282
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1283
+ timestampMs: timestampMs ?? String(Date.now()),
1284
+ type: "ACTIVITY_TYPE_CREATE_API_ONLY_USERS",
1285
+ };
1286
+ const stringifiedBody = JSON.stringify(bodyWithType);
1287
+ const stamp = await this.stamper.stamp(stringifiedBody);
888
1288
  return {
889
- body: body,
1289
+ body: stringifiedBody,
890
1290
  stamp: stamp,
891
1291
  url: fullUrl,
892
1292
  };
893
1293
  };
894
1294
  this.createAuthenticators = async (input) => {
1295
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1296
+ const session = sessionData ? utils.parseSession(sessionData) : null;
895
1297
  const { organizationId, timestampMs, ...rest } = input;
896
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
897
- session = utils.parseSession(session);
898
1298
  return this.command("/public/v1/submit/create_authenticators", {
899
1299
  parameters: rest,
900
1300
  organizationId: organizationId ??
@@ -908,19 +1308,28 @@ class TurnkeySDKClientBase {
908
1308
  if (!this.stamper) {
909
1309
  return undefined;
910
1310
  }
1311
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1312
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1313
+ const { organizationId, timestampMs, ...parameters } = input;
911
1314
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_authenticators";
912
- const body = JSON.stringify(input);
913
- const stamp = await this.stamper.stamp(body);
1315
+ const bodyWithType = {
1316
+ parameters,
1317
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1318
+ timestampMs: timestampMs ?? String(Date.now()),
1319
+ type: "ACTIVITY_TYPE_CREATE_AUTHENTICATORS_V2",
1320
+ };
1321
+ const stringifiedBody = JSON.stringify(bodyWithType);
1322
+ const stamp = await this.stamper.stamp(stringifiedBody);
914
1323
  return {
915
- body: body,
1324
+ body: stringifiedBody,
916
1325
  stamp: stamp,
917
1326
  url: fullUrl,
918
1327
  };
919
1328
  };
920
1329
  this.createFiatOnRampCredential = async (input) => {
1330
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1331
+ const session = sessionData ? utils.parseSession(sessionData) : null;
921
1332
  const { organizationId, timestampMs, ...rest } = input;
922
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
923
- session = utils.parseSession(session);
924
1333
  return this.command("/public/v1/submit/create_fiat_on_ramp_credential", {
925
1334
  parameters: rest,
926
1335
  organizationId: organizationId ??
@@ -934,20 +1343,29 @@ class TurnkeySDKClientBase {
934
1343
  if (!this.stamper) {
935
1344
  return undefined;
936
1345
  }
1346
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1347
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1348
+ const { organizationId, timestampMs, ...parameters } = input;
937
1349
  const fullUrl = this.config.apiBaseUrl +
938
1350
  "/public/v1/submit/create_fiat_on_ramp_credential";
939
- const body = JSON.stringify(input);
940
- const stamp = await this.stamper.stamp(body);
1351
+ const bodyWithType = {
1352
+ parameters,
1353
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1354
+ timestampMs: timestampMs ?? String(Date.now()),
1355
+ type: "ACTIVITY_TYPE_CREATE_FIAT_ON_RAMP_CREDENTIAL",
1356
+ };
1357
+ const stringifiedBody = JSON.stringify(bodyWithType);
1358
+ const stamp = await this.stamper.stamp(stringifiedBody);
941
1359
  return {
942
- body: body,
1360
+ body: stringifiedBody,
943
1361
  stamp: stamp,
944
1362
  url: fullUrl,
945
1363
  };
946
1364
  };
947
1365
  this.createInvitations = async (input) => {
1366
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1367
+ const session = sessionData ? utils.parseSession(sessionData) : null;
948
1368
  const { organizationId, timestampMs, ...rest } = input;
949
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
950
- session = utils.parseSession(session);
951
1369
  return this.command("/public/v1/submit/create_invitations", {
952
1370
  parameters: rest,
953
1371
  organizationId: organizationId ??
@@ -961,19 +1379,28 @@ class TurnkeySDKClientBase {
961
1379
  if (!this.stamper) {
962
1380
  return undefined;
963
1381
  }
1382
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1383
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1384
+ const { organizationId, timestampMs, ...parameters } = input;
964
1385
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_invitations";
965
- const body = JSON.stringify(input);
966
- const stamp = await this.stamper.stamp(body);
1386
+ const bodyWithType = {
1387
+ parameters,
1388
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1389
+ timestampMs: timestampMs ?? String(Date.now()),
1390
+ type: "ACTIVITY_TYPE_CREATE_INVITATIONS",
1391
+ };
1392
+ const stringifiedBody = JSON.stringify(bodyWithType);
1393
+ const stamp = await this.stamper.stamp(stringifiedBody);
967
1394
  return {
968
- body: body,
1395
+ body: stringifiedBody,
969
1396
  stamp: stamp,
970
1397
  url: fullUrl,
971
1398
  };
972
1399
  };
973
1400
  this.createOauth2Credential = async (input) => {
1401
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1402
+ const session = sessionData ? utils.parseSession(sessionData) : null;
974
1403
  const { organizationId, timestampMs, ...rest } = input;
975
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
976
- session = utils.parseSession(session);
977
1404
  return this.command("/public/v1/submit/create_oauth2_credential", {
978
1405
  parameters: rest,
979
1406
  organizationId: organizationId ??
@@ -987,19 +1414,28 @@ class TurnkeySDKClientBase {
987
1414
  if (!this.stamper) {
988
1415
  return undefined;
989
1416
  }
1417
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1418
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1419
+ const { organizationId, timestampMs, ...parameters } = input;
990
1420
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_oauth2_credential";
991
- const body = JSON.stringify(input);
992
- const stamp = await this.stamper.stamp(body);
1421
+ const bodyWithType = {
1422
+ parameters,
1423
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1424
+ timestampMs: timestampMs ?? String(Date.now()),
1425
+ type: "ACTIVITY_TYPE_CREATE_OAUTH2_CREDENTIAL",
1426
+ };
1427
+ const stringifiedBody = JSON.stringify(bodyWithType);
1428
+ const stamp = await this.stamper.stamp(stringifiedBody);
993
1429
  return {
994
- body: body,
1430
+ body: stringifiedBody,
995
1431
  stamp: stamp,
996
1432
  url: fullUrl,
997
1433
  };
998
1434
  };
999
1435
  this.createOauthProviders = async (input) => {
1436
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1437
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1000
1438
  const { organizationId, timestampMs, ...rest } = input;
1001
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1002
- session = utils.parseSession(session);
1003
1439
  return this.command("/public/v1/submit/create_oauth_providers", {
1004
1440
  parameters: rest,
1005
1441
  organizationId: organizationId ??
@@ -1013,19 +1449,28 @@ class TurnkeySDKClientBase {
1013
1449
  if (!this.stamper) {
1014
1450
  return undefined;
1015
1451
  }
1452
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1453
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1454
+ const { organizationId, timestampMs, ...parameters } = input;
1016
1455
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_oauth_providers";
1017
- const body = JSON.stringify(input);
1018
- const stamp = await this.stamper.stamp(body);
1456
+ const bodyWithType = {
1457
+ parameters,
1458
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1459
+ timestampMs: timestampMs ?? String(Date.now()),
1460
+ type: "ACTIVITY_TYPE_CREATE_OAUTH_PROVIDERS",
1461
+ };
1462
+ const stringifiedBody = JSON.stringify(bodyWithType);
1463
+ const stamp = await this.stamper.stamp(stringifiedBody);
1019
1464
  return {
1020
- body: body,
1465
+ body: stringifiedBody,
1021
1466
  stamp: stamp,
1022
1467
  url: fullUrl,
1023
1468
  };
1024
1469
  };
1025
1470
  this.createPolicies = async (input) => {
1471
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1472
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1026
1473
  const { organizationId, timestampMs, ...rest } = input;
1027
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1028
- session = utils.parseSession(session);
1029
1474
  return this.command("/public/v1/submit/create_policies", {
1030
1475
  parameters: rest,
1031
1476
  organizationId: organizationId ??
@@ -1039,19 +1484,28 @@ class TurnkeySDKClientBase {
1039
1484
  if (!this.stamper) {
1040
1485
  return undefined;
1041
1486
  }
1487
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1488
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1489
+ const { organizationId, timestampMs, ...parameters } = input;
1042
1490
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_policies";
1043
- const body = JSON.stringify(input);
1044
- const stamp = await this.stamper.stamp(body);
1491
+ const bodyWithType = {
1492
+ parameters,
1493
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1494
+ timestampMs: timestampMs ?? String(Date.now()),
1495
+ type: "ACTIVITY_TYPE_CREATE_POLICIES",
1496
+ };
1497
+ const stringifiedBody = JSON.stringify(bodyWithType);
1498
+ const stamp = await this.stamper.stamp(stringifiedBody);
1045
1499
  return {
1046
- body: body,
1500
+ body: stringifiedBody,
1047
1501
  stamp: stamp,
1048
1502
  url: fullUrl,
1049
1503
  };
1050
1504
  };
1051
1505
  this.createPolicy = async (input) => {
1506
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1507
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1052
1508
  const { organizationId, timestampMs, ...rest } = input;
1053
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1054
- session = utils.parseSession(session);
1055
1509
  return this.command("/public/v1/submit/create_policy", {
1056
1510
  parameters: rest,
1057
1511
  organizationId: organizationId ??
@@ -1065,19 +1519,28 @@ class TurnkeySDKClientBase {
1065
1519
  if (!this.stamper) {
1066
1520
  return undefined;
1067
1521
  }
1522
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1523
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1524
+ const { organizationId, timestampMs, ...parameters } = input;
1068
1525
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_policy";
1069
- const body = JSON.stringify(input);
1070
- const stamp = await this.stamper.stamp(body);
1526
+ const bodyWithType = {
1527
+ parameters,
1528
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1529
+ timestampMs: timestampMs ?? String(Date.now()),
1530
+ type: "ACTIVITY_TYPE_CREATE_POLICY_V3",
1531
+ };
1532
+ const stringifiedBody = JSON.stringify(bodyWithType);
1533
+ const stamp = await this.stamper.stamp(stringifiedBody);
1071
1534
  return {
1072
- body: body,
1535
+ body: stringifiedBody,
1073
1536
  stamp: stamp,
1074
1537
  url: fullUrl,
1075
1538
  };
1076
1539
  };
1077
1540
  this.createPrivateKeyTag = async (input) => {
1541
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1542
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1078
1543
  const { organizationId, timestampMs, ...rest } = input;
1079
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1080
- session = utils.parseSession(session);
1081
1544
  return this.command("/public/v1/submit/create_private_key_tag", {
1082
1545
  parameters: rest,
1083
1546
  organizationId: organizationId ??
@@ -1091,19 +1554,28 @@ class TurnkeySDKClientBase {
1091
1554
  if (!this.stamper) {
1092
1555
  return undefined;
1093
1556
  }
1557
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1558
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1559
+ const { organizationId, timestampMs, ...parameters } = input;
1094
1560
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_private_key_tag";
1095
- const body = JSON.stringify(input);
1096
- const stamp = await this.stamper.stamp(body);
1561
+ const bodyWithType = {
1562
+ parameters,
1563
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1564
+ timestampMs: timestampMs ?? String(Date.now()),
1565
+ type: "ACTIVITY_TYPE_CREATE_PRIVATE_KEY_TAG",
1566
+ };
1567
+ const stringifiedBody = JSON.stringify(bodyWithType);
1568
+ const stamp = await this.stamper.stamp(stringifiedBody);
1097
1569
  return {
1098
- body: body,
1570
+ body: stringifiedBody,
1099
1571
  stamp: stamp,
1100
1572
  url: fullUrl,
1101
1573
  };
1102
1574
  };
1103
1575
  this.createPrivateKeys = async (input) => {
1576
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1577
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1104
1578
  const { organizationId, timestampMs, ...rest } = input;
1105
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1106
- session = utils.parseSession(session);
1107
1579
  return this.command("/public/v1/submit/create_private_keys", {
1108
1580
  parameters: rest,
1109
1581
  organizationId: organizationId ??
@@ -1117,19 +1589,28 @@ class TurnkeySDKClientBase {
1117
1589
  if (!this.stamper) {
1118
1590
  return undefined;
1119
1591
  }
1592
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1593
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1594
+ const { organizationId, timestampMs, ...parameters } = input;
1120
1595
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_private_keys";
1121
- const body = JSON.stringify(input);
1122
- const stamp = await this.stamper.stamp(body);
1596
+ const bodyWithType = {
1597
+ parameters,
1598
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1599
+ timestampMs: timestampMs ?? String(Date.now()),
1600
+ type: "ACTIVITY_TYPE_CREATE_PRIVATE_KEYS_V2",
1601
+ };
1602
+ const stringifiedBody = JSON.stringify(bodyWithType);
1603
+ const stamp = await this.stamper.stamp(stringifiedBody);
1123
1604
  return {
1124
- body: body,
1605
+ body: stringifiedBody,
1125
1606
  stamp: stamp,
1126
1607
  url: fullUrl,
1127
1608
  };
1128
1609
  };
1129
1610
  this.createReadOnlySession = async (input) => {
1611
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1612
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1130
1613
  const { organizationId, timestampMs, ...rest } = input;
1131
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1132
- session = utils.parseSession(session);
1133
1614
  return this.command("/public/v1/submit/create_read_only_session", {
1134
1615
  parameters: rest,
1135
1616
  organizationId: organizationId ??
@@ -1143,19 +1624,28 @@ class TurnkeySDKClientBase {
1143
1624
  if (!this.stamper) {
1144
1625
  return undefined;
1145
1626
  }
1627
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1628
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1629
+ const { organizationId, timestampMs, ...parameters } = input;
1146
1630
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_read_only_session";
1147
- const body = JSON.stringify(input);
1148
- const stamp = await this.stamper.stamp(body);
1631
+ const bodyWithType = {
1632
+ parameters,
1633
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1634
+ timestampMs: timestampMs ?? String(Date.now()),
1635
+ type: "ACTIVITY_TYPE_CREATE_READ_ONLY_SESSION",
1636
+ };
1637
+ const stringifiedBody = JSON.stringify(bodyWithType);
1638
+ const stamp = await this.stamper.stamp(stringifiedBody);
1149
1639
  return {
1150
- body: body,
1640
+ body: stringifiedBody,
1151
1641
  stamp: stamp,
1152
1642
  url: fullUrl,
1153
1643
  };
1154
1644
  };
1155
1645
  this.createReadWriteSession = async (input) => {
1646
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1647
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1156
1648
  const { organizationId, timestampMs, ...rest } = input;
1157
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1158
- session = utils.parseSession(session);
1159
1649
  return this.command("/public/v1/submit/create_read_write_session", {
1160
1650
  parameters: rest,
1161
1651
  organizationId: organizationId ??
@@ -1169,19 +1659,28 @@ class TurnkeySDKClientBase {
1169
1659
  if (!this.stamper) {
1170
1660
  return undefined;
1171
1661
  }
1662
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1663
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1664
+ const { organizationId, timestampMs, ...parameters } = input;
1172
1665
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_read_write_session";
1173
- const body = JSON.stringify(input);
1174
- const stamp = await this.stamper.stamp(body);
1666
+ const bodyWithType = {
1667
+ parameters,
1668
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1669
+ timestampMs: timestampMs ?? String(Date.now()),
1670
+ type: "ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION_V2",
1671
+ };
1672
+ const stringifiedBody = JSON.stringify(bodyWithType);
1673
+ const stamp = await this.stamper.stamp(stringifiedBody);
1175
1674
  return {
1176
- body: body,
1675
+ body: stringifiedBody,
1177
1676
  stamp: stamp,
1178
1677
  url: fullUrl,
1179
1678
  };
1180
1679
  };
1181
1680
  this.createSmartContractInterface = async (input) => {
1681
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1682
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1182
1683
  const { organizationId, timestampMs, ...rest } = input;
1183
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1184
- session = utils.parseSession(session);
1185
1684
  return this.command("/public/v1/submit/create_smart_contract_interface", {
1186
1685
  parameters: rest,
1187
1686
  organizationId: organizationId ??
@@ -1195,20 +1694,29 @@ class TurnkeySDKClientBase {
1195
1694
  if (!this.stamper) {
1196
1695
  return undefined;
1197
1696
  }
1697
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1698
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1699
+ const { organizationId, timestampMs, ...parameters } = input;
1198
1700
  const fullUrl = this.config.apiBaseUrl +
1199
1701
  "/public/v1/submit/create_smart_contract_interface";
1200
- const body = JSON.stringify(input);
1201
- const stamp = await this.stamper.stamp(body);
1702
+ const bodyWithType = {
1703
+ parameters,
1704
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1705
+ timestampMs: timestampMs ?? String(Date.now()),
1706
+ type: "ACTIVITY_TYPE_CREATE_SMART_CONTRACT_INTERFACE",
1707
+ };
1708
+ const stringifiedBody = JSON.stringify(bodyWithType);
1709
+ const stamp = await this.stamper.stamp(stringifiedBody);
1202
1710
  return {
1203
- body: body,
1711
+ body: stringifiedBody,
1204
1712
  stamp: stamp,
1205
1713
  url: fullUrl,
1206
1714
  };
1207
1715
  };
1208
1716
  this.createSubOrganization = async (input) => {
1717
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1718
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1209
1719
  const { organizationId, timestampMs, ...rest } = input;
1210
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1211
- session = utils.parseSession(session);
1212
1720
  return this.command("/public/v1/submit/create_sub_organization", {
1213
1721
  parameters: rest,
1214
1722
  organizationId: organizationId ??
@@ -1222,19 +1730,28 @@ class TurnkeySDKClientBase {
1222
1730
  if (!this.stamper) {
1223
1731
  return undefined;
1224
1732
  }
1733
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1734
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1735
+ const { organizationId, timestampMs, ...parameters } = input;
1225
1736
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_sub_organization";
1226
- const body = JSON.stringify(input);
1227
- const stamp = await this.stamper.stamp(body);
1737
+ const bodyWithType = {
1738
+ parameters,
1739
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1740
+ timestampMs: timestampMs ?? String(Date.now()),
1741
+ type: "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7",
1742
+ };
1743
+ const stringifiedBody = JSON.stringify(bodyWithType);
1744
+ const stamp = await this.stamper.stamp(stringifiedBody);
1228
1745
  return {
1229
- body: body,
1746
+ body: stringifiedBody,
1230
1747
  stamp: stamp,
1231
1748
  url: fullUrl,
1232
1749
  };
1233
1750
  };
1234
1751
  this.createUserTag = async (input) => {
1752
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1753
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1235
1754
  const { organizationId, timestampMs, ...rest } = input;
1236
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1237
- session = utils.parseSession(session);
1238
1755
  return this.command("/public/v1/submit/create_user_tag", {
1239
1756
  parameters: rest,
1240
1757
  organizationId: organizationId ??
@@ -1248,19 +1765,28 @@ class TurnkeySDKClientBase {
1248
1765
  if (!this.stamper) {
1249
1766
  return undefined;
1250
1767
  }
1768
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1769
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1770
+ const { organizationId, timestampMs, ...parameters } = input;
1251
1771
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_user_tag";
1252
- const body = JSON.stringify(input);
1253
- const stamp = await this.stamper.stamp(body);
1772
+ const bodyWithType = {
1773
+ parameters,
1774
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1775
+ timestampMs: timestampMs ?? String(Date.now()),
1776
+ type: "ACTIVITY_TYPE_CREATE_USER_TAG",
1777
+ };
1778
+ const stringifiedBody = JSON.stringify(bodyWithType);
1779
+ const stamp = await this.stamper.stamp(stringifiedBody);
1254
1780
  return {
1255
- body: body,
1781
+ body: stringifiedBody,
1256
1782
  stamp: stamp,
1257
1783
  url: fullUrl,
1258
1784
  };
1259
1785
  };
1260
1786
  this.createUsers = async (input) => {
1787
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1788
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1261
1789
  const { organizationId, timestampMs, ...rest } = input;
1262
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1263
- session = utils.parseSession(session);
1264
1790
  return this.command("/public/v1/submit/create_users", {
1265
1791
  parameters: rest,
1266
1792
  organizationId: organizationId ??
@@ -1274,19 +1800,28 @@ class TurnkeySDKClientBase {
1274
1800
  if (!this.stamper) {
1275
1801
  return undefined;
1276
1802
  }
1803
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1804
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1805
+ const { organizationId, timestampMs, ...parameters } = input;
1277
1806
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_users";
1278
- const body = JSON.stringify(input);
1279
- const stamp = await this.stamper.stamp(body);
1807
+ const bodyWithType = {
1808
+ parameters,
1809
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1810
+ timestampMs: timestampMs ?? String(Date.now()),
1811
+ type: "ACTIVITY_TYPE_CREATE_USERS_V3",
1812
+ };
1813
+ const stringifiedBody = JSON.stringify(bodyWithType);
1814
+ const stamp = await this.stamper.stamp(stringifiedBody);
1280
1815
  return {
1281
- body: body,
1816
+ body: stringifiedBody,
1282
1817
  stamp: stamp,
1283
1818
  url: fullUrl,
1284
1819
  };
1285
1820
  };
1286
1821
  this.createWallet = async (input) => {
1822
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1823
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1287
1824
  const { organizationId, timestampMs, ...rest } = input;
1288
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1289
- session = utils.parseSession(session);
1290
1825
  return this.command("/public/v1/submit/create_wallet", {
1291
1826
  parameters: rest,
1292
1827
  organizationId: organizationId ??
@@ -1300,19 +1835,28 @@ class TurnkeySDKClientBase {
1300
1835
  if (!this.stamper) {
1301
1836
  return undefined;
1302
1837
  }
1838
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1839
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1840
+ const { organizationId, timestampMs, ...parameters } = input;
1303
1841
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_wallet";
1304
- const body = JSON.stringify(input);
1305
- const stamp = await this.stamper.stamp(body);
1842
+ const bodyWithType = {
1843
+ parameters,
1844
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1845
+ timestampMs: timestampMs ?? String(Date.now()),
1846
+ type: "ACTIVITY_TYPE_CREATE_WALLET",
1847
+ };
1848
+ const stringifiedBody = JSON.stringify(bodyWithType);
1849
+ const stamp = await this.stamper.stamp(stringifiedBody);
1306
1850
  return {
1307
- body: body,
1851
+ body: stringifiedBody,
1308
1852
  stamp: stamp,
1309
1853
  url: fullUrl,
1310
1854
  };
1311
1855
  };
1312
1856
  this.createWalletAccounts = async (input) => {
1857
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1858
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1313
1859
  const { organizationId, timestampMs, ...rest } = input;
1314
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1315
- session = utils.parseSession(session);
1316
1860
  return this.command("/public/v1/submit/create_wallet_accounts", {
1317
1861
  parameters: rest,
1318
1862
  organizationId: organizationId ??
@@ -1326,19 +1870,28 @@ class TurnkeySDKClientBase {
1326
1870
  if (!this.stamper) {
1327
1871
  return undefined;
1328
1872
  }
1873
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1874
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1875
+ const { organizationId, timestampMs, ...parameters } = input;
1329
1876
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_wallet_accounts";
1330
- const body = JSON.stringify(input);
1331
- const stamp = await this.stamper.stamp(body);
1877
+ const bodyWithType = {
1878
+ parameters,
1879
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1880
+ timestampMs: timestampMs ?? String(Date.now()),
1881
+ type: "ACTIVITY_TYPE_CREATE_WALLET_ACCOUNTS",
1882
+ };
1883
+ const stringifiedBody = JSON.stringify(bodyWithType);
1884
+ const stamp = await this.stamper.stamp(stringifiedBody);
1332
1885
  return {
1333
- body: body,
1886
+ body: stringifiedBody,
1334
1887
  stamp: stamp,
1335
1888
  url: fullUrl,
1336
1889
  };
1337
1890
  };
1338
1891
  this.deleteApiKeys = async (input) => {
1892
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1893
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1339
1894
  const { organizationId, timestampMs, ...rest } = input;
1340
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1341
- session = utils.parseSession(session);
1342
1895
  return this.command("/public/v1/submit/delete_api_keys", {
1343
1896
  parameters: rest,
1344
1897
  organizationId: organizationId ??
@@ -1352,19 +1905,28 @@ class TurnkeySDKClientBase {
1352
1905
  if (!this.stamper) {
1353
1906
  return undefined;
1354
1907
  }
1908
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1909
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1910
+ const { organizationId, timestampMs, ...parameters } = input;
1355
1911
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_api_keys";
1356
- const body = JSON.stringify(input);
1357
- const stamp = await this.stamper.stamp(body);
1912
+ const bodyWithType = {
1913
+ parameters,
1914
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1915
+ timestampMs: timestampMs ?? String(Date.now()),
1916
+ type: "ACTIVITY_TYPE_DELETE_API_KEYS",
1917
+ };
1918
+ const stringifiedBody = JSON.stringify(bodyWithType);
1919
+ const stamp = await this.stamper.stamp(stringifiedBody);
1358
1920
  return {
1359
- body: body,
1921
+ body: stringifiedBody,
1360
1922
  stamp: stamp,
1361
1923
  url: fullUrl,
1362
1924
  };
1363
1925
  };
1364
1926
  this.deleteAuthenticators = async (input) => {
1927
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1928
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1365
1929
  const { organizationId, timestampMs, ...rest } = input;
1366
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1367
- session = utils.parseSession(session);
1368
1930
  return this.command("/public/v1/submit/delete_authenticators", {
1369
1931
  parameters: rest,
1370
1932
  organizationId: organizationId ??
@@ -1378,19 +1940,28 @@ class TurnkeySDKClientBase {
1378
1940
  if (!this.stamper) {
1379
1941
  return undefined;
1380
1942
  }
1943
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1944
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1945
+ const { organizationId, timestampMs, ...parameters } = input;
1381
1946
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_authenticators";
1382
- const body = JSON.stringify(input);
1383
- const stamp = await this.stamper.stamp(body);
1947
+ const bodyWithType = {
1948
+ parameters,
1949
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1950
+ timestampMs: timestampMs ?? String(Date.now()),
1951
+ type: "ACTIVITY_TYPE_DELETE_AUTHENTICATORS",
1952
+ };
1953
+ const stringifiedBody = JSON.stringify(bodyWithType);
1954
+ const stamp = await this.stamper.stamp(stringifiedBody);
1384
1955
  return {
1385
- body: body,
1956
+ body: stringifiedBody,
1386
1957
  stamp: stamp,
1387
1958
  url: fullUrl,
1388
1959
  };
1389
1960
  };
1390
1961
  this.deleteFiatOnRampCredential = async (input) => {
1962
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1963
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1391
1964
  const { organizationId, timestampMs, ...rest } = input;
1392
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1393
- session = utils.parseSession(session);
1394
1965
  return this.command("/public/v1/submit/delete_fiat_on_ramp_credential", {
1395
1966
  parameters: rest,
1396
1967
  organizationId: organizationId ??
@@ -1404,20 +1975,29 @@ class TurnkeySDKClientBase {
1404
1975
  if (!this.stamper) {
1405
1976
  return undefined;
1406
1977
  }
1978
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1979
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1980
+ const { organizationId, timestampMs, ...parameters } = input;
1407
1981
  const fullUrl = this.config.apiBaseUrl +
1408
1982
  "/public/v1/submit/delete_fiat_on_ramp_credential";
1409
- const body = JSON.stringify(input);
1410
- const stamp = await this.stamper.stamp(body);
1983
+ const bodyWithType = {
1984
+ parameters,
1985
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
1986
+ timestampMs: timestampMs ?? String(Date.now()),
1987
+ type: "ACTIVITY_TYPE_DELETE_FIAT_ON_RAMP_CREDENTIAL",
1988
+ };
1989
+ const stringifiedBody = JSON.stringify(bodyWithType);
1990
+ const stamp = await this.stamper.stamp(stringifiedBody);
1411
1991
  return {
1412
- body: body,
1992
+ body: stringifiedBody,
1413
1993
  stamp: stamp,
1414
1994
  url: fullUrl,
1415
1995
  };
1416
1996
  };
1417
1997
  this.deleteInvitation = async (input) => {
1998
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
1999
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1418
2000
  const { organizationId, timestampMs, ...rest } = input;
1419
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1420
- session = utils.parseSession(session);
1421
2001
  return this.command("/public/v1/submit/delete_invitation", {
1422
2002
  parameters: rest,
1423
2003
  organizationId: organizationId ??
@@ -1431,19 +2011,28 @@ class TurnkeySDKClientBase {
1431
2011
  if (!this.stamper) {
1432
2012
  return undefined;
1433
2013
  }
2014
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2015
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2016
+ const { organizationId, timestampMs, ...parameters } = input;
1434
2017
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_invitation";
1435
- const body = JSON.stringify(input);
1436
- const stamp = await this.stamper.stamp(body);
2018
+ const bodyWithType = {
2019
+ parameters,
2020
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2021
+ timestampMs: timestampMs ?? String(Date.now()),
2022
+ type: "ACTIVITY_TYPE_DELETE_INVITATION",
2023
+ };
2024
+ const stringifiedBody = JSON.stringify(bodyWithType);
2025
+ const stamp = await this.stamper.stamp(stringifiedBody);
1437
2026
  return {
1438
- body: body,
2027
+ body: stringifiedBody,
1439
2028
  stamp: stamp,
1440
2029
  url: fullUrl,
1441
2030
  };
1442
2031
  };
1443
2032
  this.deleteOauth2Credential = async (input) => {
2033
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2034
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1444
2035
  const { organizationId, timestampMs, ...rest } = input;
1445
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1446
- session = utils.parseSession(session);
1447
2036
  return this.command("/public/v1/submit/delete_oauth2_credential", {
1448
2037
  parameters: rest,
1449
2038
  organizationId: organizationId ??
@@ -1457,19 +2046,28 @@ class TurnkeySDKClientBase {
1457
2046
  if (!this.stamper) {
1458
2047
  return undefined;
1459
2048
  }
2049
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2050
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2051
+ const { organizationId, timestampMs, ...parameters } = input;
1460
2052
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_oauth2_credential";
1461
- const body = JSON.stringify(input);
1462
- const stamp = await this.stamper.stamp(body);
2053
+ const bodyWithType = {
2054
+ parameters,
2055
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2056
+ timestampMs: timestampMs ?? String(Date.now()),
2057
+ type: "ACTIVITY_TYPE_DELETE_OAUTH2_CREDENTIAL",
2058
+ };
2059
+ const stringifiedBody = JSON.stringify(bodyWithType);
2060
+ const stamp = await this.stamper.stamp(stringifiedBody);
1463
2061
  return {
1464
- body: body,
2062
+ body: stringifiedBody,
1465
2063
  stamp: stamp,
1466
2064
  url: fullUrl,
1467
2065
  };
1468
2066
  };
1469
2067
  this.deleteOauthProviders = async (input) => {
2068
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2069
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1470
2070
  const { organizationId, timestampMs, ...rest } = input;
1471
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1472
- session = utils.parseSession(session);
1473
2071
  return this.command("/public/v1/submit/delete_oauth_providers", {
1474
2072
  parameters: rest,
1475
2073
  organizationId: organizationId ??
@@ -1483,19 +2081,28 @@ class TurnkeySDKClientBase {
1483
2081
  if (!this.stamper) {
1484
2082
  return undefined;
1485
2083
  }
2084
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2085
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2086
+ const { organizationId, timestampMs, ...parameters } = input;
1486
2087
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_oauth_providers";
1487
- const body = JSON.stringify(input);
1488
- const stamp = await this.stamper.stamp(body);
2088
+ const bodyWithType = {
2089
+ parameters,
2090
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2091
+ timestampMs: timestampMs ?? String(Date.now()),
2092
+ type: "ACTIVITY_TYPE_DELETE_OAUTH_PROVIDERS",
2093
+ };
2094
+ const stringifiedBody = JSON.stringify(bodyWithType);
2095
+ const stamp = await this.stamper.stamp(stringifiedBody);
1489
2096
  return {
1490
- body: body,
2097
+ body: stringifiedBody,
1491
2098
  stamp: stamp,
1492
2099
  url: fullUrl,
1493
2100
  };
1494
2101
  };
1495
2102
  this.deletePolicies = async (input) => {
2103
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2104
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1496
2105
  const { organizationId, timestampMs, ...rest } = input;
1497
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1498
- session = utils.parseSession(session);
1499
2106
  return this.command("/public/v1/submit/delete_policies", {
1500
2107
  parameters: rest,
1501
2108
  organizationId: organizationId ??
@@ -1509,19 +2116,28 @@ class TurnkeySDKClientBase {
1509
2116
  if (!this.stamper) {
1510
2117
  return undefined;
1511
2118
  }
2119
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2120
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2121
+ const { organizationId, timestampMs, ...parameters } = input;
1512
2122
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_policies";
1513
- const body = JSON.stringify(input);
1514
- const stamp = await this.stamper.stamp(body);
2123
+ const bodyWithType = {
2124
+ parameters,
2125
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2126
+ timestampMs: timestampMs ?? String(Date.now()),
2127
+ type: "ACTIVITY_TYPE_DELETE_POLICIES",
2128
+ };
2129
+ const stringifiedBody = JSON.stringify(bodyWithType);
2130
+ const stamp = await this.stamper.stamp(stringifiedBody);
1515
2131
  return {
1516
- body: body,
2132
+ body: stringifiedBody,
1517
2133
  stamp: stamp,
1518
2134
  url: fullUrl,
1519
2135
  };
1520
2136
  };
1521
2137
  this.deletePolicy = async (input) => {
2138
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2139
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1522
2140
  const { organizationId, timestampMs, ...rest } = input;
1523
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1524
- session = utils.parseSession(session);
1525
2141
  return this.command("/public/v1/submit/delete_policy", {
1526
2142
  parameters: rest,
1527
2143
  organizationId: organizationId ??
@@ -1535,19 +2151,28 @@ class TurnkeySDKClientBase {
1535
2151
  if (!this.stamper) {
1536
2152
  return undefined;
1537
2153
  }
2154
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2155
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2156
+ const { organizationId, timestampMs, ...parameters } = input;
1538
2157
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_policy";
1539
- const body = JSON.stringify(input);
1540
- const stamp = await this.stamper.stamp(body);
2158
+ const bodyWithType = {
2159
+ parameters,
2160
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2161
+ timestampMs: timestampMs ?? String(Date.now()),
2162
+ type: "ACTIVITY_TYPE_DELETE_POLICY",
2163
+ };
2164
+ const stringifiedBody = JSON.stringify(bodyWithType);
2165
+ const stamp = await this.stamper.stamp(stringifiedBody);
1541
2166
  return {
1542
- body: body,
2167
+ body: stringifiedBody,
1543
2168
  stamp: stamp,
1544
2169
  url: fullUrl,
1545
2170
  };
1546
2171
  };
1547
2172
  this.deletePrivateKeyTags = async (input) => {
2173
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2174
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1548
2175
  const { organizationId, timestampMs, ...rest } = input;
1549
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1550
- session = utils.parseSession(session);
1551
2176
  return this.command("/public/v1/submit/delete_private_key_tags", {
1552
2177
  parameters: rest,
1553
2178
  organizationId: organizationId ??
@@ -1561,19 +2186,28 @@ class TurnkeySDKClientBase {
1561
2186
  if (!this.stamper) {
1562
2187
  return undefined;
1563
2188
  }
2189
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2190
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2191
+ const { organizationId, timestampMs, ...parameters } = input;
1564
2192
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_private_key_tags";
1565
- const body = JSON.stringify(input);
1566
- const stamp = await this.stamper.stamp(body);
2193
+ const bodyWithType = {
2194
+ parameters,
2195
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2196
+ timestampMs: timestampMs ?? String(Date.now()),
2197
+ type: "ACTIVITY_TYPE_DELETE_PRIVATE_KEY_TAGS",
2198
+ };
2199
+ const stringifiedBody = JSON.stringify(bodyWithType);
2200
+ const stamp = await this.stamper.stamp(stringifiedBody);
1567
2201
  return {
1568
- body: body,
2202
+ body: stringifiedBody,
1569
2203
  stamp: stamp,
1570
2204
  url: fullUrl,
1571
2205
  };
1572
2206
  };
1573
2207
  this.deletePrivateKeys = async (input) => {
2208
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2209
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1574
2210
  const { organizationId, timestampMs, ...rest } = input;
1575
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1576
- session = utils.parseSession(session);
1577
2211
  return this.command("/public/v1/submit/delete_private_keys", {
1578
2212
  parameters: rest,
1579
2213
  organizationId: organizationId ??
@@ -1587,19 +2221,28 @@ class TurnkeySDKClientBase {
1587
2221
  if (!this.stamper) {
1588
2222
  return undefined;
1589
2223
  }
2224
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2225
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2226
+ const { organizationId, timestampMs, ...parameters } = input;
1590
2227
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_private_keys";
1591
- const body = JSON.stringify(input);
1592
- const stamp = await this.stamper.stamp(body);
2228
+ const bodyWithType = {
2229
+ parameters,
2230
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2231
+ timestampMs: timestampMs ?? String(Date.now()),
2232
+ type: "ACTIVITY_TYPE_DELETE_PRIVATE_KEYS",
2233
+ };
2234
+ const stringifiedBody = JSON.stringify(bodyWithType);
2235
+ const stamp = await this.stamper.stamp(stringifiedBody);
1593
2236
  return {
1594
- body: body,
2237
+ body: stringifiedBody,
1595
2238
  stamp: stamp,
1596
2239
  url: fullUrl,
1597
2240
  };
1598
2241
  };
1599
2242
  this.deleteSmartContractInterface = async (input) => {
2243
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2244
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1600
2245
  const { organizationId, timestampMs, ...rest } = input;
1601
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1602
- session = utils.parseSession(session);
1603
2246
  return this.command("/public/v1/submit/delete_smart_contract_interface", {
1604
2247
  parameters: rest,
1605
2248
  organizationId: organizationId ??
@@ -1613,20 +2256,29 @@ class TurnkeySDKClientBase {
1613
2256
  if (!this.stamper) {
1614
2257
  return undefined;
1615
2258
  }
2259
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2260
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2261
+ const { organizationId, timestampMs, ...parameters } = input;
1616
2262
  const fullUrl = this.config.apiBaseUrl +
1617
2263
  "/public/v1/submit/delete_smart_contract_interface";
1618
- const body = JSON.stringify(input);
1619
- const stamp = await this.stamper.stamp(body);
2264
+ const bodyWithType = {
2265
+ parameters,
2266
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2267
+ timestampMs: timestampMs ?? String(Date.now()),
2268
+ type: "ACTIVITY_TYPE_DELETE_SMART_CONTRACT_INTERFACE",
2269
+ };
2270
+ const stringifiedBody = JSON.stringify(bodyWithType);
2271
+ const stamp = await this.stamper.stamp(stringifiedBody);
1620
2272
  return {
1621
- body: body,
2273
+ body: stringifiedBody,
1622
2274
  stamp: stamp,
1623
2275
  url: fullUrl,
1624
2276
  };
1625
2277
  };
1626
2278
  this.deleteSubOrganization = async (input) => {
2279
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2280
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1627
2281
  const { organizationId, timestampMs, ...rest } = input;
1628
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1629
- session = utils.parseSession(session);
1630
2282
  return this.command("/public/v1/submit/delete_sub_organization", {
1631
2283
  parameters: rest,
1632
2284
  organizationId: organizationId ??
@@ -1640,19 +2292,28 @@ class TurnkeySDKClientBase {
1640
2292
  if (!this.stamper) {
1641
2293
  return undefined;
1642
2294
  }
2295
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2296
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2297
+ const { organizationId, timestampMs, ...parameters } = input;
1643
2298
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_sub_organization";
1644
- const body = JSON.stringify(input);
1645
- const stamp = await this.stamper.stamp(body);
2299
+ const bodyWithType = {
2300
+ parameters,
2301
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2302
+ timestampMs: timestampMs ?? String(Date.now()),
2303
+ type: "ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION",
2304
+ };
2305
+ const stringifiedBody = JSON.stringify(bodyWithType);
2306
+ const stamp = await this.stamper.stamp(stringifiedBody);
1646
2307
  return {
1647
- body: body,
2308
+ body: stringifiedBody,
1648
2309
  stamp: stamp,
1649
2310
  url: fullUrl,
1650
2311
  };
1651
2312
  };
1652
2313
  this.deleteUserTags = async (input) => {
2314
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2315
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1653
2316
  const { organizationId, timestampMs, ...rest } = input;
1654
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1655
- session = utils.parseSession(session);
1656
2317
  return this.command("/public/v1/submit/delete_user_tags", {
1657
2318
  parameters: rest,
1658
2319
  organizationId: organizationId ??
@@ -1666,19 +2327,28 @@ class TurnkeySDKClientBase {
1666
2327
  if (!this.stamper) {
1667
2328
  return undefined;
1668
2329
  }
2330
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2331
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2332
+ const { organizationId, timestampMs, ...parameters } = input;
1669
2333
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_user_tags";
1670
- const body = JSON.stringify(input);
1671
- const stamp = await this.stamper.stamp(body);
2334
+ const bodyWithType = {
2335
+ parameters,
2336
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2337
+ timestampMs: timestampMs ?? String(Date.now()),
2338
+ type: "ACTIVITY_TYPE_DELETE_USER_TAGS",
2339
+ };
2340
+ const stringifiedBody = JSON.stringify(bodyWithType);
2341
+ const stamp = await this.stamper.stamp(stringifiedBody);
1672
2342
  return {
1673
- body: body,
2343
+ body: stringifiedBody,
1674
2344
  stamp: stamp,
1675
2345
  url: fullUrl,
1676
2346
  };
1677
2347
  };
1678
2348
  this.deleteUsers = async (input) => {
2349
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2350
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1679
2351
  const { organizationId, timestampMs, ...rest } = input;
1680
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1681
- session = utils.parseSession(session);
1682
2352
  return this.command("/public/v1/submit/delete_users", {
1683
2353
  parameters: rest,
1684
2354
  organizationId: organizationId ??
@@ -1692,19 +2362,28 @@ class TurnkeySDKClientBase {
1692
2362
  if (!this.stamper) {
1693
2363
  return undefined;
1694
2364
  }
2365
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2366
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2367
+ const { organizationId, timestampMs, ...parameters } = input;
1695
2368
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_users";
1696
- const body = JSON.stringify(input);
1697
- const stamp = await this.stamper.stamp(body);
2369
+ const bodyWithType = {
2370
+ parameters,
2371
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2372
+ timestampMs: timestampMs ?? String(Date.now()),
2373
+ type: "ACTIVITY_TYPE_DELETE_USERS",
2374
+ };
2375
+ const stringifiedBody = JSON.stringify(bodyWithType);
2376
+ const stamp = await this.stamper.stamp(stringifiedBody);
1698
2377
  return {
1699
- body: body,
2378
+ body: stringifiedBody,
1700
2379
  stamp: stamp,
1701
2380
  url: fullUrl,
1702
2381
  };
1703
2382
  };
1704
2383
  this.deleteWalletAccounts = async (input) => {
2384
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2385
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1705
2386
  const { organizationId, timestampMs, ...rest } = input;
1706
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1707
- session = utils.parseSession(session);
1708
2387
  return this.command("/public/v1/submit/delete_wallet_accounts", {
1709
2388
  parameters: rest,
1710
2389
  organizationId: organizationId ??
@@ -1718,19 +2397,28 @@ class TurnkeySDKClientBase {
1718
2397
  if (!this.stamper) {
1719
2398
  return undefined;
1720
2399
  }
2400
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2401
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2402
+ const { organizationId, timestampMs, ...parameters } = input;
1721
2403
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_wallet_accounts";
1722
- const body = JSON.stringify(input);
1723
- const stamp = await this.stamper.stamp(body);
2404
+ const bodyWithType = {
2405
+ parameters,
2406
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2407
+ timestampMs: timestampMs ?? String(Date.now()),
2408
+ type: "ACTIVITY_TYPE_DELETE_WALLET_ACCOUNTS",
2409
+ };
2410
+ const stringifiedBody = JSON.stringify(bodyWithType);
2411
+ const stamp = await this.stamper.stamp(stringifiedBody);
1724
2412
  return {
1725
- body: body,
2413
+ body: stringifiedBody,
1726
2414
  stamp: stamp,
1727
2415
  url: fullUrl,
1728
2416
  };
1729
2417
  };
1730
2418
  this.deleteWallets = async (input) => {
2419
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2420
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1731
2421
  const { organizationId, timestampMs, ...rest } = input;
1732
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1733
- session = utils.parseSession(session);
1734
2422
  return this.command("/public/v1/submit/delete_wallets", {
1735
2423
  parameters: rest,
1736
2424
  organizationId: organizationId ??
@@ -1744,45 +2432,63 @@ class TurnkeySDKClientBase {
1744
2432
  if (!this.stamper) {
1745
2433
  return undefined;
1746
2434
  }
2435
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2436
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2437
+ const { organizationId, timestampMs, ...parameters } = input;
1747
2438
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/delete_wallets";
1748
- const body = JSON.stringify(input);
1749
- const stamp = await this.stamper.stamp(body);
2439
+ const bodyWithType = {
2440
+ parameters,
2441
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2442
+ timestampMs: timestampMs ?? String(Date.now()),
2443
+ type: "ACTIVITY_TYPE_DELETE_WALLETS",
2444
+ };
2445
+ const stringifiedBody = JSON.stringify(bodyWithType);
2446
+ const stamp = await this.stamper.stamp(stringifiedBody);
1750
2447
  return {
1751
- body: body,
2448
+ body: stringifiedBody,
1752
2449
  stamp: stamp,
1753
2450
  url: fullUrl,
1754
2451
  };
1755
2452
  };
1756
2453
  this.emailAuth = async (input) => {
2454
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2455
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1757
2456
  const { organizationId, timestampMs, ...rest } = input;
1758
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1759
- session = utils.parseSession(session);
1760
2457
  return this.command("/public/v1/submit/email_auth", {
1761
2458
  parameters: rest,
1762
2459
  organizationId: organizationId ??
1763
2460
  session?.organizationId ??
1764
2461
  this.config.organizationId,
1765
2462
  timestampMs: timestampMs ?? String(Date.now()),
1766
- type: "ACTIVITY_TYPE_EMAIL_AUTH_V2",
2463
+ type: "ACTIVITY_TYPE_EMAIL_AUTH_V3",
1767
2464
  }, "emailAuthResult");
1768
2465
  };
1769
2466
  this.stampEmailAuth = async (input) => {
1770
2467
  if (!this.stamper) {
1771
2468
  return undefined;
1772
2469
  }
2470
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2471
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2472
+ const { organizationId, timestampMs, ...parameters } = input;
1773
2473
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/email_auth";
1774
- const body = JSON.stringify(input);
1775
- const stamp = await this.stamper.stamp(body);
2474
+ const bodyWithType = {
2475
+ parameters,
2476
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2477
+ timestampMs: timestampMs ?? String(Date.now()),
2478
+ type: "ACTIVITY_TYPE_EMAIL_AUTH_V3",
2479
+ };
2480
+ const stringifiedBody = JSON.stringify(bodyWithType);
2481
+ const stamp = await this.stamper.stamp(stringifiedBody);
1776
2482
  return {
1777
- body: body,
2483
+ body: stringifiedBody,
1778
2484
  stamp: stamp,
1779
2485
  url: fullUrl,
1780
2486
  };
1781
2487
  };
1782
2488
  this.ethSendRawTransaction = async (input) => {
2489
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2490
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1783
2491
  const { organizationId, timestampMs, ...rest } = input;
1784
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1785
- session = utils.parseSession(session);
1786
2492
  return this.command("/public/v1/submit/eth_send_raw_transaction", {
1787
2493
  parameters: rest,
1788
2494
  organizationId: organizationId ??
@@ -1796,19 +2502,28 @@ class TurnkeySDKClientBase {
1796
2502
  if (!this.stamper) {
1797
2503
  return undefined;
1798
2504
  }
2505
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2506
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2507
+ const { organizationId, timestampMs, ...parameters } = input;
1799
2508
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/eth_send_raw_transaction";
1800
- const body = JSON.stringify(input);
1801
- const stamp = await this.stamper.stamp(body);
2509
+ const bodyWithType = {
2510
+ parameters,
2511
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2512
+ timestampMs: timestampMs ?? String(Date.now()),
2513
+ type: "ACTIVITY_TYPE_ETH_SEND_RAW_TRANSACTION",
2514
+ };
2515
+ const stringifiedBody = JSON.stringify(bodyWithType);
2516
+ const stamp = await this.stamper.stamp(stringifiedBody);
1802
2517
  return {
1803
- body: body,
2518
+ body: stringifiedBody,
1804
2519
  stamp: stamp,
1805
2520
  url: fullUrl,
1806
2521
  };
1807
2522
  };
1808
2523
  this.ethSendTransaction = async (input) => {
2524
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2525
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1809
2526
  const { organizationId, timestampMs, ...rest } = input;
1810
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1811
- session = utils.parseSession(session);
1812
2527
  return this.command("/public/v1/submit/eth_send_transaction", {
1813
2528
  parameters: rest,
1814
2529
  organizationId: organizationId ??
@@ -1822,19 +2537,28 @@ class TurnkeySDKClientBase {
1822
2537
  if (!this.stamper) {
1823
2538
  return undefined;
1824
2539
  }
2540
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2541
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2542
+ const { organizationId, timestampMs, ...parameters } = input;
1825
2543
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/eth_send_transaction";
1826
- const body = JSON.stringify(input);
1827
- const stamp = await this.stamper.stamp(body);
2544
+ const bodyWithType = {
2545
+ parameters,
2546
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2547
+ timestampMs: timestampMs ?? String(Date.now()),
2548
+ type: "ACTIVITY_TYPE_ETH_SEND_TRANSACTION",
2549
+ };
2550
+ const stringifiedBody = JSON.stringify(bodyWithType);
2551
+ const stamp = await this.stamper.stamp(stringifiedBody);
1828
2552
  return {
1829
- body: body,
2553
+ body: stringifiedBody,
1830
2554
  stamp: stamp,
1831
2555
  url: fullUrl,
1832
2556
  };
1833
2557
  };
1834
2558
  this.exportPrivateKey = async (input) => {
2559
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2560
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1835
2561
  const { organizationId, timestampMs, ...rest } = input;
1836
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1837
- session = utils.parseSession(session);
1838
2562
  return this.command("/public/v1/submit/export_private_key", {
1839
2563
  parameters: rest,
1840
2564
  organizationId: organizationId ??
@@ -1848,19 +2572,28 @@ class TurnkeySDKClientBase {
1848
2572
  if (!this.stamper) {
1849
2573
  return undefined;
1850
2574
  }
2575
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2576
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2577
+ const { organizationId, timestampMs, ...parameters } = input;
1851
2578
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/export_private_key";
1852
- const body = JSON.stringify(input);
1853
- const stamp = await this.stamper.stamp(body);
2579
+ const bodyWithType = {
2580
+ parameters,
2581
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2582
+ timestampMs: timestampMs ?? String(Date.now()),
2583
+ type: "ACTIVITY_TYPE_EXPORT_PRIVATE_KEY",
2584
+ };
2585
+ const stringifiedBody = JSON.stringify(bodyWithType);
2586
+ const stamp = await this.stamper.stamp(stringifiedBody);
1854
2587
  return {
1855
- body: body,
2588
+ body: stringifiedBody,
1856
2589
  stamp: stamp,
1857
2590
  url: fullUrl,
1858
2591
  };
1859
2592
  };
1860
2593
  this.exportWallet = async (input) => {
2594
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2595
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1861
2596
  const { organizationId, timestampMs, ...rest } = input;
1862
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1863
- session = utils.parseSession(session);
1864
2597
  return this.command("/public/v1/submit/export_wallet", {
1865
2598
  parameters: rest,
1866
2599
  organizationId: organizationId ??
@@ -1874,19 +2607,28 @@ class TurnkeySDKClientBase {
1874
2607
  if (!this.stamper) {
1875
2608
  return undefined;
1876
2609
  }
2610
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2611
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2612
+ const { organizationId, timestampMs, ...parameters } = input;
1877
2613
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/export_wallet";
1878
- const body = JSON.stringify(input);
1879
- const stamp = await this.stamper.stamp(body);
2614
+ const bodyWithType = {
2615
+ parameters,
2616
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2617
+ timestampMs: timestampMs ?? String(Date.now()),
2618
+ type: "ACTIVITY_TYPE_EXPORT_WALLET",
2619
+ };
2620
+ const stringifiedBody = JSON.stringify(bodyWithType);
2621
+ const stamp = await this.stamper.stamp(stringifiedBody);
1880
2622
  return {
1881
- body: body,
2623
+ body: stringifiedBody,
1882
2624
  stamp: stamp,
1883
2625
  url: fullUrl,
1884
2626
  };
1885
2627
  };
1886
2628
  this.exportWalletAccount = async (input) => {
2629
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2630
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1887
2631
  const { organizationId, timestampMs, ...rest } = input;
1888
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1889
- session = utils.parseSession(session);
1890
2632
  return this.command("/public/v1/submit/export_wallet_account", {
1891
2633
  parameters: rest,
1892
2634
  organizationId: organizationId ??
@@ -1900,19 +2642,28 @@ class TurnkeySDKClientBase {
1900
2642
  if (!this.stamper) {
1901
2643
  return undefined;
1902
2644
  }
2645
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2646
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2647
+ const { organizationId, timestampMs, ...parameters } = input;
1903
2648
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/export_wallet_account";
1904
- const body = JSON.stringify(input);
1905
- const stamp = await this.stamper.stamp(body);
2649
+ const bodyWithType = {
2650
+ parameters,
2651
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2652
+ timestampMs: timestampMs ?? String(Date.now()),
2653
+ type: "ACTIVITY_TYPE_EXPORT_WALLET_ACCOUNT",
2654
+ };
2655
+ const stringifiedBody = JSON.stringify(bodyWithType);
2656
+ const stamp = await this.stamper.stamp(stringifiedBody);
1906
2657
  return {
1907
- body: body,
2658
+ body: stringifiedBody,
1908
2659
  stamp: stamp,
1909
2660
  url: fullUrl,
1910
2661
  };
1911
2662
  };
1912
2663
  this.importPrivateKey = async (input) => {
2664
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2665
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1913
2666
  const { organizationId, timestampMs, ...rest } = input;
1914
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1915
- session = utils.parseSession(session);
1916
2667
  return this.command("/public/v1/submit/import_private_key", {
1917
2668
  parameters: rest,
1918
2669
  organizationId: organizationId ??
@@ -1926,19 +2677,28 @@ class TurnkeySDKClientBase {
1926
2677
  if (!this.stamper) {
1927
2678
  return undefined;
1928
2679
  }
2680
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2681
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2682
+ const { organizationId, timestampMs, ...parameters } = input;
1929
2683
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/import_private_key";
1930
- const body = JSON.stringify(input);
1931
- const stamp = await this.stamper.stamp(body);
2684
+ const bodyWithType = {
2685
+ parameters,
2686
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2687
+ timestampMs: timestampMs ?? String(Date.now()),
2688
+ type: "ACTIVITY_TYPE_IMPORT_PRIVATE_KEY",
2689
+ };
2690
+ const stringifiedBody = JSON.stringify(bodyWithType);
2691
+ const stamp = await this.stamper.stamp(stringifiedBody);
1932
2692
  return {
1933
- body: body,
2693
+ body: stringifiedBody,
1934
2694
  stamp: stamp,
1935
2695
  url: fullUrl,
1936
2696
  };
1937
2697
  };
1938
2698
  this.importWallet = async (input) => {
2699
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2700
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1939
2701
  const { organizationId, timestampMs, ...rest } = input;
1940
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1941
- session = utils.parseSession(session);
1942
2702
  return this.command("/public/v1/submit/import_wallet", {
1943
2703
  parameters: rest,
1944
2704
  organizationId: organizationId ??
@@ -1952,19 +2712,28 @@ class TurnkeySDKClientBase {
1952
2712
  if (!this.stamper) {
1953
2713
  return undefined;
1954
2714
  }
2715
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2716
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2717
+ const { organizationId, timestampMs, ...parameters } = input;
1955
2718
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/import_wallet";
1956
- const body = JSON.stringify(input);
1957
- const stamp = await this.stamper.stamp(body);
2719
+ const bodyWithType = {
2720
+ parameters,
2721
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2722
+ timestampMs: timestampMs ?? String(Date.now()),
2723
+ type: "ACTIVITY_TYPE_IMPORT_WALLET",
2724
+ };
2725
+ const stringifiedBody = JSON.stringify(bodyWithType);
2726
+ const stamp = await this.stamper.stamp(stringifiedBody);
1958
2727
  return {
1959
- body: body,
2728
+ body: stringifiedBody,
1960
2729
  stamp: stamp,
1961
2730
  url: fullUrl,
1962
2731
  };
1963
2732
  };
1964
2733
  this.initFiatOnRamp = async (input) => {
2734
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2735
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1965
2736
  const { organizationId, timestampMs, ...rest } = input;
1966
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1967
- session = utils.parseSession(session);
1968
2737
  return this.command("/public/v1/submit/init_fiat_on_ramp", {
1969
2738
  parameters: rest,
1970
2739
  organizationId: organizationId ??
@@ -1978,19 +2747,28 @@ class TurnkeySDKClientBase {
1978
2747
  if (!this.stamper) {
1979
2748
  return undefined;
1980
2749
  }
2750
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2751
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2752
+ const { organizationId, timestampMs, ...parameters } = input;
1981
2753
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_fiat_on_ramp";
1982
- const body = JSON.stringify(input);
1983
- const stamp = await this.stamper.stamp(body);
2754
+ const bodyWithType = {
2755
+ parameters,
2756
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2757
+ timestampMs: timestampMs ?? String(Date.now()),
2758
+ type: "ACTIVITY_TYPE_INIT_FIAT_ON_RAMP",
2759
+ };
2760
+ const stringifiedBody = JSON.stringify(bodyWithType);
2761
+ const stamp = await this.stamper.stamp(stringifiedBody);
1984
2762
  return {
1985
- body: body,
2763
+ body: stringifiedBody,
1986
2764
  stamp: stamp,
1987
2765
  url: fullUrl,
1988
2766
  };
1989
2767
  };
1990
2768
  this.initImportPrivateKey = async (input) => {
2769
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2770
+ const session = sessionData ? utils.parseSession(sessionData) : null;
1991
2771
  const { organizationId, timestampMs, ...rest } = input;
1992
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
1993
- session = utils.parseSession(session);
1994
2772
  return this.command("/public/v1/submit/init_import_private_key", {
1995
2773
  parameters: rest,
1996
2774
  organizationId: organizationId ??
@@ -2004,19 +2782,28 @@ class TurnkeySDKClientBase {
2004
2782
  if (!this.stamper) {
2005
2783
  return undefined;
2006
2784
  }
2785
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2786
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2787
+ const { organizationId, timestampMs, ...parameters } = input;
2007
2788
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_import_private_key";
2008
- const body = JSON.stringify(input);
2009
- const stamp = await this.stamper.stamp(body);
2789
+ const bodyWithType = {
2790
+ parameters,
2791
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2792
+ timestampMs: timestampMs ?? String(Date.now()),
2793
+ type: "ACTIVITY_TYPE_INIT_IMPORT_PRIVATE_KEY",
2794
+ };
2795
+ const stringifiedBody = JSON.stringify(bodyWithType);
2796
+ const stamp = await this.stamper.stamp(stringifiedBody);
2010
2797
  return {
2011
- body: body,
2798
+ body: stringifiedBody,
2012
2799
  stamp: stamp,
2013
2800
  url: fullUrl,
2014
2801
  };
2015
2802
  };
2016
2803
  this.initImportWallet = async (input) => {
2804
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2805
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2017
2806
  const { organizationId, timestampMs, ...rest } = input;
2018
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2019
- session = utils.parseSession(session);
2020
2807
  return this.command("/public/v1/submit/init_import_wallet", {
2021
2808
  parameters: rest,
2022
2809
  organizationId: organizationId ??
@@ -2030,97 +2817,133 @@ class TurnkeySDKClientBase {
2030
2817
  if (!this.stamper) {
2031
2818
  return undefined;
2032
2819
  }
2820
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2821
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2822
+ const { organizationId, timestampMs, ...parameters } = input;
2033
2823
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_import_wallet";
2034
- const body = JSON.stringify(input);
2035
- const stamp = await this.stamper.stamp(body);
2824
+ const bodyWithType = {
2825
+ parameters,
2826
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2827
+ timestampMs: timestampMs ?? String(Date.now()),
2828
+ type: "ACTIVITY_TYPE_INIT_IMPORT_WALLET",
2829
+ };
2830
+ const stringifiedBody = JSON.stringify(bodyWithType);
2831
+ const stamp = await this.stamper.stamp(stringifiedBody);
2036
2832
  return {
2037
- body: body,
2833
+ body: stringifiedBody,
2038
2834
  stamp: stamp,
2039
2835
  url: fullUrl,
2040
2836
  };
2041
2837
  };
2042
2838
  this.initOtp = async (input) => {
2839
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2840
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2043
2841
  const { organizationId, timestampMs, ...rest } = input;
2044
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2045
- session = utils.parseSession(session);
2046
2842
  return this.command("/public/v1/submit/init_otp", {
2047
2843
  parameters: rest,
2048
2844
  organizationId: organizationId ??
2049
2845
  session?.organizationId ??
2050
2846
  this.config.organizationId,
2051
2847
  timestampMs: timestampMs ?? String(Date.now()),
2052
- type: "ACTIVITY_TYPE_INIT_OTP",
2848
+ type: "ACTIVITY_TYPE_INIT_OTP_V2",
2053
2849
  }, "initOtpResult");
2054
2850
  };
2055
2851
  this.stampInitOtp = async (input) => {
2056
2852
  if (!this.stamper) {
2057
2853
  return undefined;
2058
2854
  }
2855
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2856
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2857
+ const { organizationId, timestampMs, ...parameters } = input;
2059
2858
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_otp";
2060
- const body = JSON.stringify(input);
2061
- const stamp = await this.stamper.stamp(body);
2859
+ const bodyWithType = {
2860
+ parameters,
2861
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2862
+ timestampMs: timestampMs ?? String(Date.now()),
2863
+ type: "ACTIVITY_TYPE_INIT_OTP_V2",
2864
+ };
2865
+ const stringifiedBody = JSON.stringify(bodyWithType);
2866
+ const stamp = await this.stamper.stamp(stringifiedBody);
2062
2867
  return {
2063
- body: body,
2868
+ body: stringifiedBody,
2064
2869
  stamp: stamp,
2065
2870
  url: fullUrl,
2066
2871
  };
2067
2872
  };
2068
2873
  this.initOtpAuth = async (input) => {
2874
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2875
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2069
2876
  const { organizationId, timestampMs, ...rest } = input;
2070
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2071
- session = utils.parseSession(session);
2072
2877
  return this.command("/public/v1/submit/init_otp_auth", {
2073
2878
  parameters: rest,
2074
2879
  organizationId: organizationId ??
2075
2880
  session?.organizationId ??
2076
2881
  this.config.organizationId,
2077
2882
  timestampMs: timestampMs ?? String(Date.now()),
2078
- type: "ACTIVITY_TYPE_INIT_OTP_AUTH_V2",
2883
+ type: "ACTIVITY_TYPE_INIT_OTP_AUTH_V3",
2079
2884
  }, "initOtpAuthResultV2");
2080
2885
  };
2081
2886
  this.stampInitOtpAuth = async (input) => {
2082
2887
  if (!this.stamper) {
2083
2888
  return undefined;
2084
2889
  }
2890
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2891
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2892
+ const { organizationId, timestampMs, ...parameters } = input;
2085
2893
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_otp_auth";
2086
- const body = JSON.stringify(input);
2087
- const stamp = await this.stamper.stamp(body);
2894
+ const bodyWithType = {
2895
+ parameters,
2896
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2897
+ timestampMs: timestampMs ?? String(Date.now()),
2898
+ type: "ACTIVITY_TYPE_INIT_OTP_AUTH_V3",
2899
+ };
2900
+ const stringifiedBody = JSON.stringify(bodyWithType);
2901
+ const stamp = await this.stamper.stamp(stringifiedBody);
2088
2902
  return {
2089
- body: body,
2903
+ body: stringifiedBody,
2090
2904
  stamp: stamp,
2091
2905
  url: fullUrl,
2092
2906
  };
2093
2907
  };
2094
2908
  this.initUserEmailRecovery = async (input) => {
2909
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2910
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2095
2911
  const { organizationId, timestampMs, ...rest } = input;
2096
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2097
- session = utils.parseSession(session);
2098
2912
  return this.command("/public/v1/submit/init_user_email_recovery", {
2099
2913
  parameters: rest,
2100
2914
  organizationId: organizationId ??
2101
2915
  session?.organizationId ??
2102
2916
  this.config.organizationId,
2103
2917
  timestampMs: timestampMs ?? String(Date.now()),
2104
- type: "ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY",
2918
+ type: "ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY_V2",
2105
2919
  }, "initUserEmailRecoveryResult");
2106
2920
  };
2107
2921
  this.stampInitUserEmailRecovery = async (input) => {
2108
2922
  if (!this.stamper) {
2109
2923
  return undefined;
2110
2924
  }
2925
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2926
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2927
+ const { organizationId, timestampMs, ...parameters } = input;
2111
2928
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/init_user_email_recovery";
2112
- const body = JSON.stringify(input);
2113
- const stamp = await this.stamper.stamp(body);
2929
+ const bodyWithType = {
2930
+ parameters,
2931
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2932
+ timestampMs: timestampMs ?? String(Date.now()),
2933
+ type: "ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY_V2",
2934
+ };
2935
+ const stringifiedBody = JSON.stringify(bodyWithType);
2936
+ const stamp = await this.stamper.stamp(stringifiedBody);
2114
2937
  return {
2115
- body: body,
2938
+ body: stringifiedBody,
2116
2939
  stamp: stamp,
2117
2940
  url: fullUrl,
2118
2941
  };
2119
2942
  };
2120
2943
  this.oauth = async (input) => {
2944
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2945
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2121
2946
  const { organizationId, timestampMs, ...rest } = input;
2122
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2123
- session = utils.parseSession(session);
2124
2947
  return this.command("/public/v1/submit/oauth", {
2125
2948
  parameters: rest,
2126
2949
  organizationId: organizationId ??
@@ -2134,19 +2957,28 @@ class TurnkeySDKClientBase {
2134
2957
  if (!this.stamper) {
2135
2958
  return undefined;
2136
2959
  }
2960
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2961
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2962
+ const { organizationId, timestampMs, ...parameters } = input;
2137
2963
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/oauth";
2138
- const body = JSON.stringify(input);
2139
- const stamp = await this.stamper.stamp(body);
2964
+ const bodyWithType = {
2965
+ parameters,
2966
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2967
+ timestampMs: timestampMs ?? String(Date.now()),
2968
+ type: "ACTIVITY_TYPE_OAUTH",
2969
+ };
2970
+ const stringifiedBody = JSON.stringify(bodyWithType);
2971
+ const stamp = await this.stamper.stamp(stringifiedBody);
2140
2972
  return {
2141
- body: body,
2973
+ body: stringifiedBody,
2142
2974
  stamp: stamp,
2143
2975
  url: fullUrl,
2144
2976
  };
2145
2977
  };
2146
2978
  this.oauth2Authenticate = async (input) => {
2979
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2980
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2147
2981
  const { organizationId, timestampMs, ...rest } = input;
2148
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2149
- session = utils.parseSession(session);
2150
2982
  return this.command("/public/v1/submit/oauth2_authenticate", {
2151
2983
  parameters: rest,
2152
2984
  organizationId: organizationId ??
@@ -2160,19 +2992,28 @@ class TurnkeySDKClientBase {
2160
2992
  if (!this.stamper) {
2161
2993
  return undefined;
2162
2994
  }
2995
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
2996
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2997
+ const { organizationId, timestampMs, ...parameters } = input;
2163
2998
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/oauth2_authenticate";
2164
- const body = JSON.stringify(input);
2165
- const stamp = await this.stamper.stamp(body);
2999
+ const bodyWithType = {
3000
+ parameters,
3001
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3002
+ timestampMs: timestampMs ?? String(Date.now()),
3003
+ type: "ACTIVITY_TYPE_OAUTH2_AUTHENTICATE",
3004
+ };
3005
+ const stringifiedBody = JSON.stringify(bodyWithType);
3006
+ const stamp = await this.stamper.stamp(stringifiedBody);
2166
3007
  return {
2167
- body: body,
3008
+ body: stringifiedBody,
2168
3009
  stamp: stamp,
2169
3010
  url: fullUrl,
2170
3011
  };
2171
3012
  };
2172
3013
  this.oauthLogin = async (input) => {
3014
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3015
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2173
3016
  const { organizationId, timestampMs, ...rest } = input;
2174
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2175
- session = utils.parseSession(session);
2176
3017
  return this.command("/public/v1/submit/oauth_login", {
2177
3018
  parameters: rest,
2178
3019
  organizationId: organizationId ??
@@ -2186,19 +3027,28 @@ class TurnkeySDKClientBase {
2186
3027
  if (!this.stamper) {
2187
3028
  return undefined;
2188
3029
  }
3030
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3031
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3032
+ const { organizationId, timestampMs, ...parameters } = input;
2189
3033
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/oauth_login";
2190
- const body = JSON.stringify(input);
2191
- const stamp = await this.stamper.stamp(body);
3034
+ const bodyWithType = {
3035
+ parameters,
3036
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3037
+ timestampMs: timestampMs ?? String(Date.now()),
3038
+ type: "ACTIVITY_TYPE_OAUTH_LOGIN",
3039
+ };
3040
+ const stringifiedBody = JSON.stringify(bodyWithType);
3041
+ const stamp = await this.stamper.stamp(stringifiedBody);
2192
3042
  return {
2193
- body: body,
3043
+ body: stringifiedBody,
2194
3044
  stamp: stamp,
2195
3045
  url: fullUrl,
2196
3046
  };
2197
3047
  };
2198
3048
  this.otpAuth = async (input) => {
3049
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3050
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2199
3051
  const { organizationId, timestampMs, ...rest } = input;
2200
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2201
- session = utils.parseSession(session);
2202
3052
  return this.command("/public/v1/submit/otp_auth", {
2203
3053
  parameters: rest,
2204
3054
  organizationId: organizationId ??
@@ -2212,19 +3062,28 @@ class TurnkeySDKClientBase {
2212
3062
  if (!this.stamper) {
2213
3063
  return undefined;
2214
3064
  }
3065
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3066
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3067
+ const { organizationId, timestampMs, ...parameters } = input;
2215
3068
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/otp_auth";
2216
- const body = JSON.stringify(input);
2217
- const stamp = await this.stamper.stamp(body);
3069
+ const bodyWithType = {
3070
+ parameters,
3071
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3072
+ timestampMs: timestampMs ?? String(Date.now()),
3073
+ type: "ACTIVITY_TYPE_OTP_AUTH",
3074
+ };
3075
+ const stringifiedBody = JSON.stringify(bodyWithType);
3076
+ const stamp = await this.stamper.stamp(stringifiedBody);
2218
3077
  return {
2219
- body: body,
3078
+ body: stringifiedBody,
2220
3079
  stamp: stamp,
2221
3080
  url: fullUrl,
2222
3081
  };
2223
3082
  };
2224
3083
  this.otpLogin = async (input) => {
3084
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3085
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2225
3086
  const { organizationId, timestampMs, ...rest } = input;
2226
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2227
- session = utils.parseSession(session);
2228
3087
  return this.command("/public/v1/submit/otp_login", {
2229
3088
  parameters: rest,
2230
3089
  organizationId: organizationId ??
@@ -2238,19 +3097,28 @@ class TurnkeySDKClientBase {
2238
3097
  if (!this.stamper) {
2239
3098
  return undefined;
2240
3099
  }
3100
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3101
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3102
+ const { organizationId, timestampMs, ...parameters } = input;
2241
3103
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/otp_login";
2242
- const body = JSON.stringify(input);
2243
- const stamp = await this.stamper.stamp(body);
3104
+ const bodyWithType = {
3105
+ parameters,
3106
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3107
+ timestampMs: timestampMs ?? String(Date.now()),
3108
+ type: "ACTIVITY_TYPE_OTP_LOGIN",
3109
+ };
3110
+ const stringifiedBody = JSON.stringify(bodyWithType);
3111
+ const stamp = await this.stamper.stamp(stringifiedBody);
2244
3112
  return {
2245
- body: body,
3113
+ body: stringifiedBody,
2246
3114
  stamp: stamp,
2247
3115
  url: fullUrl,
2248
3116
  };
2249
3117
  };
2250
3118
  this.recoverUser = async (input) => {
3119
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3120
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2251
3121
  const { organizationId, timestampMs, ...rest } = input;
2252
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2253
- session = utils.parseSession(session);
2254
3122
  return this.command("/public/v1/submit/recover_user", {
2255
3123
  parameters: rest,
2256
3124
  organizationId: organizationId ??
@@ -2264,19 +3132,28 @@ class TurnkeySDKClientBase {
2264
3132
  if (!this.stamper) {
2265
3133
  return undefined;
2266
3134
  }
3135
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3136
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3137
+ const { organizationId, timestampMs, ...parameters } = input;
2267
3138
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/recover_user";
2268
- const body = JSON.stringify(input);
2269
- const stamp = await this.stamper.stamp(body);
3139
+ const bodyWithType = {
3140
+ parameters,
3141
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3142
+ timestampMs: timestampMs ?? String(Date.now()),
3143
+ type: "ACTIVITY_TYPE_RECOVER_USER",
3144
+ };
3145
+ const stringifiedBody = JSON.stringify(bodyWithType);
3146
+ const stamp = await this.stamper.stamp(stringifiedBody);
2270
3147
  return {
2271
- body: body,
3148
+ body: stringifiedBody,
2272
3149
  stamp: stamp,
2273
3150
  url: fullUrl,
2274
3151
  };
2275
3152
  };
2276
3153
  this.rejectActivity = async (input) => {
3154
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3155
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2277
3156
  const { organizationId, timestampMs, ...rest } = input;
2278
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2279
- session = utils.parseSession(session);
2280
3157
  return this.activityDecision("/public/v1/submit/reject_activity", {
2281
3158
  parameters: rest,
2282
3159
  organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
@@ -2288,19 +3165,28 @@ class TurnkeySDKClientBase {
2288
3165
  if (!this.stamper) {
2289
3166
  return undefined;
2290
3167
  }
3168
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3169
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3170
+ const { organizationId, timestampMs, ...parameters } = input;
2291
3171
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/reject_activity";
2292
- const body = JSON.stringify(input);
2293
- const stamp = await this.stamper.stamp(body);
3172
+ const bodyWithType = {
3173
+ parameters,
3174
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3175
+ timestampMs: timestampMs ?? String(Date.now()),
3176
+ type: "ACTIVITY_TYPE_REJECT_ACTIVITY",
3177
+ };
3178
+ const stringifiedBody = JSON.stringify(bodyWithType);
3179
+ const stamp = await this.stamper.stamp(stringifiedBody);
2294
3180
  return {
2295
- body: body,
3181
+ body: stringifiedBody,
2296
3182
  stamp: stamp,
2297
3183
  url: fullUrl,
2298
3184
  };
2299
3185
  };
2300
3186
  this.removeOrganizationFeature = async (input) => {
3187
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3188
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2301
3189
  const { organizationId, timestampMs, ...rest } = input;
2302
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2303
- session = utils.parseSession(session);
2304
3190
  return this.command("/public/v1/submit/remove_organization_feature", {
2305
3191
  parameters: rest,
2306
3192
  organizationId: organizationId ??
@@ -2314,19 +3200,28 @@ class TurnkeySDKClientBase {
2314
3200
  if (!this.stamper) {
2315
3201
  return undefined;
2316
3202
  }
3203
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3204
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3205
+ const { organizationId, timestampMs, ...parameters } = input;
2317
3206
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/remove_organization_feature";
2318
- const body = JSON.stringify(input);
2319
- const stamp = await this.stamper.stamp(body);
3207
+ const bodyWithType = {
3208
+ parameters,
3209
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3210
+ timestampMs: timestampMs ?? String(Date.now()),
3211
+ type: "ACTIVITY_TYPE_REMOVE_ORGANIZATION_FEATURE",
3212
+ };
3213
+ const stringifiedBody = JSON.stringify(bodyWithType);
3214
+ const stamp = await this.stamper.stamp(stringifiedBody);
2320
3215
  return {
2321
- body: body,
3216
+ body: stringifiedBody,
2322
3217
  stamp: stamp,
2323
3218
  url: fullUrl,
2324
3219
  };
2325
3220
  };
2326
3221
  this.setOrganizationFeature = async (input) => {
3222
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3223
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2327
3224
  const { organizationId, timestampMs, ...rest } = input;
2328
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2329
- session = utils.parseSession(session);
2330
3225
  return this.command("/public/v1/submit/set_organization_feature", {
2331
3226
  parameters: rest,
2332
3227
  organizationId: organizationId ??
@@ -2340,19 +3235,28 @@ class TurnkeySDKClientBase {
2340
3235
  if (!this.stamper) {
2341
3236
  return undefined;
2342
3237
  }
3238
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3239
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3240
+ const { organizationId, timestampMs, ...parameters } = input;
2343
3241
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/set_organization_feature";
2344
- const body = JSON.stringify(input);
2345
- const stamp = await this.stamper.stamp(body);
3242
+ const bodyWithType = {
3243
+ parameters,
3244
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3245
+ timestampMs: timestampMs ?? String(Date.now()),
3246
+ type: "ACTIVITY_TYPE_SET_ORGANIZATION_FEATURE",
3247
+ };
3248
+ const stringifiedBody = JSON.stringify(bodyWithType);
3249
+ const stamp = await this.stamper.stamp(stringifiedBody);
2346
3250
  return {
2347
- body: body,
3251
+ body: stringifiedBody,
2348
3252
  stamp: stamp,
2349
3253
  url: fullUrl,
2350
3254
  };
2351
3255
  };
2352
3256
  this.signRawPayload = async (input) => {
3257
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3258
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2353
3259
  const { organizationId, timestampMs, ...rest } = input;
2354
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2355
- session = utils.parseSession(session);
2356
3260
  return this.command("/public/v1/submit/sign_raw_payload", {
2357
3261
  parameters: rest,
2358
3262
  organizationId: organizationId ??
@@ -2366,19 +3270,28 @@ class TurnkeySDKClientBase {
2366
3270
  if (!this.stamper) {
2367
3271
  return undefined;
2368
3272
  }
3273
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3274
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3275
+ const { organizationId, timestampMs, ...parameters } = input;
2369
3276
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/sign_raw_payload";
2370
- const body = JSON.stringify(input);
2371
- const stamp = await this.stamper.stamp(body);
3277
+ const bodyWithType = {
3278
+ parameters,
3279
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3280
+ timestampMs: timestampMs ?? String(Date.now()),
3281
+ type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
3282
+ };
3283
+ const stringifiedBody = JSON.stringify(bodyWithType);
3284
+ const stamp = await this.stamper.stamp(stringifiedBody);
2372
3285
  return {
2373
- body: body,
3286
+ body: stringifiedBody,
2374
3287
  stamp: stamp,
2375
3288
  url: fullUrl,
2376
3289
  };
2377
3290
  };
2378
3291
  this.signRawPayloads = async (input) => {
3292
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3293
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2379
3294
  const { organizationId, timestampMs, ...rest } = input;
2380
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2381
- session = utils.parseSession(session);
2382
3295
  return this.command("/public/v1/submit/sign_raw_payloads", {
2383
3296
  parameters: rest,
2384
3297
  organizationId: organizationId ??
@@ -2392,19 +3305,28 @@ class TurnkeySDKClientBase {
2392
3305
  if (!this.stamper) {
2393
3306
  return undefined;
2394
3307
  }
3308
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3309
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3310
+ const { organizationId, timestampMs, ...parameters } = input;
2395
3311
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/sign_raw_payloads";
2396
- const body = JSON.stringify(input);
2397
- const stamp = await this.stamper.stamp(body);
3312
+ const bodyWithType = {
3313
+ parameters,
3314
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3315
+ timestampMs: timestampMs ?? String(Date.now()),
3316
+ type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOADS",
3317
+ };
3318
+ const stringifiedBody = JSON.stringify(bodyWithType);
3319
+ const stamp = await this.stamper.stamp(stringifiedBody);
2398
3320
  return {
2399
- body: body,
3321
+ body: stringifiedBody,
2400
3322
  stamp: stamp,
2401
3323
  url: fullUrl,
2402
3324
  };
2403
3325
  };
2404
3326
  this.signTransaction = async (input) => {
3327
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3328
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2405
3329
  const { organizationId, timestampMs, ...rest } = input;
2406
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2407
- session = utils.parseSession(session);
2408
3330
  return this.command("/public/v1/submit/sign_transaction", {
2409
3331
  parameters: rest,
2410
3332
  organizationId: organizationId ??
@@ -2418,19 +3340,28 @@ class TurnkeySDKClientBase {
2418
3340
  if (!this.stamper) {
2419
3341
  return undefined;
2420
3342
  }
3343
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3344
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3345
+ const { organizationId, timestampMs, ...parameters } = input;
2421
3346
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/sign_transaction";
2422
- const body = JSON.stringify(input);
2423
- const stamp = await this.stamper.stamp(body);
3347
+ const bodyWithType = {
3348
+ parameters,
3349
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3350
+ timestampMs: timestampMs ?? String(Date.now()),
3351
+ type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2",
3352
+ };
3353
+ const stringifiedBody = JSON.stringify(bodyWithType);
3354
+ const stamp = await this.stamper.stamp(stringifiedBody);
2424
3355
  return {
2425
- body: body,
3356
+ body: stringifiedBody,
2426
3357
  stamp: stamp,
2427
3358
  url: fullUrl,
2428
3359
  };
2429
3360
  };
2430
3361
  this.stampLogin = async (input) => {
3362
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3363
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2431
3364
  const { organizationId, timestampMs, ...rest } = input;
2432
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2433
- session = utils.parseSession(session);
2434
3365
  return this.command("/public/v1/submit/stamp_login", {
2435
3366
  parameters: rest,
2436
3367
  organizationId: organizationId ??
@@ -2444,19 +3375,28 @@ class TurnkeySDKClientBase {
2444
3375
  if (!this.stamper) {
2445
3376
  return undefined;
2446
3377
  }
3378
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3379
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3380
+ const { organizationId, timestampMs, ...parameters } = input;
2447
3381
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/stamp_login";
2448
- const body = JSON.stringify(input);
2449
- const stamp = await this.stamper.stamp(body);
3382
+ const bodyWithType = {
3383
+ parameters,
3384
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3385
+ timestampMs: timestampMs ?? String(Date.now()),
3386
+ type: "ACTIVITY_TYPE_STAMP_LOGIN",
3387
+ };
3388
+ const stringifiedBody = JSON.stringify(bodyWithType);
3389
+ const stamp = await this.stamper.stamp(stringifiedBody);
2450
3390
  return {
2451
- body: body,
3391
+ body: stringifiedBody,
2452
3392
  stamp: stamp,
2453
3393
  url: fullUrl,
2454
3394
  };
2455
3395
  };
2456
3396
  this.updateFiatOnRampCredential = async (input) => {
3397
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3398
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2457
3399
  const { organizationId, timestampMs, ...rest } = input;
2458
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2459
- session = utils.parseSession(session);
2460
3400
  return this.command("/public/v1/submit/update_fiat_on_ramp_credential", {
2461
3401
  parameters: rest,
2462
3402
  organizationId: organizationId ??
@@ -2470,20 +3410,29 @@ class TurnkeySDKClientBase {
2470
3410
  if (!this.stamper) {
2471
3411
  return undefined;
2472
3412
  }
3413
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3414
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3415
+ const { organizationId, timestampMs, ...parameters } = input;
2473
3416
  const fullUrl = this.config.apiBaseUrl +
2474
3417
  "/public/v1/submit/update_fiat_on_ramp_credential";
2475
- const body = JSON.stringify(input);
2476
- const stamp = await this.stamper.stamp(body);
3418
+ const bodyWithType = {
3419
+ parameters,
3420
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3421
+ timestampMs: timestampMs ?? String(Date.now()),
3422
+ type: "ACTIVITY_TYPE_UPDATE_FIAT_ON_RAMP_CREDENTIAL",
3423
+ };
3424
+ const stringifiedBody = JSON.stringify(bodyWithType);
3425
+ const stamp = await this.stamper.stamp(stringifiedBody);
2477
3426
  return {
2478
- body: body,
3427
+ body: stringifiedBody,
2479
3428
  stamp: stamp,
2480
3429
  url: fullUrl,
2481
3430
  };
2482
3431
  };
2483
3432
  this.updateOauth2Credential = async (input) => {
3433
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3434
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2484
3435
  const { organizationId, timestampMs, ...rest } = input;
2485
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2486
- session = utils.parseSession(session);
2487
3436
  return this.command("/public/v1/submit/update_oauth2_credential", {
2488
3437
  parameters: rest,
2489
3438
  organizationId: organizationId ??
@@ -2497,19 +3446,28 @@ class TurnkeySDKClientBase {
2497
3446
  if (!this.stamper) {
2498
3447
  return undefined;
2499
3448
  }
3449
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3450
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3451
+ const { organizationId, timestampMs, ...parameters } = input;
2500
3452
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_oauth2_credential";
2501
- const body = JSON.stringify(input);
2502
- const stamp = await this.stamper.stamp(body);
3453
+ const bodyWithType = {
3454
+ parameters,
3455
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3456
+ timestampMs: timestampMs ?? String(Date.now()),
3457
+ type: "ACTIVITY_TYPE_UPDATE_OAUTH2_CREDENTIAL",
3458
+ };
3459
+ const stringifiedBody = JSON.stringify(bodyWithType);
3460
+ const stamp = await this.stamper.stamp(stringifiedBody);
2503
3461
  return {
2504
- body: body,
3462
+ body: stringifiedBody,
2505
3463
  stamp: stamp,
2506
3464
  url: fullUrl,
2507
3465
  };
2508
3466
  };
2509
3467
  this.updatePolicy = async (input) => {
3468
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3469
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2510
3470
  const { organizationId, timestampMs, ...rest } = input;
2511
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2512
- session = utils.parseSession(session);
2513
3471
  return this.command("/public/v1/submit/update_policy", {
2514
3472
  parameters: rest,
2515
3473
  organizationId: organizationId ??
@@ -2523,19 +3481,28 @@ class TurnkeySDKClientBase {
2523
3481
  if (!this.stamper) {
2524
3482
  return undefined;
2525
3483
  }
3484
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3485
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3486
+ const { organizationId, timestampMs, ...parameters } = input;
2526
3487
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_policy";
2527
- const body = JSON.stringify(input);
2528
- const stamp = await this.stamper.stamp(body);
3488
+ const bodyWithType = {
3489
+ parameters,
3490
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3491
+ timestampMs: timestampMs ?? String(Date.now()),
3492
+ type: "ACTIVITY_TYPE_UPDATE_POLICY_V2",
3493
+ };
3494
+ const stringifiedBody = JSON.stringify(bodyWithType);
3495
+ const stamp = await this.stamper.stamp(stringifiedBody);
2529
3496
  return {
2530
- body: body,
3497
+ body: stringifiedBody,
2531
3498
  stamp: stamp,
2532
3499
  url: fullUrl,
2533
3500
  };
2534
3501
  };
2535
3502
  this.updatePrivateKeyTag = async (input) => {
3503
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3504
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2536
3505
  const { organizationId, timestampMs, ...rest } = input;
2537
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2538
- session = utils.parseSession(session);
2539
3506
  return this.command("/public/v1/submit/update_private_key_tag", {
2540
3507
  parameters: rest,
2541
3508
  organizationId: organizationId ??
@@ -2549,19 +3516,28 @@ class TurnkeySDKClientBase {
2549
3516
  if (!this.stamper) {
2550
3517
  return undefined;
2551
3518
  }
3519
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3520
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3521
+ const { organizationId, timestampMs, ...parameters } = input;
2552
3522
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_private_key_tag";
2553
- const body = JSON.stringify(input);
2554
- const stamp = await this.stamper.stamp(body);
3523
+ const bodyWithType = {
3524
+ parameters,
3525
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3526
+ timestampMs: timestampMs ?? String(Date.now()),
3527
+ type: "ACTIVITY_TYPE_UPDATE_PRIVATE_KEY_TAG",
3528
+ };
3529
+ const stringifiedBody = JSON.stringify(bodyWithType);
3530
+ const stamp = await this.stamper.stamp(stringifiedBody);
2555
3531
  return {
2556
- body: body,
3532
+ body: stringifiedBody,
2557
3533
  stamp: stamp,
2558
3534
  url: fullUrl,
2559
3535
  };
2560
3536
  };
2561
3537
  this.updateRootQuorum = async (input) => {
3538
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3539
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2562
3540
  const { organizationId, timestampMs, ...rest } = input;
2563
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2564
- session = utils.parseSession(session);
2565
3541
  return this.command("/public/v1/submit/update_root_quorum", {
2566
3542
  parameters: rest,
2567
3543
  organizationId: organizationId ??
@@ -2575,19 +3551,28 @@ class TurnkeySDKClientBase {
2575
3551
  if (!this.stamper) {
2576
3552
  return undefined;
2577
3553
  }
3554
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3555
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3556
+ const { organizationId, timestampMs, ...parameters } = input;
2578
3557
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_root_quorum";
2579
- const body = JSON.stringify(input);
2580
- const stamp = await this.stamper.stamp(body);
3558
+ const bodyWithType = {
3559
+ parameters,
3560
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3561
+ timestampMs: timestampMs ?? String(Date.now()),
3562
+ type: "ACTIVITY_TYPE_UPDATE_ROOT_QUORUM",
3563
+ };
3564
+ const stringifiedBody = JSON.stringify(bodyWithType);
3565
+ const stamp = await this.stamper.stamp(stringifiedBody);
2581
3566
  return {
2582
- body: body,
3567
+ body: stringifiedBody,
2583
3568
  stamp: stamp,
2584
3569
  url: fullUrl,
2585
3570
  };
2586
3571
  };
2587
3572
  this.updateUser = async (input) => {
3573
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3574
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2588
3575
  const { organizationId, timestampMs, ...rest } = input;
2589
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2590
- session = utils.parseSession(session);
2591
3576
  return this.command("/public/v1/submit/update_user", {
2592
3577
  parameters: rest,
2593
3578
  organizationId: organizationId ??
@@ -2601,19 +3586,28 @@ class TurnkeySDKClientBase {
2601
3586
  if (!this.stamper) {
2602
3587
  return undefined;
2603
3588
  }
3589
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3590
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3591
+ const { organizationId, timestampMs, ...parameters } = input;
2604
3592
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_user";
2605
- const body = JSON.stringify(input);
2606
- const stamp = await this.stamper.stamp(body);
3593
+ const bodyWithType = {
3594
+ parameters,
3595
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3596
+ timestampMs: timestampMs ?? String(Date.now()),
3597
+ type: "ACTIVITY_TYPE_UPDATE_USER",
3598
+ };
3599
+ const stringifiedBody = JSON.stringify(bodyWithType);
3600
+ const stamp = await this.stamper.stamp(stringifiedBody);
2607
3601
  return {
2608
- body: body,
3602
+ body: stringifiedBody,
2609
3603
  stamp: stamp,
2610
3604
  url: fullUrl,
2611
3605
  };
2612
3606
  };
2613
3607
  this.updateUserEmail = async (input) => {
3608
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3609
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2614
3610
  const { organizationId, timestampMs, ...rest } = input;
2615
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2616
- session = utils.parseSession(session);
2617
3611
  return this.command("/public/v1/submit/update_user_email", {
2618
3612
  parameters: rest,
2619
3613
  organizationId: organizationId ??
@@ -2627,19 +3621,28 @@ class TurnkeySDKClientBase {
2627
3621
  if (!this.stamper) {
2628
3622
  return undefined;
2629
3623
  }
3624
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3625
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3626
+ const { organizationId, timestampMs, ...parameters } = input;
2630
3627
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_user_email";
2631
- const body = JSON.stringify(input);
2632
- const stamp = await this.stamper.stamp(body);
3628
+ const bodyWithType = {
3629
+ parameters,
3630
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3631
+ timestampMs: timestampMs ?? String(Date.now()),
3632
+ type: "ACTIVITY_TYPE_UPDATE_USER_EMAIL",
3633
+ };
3634
+ const stringifiedBody = JSON.stringify(bodyWithType);
3635
+ const stamp = await this.stamper.stamp(stringifiedBody);
2633
3636
  return {
2634
- body: body,
3637
+ body: stringifiedBody,
2635
3638
  stamp: stamp,
2636
3639
  url: fullUrl,
2637
3640
  };
2638
3641
  };
2639
3642
  this.updateUserName = async (input) => {
3643
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3644
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2640
3645
  const { organizationId, timestampMs, ...rest } = input;
2641
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2642
- session = utils.parseSession(session);
2643
3646
  return this.command("/public/v1/submit/update_user_name", {
2644
3647
  parameters: rest,
2645
3648
  organizationId: organizationId ??
@@ -2653,19 +3656,28 @@ class TurnkeySDKClientBase {
2653
3656
  if (!this.stamper) {
2654
3657
  return undefined;
2655
3658
  }
3659
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3660
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3661
+ const { organizationId, timestampMs, ...parameters } = input;
2656
3662
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_user_name";
2657
- const body = JSON.stringify(input);
2658
- const stamp = await this.stamper.stamp(body);
3663
+ const bodyWithType = {
3664
+ parameters,
3665
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3666
+ timestampMs: timestampMs ?? String(Date.now()),
3667
+ type: "ACTIVITY_TYPE_UPDATE_USER_NAME",
3668
+ };
3669
+ const stringifiedBody = JSON.stringify(bodyWithType);
3670
+ const stamp = await this.stamper.stamp(stringifiedBody);
2659
3671
  return {
2660
- body: body,
3672
+ body: stringifiedBody,
2661
3673
  stamp: stamp,
2662
3674
  url: fullUrl,
2663
3675
  };
2664
3676
  };
2665
3677
  this.updateUserPhoneNumber = async (input) => {
3678
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3679
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2666
3680
  const { organizationId, timestampMs, ...rest } = input;
2667
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2668
- session = utils.parseSession(session);
2669
3681
  return this.command("/public/v1/submit/update_user_phone_number", {
2670
3682
  parameters: rest,
2671
3683
  organizationId: organizationId ??
@@ -2679,19 +3691,28 @@ class TurnkeySDKClientBase {
2679
3691
  if (!this.stamper) {
2680
3692
  return undefined;
2681
3693
  }
3694
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3695
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3696
+ const { organizationId, timestampMs, ...parameters } = input;
2682
3697
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_user_phone_number";
2683
- const body = JSON.stringify(input);
2684
- const stamp = await this.stamper.stamp(body);
3698
+ const bodyWithType = {
3699
+ parameters,
3700
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3701
+ timestampMs: timestampMs ?? String(Date.now()),
3702
+ type: "ACTIVITY_TYPE_UPDATE_USER_PHONE_NUMBER",
3703
+ };
3704
+ const stringifiedBody = JSON.stringify(bodyWithType);
3705
+ const stamp = await this.stamper.stamp(stringifiedBody);
2685
3706
  return {
2686
- body: body,
3707
+ body: stringifiedBody,
2687
3708
  stamp: stamp,
2688
3709
  url: fullUrl,
2689
3710
  };
2690
3711
  };
2691
3712
  this.updateUserTag = async (input) => {
3713
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3714
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2692
3715
  const { organizationId, timestampMs, ...rest } = input;
2693
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2694
- session = utils.parseSession(session);
2695
3716
  return this.command("/public/v1/submit/update_user_tag", {
2696
3717
  parameters: rest,
2697
3718
  organizationId: organizationId ??
@@ -2705,19 +3726,28 @@ class TurnkeySDKClientBase {
2705
3726
  if (!this.stamper) {
2706
3727
  return undefined;
2707
3728
  }
3729
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3730
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3731
+ const { organizationId, timestampMs, ...parameters } = input;
2708
3732
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_user_tag";
2709
- const body = JSON.stringify(input);
2710
- const stamp = await this.stamper.stamp(body);
3733
+ const bodyWithType = {
3734
+ parameters,
3735
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3736
+ timestampMs: timestampMs ?? String(Date.now()),
3737
+ type: "ACTIVITY_TYPE_UPDATE_USER_TAG",
3738
+ };
3739
+ const stringifiedBody = JSON.stringify(bodyWithType);
3740
+ const stamp = await this.stamper.stamp(stringifiedBody);
2711
3741
  return {
2712
- body: body,
3742
+ body: stringifiedBody,
2713
3743
  stamp: stamp,
2714
3744
  url: fullUrl,
2715
3745
  };
2716
3746
  };
2717
3747
  this.updateWallet = async (input) => {
3748
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3749
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2718
3750
  const { organizationId, timestampMs, ...rest } = input;
2719
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2720
- session = utils.parseSession(session);
2721
3751
  return this.command("/public/v1/submit/update_wallet", {
2722
3752
  parameters: rest,
2723
3753
  organizationId: organizationId ??
@@ -2731,19 +3761,28 @@ class TurnkeySDKClientBase {
2731
3761
  if (!this.stamper) {
2732
3762
  return undefined;
2733
3763
  }
3764
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3765
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3766
+ const { organizationId, timestampMs, ...parameters } = input;
2734
3767
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/update_wallet";
2735
- const body = JSON.stringify(input);
2736
- const stamp = await this.stamper.stamp(body);
3768
+ const bodyWithType = {
3769
+ parameters,
3770
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3771
+ timestampMs: timestampMs ?? String(Date.now()),
3772
+ type: "ACTIVITY_TYPE_UPDATE_WALLET",
3773
+ };
3774
+ const stringifiedBody = JSON.stringify(bodyWithType);
3775
+ const stamp = await this.stamper.stamp(stringifiedBody);
2737
3776
  return {
2738
- body: body,
3777
+ body: stringifiedBody,
2739
3778
  stamp: stamp,
2740
3779
  url: fullUrl,
2741
3780
  };
2742
3781
  };
2743
3782
  this.verifyOtp = async (input) => {
3783
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3784
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2744
3785
  const { organizationId, timestampMs, ...rest } = input;
2745
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2746
- session = utils.parseSession(session);
2747
3786
  return this.command("/public/v1/submit/verify_otp", {
2748
3787
  parameters: rest,
2749
3788
  organizationId: organizationId ??
@@ -2757,18 +3796,27 @@ class TurnkeySDKClientBase {
2757
3796
  if (!this.stamper) {
2758
3797
  return undefined;
2759
3798
  }
3799
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3800
+ const session = sessionData ? utils.parseSession(sessionData) : null;
3801
+ const { organizationId, timestampMs, ...parameters } = input;
2760
3802
  const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/verify_otp";
2761
- const body = JSON.stringify(input);
2762
- const stamp = await this.stamper.stamp(body);
3803
+ const bodyWithType = {
3804
+ parameters,
3805
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3806
+ timestampMs: timestampMs ?? String(Date.now()),
3807
+ type: "ACTIVITY_TYPE_VERIFY_OTP",
3808
+ };
3809
+ const stringifiedBody = JSON.stringify(bodyWithType);
3810
+ const stamp = await this.stamper.stamp(stringifiedBody);
2763
3811
  return {
2764
- body: body,
3812
+ body: stringifiedBody,
2765
3813
  stamp: stamp,
2766
3814
  url: fullUrl,
2767
3815
  };
2768
3816
  };
2769
3817
  this.testRateLimits = async (input) => {
2770
- let session = await storage.getStorageValue(storage.StorageKeys.Session);
2771
- session = utils.parseSession(session);
3818
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3819
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2772
3820
  return this.request("/tkhq/api/v1/test_rate_limits", {
2773
3821
  ...input,
2774
3822
  organizationId: input.organizationId ??
@@ -2780,11 +3828,19 @@ class TurnkeySDKClientBase {
2780
3828
  if (!this.stamper) {
2781
3829
  return undefined;
2782
3830
  }
3831
+ const sessionData = await storage.getStorageValue(storage.StorageKeys.Session);
3832
+ const session = sessionData ? utils.parseSession(sessionData) : null;
2783
3833
  const fullUrl = this.config.apiBaseUrl + "/tkhq/api/v1/test_rate_limits";
2784
- const body = JSON.stringify(input);
2785
- const stamp = await this.stamper.stamp(body);
3834
+ const body = {
3835
+ ...input,
3836
+ organizationId: input.organizationId ??
3837
+ session?.organizationId ??
3838
+ this.config.organizationId,
3839
+ };
3840
+ const stringifiedBody = JSON.stringify(body);
3841
+ const stamp = await this.stamper.stamp(stringifiedBody);
2786
3842
  return {
2787
- body: body,
3843
+ body: stringifiedBody,
2788
3844
  stamp: stamp,
2789
3845
  url: fullUrl,
2790
3846
  };