@fogo/sessions-sdk 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.d.ts CHANGED
@@ -1,15 +1,16 @@
1
- import type { TransactionError, Connection } from "@solana/web3.js";
1
+ import type { Connection, TransactionError } from "@solana/web3.js";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import BN from "bn.js";
4
4
  import { z } from "zod";
5
5
  import type { SessionAdapter, TransactionResult } from "./adapter.js";
6
- export { type SessionAdapter, type TransactionResult, TransactionResultType, createSolanaWalletAdapter, } from "./adapter.js";
6
+ export { createSolanaWalletAdapter, TransactionResultType, type SessionAdapter, type TransactionResult, } from "./adapter.js";
7
7
  type EstablishSessionOptions = {
8
8
  adapter: SessionAdapter;
9
9
  walletPublicKey: PublicKey;
10
10
  signMessage: (message: Uint8Array) => Promise<Uint8Array>;
11
11
  expires: Date;
12
- extra?: string | undefined;
12
+ extra?: Record<string, string> | undefined;
13
+ createUnsafeExtractableSessionKey?: boolean | undefined;
13
14
  } & ({
14
15
  limits?: Map<PublicKey, bigint>;
15
16
  unlimited?: false;
@@ -22,13 +23,17 @@ export declare const replaceSession: (options: {
22
23
  session: Session;
23
24
  signMessage: (message: Uint8Array) => Promise<Uint8Array>;
24
25
  expires: Date;
25
- extra?: string | undefined;
26
+ extra?: Record<string, string> | undefined;
26
27
  } & ({
27
28
  limits?: Map<PublicKey, bigint>;
28
29
  unlimited?: false;
29
30
  } | {
30
31
  unlimited: true;
31
32
  })) => Promise<EstablishSessionResult>;
33
+ export declare const revokeSession: (options: {
34
+ adapter: SessionAdapter;
35
+ session: Session;
36
+ }) => Promise<TransactionResult | undefined>;
32
37
  export declare const reestablishSession: (adapter: SessionAdapter, walletPublicKey: PublicKey, sessionKey: CryptoKeyPair) => Promise<Session | undefined>;
33
38
  export declare const getSessionAccount: (connection: Connection, sessionPublicKey: PublicKey) => Promise<{
34
39
  authorizedPrograms: {
@@ -44,176 +49,1117 @@ export declare const getSessionAccount: (connection: Connection, sessionPublicKe
44
49
  expiration: Date;
45
50
  extra: unknown;
46
51
  major: number;
47
- minor: number;
52
+ minor: 1 | 2 | 3;
48
53
  user: PublicKey;
54
+ sponsor: PublicKey;
49
55
  } | undefined>;
50
56
  declare const sessionInfoSchema: z.ZodEffects<z.ZodObject<{
51
- session_info: z.ZodObject<{
52
- authorized_programs: z.ZodUnion<[z.ZodObject<{
53
- Specific: z.ZodObject<{
54
- 0: z.ZodArray<z.ZodObject<{
55
- program_id: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
56
- signer_pda: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
57
+ session_info: z.ZodUnion<[z.ZodObject<{
58
+ V1: z.ZodObject<{
59
+ "0": z.ZodObject<{
60
+ authorized_programs: z.ZodUnion<[z.ZodObject<{
61
+ Specific: z.ZodObject<{
62
+ 0: z.ZodArray<z.ZodObject<{
63
+ program_id: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
64
+ signer_pda: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ program_id: PublicKey;
67
+ signer_pda: PublicKey;
68
+ }, {
69
+ program_id: PublicKey;
70
+ signer_pda: PublicKey;
71
+ }>, "many">;
72
+ }, "strip", z.ZodTypeAny, {
73
+ 0: {
74
+ program_id: PublicKey;
75
+ signer_pda: PublicKey;
76
+ }[];
77
+ }, {
78
+ 0: {
79
+ program_id: PublicKey;
80
+ signer_pda: PublicKey;
81
+ }[];
82
+ }>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ Specific: {
85
+ 0: {
86
+ program_id: PublicKey;
87
+ signer_pda: PublicKey;
88
+ }[];
89
+ };
90
+ }, {
91
+ Specific: {
92
+ 0: {
93
+ program_id: PublicKey;
94
+ signer_pda: PublicKey;
95
+ }[];
96
+ };
97
+ }>, z.ZodObject<{
98
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
99
+ }, "strip", z.ZodTypeAny, {
100
+ All: {};
101
+ }, {
102
+ All: {};
103
+ }>]>;
104
+ authorized_tokens: z.ZodUnion<[z.ZodObject<{
105
+ Specific: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ Specific: {};
108
+ }, {
109
+ Specific: {};
110
+ }>, z.ZodObject<{
111
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ All: {};
114
+ }, {
115
+ All: {};
116
+ }>]>;
117
+ expiration: z.ZodType<BN, z.ZodTypeDef, BN>;
118
+ extra: z.ZodObject<{
119
+ 0: z.ZodUnknown;
57
120
  }, "strip", z.ZodTypeAny, {
58
- program_id: PublicKey;
59
- signer_pda: PublicKey;
121
+ 0?: unknown;
60
122
  }, {
61
- program_id: PublicKey;
62
- signer_pda: PublicKey;
63
- }>, "many">;
123
+ 0?: unknown;
124
+ }>;
125
+ user: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
64
126
  }, "strip", z.ZodTypeAny, {
65
- 0: {
66
- program_id: PublicKey;
67
- signer_pda: PublicKey;
68
- }[];
127
+ authorized_programs: {
128
+ Specific: {
129
+ 0: {
130
+ program_id: PublicKey;
131
+ signer_pda: PublicKey;
132
+ }[];
133
+ };
134
+ } | {
135
+ All: {};
136
+ };
137
+ authorized_tokens: {
138
+ Specific: {};
139
+ } | {
140
+ All: {};
141
+ };
142
+ expiration: BN;
143
+ extra: {
144
+ 0?: unknown;
145
+ };
146
+ user: PublicKey;
69
147
  }, {
70
- 0: {
71
- program_id: PublicKey;
72
- signer_pda: PublicKey;
73
- }[];
148
+ authorized_programs: {
149
+ Specific: {
150
+ 0: {
151
+ program_id: PublicKey;
152
+ signer_pda: PublicKey;
153
+ }[];
154
+ };
155
+ } | {
156
+ All: {};
157
+ };
158
+ authorized_tokens: {
159
+ Specific: {};
160
+ } | {
161
+ All: {};
162
+ };
163
+ expiration: BN;
164
+ extra: {
165
+ 0?: unknown;
166
+ };
167
+ user: PublicKey;
74
168
  }>;
75
169
  }, "strip", z.ZodTypeAny, {
76
- Specific: {
77
- 0: {
78
- program_id: PublicKey;
79
- signer_pda: PublicKey;
80
- }[];
170
+ "0": {
171
+ authorized_programs: {
172
+ Specific: {
173
+ 0: {
174
+ program_id: PublicKey;
175
+ signer_pda: PublicKey;
176
+ }[];
177
+ };
178
+ } | {
179
+ All: {};
180
+ };
181
+ authorized_tokens: {
182
+ Specific: {};
183
+ } | {
184
+ All: {};
185
+ };
186
+ expiration: BN;
187
+ extra: {
188
+ 0?: unknown;
189
+ };
190
+ user: PublicKey;
81
191
  };
82
192
  }, {
83
- Specific: {
84
- 0: {
85
- program_id: PublicKey;
86
- signer_pda: PublicKey;
87
- }[];
193
+ "0": {
194
+ authorized_programs: {
195
+ Specific: {
196
+ 0: {
197
+ program_id: PublicKey;
198
+ signer_pda: PublicKey;
199
+ }[];
200
+ };
201
+ } | {
202
+ All: {};
203
+ };
204
+ authorized_tokens: {
205
+ Specific: {};
206
+ } | {
207
+ All: {};
208
+ };
209
+ expiration: BN;
210
+ extra: {
211
+ 0?: unknown;
212
+ };
213
+ user: PublicKey;
88
214
  };
89
- }>, z.ZodObject<{
90
- All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
91
- }, "strip", z.ZodTypeAny, {
92
- All: {};
93
- }, {
94
- All: {};
95
- }>]>;
96
- authorized_tokens: z.ZodUnion<[z.ZodObject<{
97
- Specific: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
98
- }, "strip", z.ZodTypeAny, {
99
- Specific: {};
100
- }, {
101
- Specific: {};
102
- }>, z.ZodObject<{
103
- All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
104
- }, "strip", z.ZodTypeAny, {
105
- All: {};
106
- }, {
107
- All: {};
108
- }>]>;
109
- expiration: z.ZodType<BN, z.ZodTypeDef, BN>;
110
- extra: z.ZodObject<{
111
- 0: z.ZodUnknown;
112
- }, "strip", z.ZodTypeAny, {
113
- 0?: unknown;
114
- }, {
115
- 0?: unknown;
116
215
  }>;
117
- major: z.ZodNumber;
118
- minor: z.ZodNumber;
119
- user: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
120
216
  }, "strip", z.ZodTypeAny, {
121
- authorized_programs: {
122
- Specific: {
123
- 0: {
124
- program_id: PublicKey;
125
- signer_pda: PublicKey;
126
- }[];
217
+ V1: {
218
+ "0": {
219
+ authorized_programs: {
220
+ Specific: {
221
+ 0: {
222
+ program_id: PublicKey;
223
+ signer_pda: PublicKey;
224
+ }[];
225
+ };
226
+ } | {
227
+ All: {};
228
+ };
229
+ authorized_tokens: {
230
+ Specific: {};
231
+ } | {
232
+ All: {};
233
+ };
234
+ expiration: BN;
235
+ extra: {
236
+ 0?: unknown;
237
+ };
238
+ user: PublicKey;
127
239
  };
128
- } | {
129
- All: {};
130
240
  };
131
- authorized_tokens: {
132
- Specific: {};
133
- } | {
134
- All: {};
241
+ }, {
242
+ V1: {
243
+ "0": {
244
+ authorized_programs: {
245
+ Specific: {
246
+ 0: {
247
+ program_id: PublicKey;
248
+ signer_pda: PublicKey;
249
+ }[];
250
+ };
251
+ } | {
252
+ All: {};
253
+ };
254
+ authorized_tokens: {
255
+ Specific: {};
256
+ } | {
257
+ All: {};
258
+ };
259
+ expiration: BN;
260
+ extra: {
261
+ 0?: unknown;
262
+ };
263
+ user: PublicKey;
264
+ };
135
265
  };
136
- expiration: BN;
137
- extra: {
138
- 0?: unknown;
266
+ }>, z.ZodObject<{
267
+ V2: z.ZodObject<{
268
+ "0": z.ZodUnion<[z.ZodObject<{
269
+ Revoked: z.ZodType<BN, z.ZodTypeDef, BN>;
270
+ }, "strip", z.ZodTypeAny, {
271
+ Revoked: BN;
272
+ }, {
273
+ Revoked: BN;
274
+ }>, z.ZodObject<{
275
+ Active: z.ZodObject<{
276
+ "0": z.ZodObject<{
277
+ authorized_programs: z.ZodUnion<[z.ZodObject<{
278
+ Specific: z.ZodObject<{
279
+ 0: z.ZodArray<z.ZodObject<{
280
+ program_id: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
281
+ signer_pda: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
282
+ }, "strip", z.ZodTypeAny, {
283
+ program_id: PublicKey;
284
+ signer_pda: PublicKey;
285
+ }, {
286
+ program_id: PublicKey;
287
+ signer_pda: PublicKey;
288
+ }>, "many">;
289
+ }, "strip", z.ZodTypeAny, {
290
+ 0: {
291
+ program_id: PublicKey;
292
+ signer_pda: PublicKey;
293
+ }[];
294
+ }, {
295
+ 0: {
296
+ program_id: PublicKey;
297
+ signer_pda: PublicKey;
298
+ }[];
299
+ }>;
300
+ }, "strip", z.ZodTypeAny, {
301
+ Specific: {
302
+ 0: {
303
+ program_id: PublicKey;
304
+ signer_pda: PublicKey;
305
+ }[];
306
+ };
307
+ }, {
308
+ Specific: {
309
+ 0: {
310
+ program_id: PublicKey;
311
+ signer_pda: PublicKey;
312
+ }[];
313
+ };
314
+ }>, z.ZodObject<{
315
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ All: {};
318
+ }, {
319
+ All: {};
320
+ }>]>;
321
+ authorized_tokens: z.ZodUnion<[z.ZodObject<{
322
+ Specific: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
323
+ }, "strip", z.ZodTypeAny, {
324
+ Specific: {};
325
+ }, {
326
+ Specific: {};
327
+ }>, z.ZodObject<{
328
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
329
+ }, "strip", z.ZodTypeAny, {
330
+ All: {};
331
+ }, {
332
+ All: {};
333
+ }>]>;
334
+ expiration: z.ZodType<BN, z.ZodTypeDef, BN>;
335
+ extra: z.ZodObject<{
336
+ 0: z.ZodUnknown;
337
+ }, "strip", z.ZodTypeAny, {
338
+ 0?: unknown;
339
+ }, {
340
+ 0?: unknown;
341
+ }>;
342
+ user: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
343
+ }, "strip", z.ZodTypeAny, {
344
+ authorized_programs: {
345
+ Specific: {
346
+ 0: {
347
+ program_id: PublicKey;
348
+ signer_pda: PublicKey;
349
+ }[];
350
+ };
351
+ } | {
352
+ All: {};
353
+ };
354
+ authorized_tokens: {
355
+ Specific: {};
356
+ } | {
357
+ All: {};
358
+ };
359
+ expiration: BN;
360
+ extra: {
361
+ 0?: unknown;
362
+ };
363
+ user: PublicKey;
364
+ }, {
365
+ authorized_programs: {
366
+ Specific: {
367
+ 0: {
368
+ program_id: PublicKey;
369
+ signer_pda: PublicKey;
370
+ }[];
371
+ };
372
+ } | {
373
+ All: {};
374
+ };
375
+ authorized_tokens: {
376
+ Specific: {};
377
+ } | {
378
+ All: {};
379
+ };
380
+ expiration: BN;
381
+ extra: {
382
+ 0?: unknown;
383
+ };
384
+ user: PublicKey;
385
+ }>;
386
+ }, "strip", z.ZodTypeAny, {
387
+ "0": {
388
+ authorized_programs: {
389
+ Specific: {
390
+ 0: {
391
+ program_id: PublicKey;
392
+ signer_pda: PublicKey;
393
+ }[];
394
+ };
395
+ } | {
396
+ All: {};
397
+ };
398
+ authorized_tokens: {
399
+ Specific: {};
400
+ } | {
401
+ All: {};
402
+ };
403
+ expiration: BN;
404
+ extra: {
405
+ 0?: unknown;
406
+ };
407
+ user: PublicKey;
408
+ };
409
+ }, {
410
+ "0": {
411
+ authorized_programs: {
412
+ Specific: {
413
+ 0: {
414
+ program_id: PublicKey;
415
+ signer_pda: PublicKey;
416
+ }[];
417
+ };
418
+ } | {
419
+ All: {};
420
+ };
421
+ authorized_tokens: {
422
+ Specific: {};
423
+ } | {
424
+ All: {};
425
+ };
426
+ expiration: BN;
427
+ extra: {
428
+ 0?: unknown;
429
+ };
430
+ user: PublicKey;
431
+ };
432
+ }>;
433
+ }, "strip", z.ZodTypeAny, {
434
+ Active: {
435
+ "0": {
436
+ authorized_programs: {
437
+ Specific: {
438
+ 0: {
439
+ program_id: PublicKey;
440
+ signer_pda: PublicKey;
441
+ }[];
442
+ };
443
+ } | {
444
+ All: {};
445
+ };
446
+ authorized_tokens: {
447
+ Specific: {};
448
+ } | {
449
+ All: {};
450
+ };
451
+ expiration: BN;
452
+ extra: {
453
+ 0?: unknown;
454
+ };
455
+ user: PublicKey;
456
+ };
457
+ };
458
+ }, {
459
+ Active: {
460
+ "0": {
461
+ authorized_programs: {
462
+ Specific: {
463
+ 0: {
464
+ program_id: PublicKey;
465
+ signer_pda: PublicKey;
466
+ }[];
467
+ };
468
+ } | {
469
+ All: {};
470
+ };
471
+ authorized_tokens: {
472
+ Specific: {};
473
+ } | {
474
+ All: {};
475
+ };
476
+ expiration: BN;
477
+ extra: {
478
+ 0?: unknown;
479
+ };
480
+ user: PublicKey;
481
+ };
482
+ };
483
+ }>]>;
484
+ }, "strip", z.ZodTypeAny, {
485
+ "0": {
486
+ Revoked: BN;
487
+ } | {
488
+ Active: {
489
+ "0": {
490
+ authorized_programs: {
491
+ Specific: {
492
+ 0: {
493
+ program_id: PublicKey;
494
+ signer_pda: PublicKey;
495
+ }[];
496
+ };
497
+ } | {
498
+ All: {};
499
+ };
500
+ authorized_tokens: {
501
+ Specific: {};
502
+ } | {
503
+ All: {};
504
+ };
505
+ expiration: BN;
506
+ extra: {
507
+ 0?: unknown;
508
+ };
509
+ user: PublicKey;
510
+ };
511
+ };
512
+ };
513
+ }, {
514
+ "0": {
515
+ Revoked: BN;
516
+ } | {
517
+ Active: {
518
+ "0": {
519
+ authorized_programs: {
520
+ Specific: {
521
+ 0: {
522
+ program_id: PublicKey;
523
+ signer_pda: PublicKey;
524
+ }[];
525
+ };
526
+ } | {
527
+ All: {};
528
+ };
529
+ authorized_tokens: {
530
+ Specific: {};
531
+ } | {
532
+ All: {};
533
+ };
534
+ expiration: BN;
535
+ extra: {
536
+ 0?: unknown;
537
+ };
538
+ user: PublicKey;
539
+ };
540
+ };
541
+ };
542
+ }>;
543
+ }, "strip", z.ZodTypeAny, {
544
+ V2: {
545
+ "0": {
546
+ Revoked: BN;
547
+ } | {
548
+ Active: {
549
+ "0": {
550
+ authorized_programs: {
551
+ Specific: {
552
+ 0: {
553
+ program_id: PublicKey;
554
+ signer_pda: PublicKey;
555
+ }[];
556
+ };
557
+ } | {
558
+ All: {};
559
+ };
560
+ authorized_tokens: {
561
+ Specific: {};
562
+ } | {
563
+ All: {};
564
+ };
565
+ expiration: BN;
566
+ extra: {
567
+ 0?: unknown;
568
+ };
569
+ user: PublicKey;
570
+ };
571
+ };
572
+ };
139
573
  };
140
- major: number;
141
- minor: number;
142
- user: PublicKey;
143
574
  }, {
144
- authorized_programs: {
145
- Specific: {
146
- 0: {
147
- program_id: PublicKey;
148
- signer_pda: PublicKey;
149
- }[];
575
+ V2: {
576
+ "0": {
577
+ Revoked: BN;
578
+ } | {
579
+ Active: {
580
+ "0": {
581
+ authorized_programs: {
582
+ Specific: {
583
+ 0: {
584
+ program_id: PublicKey;
585
+ signer_pda: PublicKey;
586
+ }[];
587
+ };
588
+ } | {
589
+ All: {};
590
+ };
591
+ authorized_tokens: {
592
+ Specific: {};
593
+ } | {
594
+ All: {};
595
+ };
596
+ expiration: BN;
597
+ extra: {
598
+ 0?: unknown;
599
+ };
600
+ user: PublicKey;
601
+ };
602
+ };
150
603
  };
151
- } | {
152
- All: {};
153
604
  };
154
- authorized_tokens: {
155
- Specific: {};
156
- } | {
157
- All: {};
605
+ }>, z.ZodObject<{
606
+ V3: z.ZodObject<{
607
+ "0": z.ZodUnion<[z.ZodObject<{
608
+ Revoked: z.ZodType<BN, z.ZodTypeDef, BN>;
609
+ }, "strip", z.ZodTypeAny, {
610
+ Revoked: BN;
611
+ }, {
612
+ Revoked: BN;
613
+ }>, z.ZodObject<{
614
+ Active: z.ZodObject<{
615
+ "0": z.ZodObject<{
616
+ authorized_programs: z.ZodUnion<[z.ZodObject<{
617
+ Specific: z.ZodObject<{
618
+ 0: z.ZodArray<z.ZodObject<{
619
+ program_id: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
620
+ signer_pda: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
621
+ }, "strip", z.ZodTypeAny, {
622
+ program_id: PublicKey;
623
+ signer_pda: PublicKey;
624
+ }, {
625
+ program_id: PublicKey;
626
+ signer_pda: PublicKey;
627
+ }>, "many">;
628
+ }, "strip", z.ZodTypeAny, {
629
+ 0: {
630
+ program_id: PublicKey;
631
+ signer_pda: PublicKey;
632
+ }[];
633
+ }, {
634
+ 0: {
635
+ program_id: PublicKey;
636
+ signer_pda: PublicKey;
637
+ }[];
638
+ }>;
639
+ }, "strip", z.ZodTypeAny, {
640
+ Specific: {
641
+ 0: {
642
+ program_id: PublicKey;
643
+ signer_pda: PublicKey;
644
+ }[];
645
+ };
646
+ }, {
647
+ Specific: {
648
+ 0: {
649
+ program_id: PublicKey;
650
+ signer_pda: PublicKey;
651
+ }[];
652
+ };
653
+ }>, z.ZodObject<{
654
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
655
+ }, "strip", z.ZodTypeAny, {
656
+ All: {};
657
+ }, {
658
+ All: {};
659
+ }>]>;
660
+ authorized_tokens: z.ZodUnion<[z.ZodObject<{
661
+ Specific: z.ZodObject<{
662
+ "0": z.ZodArray<z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>, "many">;
663
+ }, "strip", z.ZodTypeAny, {
664
+ "0": PublicKey[];
665
+ }, {
666
+ "0": PublicKey[];
667
+ }>;
668
+ }, "strip", z.ZodTypeAny, {
669
+ Specific: {
670
+ "0": PublicKey[];
671
+ };
672
+ }, {
673
+ Specific: {
674
+ "0": PublicKey[];
675
+ };
676
+ }>, z.ZodObject<{
677
+ All: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
678
+ }, "strip", z.ZodTypeAny, {
679
+ All: {};
680
+ }, {
681
+ All: {};
682
+ }>]>;
683
+ expiration: z.ZodType<BN, z.ZodTypeDef, BN>;
684
+ extra: z.ZodObject<{
685
+ 0: z.ZodUnknown;
686
+ }, "strip", z.ZodTypeAny, {
687
+ 0?: unknown;
688
+ }, {
689
+ 0?: unknown;
690
+ }>;
691
+ user: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
692
+ }, "strip", z.ZodTypeAny, {
693
+ authorized_programs: {
694
+ Specific: {
695
+ 0: {
696
+ program_id: PublicKey;
697
+ signer_pda: PublicKey;
698
+ }[];
699
+ };
700
+ } | {
701
+ All: {};
702
+ };
703
+ authorized_tokens: {
704
+ Specific: {
705
+ "0": PublicKey[];
706
+ };
707
+ } | {
708
+ All: {};
709
+ };
710
+ expiration: BN;
711
+ extra: {
712
+ 0?: unknown;
713
+ };
714
+ user: PublicKey;
715
+ }, {
716
+ authorized_programs: {
717
+ Specific: {
718
+ 0: {
719
+ program_id: PublicKey;
720
+ signer_pda: PublicKey;
721
+ }[];
722
+ };
723
+ } | {
724
+ All: {};
725
+ };
726
+ authorized_tokens: {
727
+ Specific: {
728
+ "0": PublicKey[];
729
+ };
730
+ } | {
731
+ All: {};
732
+ };
733
+ expiration: BN;
734
+ extra: {
735
+ 0?: unknown;
736
+ };
737
+ user: PublicKey;
738
+ }>;
739
+ }, "strip", z.ZodTypeAny, {
740
+ "0": {
741
+ authorized_programs: {
742
+ Specific: {
743
+ 0: {
744
+ program_id: PublicKey;
745
+ signer_pda: PublicKey;
746
+ }[];
747
+ };
748
+ } | {
749
+ All: {};
750
+ };
751
+ authorized_tokens: {
752
+ Specific: {
753
+ "0": PublicKey[];
754
+ };
755
+ } | {
756
+ All: {};
757
+ };
758
+ expiration: BN;
759
+ extra: {
760
+ 0?: unknown;
761
+ };
762
+ user: PublicKey;
763
+ };
764
+ }, {
765
+ "0": {
766
+ authorized_programs: {
767
+ Specific: {
768
+ 0: {
769
+ program_id: PublicKey;
770
+ signer_pda: PublicKey;
771
+ }[];
772
+ };
773
+ } | {
774
+ All: {};
775
+ };
776
+ authorized_tokens: {
777
+ Specific: {
778
+ "0": PublicKey[];
779
+ };
780
+ } | {
781
+ All: {};
782
+ };
783
+ expiration: BN;
784
+ extra: {
785
+ 0?: unknown;
786
+ };
787
+ user: PublicKey;
788
+ };
789
+ }>;
790
+ }, "strip", z.ZodTypeAny, {
791
+ Active: {
792
+ "0": {
793
+ authorized_programs: {
794
+ Specific: {
795
+ 0: {
796
+ program_id: PublicKey;
797
+ signer_pda: PublicKey;
798
+ }[];
799
+ };
800
+ } | {
801
+ All: {};
802
+ };
803
+ authorized_tokens: {
804
+ Specific: {
805
+ "0": PublicKey[];
806
+ };
807
+ } | {
808
+ All: {};
809
+ };
810
+ expiration: BN;
811
+ extra: {
812
+ 0?: unknown;
813
+ };
814
+ user: PublicKey;
815
+ };
816
+ };
817
+ }, {
818
+ Active: {
819
+ "0": {
820
+ authorized_programs: {
821
+ Specific: {
822
+ 0: {
823
+ program_id: PublicKey;
824
+ signer_pda: PublicKey;
825
+ }[];
826
+ };
827
+ } | {
828
+ All: {};
829
+ };
830
+ authorized_tokens: {
831
+ Specific: {
832
+ "0": PublicKey[];
833
+ };
834
+ } | {
835
+ All: {};
836
+ };
837
+ expiration: BN;
838
+ extra: {
839
+ 0?: unknown;
840
+ };
841
+ user: PublicKey;
842
+ };
843
+ };
844
+ }>]>;
845
+ }, "strip", z.ZodTypeAny, {
846
+ "0": {
847
+ Revoked: BN;
848
+ } | {
849
+ Active: {
850
+ "0": {
851
+ authorized_programs: {
852
+ Specific: {
853
+ 0: {
854
+ program_id: PublicKey;
855
+ signer_pda: PublicKey;
856
+ }[];
857
+ };
858
+ } | {
859
+ All: {};
860
+ };
861
+ authorized_tokens: {
862
+ Specific: {
863
+ "0": PublicKey[];
864
+ };
865
+ } | {
866
+ All: {};
867
+ };
868
+ expiration: BN;
869
+ extra: {
870
+ 0?: unknown;
871
+ };
872
+ user: PublicKey;
873
+ };
874
+ };
875
+ };
876
+ }, {
877
+ "0": {
878
+ Revoked: BN;
879
+ } | {
880
+ Active: {
881
+ "0": {
882
+ authorized_programs: {
883
+ Specific: {
884
+ 0: {
885
+ program_id: PublicKey;
886
+ signer_pda: PublicKey;
887
+ }[];
888
+ };
889
+ } | {
890
+ All: {};
891
+ };
892
+ authorized_tokens: {
893
+ Specific: {
894
+ "0": PublicKey[];
895
+ };
896
+ } | {
897
+ All: {};
898
+ };
899
+ expiration: BN;
900
+ extra: {
901
+ 0?: unknown;
902
+ };
903
+ user: PublicKey;
904
+ };
905
+ };
906
+ };
907
+ }>;
908
+ }, "strip", z.ZodTypeAny, {
909
+ V3: {
910
+ "0": {
911
+ Revoked: BN;
912
+ } | {
913
+ Active: {
914
+ "0": {
915
+ authorized_programs: {
916
+ Specific: {
917
+ 0: {
918
+ program_id: PublicKey;
919
+ signer_pda: PublicKey;
920
+ }[];
921
+ };
922
+ } | {
923
+ All: {};
924
+ };
925
+ authorized_tokens: {
926
+ Specific: {
927
+ "0": PublicKey[];
928
+ };
929
+ } | {
930
+ All: {};
931
+ };
932
+ expiration: BN;
933
+ extra: {
934
+ 0?: unknown;
935
+ };
936
+ user: PublicKey;
937
+ };
938
+ };
939
+ };
158
940
  };
159
- expiration: BN;
160
- extra: {
161
- 0?: unknown;
941
+ }, {
942
+ V3: {
943
+ "0": {
944
+ Revoked: BN;
945
+ } | {
946
+ Active: {
947
+ "0": {
948
+ authorized_programs: {
949
+ Specific: {
950
+ 0: {
951
+ program_id: PublicKey;
952
+ signer_pda: PublicKey;
953
+ }[];
954
+ };
955
+ } | {
956
+ All: {};
957
+ };
958
+ authorized_tokens: {
959
+ Specific: {
960
+ "0": PublicKey[];
961
+ };
962
+ } | {
963
+ All: {};
964
+ };
965
+ expiration: BN;
966
+ extra: {
967
+ 0?: unknown;
968
+ };
969
+ user: PublicKey;
970
+ };
971
+ };
972
+ };
162
973
  };
163
- major: number;
164
- minor: number;
165
- user: PublicKey;
166
- }>;
974
+ }>]>;
975
+ major: z.ZodNumber;
976
+ sponsor: z.ZodType<PublicKey, z.ZodTypeDef, PublicKey>;
167
977
  }, "strip", z.ZodTypeAny, {
978
+ sponsor: PublicKey;
168
979
  session_info: {
169
- authorized_programs: {
170
- Specific: {
171
- 0: {
172
- program_id: PublicKey;
173
- signer_pda: PublicKey;
174
- }[];
980
+ V1: {
981
+ "0": {
982
+ authorized_programs: {
983
+ Specific: {
984
+ 0: {
985
+ program_id: PublicKey;
986
+ signer_pda: PublicKey;
987
+ }[];
988
+ };
989
+ } | {
990
+ All: {};
991
+ };
992
+ authorized_tokens: {
993
+ Specific: {};
994
+ } | {
995
+ All: {};
996
+ };
997
+ expiration: BN;
998
+ extra: {
999
+ 0?: unknown;
1000
+ };
1001
+ user: PublicKey;
175
1002
  };
176
- } | {
177
- All: {};
178
1003
  };
179
- authorized_tokens: {
180
- Specific: {};
181
- } | {
182
- All: {};
1004
+ } | {
1005
+ V2: {
1006
+ "0": {
1007
+ Revoked: BN;
1008
+ } | {
1009
+ Active: {
1010
+ "0": {
1011
+ authorized_programs: {
1012
+ Specific: {
1013
+ 0: {
1014
+ program_id: PublicKey;
1015
+ signer_pda: PublicKey;
1016
+ }[];
1017
+ };
1018
+ } | {
1019
+ All: {};
1020
+ };
1021
+ authorized_tokens: {
1022
+ Specific: {};
1023
+ } | {
1024
+ All: {};
1025
+ };
1026
+ expiration: BN;
1027
+ extra: {
1028
+ 0?: unknown;
1029
+ };
1030
+ user: PublicKey;
1031
+ };
1032
+ };
1033
+ };
183
1034
  };
184
- expiration: BN;
185
- extra: {
186
- 0?: unknown;
1035
+ } | {
1036
+ V3: {
1037
+ "0": {
1038
+ Revoked: BN;
1039
+ } | {
1040
+ Active: {
1041
+ "0": {
1042
+ authorized_programs: {
1043
+ Specific: {
1044
+ 0: {
1045
+ program_id: PublicKey;
1046
+ signer_pda: PublicKey;
1047
+ }[];
1048
+ };
1049
+ } | {
1050
+ All: {};
1051
+ };
1052
+ authorized_tokens: {
1053
+ Specific: {
1054
+ "0": PublicKey[];
1055
+ };
1056
+ } | {
1057
+ All: {};
1058
+ };
1059
+ expiration: BN;
1060
+ extra: {
1061
+ 0?: unknown;
1062
+ };
1063
+ user: PublicKey;
1064
+ };
1065
+ };
1066
+ };
187
1067
  };
188
- major: number;
189
- minor: number;
190
- user: PublicKey;
191
1068
  };
1069
+ major: number;
192
1070
  }, {
1071
+ sponsor: PublicKey;
193
1072
  session_info: {
194
- authorized_programs: {
195
- Specific: {
196
- 0: {
197
- program_id: PublicKey;
198
- signer_pda: PublicKey;
199
- }[];
1073
+ V1: {
1074
+ "0": {
1075
+ authorized_programs: {
1076
+ Specific: {
1077
+ 0: {
1078
+ program_id: PublicKey;
1079
+ signer_pda: PublicKey;
1080
+ }[];
1081
+ };
1082
+ } | {
1083
+ All: {};
1084
+ };
1085
+ authorized_tokens: {
1086
+ Specific: {};
1087
+ } | {
1088
+ All: {};
1089
+ };
1090
+ expiration: BN;
1091
+ extra: {
1092
+ 0?: unknown;
1093
+ };
1094
+ user: PublicKey;
200
1095
  };
201
- } | {
202
- All: {};
203
1096
  };
204
- authorized_tokens: {
205
- Specific: {};
206
- } | {
207
- All: {};
1097
+ } | {
1098
+ V2: {
1099
+ "0": {
1100
+ Revoked: BN;
1101
+ } | {
1102
+ Active: {
1103
+ "0": {
1104
+ authorized_programs: {
1105
+ Specific: {
1106
+ 0: {
1107
+ program_id: PublicKey;
1108
+ signer_pda: PublicKey;
1109
+ }[];
1110
+ };
1111
+ } | {
1112
+ All: {};
1113
+ };
1114
+ authorized_tokens: {
1115
+ Specific: {};
1116
+ } | {
1117
+ All: {};
1118
+ };
1119
+ expiration: BN;
1120
+ extra: {
1121
+ 0?: unknown;
1122
+ };
1123
+ user: PublicKey;
1124
+ };
1125
+ };
1126
+ };
208
1127
  };
209
- expiration: BN;
210
- extra: {
211
- 0?: unknown;
1128
+ } | {
1129
+ V3: {
1130
+ "0": {
1131
+ Revoked: BN;
1132
+ } | {
1133
+ Active: {
1134
+ "0": {
1135
+ authorized_programs: {
1136
+ Specific: {
1137
+ 0: {
1138
+ program_id: PublicKey;
1139
+ signer_pda: PublicKey;
1140
+ }[];
1141
+ };
1142
+ } | {
1143
+ All: {};
1144
+ };
1145
+ authorized_tokens: {
1146
+ Specific: {
1147
+ "0": PublicKey[];
1148
+ };
1149
+ } | {
1150
+ All: {};
1151
+ };
1152
+ expiration: BN;
1153
+ extra: {
1154
+ 0?: unknown;
1155
+ };
1156
+ user: PublicKey;
1157
+ };
1158
+ };
1159
+ };
212
1160
  };
213
- major: number;
214
- minor: number;
215
- user: PublicKey;
216
1161
  };
1162
+ major: number;
217
1163
  }>, {
218
1164
  authorizedPrograms: {
219
1165
  type: AuthorizedProgramsType.All;
@@ -228,33 +1174,102 @@ declare const sessionInfoSchema: z.ZodEffects<z.ZodObject<{
228
1174
  expiration: Date;
229
1175
  extra: unknown;
230
1176
  major: number;
231
- minor: number;
1177
+ minor: 1 | 2 | 3;
232
1178
  user: PublicKey;
233
- }, {
1179
+ sponsor: PublicKey;
1180
+ } | undefined, {
1181
+ sponsor: PublicKey;
234
1182
  session_info: {
235
- authorized_programs: {
236
- Specific: {
237
- 0: {
238
- program_id: PublicKey;
239
- signer_pda: PublicKey;
240
- }[];
1183
+ V1: {
1184
+ "0": {
1185
+ authorized_programs: {
1186
+ Specific: {
1187
+ 0: {
1188
+ program_id: PublicKey;
1189
+ signer_pda: PublicKey;
1190
+ }[];
1191
+ };
1192
+ } | {
1193
+ All: {};
1194
+ };
1195
+ authorized_tokens: {
1196
+ Specific: {};
1197
+ } | {
1198
+ All: {};
1199
+ };
1200
+ expiration: BN;
1201
+ extra: {
1202
+ 0?: unknown;
1203
+ };
1204
+ user: PublicKey;
241
1205
  };
242
- } | {
243
- All: {};
244
1206
  };
245
- authorized_tokens: {
246
- Specific: {};
247
- } | {
248
- All: {};
1207
+ } | {
1208
+ V2: {
1209
+ "0": {
1210
+ Revoked: BN;
1211
+ } | {
1212
+ Active: {
1213
+ "0": {
1214
+ authorized_programs: {
1215
+ Specific: {
1216
+ 0: {
1217
+ program_id: PublicKey;
1218
+ signer_pda: PublicKey;
1219
+ }[];
1220
+ };
1221
+ } | {
1222
+ All: {};
1223
+ };
1224
+ authorized_tokens: {
1225
+ Specific: {};
1226
+ } | {
1227
+ All: {};
1228
+ };
1229
+ expiration: BN;
1230
+ extra: {
1231
+ 0?: unknown;
1232
+ };
1233
+ user: PublicKey;
1234
+ };
1235
+ };
1236
+ };
249
1237
  };
250
- expiration: BN;
251
- extra: {
252
- 0?: unknown;
1238
+ } | {
1239
+ V3: {
1240
+ "0": {
1241
+ Revoked: BN;
1242
+ } | {
1243
+ Active: {
1244
+ "0": {
1245
+ authorized_programs: {
1246
+ Specific: {
1247
+ 0: {
1248
+ program_id: PublicKey;
1249
+ signer_pda: PublicKey;
1250
+ }[];
1251
+ };
1252
+ } | {
1253
+ All: {};
1254
+ };
1255
+ authorized_tokens: {
1256
+ Specific: {
1257
+ "0": PublicKey[];
1258
+ };
1259
+ } | {
1260
+ All: {};
1261
+ };
1262
+ expiration: BN;
1263
+ extra: {
1264
+ 0?: unknown;
1265
+ };
1266
+ user: PublicKey;
1267
+ };
1268
+ };
1269
+ };
253
1270
  };
254
- major: number;
255
- minor: number;
256
- user: PublicKey;
257
1271
  };
1272
+ major: number;
258
1273
  }>;
259
1274
  export declare enum AuthorizedProgramsType {
260
1275
  All = 0,
@@ -288,7 +1303,7 @@ export type Session = {
288
1303
  walletPublicKey: PublicKey;
289
1304
  payer: PublicKey;
290
1305
  sendTransaction: (instructions: Parameters<SessionAdapter["sendTransaction"]>[1]) => Promise<TransactionResult>;
291
- sessionInfo: z.infer<typeof sessionInfoSchema>;
1306
+ sessionInfo: NonNullable<z.infer<typeof sessionInfoSchema>>;
292
1307
  };
293
1308
  type SendTransferOptions = {
294
1309
  adapter: SessionAdapter;
@@ -299,3 +1314,33 @@ type SendTransferOptions = {
299
1314
  recipient: PublicKey;
300
1315
  };
301
1316
  export declare const sendTransfer: (options: SendTransferOptions) => Promise<TransactionResult>;
1317
+ /**
1318
+ * Create a login token signed with the session key
1319
+ * @param session - The session to create a login token for
1320
+ * @returns The login token
1321
+ */
1322
+ export declare const createLogInToken: (session: Session) => Promise<string>;
1323
+ /**
1324
+ * Verify a login token
1325
+ * @param token - The login token to verify against the session public key
1326
+ * @param connection - The connection to use to get the session account
1327
+ * @returns The session account if the token is valid, otherwise undefined
1328
+ */
1329
+ export declare const verifyLogInToken: (token: string, connection: Connection) => Promise<{
1330
+ authorizedPrograms: {
1331
+ type: AuthorizedProgramsType.All;
1332
+ } | {
1333
+ type: AuthorizedProgramsType.Specific;
1334
+ programs: {
1335
+ programId: PublicKey;
1336
+ signerPda: PublicKey;
1337
+ }[];
1338
+ };
1339
+ authorizedTokens: AuthorizedTokens;
1340
+ expiration: Date;
1341
+ extra: unknown;
1342
+ major: number;
1343
+ minor: 1 | 2 | 3;
1344
+ user: PublicKey;
1345
+ sponsor: PublicKey;
1346
+ } | undefined>;