@plitzi/sdk-server 0.38.24 → 0.39.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.
Files changed (233) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/README.md +55 -9
  3. package/dist/actions.d.ts +4 -1
  4. package/dist/actions.js +3 -2
  5. package/dist/auth.d.ts +2 -2
  6. package/dist/auth.js +5 -4
  7. package/dist/core/auth/api/accounts.d.ts +11 -0
  8. package/dist/core/auth/api/accounts.js +175 -0
  9. package/dist/core/auth/api/admin.d.ts +41 -0
  10. package/dist/core/auth/api/admin.js +146 -0
  11. package/dist/core/auth/api/context.d.ts +119 -0
  12. package/dist/core/auth/api/context.js +262 -0
  13. package/dist/core/auth/api/factors.d.ts +31 -0
  14. package/dist/core/auth/api/factors.js +209 -0
  15. package/dist/core/auth/api/index.d.ts +94 -0
  16. package/dist/core/auth/api/index.js +43 -0
  17. package/dist/core/auth/api/profile.d.ts +43 -0
  18. package/dist/core/auth/api/profile.js +243 -0
  19. package/dist/core/auth/api/session.d.ts +62 -0
  20. package/dist/core/auth/api/session.js +312 -0
  21. package/dist/core/auth/{api.d.ts → api/types.d.ts} +41 -195
  22. package/dist/core/auth/api/values.d.ts +67 -0
  23. package/dist/core/auth/api/values.js +90 -0
  24. package/dist/core/auth/createAuth.d.ts +49 -39
  25. package/dist/core/auth/createAuth.js +21 -1
  26. package/dist/core/auth/oauth/client.d.ts +2 -2
  27. package/dist/core/auth/oauth/client.js +6 -1
  28. package/dist/core/auth/oauth/index.d.ts +30 -7
  29. package/dist/core/auth/oauth/index.js +33 -14
  30. package/dist/core/auth/oauth/providers/github.js +1 -1
  31. package/dist/core/auth/oauth/providers/google.js +1 -1
  32. package/dist/core/auth/oauth/providers/oidc.d.ts +40 -0
  33. package/dist/core/auth/oauth/providers/oidc.js +197 -0
  34. package/dist/core/auth/oauth/state.d.ts +2 -0
  35. package/dist/core/auth/oauth/state.js +2 -0
  36. package/dist/core/auth/oauth/types.d.ts +21 -3
  37. package/dist/core/auth/oauth/types.js +4 -1
  38. package/dist/core/auth/routes.js +1 -1
  39. package/dist/core/auth/tokens.d.ts +3 -1
  40. package/dist/core/auth/tokens.js +2 -1
  41. package/dist/core/configSeam.d.ts +0 -4
  42. package/dist/core/configSeam.js +12 -1
  43. package/dist/core/createServer.js +16 -4
  44. package/dist/core/freePort.d.ts +10 -0
  45. package/dist/core/freePort.js +39 -1
  46. package/dist/core/handlers/socialRouteHandlers.d.ts +9 -1
  47. package/dist/core/handlers/socialRouteHandlers.js +46 -12
  48. package/dist/core/health.d.ts +1 -0
  49. package/dist/core/health.js +2 -1
  50. package/dist/core/http/stages/authRoutes.d.ts +6 -0
  51. package/dist/core/http/stages/authRoutes.js +42 -1
  52. package/dist/core/http/stages/images.js +5 -3
  53. package/dist/core/http/stages/livePages.js +1 -1
  54. package/dist/core/server/fleet/relay.js +9 -1
  55. package/dist/core/server/fleet/stores.d.ts +7 -0
  56. package/dist/core/server/fleet/stores.js +15 -2
  57. package/dist/core/server/pageServer.js +5 -1
  58. package/dist/core/services/realtime.js +4 -2
  59. package/dist/core/services/registry.js +7 -1
  60. package/dist/core/services/robotsTxt.d.ts +16 -0
  61. package/dist/core/services/robotsTxt.js +50 -0
  62. package/dist/core/services/servedSpace.d.ts +8 -0
  63. package/dist/core/services/servedSpace.js +16 -0
  64. package/dist/core/services/sitemapXml.d.ts +7 -0
  65. package/dist/core/services/sitemapXml.js +37 -0
  66. package/dist/functions-api.d.ts +69 -2
  67. package/dist/helpers/fileStore.d.ts +60 -0
  68. package/dist/helpers/fileStore.js +127 -0
  69. package/dist/helpers/outboundGuard.d.ts +32 -3
  70. package/dist/helpers/outboundGuard.js +50 -5
  71. package/dist/hosts/project/agentRuns.d.ts +24 -0
  72. package/dist/hosts/project/agentRuns.js +107 -0
  73. package/dist/hosts/project/laterAsks.d.ts +41 -0
  74. package/dist/hosts/project/laterAsks.js +117 -0
  75. package/dist/hosts/project/plugins.js +11 -4
  76. package/dist/hosts/project/serveProject.d.ts +8 -1
  77. package/dist/hosts/project/serveProject.js +81 -24
  78. package/dist/hosts/project/spaceFailure.d.ts +4 -0
  79. package/dist/hosts/project/spaceFailure.js +10 -0
  80. package/dist/hosts/project/watchSpace.d.ts +5 -5
  81. package/dist/hosts/project/watchSpace.js +15 -6
  82. package/dist/index.js +2 -2
  83. package/dist/kernel.js +1 -1
  84. package/dist/modules/actions/connectorWrite.js +3 -1
  85. package/dist/modules/actions/index.js +1 -1
  86. package/dist/modules/actions/jobs/fileQueue.d.ts +34 -0
  87. package/dist/modules/actions/jobs/fileQueue.js +72 -0
  88. package/dist/modules/actions/jobs/index.js +3 -3
  89. package/dist/modules/actions/jobs/memoryQueue.js +6 -215
  90. package/dist/modules/actions/jobs/queueDocument.d.ts +14 -0
  91. package/dist/modules/actions/jobs/queueDocument.js +22 -0
  92. package/dist/modules/actions/jobs/queueRules.d.ts +39 -0
  93. package/dist/modules/actions/jobs/queueRules.js +270 -0
  94. package/dist/modules/actions/moduleFor.js +2 -0
  95. package/dist/modules/actions/runtime/fileKv.d.ts +3 -1
  96. package/dist/modules/actions/runtime/fileKv.js +12 -98
  97. package/dist/modules/actions/runtime/guards.d.ts +19 -1
  98. package/dist/modules/actions/runtime/guards.js +10 -1
  99. package/dist/modules/actions/runtime/kvChange.d.ts +40 -0
  100. package/dist/modules/actions/runtime/kvChange.js +23 -1
  101. package/dist/modules/actions/runtime/kvList.d.ts +4 -0
  102. package/dist/modules/actions/runtime/kvList.js +5 -1
  103. package/dist/modules/actions/runtime/kvStore.js +15 -1
  104. package/dist/modules/actions/runtime/namespaceKv.js +2 -0
  105. package/dist/modules/actions/runtime/renderResolver.js +31 -5
  106. package/dist/modules/actions/runtime/runAction.js +16 -6
  107. package/dist/modules/actions/runtime/scope.js +11 -0
  108. package/dist/modules/actions/runtime/taskContext.js +11 -32
  109. package/dist/modules/actions/tasks/auth.js +2 -0
  110. package/dist/modules/actions/tasks/connector.js +6 -2
  111. package/dist/modules/actions/tasks/flow.js +5 -0
  112. package/dist/modules/actions/tasks/http.js +2 -1
  113. package/dist/modules/actions/tasks/kv.js +5 -0
  114. package/dist/modules/actions/tasks/list.js +11 -2
  115. package/dist/modules/actions/tasks/transform.js +2 -0
  116. package/dist/modules/actions/transport/callHandler.js +25 -4
  117. package/dist/modules/actions/types.d.ts +46 -1
  118. package/dist/modules/connectors/engine.d.ts +7 -2
  119. package/dist/modules/connectors/engine.js +4 -4
  120. package/dist/modules/connectors/resolver.d.ts +2 -1
  121. package/dist/modules/connectors/resolver.js +3 -2
  122. package/dist/modules/functions/build.d.ts +7 -2
  123. package/dist/modules/functions/build.js +90 -6
  124. package/dist/modules/functions/capabilities.js +16 -0
  125. package/dist/modules/functions/context.js +6 -2
  126. package/dist/modules/functions/contract.d.ts +39 -1
  127. package/dist/modules/functions/driver.d.ts +2 -1
  128. package/dist/modules/functions/driver.js +35 -0
  129. package/dist/modules/functions/load.d.ts +1 -1
  130. package/dist/modules/functions/load.js +2 -2
  131. package/dist/modules/functions/manifest.js +7 -1
  132. package/dist/modules/functions/oauth.d.ts +1 -1
  133. package/dist/modules/functions/oauth.js +4 -4
  134. package/dist/modules/functions/protocol.d.ts +6 -0
  135. package/dist/modules/functions/sandbox/guest/bytes.d.ts +27 -0
  136. package/dist/modules/functions/sandbox/guest/bytes.js +108 -0
  137. package/dist/modules/functions/sandbox/guest/crypto.d.ts +47 -0
  138. package/dist/modules/functions/sandbox/guest/crypto.js +144 -0
  139. package/dist/modules/functions/sandbox/guest/events.d.ts +152 -0
  140. package/dist/modules/functions/sandbox/guest/events.js +143 -0
  141. package/dist/modules/functions/sandbox/guest/fetch.d.ts +305 -0
  142. package/dist/modules/functions/sandbox/guest/fetch.js +237 -0
  143. package/dist/modules/functions/sandbox/guest/index.d.ts +28 -0
  144. package/dist/modules/functions/sandbox/guest/index.js +130 -0
  145. package/dist/modules/functions/sandbox/{guest.d.ts → guest/types.d.ts} +5 -12
  146. package/dist/modules/functions/sandbox/isolate.js +20 -6
  147. package/dist/modules/functions/space.js +2 -8
  148. package/dist/modules/images/imageProxy.d.ts +3 -2
  149. package/dist/modules/images/imageProxy.js +2 -2
  150. package/dist/modules/mongo/jobQueue.js +0 -19
  151. package/dist/modules/mysql/accounts.js +12 -5
  152. package/dist/modules/mysql/jobs/index.d.ts +1 -1
  153. package/dist/modules/mysql/jobs/schema.d.ts +0 -6
  154. package/dist/modules/mysql/jobs/schema.js +2 -46
  155. package/dist/modules/mysql/schema.js +26 -1
  156. package/dist/modules/mysql/sessions.js +2 -1
  157. package/dist/modules/realtime/handlers.d.ts +9 -4
  158. package/dist/modules/realtime/handlers.js +20 -3
  159. package/dist/modules/realtime/hub.d.ts +4 -2
  160. package/dist/modules/realtime/hub.js +36 -4
  161. package/dist/modules/realtime/index.d.ts +14 -0
  162. package/dist/modules/realtime/index.js +14 -1
  163. package/dist/modules/realtime/presence.d.ts +33 -0
  164. package/dist/modules/realtime/presence.js +56 -0
  165. package/dist/modules/realtime/socket.d.ts +3 -1
  166. package/dist/modules/realtime/socket.js +2 -2
  167. package/dist/modules/rsc/connectorRscData.d.ts +6 -1
  168. package/dist/modules/rsc/connectorRscData.js +27 -6
  169. package/dist/modules/rsc/externalQueryReader.d.ts +28 -0
  170. package/dist/modules/rsc/externalQueryReader.js +43 -0
  171. package/dist/modules/rsc/handler.js +1 -1
  172. package/dist/modules/rsc/resolveRscData.d.ts +11 -1
  173. package/dist/modules/rsc/resolveRscData.js +86 -16
  174. package/dist/modules/runtime/inside.js +1 -1
  175. package/dist/modules/runtime/runner.js +2 -1
  176. package/dist/modules/sqlite/jobQueue.d.ts +35 -0
  177. package/dist/modules/sqlite/jobQueue.js +56 -0
  178. package/dist/modules/sqlite/kv.d.ts +1 -1
  179. package/dist/modules/sqlite/kv.js +2 -10
  180. package/dist/modules/sqlite/open.d.ts +3 -0
  181. package/dist/modules/sqlite/open.js +13 -0
  182. package/dist/modules/ssr/Component.d.ts +5 -1
  183. package/dist/modules/ssr/Component.js +3 -1
  184. package/dist/modules/ssr/applySSRResult.d.ts +8 -1
  185. package/dist/modules/ssr/applySSRResult.js +23 -3
  186. package/dist/modules/ssr/handler.js +30 -5
  187. package/dist/modules/ssr/prepareRender.js +27 -5
  188. package/dist/modules/ssr/preview.d.ts +2 -0
  189. package/dist/modules/ssr/preview.js +6 -3
  190. package/dist/modules/ssr/registerExternalPlugins.d.ts +2 -6
  191. package/dist/modules/ssr/registerExternalPlugins.js +2 -2
  192. package/dist/modules/ssr/resolvePageSeo.d.ts +11 -0
  193. package/dist/modules/ssr/resolvePageSeo.js +13 -2
  194. package/dist/modules/ssr/streamBody.js +2 -2
  195. package/dist/modules/ssr/views/template.ejs +21 -17
  196. package/dist/mysql.d.ts +1 -1
  197. package/dist/mysql.js +2 -2
  198. package/dist/plugins/manager.d.ts +5 -0
  199. package/dist/plugins/manager.js +9 -0
  200. package/dist/sqlite.d.ts +8 -1
  201. package/dist/sqlite.js +3 -1
  202. package/package.json +5 -5
  203. package/skills/plitzi-authoring/CHEATSHEET.md +6 -6
  204. package/skills/plitzi-authoring/SKILL.md +4 -2
  205. package/skills/plitzi-authoring/recipes/accordion.ts +2 -1
  206. package/skills/plitzi-authoring/recipes/carousel.ts +24 -3
  207. package/skills/plitzi-authoring/recipes/detail-page.ts +0 -1
  208. package/skills/plitzi-authoring/recipes/embed-and-svg.ts +3 -1
  209. package/skills/plitzi-authoring/recipes/filter-a-list.ts +0 -1
  210. package/skills/plitzi-authoring/recipes/show-data.ts +0 -1
  211. package/skills/plitzi-authoring/recipes/typed-data.ts +0 -1
  212. package/skills/plitzi-authoring/reference/accessibility.md +7 -2
  213. package/skills/plitzi-authoring/reference/auth.md +15 -4
  214. package/skills/plitzi-authoring/reference/authoring-errors.md +51 -10
  215. package/skills/plitzi-authoring/reference/colours-and-motion.md +7 -1
  216. package/skills/plitzi-authoring/reference/components.md +4 -1
  217. package/skills/plitzi-authoring/reference/data-and-visibility.md +31 -22
  218. package/skills/plitzi-authoring/reference/efficiency.md +2 -1
  219. package/skills/plitzi-authoring/reference/elements-and-styles.md +16 -15
  220. package/skills/plitzi-authoring/reference/flows.md +20 -8
  221. package/skills/plitzi-authoring/reference/kept-state.md +8 -0
  222. package/skills/plitzi-authoring/reference/layouts.md +18 -2
  223. package/skills/plitzi-authoring/reference/lists.md +20 -4
  224. package/skills/plitzi-authoring/reference/plugin-reach.md +12 -0
  225. package/skills/plitzi-authoring/reference/plugins.md +13 -2
  226. package/skills/plitzi-authoring/reference/realtime.md +8 -5
  227. package/skills/plitzi-authoring/reference/structure.md +17 -1
  228. package/skills/plitzi-authoring/reference/templates.md +11 -3
  229. package/skills/plitzi-authoring/reference/testing.md +82 -5
  230. package/skills/plitzi-authoring/reference/typed-sources.md +6 -0
  231. package/skills/plitzi-authoring/reference/validation.md +1 -1
  232. package/dist/core/auth/api.js +0 -1323
  233. package/dist/modules/functions/sandbox/guest.js +0 -662
