@turnkey/sdk-browser 5.13.5 → 5.14.0

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