@pexis/auth 0.1.2 → 0.1.4

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/api.json ADDED
@@ -0,0 +1,2191 @@
1
+ {
2
+ "format": 1,
3
+ "package": "@pexis/auth",
4
+ "version": "0.1.4",
5
+ "entries": [
6
+ {
7
+ "import": "@pexis/auth",
8
+ "exports": [
9
+ {
10
+ "name": "apple",
11
+ "kind": "function",
12
+ "stability": "stable",
13
+ "deprecated": null,
14
+ "summary": "Sign in with Apple (OpenID Connect).",
15
+ "description": "The client secret is a short-lived\ntoken signed with your key, made for you. Apple posts the callback as a\nform, which Pexis lets past CSRF from appleid.apple.com only.",
16
+ "signatures": [
17
+ {
18
+ "text": "apple(options: AppleOptions): Provider",
19
+ "parameters": [
20
+ {
21
+ "name": "options",
22
+ "type": "AppleOptions",
23
+ "required": true,
24
+ "default": null,
25
+ "description": "Your Services ID, team id, key id and private key.",
26
+ "stability": "stable",
27
+ "deprecated": null
28
+ }
29
+ ],
30
+ "returns": {
31
+ "type": "Provider",
32
+ "description": null
33
+ }
34
+ }
35
+ ],
36
+ "examples": [],
37
+ "see": [],
38
+ "references": [
39
+ "AppleOptions",
40
+ "Provider"
41
+ ]
42
+ },
43
+ {
44
+ "name": "AppleOptions",
45
+ "kind": "interface",
46
+ "stability": "stable",
47
+ "deprecated": null,
48
+ "summary": "What apple() takes, from the Apple Developer account.",
49
+ "description": "",
50
+ "members": [
51
+ {
52
+ "name": "clientId",
53
+ "type": "string",
54
+ "required": true,
55
+ "default": null,
56
+ "description": "The Services ID.",
57
+ "stability": "stable",
58
+ "deprecated": null
59
+ },
60
+ {
61
+ "name": "teamId",
62
+ "type": "string",
63
+ "required": true,
64
+ "default": null,
65
+ "description": "Your Apple Developer team id.",
66
+ "stability": "stable",
67
+ "deprecated": null
68
+ },
69
+ {
70
+ "name": "keyId",
71
+ "type": "string",
72
+ "required": true,
73
+ "default": null,
74
+ "description": "The id of the Sign in with Apple key.",
75
+ "stability": "stable",
76
+ "deprecated": null
77
+ },
78
+ {
79
+ "name": "privateKey",
80
+ "type": "string",
81
+ "required": true,
82
+ "default": null,
83
+ "description": "The .p8 private key, as PEM text. Read it from a secret, never commit it.",
84
+ "stability": "stable",
85
+ "deprecated": null
86
+ }
87
+ ],
88
+ "examples": [],
89
+ "see": [],
90
+ "references": []
91
+ },
92
+ {
93
+ "name": "auth",
94
+ "kind": "function",
95
+ "stability": "stable",
96
+ "deprecated": null,
97
+ "summary": "Sign-in with Google, Microsoft, GitHub, Apple or any OpenID Connect provider: a sign-in page at /auth/sign-in, the callback, and sign-out.",
98
+ "description": "Needs sessions() listed before it.",
99
+ "signatures": [
100
+ {
101
+ "text": "auth(options: AuthOptions): Plugin",
102
+ "parameters": [
103
+ {
104
+ "name": "options",
105
+ "type": "AuthOptions",
106
+ "required": true,
107
+ "default": null,
108
+ "description": "The providers, and how a profile becomes your user.",
109
+ "stability": "stable",
110
+ "deprecated": null
111
+ }
112
+ ],
113
+ "returns": {
114
+ "type": "Plugin",
115
+ "description": null
116
+ }
117
+ }
118
+ ],
119
+ "examples": [
120
+ {
121
+ "code": "plugins: [\n sessions({ store: sessionStore(db) }),\n auth({ providers: [google({ clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET! })] }),\n]"
122
+ }
123
+ ],
124
+ "see": [],
125
+ "references": [
126
+ "AuthOptions",
127
+ "Plugin"
128
+ ]
129
+ },
130
+ {
131
+ "name": "AuthOptions",
132
+ "kind": "interface",
133
+ "stability": "stable",
134
+ "deprecated": null,
135
+ "summary": "What auth() takes.",
136
+ "description": "",
137
+ "members": [
138
+ {
139
+ "name": "providers",
140
+ "type": "Provider[]",
141
+ "required": true,
142
+ "default": null,
143
+ "description": "The sign-in providers offered, such as google() and github().",
144
+ "stability": "stable",
145
+ "deprecated": null
146
+ },
147
+ {
148
+ "name": "onSignIn",
149
+ "type": "(profile: Profile & {\n provider: string;\n }, ctx: Context) => User | null | Promise<User | null>",
150
+ "required": false,
151
+ "default": null,
152
+ "description": "Turns a provider profile into your user, or returns null to refuse the\nsign-in. Use it to find or create the user in your database. Default: a\nuser whose id is \"<provider>:<subject>\".",
153
+ "stability": "stable",
154
+ "deprecated": null
155
+ },
156
+ {
157
+ "name": "basePath",
158
+ "type": "string",
159
+ "required": false,
160
+ "default": null,
161
+ "description": "Where the auth routes live. Default /auth.",
162
+ "stability": "stable",
163
+ "deprecated": null
164
+ },
165
+ {
166
+ "name": "fetch",
167
+ "type": "typeof fetch",
168
+ "required": false,
169
+ "default": null,
170
+ "description": "For tests: the fetch used to reach providers.",
171
+ "stability": "stable",
172
+ "deprecated": null
173
+ }
174
+ ],
175
+ "examples": [],
176
+ "see": [],
177
+ "references": [
178
+ "Context",
179
+ "Profile",
180
+ "Provider",
181
+ "User"
182
+ ]
183
+ },
184
+ {
185
+ "name": "base64urlEncode",
186
+ "kind": "function",
187
+ "stability": "plugins",
188
+ "deprecated": null,
189
+ "summary": "Base64url without padding, as JWTs and PKCE use.",
190
+ "description": "",
191
+ "signatures": [
192
+ {
193
+ "text": "base64urlEncode(bytes: Uint8Array | string): string",
194
+ "parameters": [
195
+ {
196
+ "name": "bytes",
197
+ "type": "Uint8Array | string",
198
+ "required": true,
199
+ "default": null,
200
+ "description": "Bytes, or text encoded as UTF-8.",
201
+ "stability": "stable",
202
+ "deprecated": null
203
+ }
204
+ ],
205
+ "returns": {
206
+ "type": "string",
207
+ "description": null
208
+ }
209
+ }
210
+ ],
211
+ "examples": [],
212
+ "see": [],
213
+ "references": []
214
+ },
215
+ {
216
+ "name": "Claims",
217
+ "kind": "type",
218
+ "stability": "plugins",
219
+ "deprecated": null,
220
+ "summary": "A JWT's claims: the registered ones typed, any others as unknown.",
221
+ "description": "",
222
+ "type": "Record<string, unknown> & {\n iss?: string;\n sub?: string;\n aud?: string | string[];\n azp?: string;\n exp?: number;\n iat?: number;\n nbf?: number;\n nonce?: string;\n}",
223
+ "examples": [],
224
+ "see": [],
225
+ "references": []
226
+ },
227
+ {
228
+ "name": "decodeJwt",
229
+ "kind": "function",
230
+ "stability": "plugins",
231
+ "deprecated": null,
232
+ "summary": "Splits a JWT into its header, claims and signature without verifying it.",
233
+ "description": "Never trust the claims from this alone; use verifyJwt(). Throws JwtError\nfor a malformed token.",
234
+ "signatures": [
235
+ {
236
+ "text": "decodeJwt(token: string): {\n header: JoseHeader;\n claims: Claims;\n signingInput: string;\n signature: Uint8Array<ArrayBuffer>;\n}",
237
+ "parameters": [
238
+ {
239
+ "name": "token",
240
+ "type": "string",
241
+ "required": true,
242
+ "default": null,
243
+ "description": "A compact JWT.",
244
+ "stability": "stable",
245
+ "deprecated": null
246
+ }
247
+ ],
248
+ "returns": {
249
+ "type": "{\n header: JoseHeader;\n claims: Claims;\n signingInput: string;\n signature: Uint8Array<ArrayBuffer>;\n}",
250
+ "description": null
251
+ }
252
+ }
253
+ ],
254
+ "examples": [],
255
+ "see": [],
256
+ "references": [
257
+ "Claims"
258
+ ]
259
+ },
260
+ {
261
+ "name": "github",
262
+ "kind": "function",
263
+ "stability": "stable",
264
+ "deprecated": null,
265
+ "summary": "Sign in with GitHub (OAuth).",
266
+ "description": "The profile comes from GitHub's API, with the\nprimary verified email.",
267
+ "signatures": [
268
+ {
269
+ "text": "github(options: Credentials): Provider",
270
+ "parameters": [
271
+ {
272
+ "name": "options",
273
+ "type": "Credentials",
274
+ "required": true,
275
+ "default": null,
276
+ "description": "Your OAuth app's client id and secret, and extra scopes.",
277
+ "stability": "stable",
278
+ "deprecated": null
279
+ }
280
+ ],
281
+ "returns": {
282
+ "type": "Provider",
283
+ "description": null
284
+ }
285
+ }
286
+ ],
287
+ "examples": [],
288
+ "see": [],
289
+ "references": [
290
+ "Provider"
291
+ ]
292
+ },
293
+ {
294
+ "name": "google",
295
+ "kind": "function",
296
+ "stability": "stable",
297
+ "deprecated": null,
298
+ "summary": "Sign in with Google (OpenID Connect).",
299
+ "description": "",
300
+ "signatures": [
301
+ {
302
+ "text": "google(options: Credentials): Provider",
303
+ "parameters": [
304
+ {
305
+ "name": "options",
306
+ "type": "Credentials",
307
+ "required": true,
308
+ "default": null,
309
+ "description": "Your client id and secret from the Google Cloud console, and extra scopes.",
310
+ "stability": "stable",
311
+ "deprecated": null
312
+ }
313
+ ],
314
+ "returns": {
315
+ "type": "Provider",
316
+ "description": null
317
+ }
318
+ }
319
+ ],
320
+ "examples": [
321
+ {
322
+ "code": "google({ clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET! })"
323
+ }
324
+ ],
325
+ "see": [],
326
+ "references": [
327
+ "Provider"
328
+ ]
329
+ },
330
+ {
331
+ "name": "Jwk",
332
+ "kind": "interface",
333
+ "stability": "plugins",
334
+ "deprecated": null,
335
+ "summary": "A public key in JSON Web Key form, as providers publish them.",
336
+ "description": "",
337
+ "members": [
338
+ {
339
+ "name": "kty",
340
+ "type": "string",
341
+ "required": true,
342
+ "default": null,
343
+ "description": "The key type: \"RSA\" or \"EC\".",
344
+ "stability": "stable",
345
+ "deprecated": null
346
+ },
347
+ {
348
+ "name": "kid",
349
+ "type": "string",
350
+ "required": false,
351
+ "default": null,
352
+ "description": "The key's id, which tokens name in their header.",
353
+ "stability": "stable",
354
+ "deprecated": null
355
+ },
356
+ {
357
+ "name": "alg",
358
+ "type": "string",
359
+ "required": false,
360
+ "default": null,
361
+ "description": "The algorithm the key is for, such as \"RS256\".",
362
+ "stability": "stable",
363
+ "deprecated": null
364
+ },
365
+ {
366
+ "name": "use",
367
+ "type": "string",
368
+ "required": false,
369
+ "default": null,
370
+ "description": "What the key is for: \"sig\" for signatures.",
371
+ "stability": "stable",
372
+ "deprecated": null
373
+ },
374
+ {
375
+ "name": "n",
376
+ "type": "string",
377
+ "required": false,
378
+ "default": null,
379
+ "description": "An RSA key's modulus.",
380
+ "stability": "stable",
381
+ "deprecated": null
382
+ },
383
+ {
384
+ "name": "e",
385
+ "type": "string",
386
+ "required": false,
387
+ "default": null,
388
+ "description": "An RSA key's exponent.",
389
+ "stability": "stable",
390
+ "deprecated": null
391
+ },
392
+ {
393
+ "name": "crv",
394
+ "type": "string",
395
+ "required": false,
396
+ "default": null,
397
+ "description": "An EC key's curve, such as \"P-256\".",
398
+ "stability": "stable",
399
+ "deprecated": null
400
+ },
401
+ {
402
+ "name": "x",
403
+ "type": "string",
404
+ "required": false,
405
+ "default": null,
406
+ "description": "An EC key's x coordinate.",
407
+ "stability": "stable",
408
+ "deprecated": null
409
+ },
410
+ {
411
+ "name": "y",
412
+ "type": "string",
413
+ "required": false,
414
+ "default": null,
415
+ "description": "An EC key's y coordinate.",
416
+ "stability": "stable",
417
+ "deprecated": null
418
+ }
419
+ ],
420
+ "examples": [],
421
+ "see": [],
422
+ "references": []
423
+ },
424
+ {
425
+ "name": "JwtError",
426
+ "kind": "class",
427
+ "stability": "plugins",
428
+ "deprecated": null,
429
+ "summary": "A token that failed verification, or keys that could not be read.",
430
+ "description": "The\nmessage says why, never the token.",
431
+ "members": [],
432
+ "examples": [],
433
+ "see": [],
434
+ "references": []
435
+ },
436
+ {
437
+ "name": "KeySet",
438
+ "kind": "class",
439
+ "stability": "plugins",
440
+ "deprecated": null,
441
+ "summary": "Fetches and caches a provider's signing keys, fetching again when a token names a key it has not seen (at most once a minute).",
442
+ "description": "",
443
+ "members": [
444
+ {
445
+ "name": "(constructor)",
446
+ "type": "(url: string, fetcher?: typeof fetch)",
447
+ "required": true,
448
+ "default": null,
449
+ "description": "A key set read from a provider's JWKS URL, with an optional fetch for tests.",
450
+ "stability": "stable",
451
+ "deprecated": null
452
+ },
453
+ {
454
+ "name": "get",
455
+ "type": "(kid: string): Promise<Jwk>",
456
+ "required": true,
457
+ "default": null,
458
+ "description": "The key with this id, fetching the key set again if it is not known yet. Throws JwtError when there is none.",
459
+ "stability": "stable",
460
+ "deprecated": null
461
+ }
462
+ ],
463
+ "examples": [],
464
+ "see": [],
465
+ "references": [
466
+ "Jwk"
467
+ ]
468
+ },
469
+ {
470
+ "name": "microsoft",
471
+ "kind": "function",
472
+ "stability": "stable",
473
+ "deprecated": null,
474
+ "summary": "Sign in with Microsoft: work, school and personal accounts (OpenID Connect).",
475
+ "description": "Microsoft does not promise emails are verified, so they are never marked so.",
476
+ "signatures": [
477
+ {
478
+ "text": "microsoft(options: Credentials & {\n tenant?: string;\n}): Provider",
479
+ "parameters": [
480
+ {
481
+ "name": "options",
482
+ "type": "Credentials & {\n tenant?: string;\n}",
483
+ "required": true,
484
+ "default": null,
485
+ "description": "Your client id and secret, and `tenant`: \"common\" (default), \"organizations\", \"consumers\" or a tenant id.",
486
+ "stability": "stable",
487
+ "deprecated": null
488
+ }
489
+ ],
490
+ "returns": {
491
+ "type": "Provider",
492
+ "description": null
493
+ }
494
+ }
495
+ ],
496
+ "examples": [],
497
+ "see": [],
498
+ "references": [
499
+ "Provider"
500
+ ]
501
+ },
502
+ {
503
+ "name": "oidc",
504
+ "kind": "function",
505
+ "stability": "stable",
506
+ "deprecated": null,
507
+ "summary": "Any OpenID Connect provider: Okta, Auth0, Keycloak, Entra ID, Cognito, GitLab and others.",
508
+ "description": "",
509
+ "signatures": [
510
+ {
511
+ "text": "oidc(options: OidcOptions): Provider",
512
+ "parameters": [
513
+ {
514
+ "name": "options",
515
+ "type": "OidcOptions",
516
+ "required": true,
517
+ "default": null,
518
+ "description": "Its id, name, issuer, and your client id and secret.",
519
+ "stability": "stable",
520
+ "deprecated": null
521
+ }
522
+ ],
523
+ "returns": {
524
+ "type": "Provider",
525
+ "description": null
526
+ }
527
+ }
528
+ ],
529
+ "examples": [
530
+ {
531
+ "code": "oidc({ id: 'okta', name: 'Okta', issuer: 'https://dev-123.okta.com', clientId: '...', clientSecret: process.env.OKTA_SECRET! })"
532
+ }
533
+ ],
534
+ "see": [],
535
+ "references": [
536
+ "OidcOptions",
537
+ "Provider"
538
+ ]
539
+ },
540
+ {
541
+ "name": "OidcOptions",
542
+ "kind": "interface",
543
+ "stability": "stable",
544
+ "deprecated": null,
545
+ "summary": "What oidc() takes.",
546
+ "description": "",
547
+ "members": [
548
+ {
549
+ "name": "id",
550
+ "type": "string",
551
+ "required": true,
552
+ "default": null,
553
+ "description": "The provider's id, in sign-in URLs: lowercase letters, digits and hyphens.",
554
+ "stability": "stable",
555
+ "deprecated": null
556
+ },
557
+ {
558
+ "name": "name",
559
+ "type": "string",
560
+ "required": true,
561
+ "default": null,
562
+ "description": "Shown on the sign-in button: \"Continue with <name>\".",
563
+ "stability": "stable",
564
+ "deprecated": null
565
+ },
566
+ {
567
+ "name": "issuer",
568
+ "type": "string",
569
+ "required": true,
570
+ "default": null,
571
+ "description": "The issuer URL; its endpoints are read from /.well-known/openid-configuration.",
572
+ "stability": "stable",
573
+ "deprecated": null
574
+ },
575
+ {
576
+ "name": "scopes",
577
+ "type": "string[]",
578
+ "required": false,
579
+ "default": null,
580
+ "description": "Default [\"openid\", \"email\", \"profile\"].",
581
+ "stability": "stable",
582
+ "deprecated": null
583
+ }
584
+ ],
585
+ "extends": [
586
+ "Credentials"
587
+ ],
588
+ "examples": [],
589
+ "see": [],
590
+ "references": []
591
+ },
592
+ {
593
+ "name": "Profile",
594
+ "kind": "interface",
595
+ "stability": "stable",
596
+ "deprecated": null,
597
+ "summary": "What a provider tells us about the person.",
598
+ "description": "",
599
+ "members": [
600
+ {
601
+ "name": "subject",
602
+ "type": "string",
603
+ "required": true,
604
+ "default": null,
605
+ "description": "The provider's stable ID for the person.",
606
+ "stability": "stable",
607
+ "deprecated": null
608
+ },
609
+ {
610
+ "name": "email",
611
+ "type": "string",
612
+ "required": false,
613
+ "default": null,
614
+ "description": "Their email address, if the provider shared it.",
615
+ "stability": "stable",
616
+ "deprecated": null
617
+ },
618
+ {
619
+ "name": "emailVerified",
620
+ "type": "boolean",
621
+ "required": true,
622
+ "default": null,
623
+ "description": "Whether the provider verified the email. Never link accounts by an unverified email.",
624
+ "stability": "stable",
625
+ "deprecated": null
626
+ },
627
+ {
628
+ "name": "name",
629
+ "type": "string",
630
+ "required": false,
631
+ "default": null,
632
+ "description": "Their display name.",
633
+ "stability": "stable",
634
+ "deprecated": null
635
+ },
636
+ {
637
+ "name": "picture",
638
+ "type": "string",
639
+ "required": false,
640
+ "default": null,
641
+ "description": "An https URL of their picture.",
642
+ "stability": "stable",
643
+ "deprecated": null
644
+ }
645
+ ],
646
+ "examples": [],
647
+ "see": [],
648
+ "references": []
649
+ },
650
+ {
651
+ "name": "Provider",
652
+ "kind": "interface",
653
+ "stability": "plugins",
654
+ "deprecated": null,
655
+ "summary": "A sign-in provider, from google(), microsoft(), github(), apple() or oidc(): a few facts about the provider and how to read its answer.",
656
+ "description": "",
657
+ "members": [
658
+ {
659
+ "name": "id",
660
+ "type": "string",
661
+ "required": true,
662
+ "default": null,
663
+ "description": "The provider's id, in sign-in URLs: /auth/<id>.",
664
+ "stability": "stable",
665
+ "deprecated": null
666
+ },
667
+ {
668
+ "name": "name",
669
+ "type": "string",
670
+ "required": true,
671
+ "default": null,
672
+ "description": "Shown on the sign-in button: \"Continue with <name>\".",
673
+ "stability": "stable",
674
+ "deprecated": null
675
+ },
676
+ {
677
+ "name": "clientId",
678
+ "type": "string",
679
+ "required": true,
680
+ "default": null,
681
+ "description": "Your app's client id at the provider.",
682
+ "stability": "stable",
683
+ "deprecated": null
684
+ },
685
+ {
686
+ "name": "clientSecret",
687
+ "type": "string | (() => Promise<string>)",
688
+ "required": false,
689
+ "default": null,
690
+ "description": "A fixed secret, or a function for providers whose secret is a short-lived token (Apple).",
691
+ "stability": "stable",
692
+ "deprecated": null
693
+ },
694
+ {
695
+ "name": "scopes",
696
+ "type": "string[]",
697
+ "required": true,
698
+ "default": null,
699
+ "description": "The scopes asked for.",
700
+ "stability": "stable",
701
+ "deprecated": null
702
+ },
703
+ {
704
+ "name": "issuer",
705
+ "type": "string",
706
+ "required": false,
707
+ "default": null,
708
+ "description": "OpenID Connect issuer. Set this, or the endpoints below.",
709
+ "stability": "stable",
710
+ "deprecated": null
711
+ },
712
+ {
713
+ "name": "issuerCheck",
714
+ "type": "(iss: string, claims: Claims) => boolean",
715
+ "required": false,
716
+ "default": null,
717
+ "description": "For providers whose issuer varies, such as Microsoft's multi-tenant endpoint.",
718
+ "stability": "stable",
719
+ "deprecated": null
720
+ },
721
+ {
722
+ "name": "authorizationEndpoint",
723
+ "type": "string",
724
+ "required": false,
725
+ "default": null,
726
+ "description": "Where people are sent to sign in, when there is no issuer to discover it from.",
727
+ "stability": "stable",
728
+ "deprecated": null
729
+ },
730
+ {
731
+ "name": "tokenEndpoint",
732
+ "type": "string",
733
+ "required": false,
734
+ "default": null,
735
+ "description": "Where the code is exchanged for tokens, when there is no issuer.",
736
+ "stability": "stable",
737
+ "deprecated": null
738
+ },
739
+ {
740
+ "name": "jwksUri",
741
+ "type": "string",
742
+ "required": false,
743
+ "default": null,
744
+ "description": "Where the provider's signing keys are, when there is no issuer.",
745
+ "stability": "stable",
746
+ "deprecated": null
747
+ },
748
+ {
749
+ "name": "oidc",
750
+ "type": "boolean",
751
+ "required": true,
752
+ "default": null,
753
+ "description": "Whether the provider returns an ID token to verify.",
754
+ "stability": "stable",
755
+ "deprecated": null
756
+ },
757
+ {
758
+ "name": "responseMode",
759
+ "type": "'query' | 'form_post'",
760
+ "required": false,
761
+ "default": null,
762
+ "description": "Some providers post the callback as a form (Apple, when asking for name and email).",
763
+ "stability": "stable",
764
+ "deprecated": null
765
+ },
766
+ {
767
+ "name": "authorizationParams",
768
+ "type": "Record<string, string>",
769
+ "required": false,
770
+ "default": null,
771
+ "description": "Extra parameters for the authorization request, such as prompt.",
772
+ "stability": "stable",
773
+ "deprecated": null
774
+ },
775
+ {
776
+ "name": "tokenAuth",
777
+ "type": "'post' | 'basic'",
778
+ "required": false,
779
+ "default": null,
780
+ "description": "How the client secret is sent to the token endpoint: in the body, or as HTTP Basic.",
781
+ "stability": "stable",
782
+ "deprecated": null
783
+ },
784
+ {
785
+ "name": "profile",
786
+ "type": "(input: ProfileInput): Promise<Profile>",
787
+ "required": true,
788
+ "default": null,
789
+ "description": "Reads the person's profile from the verified ID token, or from the provider's API.",
790
+ "stability": "stable",
791
+ "deprecated": null
792
+ }
793
+ ],
794
+ "examples": [],
795
+ "see": [],
796
+ "references": [
797
+ "Claims",
798
+ "Profile"
799
+ ]
800
+ },
801
+ {
802
+ "name": "requireRecentSignIn",
803
+ "kind": "function",
804
+ "stability": "stable",
805
+ "deprecated": null,
806
+ "summary": "For the page in front of something sensitive (changing an email, deleting an account): sends people who signed in more than `seconds` ago (default five minutes) to sign in again, and back here afterwards.",
807
+ "description": "The provider is\nasked to make them enter their credentials again, and providers that speak\nOpenID Connect must prove it. Guard the action itself too, with\npermission: (ctx) => signedInWithin(ctx, 300) from @pexis/sessions.",
808
+ "signatures": [
809
+ {
810
+ "text": "requireRecentSignIn(ctx?: Context, seconds?: number): Redirect | null",
811
+ "parameters": [
812
+ {
813
+ "name": "ctx",
814
+ "type": "Context",
815
+ "required": false,
816
+ "default": "the current request's",
817
+ "description": "The request's context. Default: the current request's.",
818
+ "stability": "stable",
819
+ "deprecated": null
820
+ },
821
+ {
822
+ "name": "seconds",
823
+ "type": "number",
824
+ "required": false,
825
+ "default": "300",
826
+ "description": "How recent the sign-in must be. Default: 300.",
827
+ "stability": "stable",
828
+ "deprecated": null
829
+ }
830
+ ],
831
+ "returns": {
832
+ "type": "Redirect | null",
833
+ "description": "A redirect to sign in again, or null when the sign-in is recent enough."
834
+ }
835
+ }
836
+ ],
837
+ "examples": [
838
+ {
839
+ "code": "load: (ctx) => requireRecentSignIn(ctx) ?? loadSettings(ctx.user!),"
840
+ }
841
+ ],
842
+ "see": [],
843
+ "references": [
844
+ "Context",
845
+ "Redirect"
846
+ ]
847
+ },
848
+ {
849
+ "name": "requireUser",
850
+ "kind": "function",
851
+ "stability": "stable",
852
+ "deprecated": null,
853
+ "summary": "For a page's load(): sends visitors who are not signed in to the sign-in page, and back here afterwards.",
854
+ "description": "",
855
+ "signatures": [
856
+ {
857
+ "text": "requireUser(ctx?: Context): Redirect | null",
858
+ "parameters": [
859
+ {
860
+ "name": "ctx",
861
+ "type": "Context",
862
+ "required": false,
863
+ "default": "the current request's",
864
+ "description": "The request's context. Default: the current request's.",
865
+ "stability": "stable",
866
+ "deprecated": null
867
+ }
868
+ ],
869
+ "returns": {
870
+ "type": "Redirect | null",
871
+ "description": "A redirect to sign in, or null when the visitor is signed in."
872
+ }
873
+ }
874
+ ],
875
+ "examples": [
876
+ {
877
+ "code": "load: (ctx) => requireUser(ctx) ?? loadAccount(ctx.user!),"
878
+ }
879
+ ],
880
+ "see": [],
881
+ "references": [
882
+ "Context",
883
+ "Redirect"
884
+ ]
885
+ },
886
+ {
887
+ "name": "safeReturnTo",
888
+ "kind": "function",
889
+ "stability": "plugins",
890
+ "deprecated": null,
891
+ "summary": "A path to return to after sign-in, only if it is on this site: never another origin, never \"//host\".",
892
+ "description": "Anything else gives the fallback.",
893
+ "signatures": [
894
+ {
895
+ "text": "safeReturnTo(value: string | null | undefined, fallback?: string): string",
896
+ "parameters": [
897
+ {
898
+ "name": "value",
899
+ "type": "string | null | undefined",
900
+ "required": true,
901
+ "default": null,
902
+ "description": "The requested path.",
903
+ "stability": "stable",
904
+ "deprecated": null
905
+ },
906
+ {
907
+ "name": "fallback",
908
+ "type": "string",
909
+ "required": false,
910
+ "default": "\"/\"",
911
+ "description": "Where to go instead. Default: \"/\".",
912
+ "stability": "stable",
913
+ "deprecated": null
914
+ }
915
+ ],
916
+ "returns": {
917
+ "type": "string",
918
+ "description": null
919
+ }
920
+ }
921
+ ],
922
+ "examples": [],
923
+ "see": [],
924
+ "references": []
925
+ },
926
+ {
927
+ "name": "signEs256",
928
+ "kind": "function",
929
+ "stability": "plugins",
930
+ "deprecated": null,
931
+ "summary": "Signs an ES256 token with a PKCS#8 PEM private key, for Apple's client secret.",
932
+ "description": "",
933
+ "signatures": [
934
+ {
935
+ "text": "signEs256(header: Record<string, unknown>, claims: Record<string, unknown>, pem: string): Promise<string>",
936
+ "parameters": [
937
+ {
938
+ "name": "header",
939
+ "type": "Record<string, unknown>",
940
+ "required": true,
941
+ "default": null,
942
+ "description": "The JOSE header; `alg` is set to ES256.",
943
+ "stability": "stable",
944
+ "deprecated": null
945
+ },
946
+ {
947
+ "name": "claims",
948
+ "type": "Record<string, unknown>",
949
+ "required": true,
950
+ "default": null,
951
+ "description": "The claims.",
952
+ "stability": "stable",
953
+ "deprecated": null
954
+ },
955
+ {
956
+ "name": "pem",
957
+ "type": "string",
958
+ "required": true,
959
+ "default": null,
960
+ "description": "The private key, as PEM text.",
961
+ "stability": "stable",
962
+ "deprecated": null
963
+ }
964
+ ],
965
+ "returns": {
966
+ "type": "Promise<string>",
967
+ "description": null
968
+ }
969
+ }
970
+ ],
971
+ "examples": [],
972
+ "see": [],
973
+ "references": []
974
+ },
975
+ {
976
+ "name": "SignInLink",
977
+ "kind": "component",
978
+ "stability": "stable",
979
+ "deprecated": null,
980
+ "summary": "A link that starts signing in with a provider.",
981
+ "description": "",
982
+ "signatures": [
983
+ {
984
+ "text": "SignInLink({ provider, returnTo, fresh, children }: {\n provider: string;\n returnTo?: string;\n fresh?: boolean;\n children?: Child;\n}): Markup",
985
+ "parameters": [
986
+ {
987
+ "name": "props",
988
+ "type": "{\n provider: string;\n returnTo?: string;\n fresh?: boolean;\n children?: Child;\n}",
989
+ "required": true,
990
+ "default": null,
991
+ "description": "The provider, where to return, and the link's text.",
992
+ "stability": "stable",
993
+ "deprecated": null,
994
+ "members": [
995
+ {
996
+ "name": "provider",
997
+ "type": "string",
998
+ "required": true,
999
+ "default": null,
1000
+ "description": "The provider's id, such as \"google\".",
1001
+ "stability": "stable",
1002
+ "deprecated": null
1003
+ },
1004
+ {
1005
+ "name": "returnTo",
1006
+ "type": "string",
1007
+ "required": false,
1008
+ "default": null,
1009
+ "description": "A path on this site to come back to afterwards.",
1010
+ "stability": "stable",
1011
+ "deprecated": null
1012
+ },
1013
+ {
1014
+ "name": "fresh",
1015
+ "type": "boolean",
1016
+ "required": false,
1017
+ "default": null,
1018
+ "description": "Ask the provider to make the person sign in again, even if they are signed in there.",
1019
+ "stability": "stable",
1020
+ "deprecated": null
1021
+ },
1022
+ {
1023
+ "name": "children",
1024
+ "type": "Child",
1025
+ "required": false,
1026
+ "default": null,
1027
+ "description": "The link's text. Default: \"Sign in\".",
1028
+ "stability": "stable",
1029
+ "deprecated": null
1030
+ }
1031
+ ]
1032
+ }
1033
+ ],
1034
+ "returns": {
1035
+ "type": "Markup",
1036
+ "description": null
1037
+ }
1038
+ }
1039
+ ],
1040
+ "examples": [
1041
+ {
1042
+ "code": "<SignInLink provider=\"google\" returnTo=\"/account\">Continue with Google</SignInLink>"
1043
+ }
1044
+ ],
1045
+ "see": [],
1046
+ "references": [
1047
+ "Child",
1048
+ "Markup"
1049
+ ]
1050
+ },
1051
+ {
1052
+ "name": "SignOutButton",
1053
+ "kind": "component",
1054
+ "stability": "stable",
1055
+ "deprecated": null,
1056
+ "summary": "A sign-out button.",
1057
+ "description": "Signing out is a POST, so other sites cannot sign people out.",
1058
+ "signatures": [
1059
+ {
1060
+ "text": "SignOutButton({ children }: {\n children?: Child;\n}): Markup",
1061
+ "parameters": [
1062
+ {
1063
+ "name": "props",
1064
+ "type": "{\n children?: Child;\n}",
1065
+ "required": true,
1066
+ "default": null,
1067
+ "description": "The button's text.",
1068
+ "stability": "stable",
1069
+ "deprecated": null,
1070
+ "members": [
1071
+ {
1072
+ "name": "children",
1073
+ "type": "Child",
1074
+ "required": false,
1075
+ "default": null,
1076
+ "description": "The button's text. Default: \"Sign out\".",
1077
+ "stability": "stable",
1078
+ "deprecated": null
1079
+ }
1080
+ ]
1081
+ }
1082
+ ],
1083
+ "returns": {
1084
+ "type": "Markup",
1085
+ "description": null
1086
+ }
1087
+ }
1088
+ ],
1089
+ "examples": [],
1090
+ "see": [],
1091
+ "references": [
1092
+ "Child",
1093
+ "Markup"
1094
+ ]
1095
+ },
1096
+ {
1097
+ "name": "TokenResponse",
1098
+ "kind": "interface",
1099
+ "stability": "plugins",
1100
+ "deprecated": null,
1101
+ "summary": "What a provider's token endpoint answered, as OAuth names it.",
1102
+ "description": "",
1103
+ "members": [
1104
+ {
1105
+ "name": "access_token",
1106
+ "type": "string",
1107
+ "required": false,
1108
+ "default": null,
1109
+ "description": "The access token, for calling the provider's API. Never logged.",
1110
+ "stability": "stable",
1111
+ "deprecated": null
1112
+ },
1113
+ {
1114
+ "name": "id_token",
1115
+ "type": "string",
1116
+ "required": false,
1117
+ "default": null,
1118
+ "description": "The OpenID Connect ID token, verified before use.",
1119
+ "stability": "stable",
1120
+ "deprecated": null
1121
+ },
1122
+ {
1123
+ "name": "token_type",
1124
+ "type": "string",
1125
+ "required": false,
1126
+ "default": null,
1127
+ "description": "Usually \"Bearer\".",
1128
+ "stability": "stable",
1129
+ "deprecated": null
1130
+ },
1131
+ {
1132
+ "name": "expires_in",
1133
+ "type": "number",
1134
+ "required": false,
1135
+ "default": null,
1136
+ "description": "Seconds until the access token expires.",
1137
+ "stability": "stable",
1138
+ "deprecated": null
1139
+ },
1140
+ {
1141
+ "name": "scope",
1142
+ "type": "string",
1143
+ "required": false,
1144
+ "default": null,
1145
+ "description": "The scopes granted, space-separated.",
1146
+ "stability": "stable",
1147
+ "deprecated": null
1148
+ },
1149
+ {
1150
+ "name": "[key: string]",
1151
+ "type": "unknown",
1152
+ "required": true,
1153
+ "default": null,
1154
+ "description": "Any other fields the provider sent.",
1155
+ "stability": "stable",
1156
+ "deprecated": null
1157
+ }
1158
+ ],
1159
+ "examples": [],
1160
+ "see": [],
1161
+ "references": []
1162
+ },
1163
+ {
1164
+ "name": "verifyJwt",
1165
+ "kind": "function",
1166
+ "stability": "plugins",
1167
+ "deprecated": null,
1168
+ "summary": "Verifies a JWT's signature (RS256 or ES256), issuer, audience, expiry and nonce, and returns its claims.",
1169
+ "description": "Throws JwtError when anything is wrong.",
1170
+ "signatures": [
1171
+ {
1172
+ "text": "verifyJwt(token: string, keys: {\n get(kid: string): Promise<Jwk>;\n}, expect: Expectations): Promise<Claims>",
1173
+ "parameters": [
1174
+ {
1175
+ "name": "token",
1176
+ "type": "string",
1177
+ "required": true,
1178
+ "default": null,
1179
+ "description": "A compact JWT.",
1180
+ "stability": "stable",
1181
+ "deprecated": null
1182
+ },
1183
+ {
1184
+ "name": "keys",
1185
+ "type": "{\n get(kid: string): Promise<Jwk>;\n}",
1186
+ "required": true,
1187
+ "default": null,
1188
+ "description": "Where to find the signing key by id, such as a KeySet.",
1189
+ "stability": "stable",
1190
+ "deprecated": null,
1191
+ "members": [
1192
+ {
1193
+ "name": "get",
1194
+ "type": "(kid: string): Promise<Jwk>",
1195
+ "required": true,
1196
+ "default": null,
1197
+ "description": "The key with this id.",
1198
+ "stability": "stable",
1199
+ "deprecated": null
1200
+ }
1201
+ ]
1202
+ },
1203
+ {
1204
+ "name": "expect",
1205
+ "type": "Expectations",
1206
+ "required": true,
1207
+ "default": null,
1208
+ "description": "The issuer, audience and nonce the token must have.",
1209
+ "stability": "stable",
1210
+ "deprecated": null
1211
+ }
1212
+ ],
1213
+ "returns": {
1214
+ "type": "Promise<Claims>",
1215
+ "description": null
1216
+ }
1217
+ }
1218
+ ],
1219
+ "examples": [],
1220
+ "see": [],
1221
+ "references": [
1222
+ "Claims",
1223
+ "Jwk"
1224
+ ]
1225
+ }
1226
+ ]
1227
+ },
1228
+ {
1229
+ "import": "@pexis/auth/server",
1230
+ "exports": [
1231
+ {
1232
+ "name": "bearerToken",
1233
+ "kind": "function",
1234
+ "stability": "experimental",
1235
+ "deprecated": null,
1236
+ "summary": "The Bearer token in an Authorization header, or null.",
1237
+ "description": "Other schemes (Basic) are not ours.",
1238
+ "signatures": [
1239
+ {
1240
+ "text": "bearerToken(request: Request): string | null",
1241
+ "parameters": [
1242
+ {
1243
+ "name": "request",
1244
+ "type": "Request",
1245
+ "required": true,
1246
+ "default": null,
1247
+ "description": "The request.",
1248
+ "stability": "stable",
1249
+ "deprecated": null
1250
+ }
1251
+ ],
1252
+ "returns": {
1253
+ "type": "string | null",
1254
+ "description": null
1255
+ }
1256
+ }
1257
+ ],
1258
+ "examples": [],
1259
+ "see": [],
1260
+ "references": []
1261
+ },
1262
+ {
1263
+ "name": "checkRedirectUri",
1264
+ "kind": "function",
1265
+ "stability": "experimental",
1266
+ "deprecated": null,
1267
+ "summary": "A redirect URI a client may list: https, or http on a loopback address for apps on the person's computer (RFC 8252).",
1268
+ "description": "Throws ClientError otherwise.",
1269
+ "signatures": [
1270
+ {
1271
+ "text": "checkRedirectUri(raw: string): URL",
1272
+ "parameters": [
1273
+ {
1274
+ "name": "raw",
1275
+ "type": "string",
1276
+ "required": true,
1277
+ "default": null,
1278
+ "description": "The redirect URI as listed.",
1279
+ "stability": "stable",
1280
+ "deprecated": null
1281
+ }
1282
+ ],
1283
+ "returns": {
1284
+ "type": "URL",
1285
+ "description": null
1286
+ }
1287
+ }
1288
+ ],
1289
+ "examples": [],
1290
+ "see": [],
1291
+ "references": []
1292
+ },
1293
+ {
1294
+ "name": "ClientError",
1295
+ "kind": "class",
1296
+ "stability": "experimental",
1297
+ "deprecated": null,
1298
+ "summary": "A client that cannot be used, with a reason safe to show the person.",
1299
+ "description": "",
1300
+ "members": [],
1301
+ "examples": [],
1302
+ "see": [],
1303
+ "references": []
1304
+ },
1305
+ {
1306
+ "name": "clientIdUrl",
1307
+ "kind": "function",
1308
+ "stability": "experimental",
1309
+ "deprecated": null,
1310
+ "summary": "The client_id as a URL, or a ClientError saying why it cannot be one.",
1311
+ "description": "",
1312
+ "signatures": [
1313
+ {
1314
+ "text": "clientIdUrl(raw: string): URL",
1315
+ "parameters": [
1316
+ {
1317
+ "name": "raw",
1318
+ "type": "string",
1319
+ "required": true,
1320
+ "default": null,
1321
+ "description": "The client_id as sent.",
1322
+ "stability": "stable",
1323
+ "deprecated": null
1324
+ }
1325
+ ],
1326
+ "returns": {
1327
+ "type": "URL",
1328
+ "description": null
1329
+ }
1330
+ }
1331
+ ],
1332
+ "examples": [],
1333
+ "see": [],
1334
+ "references": []
1335
+ },
1336
+ {
1337
+ "name": "clientLoader",
1338
+ "kind": "function",
1339
+ "stability": "experimental",
1340
+ "deprecated": null,
1341
+ "summary": "A cached, rate-limited loader of client metadata documents.",
1342
+ "description": "",
1343
+ "signatures": [
1344
+ {
1345
+ "text": "clientLoader(options: ClientLoaderOptions): ClientLoader",
1346
+ "parameters": [
1347
+ {
1348
+ "name": "options",
1349
+ "type": "ClientLoaderOptions",
1350
+ "required": true,
1351
+ "default": null,
1352
+ "description": "The fetch, and cache and concurrency limits.",
1353
+ "stability": "stable",
1354
+ "deprecated": null
1355
+ }
1356
+ ],
1357
+ "returns": {
1358
+ "type": "ClientLoader",
1359
+ "description": null
1360
+ }
1361
+ }
1362
+ ],
1363
+ "examples": [],
1364
+ "see": [],
1365
+ "references": [
1366
+ "ClientLoader",
1367
+ "ClientLoaderOptions"
1368
+ ]
1369
+ },
1370
+ {
1371
+ "name": "ClientLoader",
1372
+ "kind": "interface",
1373
+ "stability": "experimental",
1374
+ "deprecated": null,
1375
+ "summary": "Loads and caches client metadata, with limits on fetches at once.",
1376
+ "description": "",
1377
+ "members": [
1378
+ {
1379
+ "name": "load",
1380
+ "type": "(clientId: string): Promise<ClientMetadata>",
1381
+ "required": true,
1382
+ "default": null,
1383
+ "description": "The client, from the cache or fetched. Throws ClientError.",
1384
+ "stability": "stable",
1385
+ "deprecated": null
1386
+ }
1387
+ ],
1388
+ "examples": [],
1389
+ "see": [],
1390
+ "references": [
1391
+ "ClientMetadata"
1392
+ ]
1393
+ },
1394
+ {
1395
+ "name": "ClientLoaderOptions",
1396
+ "kind": "interface",
1397
+ "stability": "experimental",
1398
+ "deprecated": null,
1399
+ "summary": "What clientLoader() takes.",
1400
+ "description": "",
1401
+ "members": [
1402
+ {
1403
+ "name": "fetch",
1404
+ "type": "MetadataFetch",
1405
+ "required": true,
1406
+ "default": null,
1407
+ "description": "How metadata documents are fetched.",
1408
+ "stability": "stable",
1409
+ "deprecated": null
1410
+ },
1411
+ {
1412
+ "name": "maxEntries",
1413
+ "type": "number",
1414
+ "required": false,
1415
+ "default": null,
1416
+ "description": "Cached clients and failures, at most. Default 1000.",
1417
+ "stability": "stable",
1418
+ "deprecated": null
1419
+ },
1420
+ {
1421
+ "name": "concurrency",
1422
+ "type": "number",
1423
+ "required": false,
1424
+ "default": null,
1425
+ "description": "Fetches running at once, in all. Default 8.",
1426
+ "stability": "stable",
1427
+ "deprecated": null
1428
+ },
1429
+ {
1430
+ "name": "perHost",
1431
+ "type": "number",
1432
+ "required": false,
1433
+ "default": null,
1434
+ "description": "Fetches running at once to one host. Default 2.",
1435
+ "stability": "stable",
1436
+ "deprecated": null
1437
+ }
1438
+ ],
1439
+ "examples": [],
1440
+ "see": [],
1441
+ "references": [
1442
+ "MetadataFetch"
1443
+ ]
1444
+ },
1445
+ {
1446
+ "name": "ClientMetadata",
1447
+ "kind": "interface",
1448
+ "stability": "experimental",
1449
+ "deprecated": null,
1450
+ "summary": "An OAuth client, from its Client ID Metadata Document.",
1451
+ "description": "",
1452
+ "members": [
1453
+ {
1454
+ "name": "clientId",
1455
+ "type": "string",
1456
+ "required": true,
1457
+ "default": null,
1458
+ "description": "The client's id: the URL of its metadata document.",
1459
+ "stability": "stable",
1460
+ "deprecated": null
1461
+ },
1462
+ {
1463
+ "name": "name",
1464
+ "type": "string",
1465
+ "required": true,
1466
+ "default": null,
1467
+ "description": "What the client calls itself. Untrusted text: show it escaped, never as the client's identity.",
1468
+ "stability": "stable",
1469
+ "deprecated": null
1470
+ },
1471
+ {
1472
+ "name": "redirectUris",
1473
+ "type": "string[]",
1474
+ "required": true,
1475
+ "default": null,
1476
+ "description": "Where codes may be sent, as the document lists them.",
1477
+ "stability": "stable",
1478
+ "deprecated": null
1479
+ }
1480
+ ],
1481
+ "examples": [],
1482
+ "see": [],
1483
+ "references": []
1484
+ },
1485
+ {
1486
+ "name": "CodeDetails",
1487
+ "kind": "interface",
1488
+ "stability": "experimental",
1489
+ "deprecated": null,
1490
+ "summary": "What a code was issued for, checked again at the token endpoint.",
1491
+ "description": "",
1492
+ "members": [
1493
+ {
1494
+ "name": "redirectUri",
1495
+ "type": "string",
1496
+ "required": true,
1497
+ "default": null,
1498
+ "description": "The redirect URI the code was sent to; the token request must name the same one.",
1499
+ "stability": "stable",
1500
+ "deprecated": null
1501
+ },
1502
+ {
1503
+ "name": "codeChallenge",
1504
+ "type": "string",
1505
+ "required": true,
1506
+ "default": null,
1507
+ "description": "The PKCE challenge the token request's verifier must match.",
1508
+ "stability": "stable",
1509
+ "deprecated": null
1510
+ },
1511
+ {
1512
+ "name": "resource",
1513
+ "type": "string",
1514
+ "required": true,
1515
+ "default": null,
1516
+ "description": "The resource (the MCP endpoint's URL) the token is for.",
1517
+ "stability": "stable",
1518
+ "deprecated": null
1519
+ }
1520
+ ],
1521
+ "examples": [],
1522
+ "see": [],
1523
+ "references": []
1524
+ },
1525
+ {
1526
+ "name": "hashSecret",
1527
+ "kind": "function",
1528
+ "stability": "experimental",
1529
+ "deprecated": null,
1530
+ "summary": "The secret a client holds, as stored: hex SHA-256.",
1531
+ "description": "",
1532
+ "signatures": [
1533
+ {
1534
+ "text": "hashSecret(secret: string): Promise<string>",
1535
+ "parameters": [
1536
+ {
1537
+ "name": "secret",
1538
+ "type": "string",
1539
+ "required": true,
1540
+ "default": null,
1541
+ "description": "The code or token.",
1542
+ "stability": "stable",
1543
+ "deprecated": null
1544
+ }
1545
+ ],
1546
+ "returns": {
1547
+ "type": "Promise<string>",
1548
+ "description": null
1549
+ }
1550
+ }
1551
+ ],
1552
+ "examples": [],
1553
+ "see": [],
1554
+ "references": []
1555
+ },
1556
+ {
1557
+ "name": "isLoopback",
1558
+ "kind": "constant",
1559
+ "stability": "experimental",
1560
+ "deprecated": null,
1561
+ "summary": "Whether a URL is http on a loopback address: an app on the person's own computer.",
1562
+ "description": "",
1563
+ "type": "(url: URL) => boolean",
1564
+ "examples": [],
1565
+ "see": [],
1566
+ "references": []
1567
+ },
1568
+ {
1569
+ "name": "memoryOAuthStore",
1570
+ "kind": "function",
1571
+ "stability": "experimental",
1572
+ "deprecated": null,
1573
+ "summary": "Keeps grants in memory: for development and single-server sites.",
1574
+ "description": "Single\nuse is per process, so with several servers use oauthStore(db) from",
1575
+ "signatures": [
1576
+ {
1577
+ "text": "memoryOAuthStore(options?: {\n maxGrants?: number;\n}): OAuthStore",
1578
+ "parameters": [
1579
+ {
1580
+ "name": "options",
1581
+ "type": "{\n maxGrants?: number;\n}",
1582
+ "required": false,
1583
+ "default": null,
1584
+ "description": "How many grants to keep at most.",
1585
+ "stability": "stable",
1586
+ "deprecated": null,
1587
+ "members": [
1588
+ {
1589
+ "name": "maxGrants",
1590
+ "type": "number",
1591
+ "required": false,
1592
+ "default": "10000",
1593
+ "description": "The most grants kept.",
1594
+ "stability": "stable",
1595
+ "deprecated": null
1596
+ }
1597
+ ]
1598
+ }
1599
+ ],
1600
+ "returns": {
1601
+ "type": "OAuthStore",
1602
+ "description": null
1603
+ }
1604
+ }
1605
+ ],
1606
+ "examples": [],
1607
+ "see": [],
1608
+ "references": [
1609
+ "OAuthStore"
1610
+ ]
1611
+ },
1612
+ {
1613
+ "name": "MetadataFetch",
1614
+ "kind": "type",
1615
+ "stability": "experimental",
1616
+ "deprecated": null,
1617
+ "summary": "Fetches a metadata URL.",
1618
+ "description": "Must not follow redirects, and must stop at maxBytes\nand when the signal aborts. publicFetch from @pexis/node/public-fetch also\nrefuses names that resolve to non-public addresses; the default (web fetch)\ncannot see addresses, so it is accepted only for clients the app lists.",
1619
+ "type": "(url: URL, options: {\n signal: AbortSignal;\n maxBytes: number;\n}) => Promise<MetadataResponse>",
1620
+ "examples": [],
1621
+ "see": [],
1622
+ "references": [
1623
+ "MetadataResponse"
1624
+ ]
1625
+ },
1626
+ {
1627
+ "name": "MetadataResponse",
1628
+ "kind": "interface",
1629
+ "stability": "experimental",
1630
+ "deprecated": null,
1631
+ "summary": "What the loader's fetch returns.",
1632
+ "description": "",
1633
+ "members": [
1634
+ {
1635
+ "name": "status",
1636
+ "type": "number",
1637
+ "required": true,
1638
+ "default": null,
1639
+ "description": "The HTTP status.",
1640
+ "stability": "stable",
1641
+ "deprecated": null
1642
+ },
1643
+ {
1644
+ "name": "headers",
1645
+ "type": "Headers",
1646
+ "required": true,
1647
+ "default": null,
1648
+ "description": "The response headers.",
1649
+ "stability": "stable",
1650
+ "deprecated": null
1651
+ },
1652
+ {
1653
+ "name": "body",
1654
+ "type": "Uint8Array",
1655
+ "required": true,
1656
+ "default": null,
1657
+ "description": "The body, at most maxBytes.",
1658
+ "stability": "stable",
1659
+ "deprecated": null
1660
+ }
1661
+ ],
1662
+ "examples": [],
1663
+ "see": [],
1664
+ "references": []
1665
+ },
1666
+ {
1667
+ "name": "newSecret",
1668
+ "kind": "function",
1669
+ "stability": "experimental",
1670
+ "deprecated": null,
1671
+ "summary": "A new secret: 256 random bits, base64url.",
1672
+ "description": "",
1673
+ "signatures": [
1674
+ {
1675
+ "text": "newSecret(): string",
1676
+ "parameters": [],
1677
+ "returns": {
1678
+ "type": "string",
1679
+ "description": null
1680
+ }
1681
+ }
1682
+ ],
1683
+ "examples": [],
1684
+ "see": [],
1685
+ "references": []
1686
+ },
1687
+ {
1688
+ "name": "OAuthGrant",
1689
+ "kind": "interface",
1690
+ "stability": "experimental",
1691
+ "deprecated": null,
1692
+ "summary": "A person allowed a client to act for them.",
1693
+ "description": "",
1694
+ "members": [
1695
+ {
1696
+ "name": "id",
1697
+ "type": "string",
1698
+ "required": true,
1699
+ "default": null,
1700
+ "description": "The grant's id.",
1701
+ "stability": "stable",
1702
+ "deprecated": null
1703
+ },
1704
+ {
1705
+ "name": "userId",
1706
+ "type": "string",
1707
+ "required": true,
1708
+ "default": null,
1709
+ "description": "The person who allowed it.",
1710
+ "stability": "stable",
1711
+ "deprecated": null
1712
+ },
1713
+ {
1714
+ "name": "clientId",
1715
+ "type": "string",
1716
+ "required": true,
1717
+ "default": null,
1718
+ "description": "The client's metadata URL.",
1719
+ "stability": "stable",
1720
+ "deprecated": null
1721
+ },
1722
+ {
1723
+ "name": "clientName",
1724
+ "type": "string",
1725
+ "required": true,
1726
+ "default": null,
1727
+ "description": "What the client calls itself, as it said at consent. Untrusted text.",
1728
+ "stability": "stable",
1729
+ "deprecated": null
1730
+ },
1731
+ {
1732
+ "name": "redirectHost",
1733
+ "type": "string",
1734
+ "required": true,
1735
+ "default": null,
1736
+ "description": "Where the code was sent, shown on the connected-apps page.",
1737
+ "stability": "stable",
1738
+ "deprecated": null
1739
+ },
1740
+ {
1741
+ "name": "scopes",
1742
+ "type": "string[]",
1743
+ "required": true,
1744
+ "default": null,
1745
+ "description": "What the person allowed: \"actions:read\", and \"actions:write\" for changes.",
1746
+ "stability": "stable",
1747
+ "deprecated": null
1748
+ },
1749
+ {
1750
+ "name": "createdAt",
1751
+ "type": "number",
1752
+ "required": true,
1753
+ "default": null,
1754
+ "description": "When the person allowed it, in ms since the epoch.",
1755
+ "stability": "stable",
1756
+ "deprecated": null
1757
+ },
1758
+ {
1759
+ "name": "expiresAt",
1760
+ "type": "number",
1761
+ "required": true,
1762
+ "default": null,
1763
+ "description": "The grant ends then, however often it is refreshed.",
1764
+ "stability": "stable",
1765
+ "deprecated": null
1766
+ },
1767
+ {
1768
+ "name": "lastUsedAt",
1769
+ "type": "number | null",
1770
+ "required": true,
1771
+ "default": null,
1772
+ "description": "When a token from it was last used, or null.",
1773
+ "stability": "stable",
1774
+ "deprecated": null
1775
+ },
1776
+ {
1777
+ "name": "revokedAt",
1778
+ "type": "number | null",
1779
+ "required": true,
1780
+ "default": null,
1781
+ "description": "When the person or the server revoked it, or null.",
1782
+ "stability": "stable",
1783
+ "deprecated": null
1784
+ }
1785
+ ],
1786
+ "examples": [],
1787
+ "see": [],
1788
+ "references": []
1789
+ },
1790
+ {
1791
+ "name": "oauthServer",
1792
+ "kind": "function",
1793
+ "stability": "experimental",
1794
+ "deprecated": null,
1795
+ "summary": "Lets MCP clients sign in as a person with OAuth 2.1, so they can call actions that need a permission.",
1796
+ "description": "Needs sessions() and auth().",
1797
+ "signatures": [
1798
+ {
1799
+ "text": "oauthServer(options: OAuthServerOptions): Plugin",
1800
+ "parameters": [
1801
+ {
1802
+ "name": "options",
1803
+ "type": "OAuthServerOptions",
1804
+ "required": true,
1805
+ "default": null,
1806
+ "description": "How users are loaded, which clients may sign in, and where grants are kept.",
1807
+ "stability": "stable",
1808
+ "deprecated": null
1809
+ }
1810
+ ],
1811
+ "returns": {
1812
+ "type": "Plugin",
1813
+ "description": null
1814
+ }
1815
+ }
1816
+ ],
1817
+ "examples": [
1818
+ {
1819
+ "code": "oauthServer({ loadUser: (id) => findUser(db, id), clients: ['https://claude.ai/oauth/mcp-client'], store: oauthStore(db) })"
1820
+ }
1821
+ ],
1822
+ "see": [],
1823
+ "references": [
1824
+ "OAuthServerOptions",
1825
+ "Plugin"
1826
+ ]
1827
+ },
1828
+ {
1829
+ "name": "OAuthServerOptions",
1830
+ "kind": "interface",
1831
+ "stability": "experimental",
1832
+ "deprecated": null,
1833
+ "summary": "What oauthServer() takes.",
1834
+ "description": "",
1835
+ "members": [
1836
+ {
1837
+ "name": "loadUser",
1838
+ "type": "(id: string) => User | null | Promise<User | null>",
1839
+ "required": true,
1840
+ "default": null,
1841
+ "description": "The person a grant acts for, looked up again on every request (cached for\na minute), so a banned, deleted or demoted account loses its agents at\nonce. Return null to revoke the grant.",
1842
+ "stability": "stable",
1843
+ "deprecated": null
1844
+ },
1845
+ {
1846
+ "name": "clients",
1847
+ "type": "readonly string[] | 'any'",
1848
+ "required": true,
1849
+ "default": null,
1850
+ "description": "Which clients may sign in: exact client_id URLs, or host names. 'any'\nallows every public https client_id, and needs fetchMetadata from",
1851
+ "stability": "stable",
1852
+ "deprecated": null
1853
+ },
1854
+ {
1855
+ "name": "fetchMetadata",
1856
+ "type": "MetadataFetch",
1857
+ "required": false,
1858
+ "default": null,
1859
+ "description": "How client metadata is fetched. Default: web fetch, allowed only with a list of clients.",
1860
+ "stability": "stable",
1861
+ "deprecated": null
1862
+ },
1863
+ {
1864
+ "name": "store",
1865
+ "type": "OAuthStore",
1866
+ "required": false,
1867
+ "default": null,
1868
+ "description": "Where grants and tokens are kept. Default: memoryOAuthStore(), one server only; use oauthStore(db) from @pexis/data.",
1869
+ "stability": "stable",
1870
+ "deprecated": null
1871
+ },
1872
+ {
1873
+ "name": "grantDays",
1874
+ "type": "number",
1875
+ "required": false,
1876
+ "default": null,
1877
+ "description": "Days a grant lasts at most. Default 30; loopback clients (apps on the person's computer) get at most 7.",
1878
+ "stability": "stable",
1879
+ "deprecated": null
1880
+ },
1881
+ {
1882
+ "name": "connectedAppsPath",
1883
+ "type": "string",
1884
+ "required": false,
1885
+ "default": null,
1886
+ "description": "The connected-apps page. Default \"/account/connected-apps\".",
1887
+ "stability": "stable",
1888
+ "deprecated": null
1889
+ },
1890
+ {
1891
+ "name": "resourcePath",
1892
+ "type": "string",
1893
+ "required": false,
1894
+ "default": null,
1895
+ "description": "The MCP endpoint the tokens are for. Default \"/pexis/mcp\".",
1896
+ "stability": "stable",
1897
+ "deprecated": null
1898
+ }
1899
+ ],
1900
+ "examples": [],
1901
+ "see": [],
1902
+ "references": [
1903
+ "MetadataFetch",
1904
+ "OAuthStore",
1905
+ "User"
1906
+ ]
1907
+ },
1908
+ {
1909
+ "name": "OAuthStore",
1910
+ "kind": "interface",
1911
+ "stability": "experimental",
1912
+ "deprecated": null,
1913
+ "summary": "Where the OAuth server keeps grants, codes and tokens.",
1914
+ "description": "memoryOAuthStore()\nis for one server; oauthStore(db) from @pexis/data shares them.",
1915
+ "members": [
1916
+ {
1917
+ "name": "createGrant",
1918
+ "type": "(grant: OAuthGrant, code: StoredSecret): Promise<void>",
1919
+ "required": true,
1920
+ "default": null,
1921
+ "description": "A new grant and its code, at consent.",
1922
+ "stability": "stable",
1923
+ "deprecated": null
1924
+ },
1925
+ {
1926
+ "name": "getGrant",
1927
+ "type": "(id: string): Promise<OAuthGrant | undefined>",
1928
+ "required": true,
1929
+ "default": null,
1930
+ "description": "The grant with this id, or undefined.",
1931
+ "stability": "stable",
1932
+ "deprecated": null
1933
+ },
1934
+ {
1935
+ "name": "use",
1936
+ "type": "(hash: string, kind: 'code' | 'refresh', now: number): Promise<Use>",
1937
+ "required": true,
1938
+ "default": null,
1939
+ "description": "Uses a code or refresh token once. Atomic: of two callers, one gets ok.",
1940
+ "stability": "stable",
1941
+ "deprecated": null
1942
+ },
1943
+ {
1944
+ "name": "burn",
1945
+ "type": "(hash: string, now: number): Promise<void>",
1946
+ "required": true,
1947
+ "default": null,
1948
+ "description": "Marks a code as used without issuing anything, after a wrong code_verifier.",
1949
+ "stability": "stable",
1950
+ "deprecated": null
1951
+ },
1952
+ {
1953
+ "name": "issue",
1954
+ "type": "(secrets: StoredSecret[]): Promise<void>",
1955
+ "required": true,
1956
+ "default": null,
1957
+ "description": "New access and refresh tokens for a grant.",
1958
+ "stability": "stable",
1959
+ "deprecated": null
1960
+ },
1961
+ {
1962
+ "name": "lookup",
1963
+ "type": "(hash: string): Promise<StoredSecret | undefined>",
1964
+ "required": true,
1965
+ "default": null,
1966
+ "description": "Any code or token by hash, used or not, for revocation.",
1967
+ "stability": "stable",
1968
+ "deprecated": null
1969
+ },
1970
+ {
1971
+ "name": "access",
1972
+ "type": "(hash: string, now: number): Promise<StoredSecret | undefined>",
1973
+ "required": true,
1974
+ "default": null,
1975
+ "description": "An access token, if it exists and has not expired; its grant must still be checked.",
1976
+ "stability": "stable",
1977
+ "deprecated": null
1978
+ },
1979
+ {
1980
+ "name": "revoke",
1981
+ "type": "(grantId: string, now: number): Promise<void>",
1982
+ "required": true,
1983
+ "default": null,
1984
+ "description": "Ends a grant and deletes its tokens. Codes stay, so a reused code is still recognized.",
1985
+ "stability": "stable",
1986
+ "deprecated": null
1987
+ },
1988
+ {
1989
+ "name": "touch",
1990
+ "type": "(grantId: string, now: number): Promise<void>",
1991
+ "required": true,
1992
+ "default": null,
1993
+ "description": "Records when the grant was last used, at most once a minute.",
1994
+ "stability": "stable",
1995
+ "deprecated": null
1996
+ },
1997
+ {
1998
+ "name": "grantsOf",
1999
+ "type": "(userId: string, now: number): Promise<OAuthGrant[]>",
2000
+ "required": true,
2001
+ "default": null,
2002
+ "description": "A person's live grants, newest first, for the connected-apps page.",
2003
+ "stability": "stable",
2004
+ "deprecated": null
2005
+ },
2006
+ {
2007
+ "name": "recent",
2008
+ "type": "(limit: number, now: number): Promise<OAuthGrant[]>",
2009
+ "required": true,
2010
+ "default": null,
2011
+ "description": "Live grants, newest first, for the admin.",
2012
+ "stability": "stable",
2013
+ "deprecated": null
2014
+ }
2015
+ ],
2016
+ "examples": [],
2017
+ "see": [],
2018
+ "references": [
2019
+ "OAuthGrant",
2020
+ "StoredSecret",
2021
+ "Use"
2022
+ ]
2023
+ },
2024
+ {
2025
+ "name": "redirectAllowed",
2026
+ "kind": "function",
2027
+ "stability": "experimental",
2028
+ "deprecated": null,
2029
+ "summary": "Whether a requested redirect URI is one the client listed: exact, except the port of a loopback URI (RFC 8252 §7.3).",
2030
+ "description": "",
2031
+ "signatures": [
2032
+ {
2033
+ "text": "redirectAllowed(client: ClientMetadata, requested: string): boolean",
2034
+ "parameters": [
2035
+ {
2036
+ "name": "client",
2037
+ "type": "ClientMetadata",
2038
+ "required": true,
2039
+ "default": null,
2040
+ "description": "The client.",
2041
+ "stability": "stable",
2042
+ "deprecated": null
2043
+ },
2044
+ {
2045
+ "name": "requested",
2046
+ "type": "string",
2047
+ "required": true,
2048
+ "default": null,
2049
+ "description": "The redirect URI in the request.",
2050
+ "stability": "stable",
2051
+ "deprecated": null
2052
+ }
2053
+ ],
2054
+ "returns": {
2055
+ "type": "boolean",
2056
+ "description": null
2057
+ }
2058
+ }
2059
+ ],
2060
+ "examples": [],
2061
+ "see": [],
2062
+ "references": [
2063
+ "ClientMetadata"
2064
+ ]
2065
+ },
2066
+ {
2067
+ "name": "SCOPES",
2068
+ "kind": "constant",
2069
+ "stability": "experimental",
2070
+ "deprecated": null,
2071
+ "summary": "The scopes a person can grant a client: \"actions:read\" to look things up, \"actions:write\" to make changes (which includes reading).",
2072
+ "description": "",
2073
+ "type": "readonly ['actions:read', 'actions:write']",
2074
+ "examples": [],
2075
+ "see": [],
2076
+ "references": []
2077
+ },
2078
+ {
2079
+ "name": "SecretKind",
2080
+ "kind": "type",
2081
+ "stability": "experimental",
2082
+ "deprecated": null,
2083
+ "summary": "Which kind of secret: an authorization code, an access token or a refresh token.",
2084
+ "description": "",
2085
+ "type": "'code' | 'access' | 'refresh'",
2086
+ "examples": [],
2087
+ "see": [],
2088
+ "references": []
2089
+ },
2090
+ {
2091
+ "name": "StoredSecret",
2092
+ "kind": "interface",
2093
+ "stability": "experimental",
2094
+ "deprecated": null,
2095
+ "summary": "A code or token as stored: only its hash, never the secret itself.",
2096
+ "description": "",
2097
+ "members": [
2098
+ {
2099
+ "name": "hash",
2100
+ "type": "string",
2101
+ "required": true,
2102
+ "default": null,
2103
+ "description": "The secret's SHA-256 hash, as hex.",
2104
+ "stability": "stable",
2105
+ "deprecated": null
2106
+ },
2107
+ {
2108
+ "name": "grantId",
2109
+ "type": "string",
2110
+ "required": true,
2111
+ "default": null,
2112
+ "description": "The grant it belongs to.",
2113
+ "stability": "stable",
2114
+ "deprecated": null
2115
+ },
2116
+ {
2117
+ "name": "kind",
2118
+ "type": "SecretKind",
2119
+ "required": true,
2120
+ "default": null,
2121
+ "description": "What kind of secret it is.",
2122
+ "stability": "stable",
2123
+ "deprecated": null
2124
+ },
2125
+ {
2126
+ "name": "expiresAt",
2127
+ "type": "number",
2128
+ "required": true,
2129
+ "default": null,
2130
+ "description": "It may be used until then.",
2131
+ "stability": "stable",
2132
+ "deprecated": null
2133
+ },
2134
+ {
2135
+ "name": "usedAt",
2136
+ "type": "number | null",
2137
+ "required": true,
2138
+ "default": null,
2139
+ "description": "When a code or refresh token was used, or null; each is used once.",
2140
+ "stability": "stable",
2141
+ "deprecated": null
2142
+ },
2143
+ {
2144
+ "name": "details",
2145
+ "type": "CodeDetails",
2146
+ "required": false,
2147
+ "default": null,
2148
+ "description": "For codes.",
2149
+ "stability": "stable",
2150
+ "deprecated": null
2151
+ }
2152
+ ],
2153
+ "examples": [],
2154
+ "see": [],
2155
+ "references": [
2156
+ "CodeDetails",
2157
+ "SecretKind"
2158
+ ]
2159
+ },
2160
+ {
2161
+ "name": "Use",
2162
+ "kind": "type",
2163
+ "stability": "experimental",
2164
+ "deprecated": null,
2165
+ "summary": "The result of using a code or refresh token.",
2166
+ "description": "",
2167
+ "type": "{\n ok: true;\n secret: StoredSecret;\n} | {\n ok: false;\n reason: 'unknown' | 'expired';\n} | {\n ok: false;\n reason: 'reused';\n grantId: string;\n}",
2168
+ "examples": [],
2169
+ "see": [],
2170
+ "references": [
2171
+ "StoredSecret"
2172
+ ]
2173
+ },
2174
+ {
2175
+ "name": "webMetadataFetch",
2176
+ "kind": "constant",
2177
+ "stability": "experimental",
2178
+ "deprecated": null,
2179
+ "summary": "Web fetch, for clients the app lists by name.",
2180
+ "description": "No redirects, a byte limit counted after decompression.",
2181
+ "type": "MetadataFetch",
2182
+ "examples": [],
2183
+ "see": [],
2184
+ "references": [
2185
+ "MetadataFetch"
2186
+ ]
2187
+ }
2188
+ ]
2189
+ }
2190
+ ]
2191
+ }