@@ -0,0 +1,67 @@
1
+ import { CredentialCarrier } from '../credentials';
2
+ import { AuthFailure } from '../tokens';
3
+ import { AccountRecord, SessionClient, AccountStatus, AuthOutcome } from './types';
4
+ export declare const clientOf: (carrier?: CredentialCarrier) => SessionClient | undefined;
5
+ /**
6
+ * The account store, as auth needs to see it. Every method is optional except the three the session cycle cannot do
7
+ * without, and **what is absent decides what this server offers**: a deployment with no `createAccount` has no
8
+ * signup, and its route answers 404 rather than failing at runtime. That rule is what lets one server serve a
9
+ * deployment with its own user table and one that signs everybody in through an external provider.
10
+ */
11
+ export declare const refuse: (status: number, error: string, reason?: AuthFailure) => AuthOutcome;
12
+ export declare const NOT_OFFERED: AuthOutcome;
13
+ /**
14
+ * A field from a request body, as a string. Numbers count: JSON carries an all-digits password as a number, and a
15
+ * client that sends one has supplied a password — refusing it as "credentials are required" is a lie about what
16
+ * arrived. Objects and arrays do not, since `[object Object]` is not a value anybody sent.
17
+ */
18
+ export declare const asText: (value: unknown) => string;
19
+ export declare const asString: (value: unknown) => string;
20
+ /**
21
+ * The destination a caller named, for a mail to carry — or nothing at all.
22
+ *
23
+ * Carried, not judged: the kernel has no redirect policy, and the link it ends up in is composed by the deployment,
24
+ * which vets it there (`createRedirectPolicy`). Absent rather than empty when there is none, so a mail template never
25
+ * has to know that `''` means "nowhere".
26
+ */
27
+ export declare const destinationOf: (value: unknown) => {
28
+ redirect?: string;
29
+ };
30
+ export declare const now: () => number;
31
+ export declare const MINUTE = 60;
32
+ export declare const HOUR = 3600;
33
+ /**
34
+ * How long the things this server mails or hands out stay good for. Constants rather than configuration: each is a
35
+ * security answer with one sensible value, and an option here is a question every deployment has to work out an
36
+ * answer to before it can start.
37
+ */
38
+ export declare const LIFETIME: {
39
+ /** A code from an email. Long enough to go and find it, short enough that a stolen one is worthless. */
40
+ signInCode: number;
41
+ /** A reset link IS a password, and it sits in an inbox, a mail archive, a forwarded ticket. */
42
+ resetLink: number;
43
+ /** Confirming an address is not a credential in the same way, and people read their mail tomorrow. */
44
+ confirmLink: number;
45
+ /** A borrowed session — see `admin.impersonate`. Short, and it cannot renew. */
46
+ impersonation: number;
47
+ };
48
+ export declare const STATUSES: AccountStatus[];
49
+ /**
50
+ * Why an account may not hold a session, when it may not.
51
+ *
52
+ * `active` answers whether it may sign in at all; `verified` answers whether its owner can do anything about that.
53
+ * A deployment where confirming an address is what makes an account active — Plitzi is one — refuses both through
54
+ * the same flag, so a screen told only `inactive` has to tell somebody whose address has simply never answered that
55
+ * their password was wrong. It was, in fact, right.
56
+ */
57
+ export declare const deniedReason: (account?: {
58
+ verified: boolean;
59
+ }) => AuthFailure;
60
+ /** An account as it may be shown. Never the password hash, and never the credentials — not even to an admin. */
61
+ export declare const profileOf: (account: AccountRecord) => {
62
+ id: number;
63
+ username: string;
64
+ email: string;
65
+ active: boolean;
66
+ verified: boolean;
67
+ };
@@ -0,0 +1,90 @@
1
+ import { forwardedIp } from "../../requestParser.js";
2
+ //#region src/core/auth/api/values.ts
3
+ var clientOf = (carrier) => {
4
+ if (!carrier) return;
5
+ const userAgent = carrier.headers["user-agent"];
6
+ const ip = carrier.ip || forwardedIp(carrier.headers);
7
+ const client = {
8
+ ...typeof userAgent === "string" && userAgent ? { userAgent } : {},
9
+ ...ip ? { ip } : {},
10
+ ...carrier.hostname ? { host: carrier.hostname.toLowerCase() } : {}
11
+ };
12
+ return client.userAgent || client.ip || client.host ? client : void 0;
13
+ };
14
+ /**
15
+ * The account store, as auth needs to see it. Every method is optional except the three the session cycle cannot do
16
+ * without, and **what is absent decides what this server offers**: a deployment with no `createAccount` has no
17
+ * signup, and its route answers 404 rather than failing at runtime. That rule is what lets one server serve a
18
+ * deployment with its own user table and one that signs everybody in through an external provider.
19
+ */
20
+ var refuse = (status, error, reason) => ({
21
+ ok: false,
22
+ status,
23
+ body: reason ? {
24
+ error,
25
+ reason
26
+ } : { error }
27
+ });
28
+ var NOT_OFFERED = refuse(404, "Not found");
29
+ /**
30
+ * A field from a request body, as a string. Numbers count: JSON carries an all-digits password as a number, and a
31
+ * client that sends one has supplied a password — refusing it as "credentials are required" is a lie about what
32
+ * arrived. Objects and arrays do not, since `[object Object]` is not a value anybody sent.
33
+ */
34
+ var asText = (value) => {
35
+ if (typeof value === "string") return value;
36
+ return typeof value === "number" && Number.isFinite(value) ? String(value) : "";
37
+ };
38
+ var asString = (value) => asText(value).trim();
39
+ /**
40
+ * The destination a caller named, for a mail to carry — or nothing at all.
41
+ *
42
+ * Carried, not judged: the kernel has no redirect policy, and the link it ends up in is composed by the deployment,
43
+ * which vets it there (`createRedirectPolicy`). Absent rather than empty when there is none, so a mail template never
44
+ * has to know that `''` means "nowhere".
45
+ */
46
+ var destinationOf = (value) => {
47
+ const redirect = asString(value);
48
+ return redirect ? { redirect } : {};
49
+ };
50
+ var now = () => Math.floor(Date.now() / 1e3);
51
+ var HOUR = 3600;
52
+ /**
53
+ * How long the things this server mails or hands out stay good for. Constants rather than configuration: each is a
54
+ * security answer with one sensible value, and an option here is a question every deployment has to work out an
55
+ * answer to before it can start.
56
+ */
57
+ var LIFETIME = {
58
+ /** A code from an email. Long enough to go and find it, short enough that a stolen one is worthless. */
59
+ signInCode: 600,
60
+ /** A reset link IS a password, and it sits in an inbox, a mail archive, a forwarded ticket. */
61
+ resetLink: HOUR,
62
+ /** Confirming an address is not a credential in the same way, and people read their mail tomorrow. */
63
+ confirmLink: 24 * HOUR,
64
+ /** A borrowed session — see `admin.impersonate`. Short, and it cannot renew. */
65
+ impersonation: 900
66
+ };
67
+ var STATUSES = [
68
+ "active",
69
+ "inactive",
70
+ "blocked"
71
+ ];
72
+ /**
73
+ * Why an account may not hold a session, when it may not.
74
+ *
75
+ * `active` answers whether it may sign in at all; `verified` answers whether its owner can do anything about that.
76
+ * A deployment where confirming an address is what makes an account active — Plitzi is one — refuses both through
77
+ * the same flag, so a screen told only `inactive` has to tell somebody whose address has simply never answered that
78
+ * their password was wrong. It was, in fact, right.
79
+ */
80
+ var deniedReason = (account) => account && !account.verified ? "unverified" : "inactive";
81
+ /** An account as it may be shown. Never the password hash, and never the credentials — not even to an admin. */
82
+ var profileOf = (account) => ({
83
+ id: account.id,
84
+ username: account.username,
85
+ email: account.email,
86
+ active: account.active,
87
+ verified: account.verified
88
+ });
89
+ //#endregion
90
+ export { HOUR, LIFETIME, NOT_OFFERED, STATUSES, asString, asText, clientOf, deniedReason, destinationOf, now, profileOf, refuse };
@@ -4,7 +4,7 @@ import { CredentialCarrier } from './credentials';
4
4
  import { IdentityAdapters, IdentityConfig } from './identity';
5
5
  import { CookieSink } from './session';
6
6
  import { TokenConfig } from './tokens';
7
- import { ServerAuth, SSRAuthCookie, SSRSession, SSRUser } from '@plitzi/sdk-shared';
7
+ import { ServerAuth, SessionScope, SSRAuthCookie, SSRSession, SSRUser } from '@plitzi/sdk-shared';
8
8
  /**
9
9
  * Everything a deployment says about its own auth, in one object.
10
10
  *
@@ -96,6 +96,43 @@ export declare const createAuth: (config: AuthConfig) => {
96
96
  grantCan: (grant: import('./identity').Grant, permission: string) => Promise<boolean>;
97
97
  };
98
98
  api: {
99
+ exchangeAccount: (provider: string, token: string, carrier: CredentialCarrier) => Promise<import('./api').ExchangeResult>;
100
+ issueSession: (userId: number, context?: import('./api').SessionContext, options?: {
101
+ actingAs?: number;
102
+ ttlSeconds?: number;
103
+ renewable?: boolean;
104
+ }) => Promise<SSRSession>;
105
+ resolveActor: (carrier: CredentialCarrier) => Promise<import('./identity').ActorResult>;
106
+ admin: {
107
+ list: (actor: import('./identity').Actor | undefined, query: import('./api').AccountQuery) => Promise<AuthOutcome>;
108
+ get: (actor: import('./identity').Actor | undefined, userId: number) => Promise<AuthOutcome>;
109
+ setStatus: (actor: import('./identity').Actor | undefined, userId: number, status: import('./api').AccountStatus) => Promise<AuthOutcome>;
110
+ setRoles: (actor: import('./identity').Actor | undefined, userId: number, roles: unknown) => Promise<AuthOutcome>;
111
+ remove: (actor: import('./identity').Actor | undefined, userId: number) => Promise<AuthOutcome>;
112
+ impersonate: (actor: import('./identity').Actor | undefined, userId: number, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
113
+ };
114
+ updateProfile: (actor: import('./identity').Actor | undefined, fields: Record<string, unknown>) => Promise<AuthOutcome>;
115
+ confirmEmailChange: (token: string) => Promise<AuthOutcome>;
116
+ changePassword: (actor: import('./identity').Actor | undefined, currentPassword: string, newPassword: string) => Promise<AuthOutcome>;
117
+ deleteSelf: (actor: import('./identity').Actor | undefined, password?: string) => Promise<AuthOutcome>;
118
+ listSessions: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
119
+ revokeSession: (actor: import('./identity').Actor | undefined, sessionId: number) => Promise<AuthOutcome>;
120
+ revokeOtherSessions: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
121
+ signup: (fields: Record<string, unknown>) => Promise<AuthOutcome>;
122
+ forgotPassword: (email: string) => Promise<AuthOutcome>;
123
+ resetPassword: (token: string, password: string) => Promise<AuthOutcome>;
124
+ validateAccount: (token: string) => Promise<AuthOutcome>;
125
+ resendVerification: (email: string, redirect?: string) => Promise<AuthOutcome>;
126
+ passwordless: {
127
+ request: (email: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
128
+ complete: (email: string, code: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
129
+ };
130
+ mfa: {
131
+ status: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
132
+ begin: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
133
+ confirm: (actor: import('./identity').Actor | undefined, code: string) => Promise<AuthOutcome>;
134
+ disable: (actor: import('./identity').Actor | undefined, password?: string) => Promise<AuthOutcome>;
135
+ };
99
136
  capabilities: {
100
137
  passwordLogin: boolean;
101
138
  refresh: boolean;
@@ -117,51 +154,14 @@ export declare const createAuth: (config: AuthConfig) => {
117
154
  session: (actor?: import('./identity').Actor) => AuthOutcome;
118
155
  login: (credentials: Record<string, unknown>, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
119
156
  completeMfa: (mfaToken: string, code: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
120
- passwordless: {
121
- request: (email: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
122
- complete: (email: string, code: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
123
- };
124
- mfa: {
125
- status: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
126
- begin: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
127
- confirm: (actor: import('./identity').Actor | undefined, code: string) => Promise<AuthOutcome>;
128
- disable: (actor: import('./identity').Actor | undefined, password?: string) => Promise<AuthOutcome>;
129
- };
130
157
  refresh: (refreshToken?: string, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
131
158
  logout: (credentials: {
132
159
  accessToken?: string;
133
160
  refreshToken?: string;
134
161
  }) => Promise<AuthOutcome>;
135
- revokeSessions: (userId?: number) => Promise<AuthOutcome>;
162
+ revokeSessions: (userId: number | undefined, scope: unknown, host: string) => Promise<AuthOutcome>;
136
163
  exchange: (provider: string, token: string, carrier: CredentialCarrier) => Promise<AuthOutcome>;
137
- exchangeAccount: (provider: string, token: string, carrier: CredentialCarrier) => Promise<import('./api').ExchangeResult>;
138
- signup: (fields: Record<string, unknown>) => Promise<AuthOutcome>;
139
- forgotPassword: (email: string) => Promise<AuthOutcome>;
140
- resetPassword: (token: string, password: string) => Promise<AuthOutcome>;
141
- validateAccount: (token: string) => Promise<AuthOutcome>;
142
- resendVerification: (email: string, redirect?: string) => Promise<AuthOutcome>;
143
- updateProfile: (actor: import('./identity').Actor | undefined, fields: Record<string, unknown>) => Promise<AuthOutcome>;
144
- confirmEmailChange: (token: string) => Promise<AuthOutcome>;
145
- changePassword: (actor: import('./identity').Actor | undefined, currentPassword: string, newPassword: string) => Promise<AuthOutcome>;
146
- deleteSelf: (actor: import('./identity').Actor | undefined, password?: string) => Promise<AuthOutcome>;
147
- listSessions: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
148
- revokeSession: (actor: import('./identity').Actor | undefined, sessionId: number) => Promise<AuthOutcome>;
149
- revokeOtherSessions: (actor: import('./identity').Actor | undefined) => Promise<AuthOutcome>;
150
- admin: {
151
- list: (actor: import('./identity').Actor | undefined, query: import('./api').AccountQuery) => Promise<AuthOutcome>;
152
- get: (actor: import('./identity').Actor | undefined, userId: number) => Promise<AuthOutcome>;
153
- setStatus: (actor: import('./identity').Actor | undefined, userId: number, status: import('./api').AccountStatus) => Promise<AuthOutcome>;
154
- setRoles: (actor: import('./identity').Actor | undefined, userId: number, roles: unknown) => Promise<AuthOutcome>;
155
- remove: (actor: import('./identity').Actor | undefined, userId: number) => Promise<AuthOutcome>;
156
- impersonate: (actor: import('./identity').Actor | undefined, userId: number, carrier?: CredentialCarrier) => Promise<AuthOutcome>;
157
- };
158
164
  issueCsrf: (sessionToken?: string) => AuthOutcome;
159
- issueSession: (userId: number, context?: import('./api').SessionContext, options?: {
160
- actingAs?: number;
161
- ttlSeconds?: number;
162
- renewable?: boolean;
163
- }) => Promise<SSRSession>;
164
- resolveActor: (carrier: CredentialCarrier) => Promise<import('./identity').ActorResult>;
165
165
  };
166
166
  cookies: {
167
167
  write: (req: {
@@ -232,6 +232,15 @@ export declare const createAuth: (config: AuthConfig) => {
232
232
  }, res: CookieSink, outcome: AuthOutcome) => void;
233
233
  /** Both halves of a space permission: a global capability, and membership of that space. */
234
234
  can: (actor: import('./identity').Actor, spaceId: number, permission: string) => Promise<boolean>;
235
+ /**
236
+ * One account's public face — its id and username, nothing else: by username or id, an active account only. What a
237
+ * self-hosted space's functions read of another person (`ctx.visitors.get`): every account of its own is its
238
+ * visitor. The platform says its own (`lookups.getVisitor`): only the people of the space being asked.
239
+ */
240
+ publicAccount: (who: string | number) => Promise<{
241
+ id: number;
242
+ username: string;
243
+ } | undefined>;
235
244
  /**
236
245
  * WHO a page request carries, and nothing about signing anyone in or out.
237
246
  *
@@ -280,6 +289,7 @@ export declare const createAuth: (config: AuthConfig) => {
280
289
  getUser: (req: CredentialCarrier) => Promise<SSRUser | undefined>;
281
290
  authenticate: (credentials: Record<string, string>) => Promise<SSRSession | undefined>;
282
291
  endSession: (req: CredentialCarrier) => Promise<void>;
292
+ endSessions: (req: CredentialCarrier, scope: SessionScope) => Promise<boolean>;
283
293
  };
284
294
  };
285
295
  export type Auth = ReturnType<typeof createAuth>;
@@ -4,7 +4,7 @@ import { createCsrf } from "./csrf.js";
4
4
  import { applySessionOutcome, authPolicyRules, authRoutes } from "./routes.js";
5
5
  import { createAuthorizer } from "./authorize.js";
6
6
  import { createTokens } from "./tokens.js";
7
- import { createAuthApi } from "./api.js";
7
+ import { createAuthApi } from "./api/index.js";
8
8
  import { createIdentity } from "./identity.js";
9
9
  //#region src/core/auth/createAuth.ts
10
10
  /**
@@ -59,6 +59,7 @@ var createAuth = (config) => {
59
59
  loginUrl: `${basePath}/login`,
60
60
  userUrl: `${basePath}/session`,
61
61
  logoutUrl: `${basePath}/logout`,
62
+ revokeUrl: `${basePath}/sessions/revoke`,
62
63
  ...api.capabilities.refresh ? { refreshUrl: `${basePath}/refresh` } : {},
63
64
  ...api.capabilities.mfa ? { mfaUrl: `${basePath}/mfa/complete` } : {}
64
65
  };
@@ -159,6 +160,19 @@ var createAuth = (config) => {
159
160
  /** Both halves of a space permission: a global capability, and membership of that space. */
160
161
  can: identity.can,
161
162
  /**
163
+ * One account's public face — its id and username, nothing else: by username or id, an active account only. What a
164
+ * self-hosted space's functions read of another person (`ctx.visitors.get`): every account of its own is its
165
+ * visitor. The platform says its own (`lookups.getVisitor`): only the people of the space being asked.
166
+ */
167
+ publicAccount: async (who) => {
168
+ const { findById, findByUsername } = config.adapters;
169
+ const account = typeof who === "number" ? await findById?.(who) : await findByUsername?.(who);
170
+ return account?.active ? {
171
+ id: account.id,
172
+ username: account.username
173
+ } : void 0;
174
+ },
175
+ /**
162
176
  * WHO a page request carries, and nothing about signing anyone in or out.
163
177
  *
164
178
  * This is the set a deployment wants when its renderer and its sign-in live in different processes — a page
@@ -188,6 +202,12 @@ var createAuth = (config) => {
188
202
  endSession: async (req) => {
189
203
  await api.logout({ accessToken: cookies.resolveSessionToken(req) });
190
204
  },
205
+ endSessions: async (req, scope) => {
206
+ const resolved = await identity.resolveActor(req);
207
+ if (!resolved.ok) return false;
208
+ await api.revokeSessions(resolved.actor.id, scope, req.hostname);
209
+ return true;
210
+ },
191
211
  ...ssrIdentityAdapters
192
212
  }
193
213
  };
@@ -1,5 +1,5 @@
1
1
  import { OAuthFlowState } from './state';
2
- import { OAuthProvider } from './types';
2
+ import { OAuthProvider, OAuthTokens } from './types';
3
3
  export declare function buildAuthorizationUrl(provider: OAuthProvider, state: OAuthFlowState, challenge?: string): string;
4
- export declare function exchangeCodeForToken(provider: OAuthProvider, code: string, state: OAuthFlowState): Promise<string>;
4
+ export declare function exchangeCodeForToken(provider: OAuthProvider, code: string, state: OAuthFlowState): Promise<OAuthTokens>;
5
5
  export declare function requestProfileJson<T>(url: string, headers: Record<string, string>): Promise<T>;
@@ -13,6 +13,7 @@ function buildAuthorizationUrl(provider, state, challenge) {
13
13
  params.set("code_challenge", challenge);
14
14
  params.set("code_challenge_method", "S256");
15
15
  }
16
+ if (provider.sendsNonce) params.set("nonce", state.idNonce);
16
17
  return `${provider.authorizationUrl}?${params.toString()}`;
17
18
  }
18
19
  async function exchangeCodeForToken(provider, code, state) {
@@ -36,7 +37,11 @@ async function exchangeCodeForToken(provider, code, state) {
36
37
  if (!response.ok) throw new OAuthFailure("exchange_failed", `${provider.id} rejected the authorization code (${response.status})`);
37
38
  const payload = await response.json();
38
39
  if (!payload.access_token) throw new OAuthFailure("exchange_failed", `${provider.id} returned no access token (${payload.error ?? "unknown"})`);
39
- return payload.access_token;
40
+ return {
41
+ accessToken: payload.access_token,
42
+ ...payload.id_token ? { idToken: payload.id_token } : {},
43
+ nonce: state.idNonce
44
+ };
40
45
  }
41
46
  async function requestProfileJson(url, headers) {
42
47
  const response = await fetch(url, { headers });
@@ -2,7 +2,9 @@ import { OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig }
2
2
  import { AccountRecord } from '../api';
3
3
  export { OAuthFailure } from './types';
4
4
  export { requestProfileJson } from './client';
5
- export type { OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig } from './types';
5
+ export { createOidcProvider, discoverOidc } from './providers/oidc';
6
+ export type { OidcDiscovery, OidcProviderOptions } from './providers/oidc';
7
+ export type { OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig, OAuthTokens } from './types';
6
8
  export type OAuthProviderFactory = (config: OAuthProviderConfig) => OAuthProvider;
7
9
  /** The adapters shipped with the server. A deployment adds its credentials and gets the provider; nothing else. */
8
10
  export declare const BUILT_IN_PROVIDERS: Partial<Record<string, OAuthProviderFactory>>;
@@ -25,6 +27,20 @@ export interface SocialAuthAdapters {
25
27
  * {@link OAuthFailure} reports the reason to the browser; anything else is a server error.
26
28
  */
27
29
  linkAccount: (provider: string, profile: OAuthProfile) => Promise<AccountRecord>;
30
+ /**
31
+ * A provider known only at run time — an organization's own sign-in (single sign-on), configured by its
32
+ * administrators rather than by the deployment: asked for an id the configured providers do not have, with the
33
+ * callback address that id is reached at. `createOidcProvider` makes one from an issuer, a client and a secret.
34
+ */
35
+ resolveProvider?: (id: string, redirectUri: string) => Promise<OAuthProvider | undefined>;
36
+ /** Which run-time provider signs in `email`, by its domain, if any: what single sign-on starts from (`sso`). */
37
+ providerForEmail?: (email: string) => Promise<string | undefined>;
38
+ }
39
+ /** A provider a sign-in screen can send somebody to: its name and the address that starts it. */
40
+ export interface ListedProvider {
41
+ id: string;
42
+ label: string;
43
+ url: string;
28
44
  }
29
45
  export type StartedFlow = {
30
46
  redirectTo: string;
@@ -40,6 +56,7 @@ export type CompletedFlow = {
40
56
  redirectTo?: string;
41
57
  error: string;
42
58
  reason: OAuthFailureReason;
59
+ detail?: string;
43
60
  };
44
61
  /**
45
62
  * Social sign-in, as two functions and a list.
@@ -69,13 +86,19 @@ export declare const createSocialAuth: ({ config, adapters, providers: configure
69
86
  */
70
87
  sanitizeRedirect: (target: unknown) => string;
71
88
  /** Registered providers, so a front-end renders exactly the buttons that will work. */
72
- list: () => {
73
- id: string;
74
- label: string;
75
- url: string;
76
- }[];
89
+ list: () => ListedProvider[];
90
+ /** A configured provider. Run-time ones are not here: they sign in through the flow, never a token handed over. */
77
91
  get: (id: string) => OAuthProvider | undefined;
78
- start: (providerId: string, redirect: unknown) => StartedFlow | undefined;
92
+ /**
93
+ * The single sign-on that signs in `email`, if its domain has one — or why there is none. Asked by a sign-in
94
+ * screen before it sends anybody anywhere, so an address with no sign-on of its own hears so instead of a 404.
95
+ */
96
+ sso: (email: string) => Promise<{
97
+ provider: ListedProvider;
98
+ } | {
99
+ error: string;
100
+ }>;
101
+ start: (providerId: string, redirect: unknown) => Promise<StartedFlow | undefined>;
79
102
  complete: (providerId: string, params: {
80
103
  code?: string;
81
104
  state?: string;
@@ -4,6 +4,7 @@ import { createGitHubProvider } from "./providers/github.js";
4
4
  import { createGoogleProvider } from "./providers/google.js";
5
5
  import { codeChallenge, consumeFlow, startFlow } from "./state.js";
6
6
  import { createRedirectPolicy } from "../redirects.js";
7
+ import { createOidcProvider, discoverOidc } from "./providers/oidc.js";
7
8
  //#region src/core/auth/oauth/index.ts
8
9
  /** The adapters shipped with the server. A deployment adds its credentials and gets the provider; nothing else. */
9
10
  var BUILT_IN_PROVIDERS = {
@@ -37,7 +38,15 @@ var createSocialAuth = ({ config, adapters, providers: configured, customProvide
37
38
  defaultRedirect: config.defaultRedirect,
38
39
  allowedRedirects: config.allowedRedirects
39
40
  });
40
- const withError = (target, reason) => `${target}${target.includes("?") ? "&" : "?"}error=${encodeURIComponent(reason)}`;
41
+ const withError = (target, reason, detail) => `${target}${target.includes("?") ? "&" : "?"}error=${encodeURIComponent(reason)}${detail ? `&detail=${encodeURIComponent(detail)}` : ""}`;
42
+ const loginBase = config.loginBaseUrl ?? config.callbackBaseUrl ?? "";
43
+ const listed = (provider) => ({
44
+ id: provider.id,
45
+ label: provider.label,
46
+ url: `${loginBase}/auth/${provider.id}/login`
47
+ });
48
+ /** A configured provider, or one the deployment resolves at run time; never a run-time one under a configured id. */
49
+ const lookup = async (id) => registry.get(id) ?? await adapters.resolveProvider?.(id, `${config.callbackBaseUrl ?? ""}/auth/${id}/callback`);
41
50
  return {
42
51
  /**
43
52
  * Vet a caller-supplied landing page against this deployment's policy, for the flows that are not this one.
@@ -48,14 +57,22 @@ var createSocialAuth = ({ config, adapters, providers: configured, customProvide
48
57
  */
49
58
  sanitizeRedirect,
50
59
  /** Registered providers, so a front-end renders exactly the buttons that will work. */
51
- list: () => [...registry.values()].map((provider) => ({
52
- id: provider.id,
53
- label: provider.label,
54
- url: `${config.loginBaseUrl ?? config.callbackBaseUrl ?? ""}/auth/${provider.id}/login`
55
- })),
60
+ list: () => [...registry.values()].map(listed),
61
+ /** A configured provider. Run-time ones are not here: they sign in through the flow, never a token handed over. */
56
62
  get: (id) => registry.get(id),
57
- start: (providerId, redirect) => {
58
- const provider = registry.get(providerId);
63
+ /**
64
+ * The single sign-on that signs in `email`, if its domain has one — or why there is none. Asked by a sign-in
65
+ * screen before it sends anybody anywhere, so an address with no sign-on of its own hears so instead of a 404.
66
+ */
67
+ sso: async (email) => {
68
+ const address = email.trim().toLowerCase();
69
+ if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(address)) return { error: "An email address is required" };
70
+ const id = await adapters.providerForEmail?.(address);
71
+ const provider = id ? await lookup(id) : void 0;
72
+ return provider ? { provider: listed(provider) } : { error: `${address.split("@")[1] ?? address} has no single sign-on here: sign in another way` };
73
+ },
74
+ start: async (providerId, redirect) => {
75
+ const provider = await lookup(providerId);
59
76
  if (!provider) return;
60
77
  const { state, cookie } = startFlow(provider.id, sanitizeRedirect(redirect), config.secret, stateTtl);
61
78
  return {
@@ -65,7 +82,7 @@ var createSocialAuth = ({ config, adapters, providers: configured, customProvide
65
82
  };
66
83
  },
67
84
  complete: async (providerId, params) => {
68
- const provider = registry.get(providerId);
85
+ const provider = await lookup(providerId);
69
86
  if (!provider) return {
70
87
  ok: false,
71
88
  error: "Unknown provider",
@@ -87,8 +104,8 @@ var createSocialAuth = ({ config, adapters, providers: configured, customProvide
87
104
  };
88
105
  }
89
106
  try {
90
- const accessToken = await exchangeCodeForToken(provider, params.code, flow);
91
- const profile = await provider.fetchProfile(accessToken);
107
+ const tokens = await exchangeCodeForToken(provider, params.code, flow);
108
+ const profile = await provider.fetchProfile(tokens);
92
109
  const account = await adapters.linkAccount(provider.id, profile);
93
110
  return {
94
111
  ok: true,
@@ -97,15 +114,17 @@ var createSocialAuth = ({ config, adapters, providers: configured, customProvide
97
114
  };
98
115
  } catch (error) {
99
116
  const reason = error instanceof OAuthFailure ? error.reason : "server_error";
117
+ const detail = error instanceof OAuthFailure ? error.detail : void 0;
100
118
  return {
101
119
  ok: false,
102
- redirectTo: withError(flow.redirect, reason),
120
+ redirectTo: withError(flow.redirect, reason, detail),
103
121
  error: error instanceof Error ? error.message : "server_error",
104
- reason
122
+ reason,
123
+ ...detail === void 0 ? {} : { detail }
105
124
  };
106
125
  }
107
126
  }
108
127
  };
109
128
  };
110
129
  //#endregion
111
- export { BUILT_IN_PROVIDERS, OAuthFailure, createSocialAuth, requestProfileJson };
130
+ export { BUILT_IN_PROVIDERS, OAuthFailure, createOidcProvider, createSocialAuth, discoverOidc, requestProfileJson };
@@ -30,7 +30,7 @@ var createGitHubProvider = (config) => ({
30
30
  body: JSON.stringify({ access_token: accessToken })
31
31
  })).ok;
32
32
  },
33
- async fetchProfile(accessToken) {
33
+ async fetchProfile({ accessToken }) {
34
34
  const headers = apiHeaders(accessToken);
35
35
  const user = await requestProfileJson(USER_URL, headers);
36
36
  const emails = await requestProfileJson(EMAILS_URL, headers);
@@ -16,7 +16,7 @@ var createGoogleProvider = (config) => ({
16
16
  if (!response.ok) return false;
17
17
  return (await response.json()).aud === config.clientId;
18
18
  },
19
- async fetchProfile(accessToken) {
19
+ async fetchProfile({ accessToken }) {
20
20
  const profile = await requestProfileJson(USERINFO_URL, { Authorization: `Bearer ${accessToken}` });
21
21
  return {
22
22
  id: profile.sub,
@@ -0,0 +1,40 @@
1
+ import { OAuthProvider } from '../types';
2
+ /** What an issuer publishes at `/.well-known/openid-configuration` that a sign-in needs. */
3
+ export interface OidcDiscovery {
4
+ issuer: string;
5
+ authorizationEndpoint: string;
6
+ tokenEndpoint: string;
7
+ jwksUri: string;
8
+ }
9
+ export interface OidcProviderOptions {
10
+ /** Route segment and the stored identity's source, as for every provider: never change it once people use it. */
11
+ id: string;
12
+ label: string;
13
+ /** The issuer's identifier, exactly as its discovery document and its ID tokens state it. */
14
+ issuer: string;
15
+ clientId: string;
16
+ clientSecret: string;
17
+ redirectUri: string;
18
+ }
19
+ /**
20
+ * Reads an issuer's discovery document, and checks it is the issuer's: its `issuer` is the one asked for, exactly
21
+ * (OpenID Connect Discovery §4.3 — a document that names another issuer is somebody else's), and every endpoint it
22
+ * names is one a sign-in may use. Kept an hour. Throws, saying what is wrong, for whoever set the issuer to read.
23
+ */
24
+ export declare const discoverOidc: (issuer: string) => Promise<OidcDiscovery>;
25
+ /**
26
+ * Who an ID token says signed in, once it is proved to be this sign-in's: signed by the issuer's published key with an
27
+ * asymmetric algorithm, from this issuer, for this client — and, when it names several audiences, authorized for this
28
+ * one (`azp`) — unexpired, and carrying this flow's nonce, so a token from another sign-in cannot be replayed into it.
29
+ */
30
+ export declare const verifyIdToken: (idToken: string, discovery: OidcDiscovery, clientId: string, nonce: string) => Promise<Record<string, unknown>>;
31
+ /**
32
+ * A provider for any OpenID Connect issuer — a company's own identity provider (Okta, Microsoft Entra ID, Google
33
+ * Workspace, Keycloak…) — from its issuer, its client and its secret. The authorization-code grant with PKCE, as every
34
+ * provider here; what makes it OpenID Connect is the profile: read from the ID token the token endpoint returns,
35
+ * verified against the issuer's published keys, never from an endpoint the access token would reach.
36
+ *
37
+ * `email_verified` is reported as the issuer states it — many corporate issuers omit it for addresses they own. What a
38
+ * deployment trusts an issuer to vouch for is the deployment's to decide in `linkAccount`.
39
+ */
40
+ export declare const createOidcProvider: (options: OidcProviderOptions) => Promise<OAuthProvider>;