@atlasauth/backend 0.23.0 → 0.25.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 (188) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/auth0-session.d.ts +23 -0
  3. package/dist/auth0-session.js +80 -0
  4. package/dist/auth0-session.js.map +1 -0
  5. package/dist/better-auth.d.ts +4 -8
  6. package/dist/better-auth.js +42 -150
  7. package/dist/better-auth.js.map +1 -1
  8. package/dist/client/abac.d.ts +132 -0
  9. package/dist/client/abac.js +48 -0
  10. package/dist/client/abac.js.map +1 -0
  11. package/dist/client/access-policies.d.ts +100 -0
  12. package/dist/client/access-policies.js +29 -0
  13. package/dist/client/access-policies.js.map +1 -0
  14. package/dist/client/action-gallery.d.ts +1 -1
  15. package/dist/client/action-gallery.js.map +1 -1
  16. package/dist/client/actions.d.ts +129 -6
  17. package/dist/client/actions.js +4 -0
  18. package/dist/client/actions.js.map +1 -1
  19. package/dist/client/analytics-reports.d.ts +215 -0
  20. package/dist/client/analytics-reports.js +56 -0
  21. package/dist/client/analytics-reports.js.map +1 -0
  22. package/dist/client/app-catalog.d.ts +74 -0
  23. package/dist/client/app-catalog.js +30 -0
  24. package/dist/client/app-catalog.js.map +1 -0
  25. package/dist/client/attack-protection.d.ts +10 -0
  26. package/dist/client/attack-protection.js +8 -0
  27. package/dist/client/attack-protection.js.map +1 -1
  28. package/dist/client/audit-events.d.ts +71 -0
  29. package/dist/client/audit-events.js +28 -0
  30. package/dist/client/audit-events.js.map +1 -1
  31. package/dist/client/credentials.d.ts +8 -0
  32. package/dist/client/credentials.js.map +1 -1
  33. package/dist/client/delegated-ui-proxy.d.ts +25 -0
  34. package/dist/client/delegated-ui-proxy.js +46 -0
  35. package/dist/client/delegated-ui-proxy.js.map +1 -0
  36. package/dist/client/devices.d.ts +44 -0
  37. package/dist/client/devices.js +26 -0
  38. package/dist/client/devices.js.map +1 -0
  39. package/dist/client/email-templates.d.ts +1 -1
  40. package/dist/client/email-templates.js.map +1 -1
  41. package/dist/client/flags.d.ts +101 -0
  42. package/dist/client/flags.js +104 -0
  43. package/dist/client/flags.js.map +1 -0
  44. package/dist/client/groups.d.ts +146 -0
  45. package/dist/client/groups.js +67 -0
  46. package/dist/client/groups.js.map +1 -0
  47. package/dist/client/identity-verification.d.ts +62 -0
  48. package/dist/client/identity-verification.js +39 -0
  49. package/dist/client/identity-verification.js.map +1 -0
  50. package/dist/client/index.d.ts +997 -2
  51. package/dist/client/index.js +77 -0
  52. package/dist/client/index.js.map +1 -1
  53. package/dist/client/journeys.d.ts +108 -0
  54. package/dist/client/journeys.js +35 -0
  55. package/dist/client/journeys.js.map +1 -0
  56. package/dist/client/log-streams.d.ts +1 -1
  57. package/dist/client/marketing.d.ts +67 -0
  58. package/dist/client/marketing.js +26 -0
  59. package/dist/client/marketing.js.map +1 -0
  60. package/dist/client/mcp-gateways.d.ts +54 -0
  61. package/dist/client/mcp-gateways.js +25 -0
  62. package/dist/client/mcp-gateways.js.map +1 -0
  63. package/dist/client/messaging.d.ts +14 -3
  64. package/dist/client/messaging.js.map +1 -1
  65. package/dist/client/mfa-factors.d.ts +120 -0
  66. package/dist/client/mfa-factors.js +73 -0
  67. package/dist/client/mfa-factors.js.map +1 -0
  68. package/dist/client/migrations.d.ts +286 -0
  69. package/dist/client/migrations.js +103 -0
  70. package/dist/client/migrations.js.map +1 -0
  71. package/dist/client/network-acls.d.ts +6 -1
  72. package/dist/client/network-acls.js.map +1 -1
  73. package/dist/client/network-zones.d.ts +56 -0
  74. package/dist/client/network-zones.js +29 -0
  75. package/dist/client/network-zones.js.map +1 -0
  76. package/dist/client/notifications.d.ts +1 -1
  77. package/dist/client/notifications.js.map +1 -1
  78. package/dist/client/oauth-clients.d.ts +183 -3
  79. package/dist/client/oauth-clients.js +64 -0
  80. package/dist/client/oauth-clients.js.map +1 -1
  81. package/dist/client/org-role-grants.d.ts +57 -0
  82. package/dist/client/org-role-grants.js +40 -0
  83. package/dist/client/org-role-grants.js.map +1 -0
  84. package/dist/client/organizations.d.ts +52 -0
  85. package/dist/client/organizations.js +44 -0
  86. package/dist/client/organizations.js.map +1 -1
  87. package/dist/client/page-templates.d.ts +78 -0
  88. package/dist/client/page-templates.js +31 -0
  89. package/dist/client/page-templates.js.map +1 -0
  90. package/dist/client/passkey-api.d.ts +73 -0
  91. package/dist/client/passkey-api.js +34 -0
  92. package/dist/client/passkey-api.js.map +1 -0
  93. package/dist/client/resources.d.ts +149 -0
  94. package/dist/client/resources.js +73 -0
  95. package/dist/client/resources.js.map +1 -0
  96. package/dist/client/risk-based-mfa.d.ts +147 -0
  97. package/dist/client/risk-based-mfa.js +30 -0
  98. package/dist/client/risk-based-mfa.js.map +1 -1
  99. package/dist/client/roles.d.ts +4 -0
  100. package/dist/client/roles.js.map +1 -1
  101. package/dist/client/service-connectors.d.ts +83 -0
  102. package/dist/client/service-connectors.js +33 -0
  103. package/dist/client/service-connectors.js.map +1 -0
  104. package/dist/client/ssf.d.ts +111 -0
  105. package/dist/client/ssf.js +49 -0
  106. package/dist/client/ssf.js.map +1 -0
  107. package/dist/client/sso-onboarding.d.ts +6 -0
  108. package/dist/client/sso-onboarding.js.map +1 -1
  109. package/dist/client/users.d.ts +302 -0
  110. package/dist/client/users.js +125 -0
  111. package/dist/client/users.js.map +1 -1
  112. package/dist/client/vault.d.ts +85 -0
  113. package/dist/client/vault.js +50 -0
  114. package/dist/client/vault.js.map +1 -0
  115. package/dist/client/vc.d.ts +128 -0
  116. package/dist/client/vc.js +43 -0
  117. package/dist/client/vc.js.map +1 -0
  118. package/dist/client/webhooks.d.ts +31 -2
  119. package/dist/client/webhooks.js.map +1 -1
  120. package/dist/client/workflows.d.ts +131 -0
  121. package/dist/client/workflows.js +36 -0
  122. package/dist/client/workflows.js.map +1 -0
  123. package/dist/framework-bridge.d.ts +98 -0
  124. package/dist/framework-bridge.js +264 -0
  125. package/dist/framework-bridge.js.map +1 -0
  126. package/dist/framework-sessions.d.ts +147 -0
  127. package/dist/framework-sessions.js +544 -0
  128. package/dist/framework-sessions.js.map +1 -0
  129. package/dist/index.d.ts +11 -1
  130. package/dist/index.js +19 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/legacy-issuer-presets.d.ts +85 -0
  133. package/dist/legacy-issuer-presets.js +165 -0
  134. package/dist/legacy-issuer-presets.js.map +1 -0
  135. package/dist/legacy-issuers.d.ts +16 -2
  136. package/dist/legacy-issuers.js +16 -1
  137. package/dist/legacy-issuers.js.map +1 -1
  138. package/dist/legacy-verify.d.ts +103 -0
  139. package/dist/legacy-verify.js +244 -0
  140. package/dist/legacy-verify.js.map +1 -0
  141. package/dist/magic-did.d.ts +5 -0
  142. package/dist/magic-did.js +49 -0
  143. package/dist/magic-did.js.map +1 -0
  144. package/dist/migration-bridge.d.ts +162 -0
  145. package/dist/migration-bridge.js +354 -0
  146. package/dist/migration-bridge.js.map +1 -0
  147. package/dist/migration-presets-g3.d.ts +2 -0
  148. package/dist/migration-presets-g3.js +254 -0
  149. package/dist/migration-presets-g3.js.map +1 -0
  150. package/dist/migration-presets-g4/authentik.d.ts +14 -0
  151. package/dist/migration-presets-g4/authentik.js +37 -0
  152. package/dist/migration-presets-g4/authentik.js.map +1 -0
  153. package/dist/migration-presets-g4/fusionauth.d.ts +2 -0
  154. package/dist/migration-presets-g4/fusionauth.js +52 -0
  155. package/dist/migration-presets-g4/fusionauth.js.map +1 -0
  156. package/dist/migration-presets-g4/hanko.d.ts +12 -0
  157. package/dist/migration-presets-g4/hanko.js +46 -0
  158. package/dist/migration-presets-g4/hanko.js.map +1 -0
  159. package/dist/migration-presets-g4/keycloak.d.ts +16 -0
  160. package/dist/migration-presets-g4/keycloak.js +37 -0
  161. package/dist/migration-presets-g4/keycloak.js.map +1 -0
  162. package/dist/migration-presets-g4/logto.d.ts +12 -0
  163. package/dist/migration-presets-g4/logto.js +35 -0
  164. package/dist/migration-presets-g4/logto.js.map +1 -0
  165. package/dist/migration-presets-g4/ory.d.ts +2 -0
  166. package/dist/migration-presets-g4/ory.js +67 -0
  167. package/dist/migration-presets-g4/ory.js.map +1 -0
  168. package/dist/migration-presets-g4/supertokens.d.ts +13 -0
  169. package/dist/migration-presets-g4/supertokens.js +35 -0
  170. package/dist/migration-presets-g4/supertokens.js.map +1 -0
  171. package/dist/migration-presets-g4/zitadel.d.ts +2 -0
  172. package/dist/migration-presets-g4/zitadel.js +36 -0
  173. package/dist/migration-presets-g4/zitadel.js.map +1 -0
  174. package/dist/migration-presets-g4.d.ts +10 -0
  175. package/dist/migration-presets-g4.js +30 -0
  176. package/dist/migration-presets-g4.js.map +1 -0
  177. package/dist/migration-presets.d.ts +156 -0
  178. package/dist/migration-presets.js +536 -0
  179. package/dist/migration-presets.js.map +1 -0
  180. package/dist/request-auth.d.ts +32 -0
  181. package/dist/request-auth.js +72 -0
  182. package/dist/request-auth.js.map +1 -0
  183. package/dist/verify.d.ts +2 -0
  184. package/dist/verify.js.map +1 -1
  185. package/dist/workos-session.d.ts +30 -0
  186. package/dist/workos-session.js +123 -0
  187. package/dist/workos-session.js.map +1 -0
  188. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ /**
2
+ * ZERO-LOGOUT BRIDGE PRESETS — per vendor, how an old session is recognised.
3
+ *
4
+ * Shared by the Atlas API (which verifies the token and resolves the user) and
5
+ * the SDK middleware (which knows which cookie / header carries it), so both
6
+ * read one table. Pure data plus a few string templates: safe on every runtime.
7
+ *
8
+ * Three modes:
9
+ * - `jwt`: the vendor's session (or a token inside it) is a JWT. Atlas
10
+ * verifies it against the vendor's issuer and keys (JWKS, or an X.509 map
11
+ * like Firebase session cookies use), maps `claims.subject` to the imported
12
+ * user (`external_id` = the source user id), and spends `claims.sessionKey`
13
+ * (`jti` / `sid`, falling back to the whole token) in the single-use ledger.
14
+ * - `session_table`: an opaque token; Atlas looks up sha256(token) among the
15
+ * sessions imported in the migration bundle.
16
+ * - `remote`: the vendor's session can only be checked by asking the vendor
17
+ * with the user's own token (Appwrite, PocketBase): Atlas calls
18
+ * `remote.url` with the token filled into `{token}` and reads the subject
19
+ * (and profile) from the JSON answer by dot path.
20
+ *
21
+ * Templates use `{var}` placeholders filled from the bridge settings'
22
+ * `preset_vars` (e.g. `{domain}`, `{region}`); {@link resolveMigrationBridgePreset}
23
+ * refuses a template with a missing variable.
24
+ *
25
+ * Vendor tracks register their preset (or refine the starter below) with
26
+ * {@link registerMigrationBridgePreset}; a test checks every preset resolves.
27
+ */
28
+ export interface MigrationBridgeClaims {
29
+ /** Claim holding the source user id (default `sub`). */
30
+ subject: string;
31
+ email?: string;
32
+ emailVerified?: string;
33
+ name?: string;
34
+ /** Claim whose value spends the token in the single-use ledger (`jti`, `sid`); the whole token when absent. */
35
+ sessionKey?: string;
36
+ /**
37
+ * How the vendor says a second factor was passed: `amr:mfa` (the `amr` array
38
+ * contains `mfa`), `acr:<value>`, or `claim:<name>` (a truthy claim).
39
+ */
40
+ mfa?: string;
41
+ }
42
+ /**
43
+ * How the middleware gets the token out of the cookie: `raw` (the cookie value
44
+ * is the token), `supabase` (Supabase SSR's `base64-` JSON cookie, possibly
45
+ * chunked `.0`/`.1`, holding `access_token`), or a custom extractor a vendor
46
+ * track registers on the middleware side.
47
+ */
48
+ export type TokenFormat = 'raw' | 'supabase' | (string & {});
49
+ export interface MigrationBridgePreset {
50
+ id: string;
51
+ label: string;
52
+ mode: 'jwt' | 'session_table' | 'remote';
53
+ /** Variables the templates need, with a one-line hint each. */
54
+ vars?: Record<string, string>;
55
+ /** Optional variables and their defaults. */
56
+ defaults?: Record<string, string>;
57
+ jwt?: {
58
+ issuer: string;
59
+ /** Where the keys are. Omitted → OIDC discovery from the issuer. */
60
+ keysUrl?: string;
61
+ /** `jwks` (default) or `x509` (a `{ kid: PEM certificate }` map). */
62
+ keysFormat?: 'jwks' | 'x509';
63
+ /** Expected `aud` template(s); unchecked when absent. */
64
+ audience?: string[];
65
+ algorithms: string[];
66
+ claims: MigrationBridgeClaims;
67
+ /**
68
+ * Accept a validly signed token this many seconds past `exp` (each one still
69
+ * exchanges once). For vendors whose cookie holds a short-lived token that
70
+ * their client SDK refreshes and nothing refreshes after the switch. 0 by default.
71
+ */
72
+ expiredGraceSeconds?: number;
73
+ /** The vendor may sign with a shared secret (HS256) instead of keys (Supabase legacy JWT secret). */
74
+ allowSharedSecret?: boolean;
75
+ /**
76
+ * The token is not a JWT but another signed token Atlas checks natively:
77
+ * `magic_did` (Magic DID tokens — signed by the user's own key, subject the
78
+ * `iss` DID, audience the Magic client id). Default `jwt`.
79
+ */
80
+ tokenType?: 'jwt' | 'magic_did';
81
+ };
82
+ /**
83
+ * Mode `remote`: the vendor call that vouches for a token. Templates take the
84
+ * preset variables; `{token}` is the presented token and is filled only at
85
+ * call time, by the server.
86
+ */
87
+ remote?: MigrationBridgeRemote;
88
+ /**
89
+ * Cookies that may carry the token, most specific first. `*` matches any run
90
+ * of characters (Amplify names cookies per client id and username).
91
+ */
92
+ cookies: string[];
93
+ tokenFormat?: TokenFormat;
94
+ /** Read `Authorization: Bearer` too (API clients holding the old token). */
95
+ bearer?: boolean;
96
+ /** Cookies to clear once exchanged (defaults to `cookies`). */
97
+ clearCookies?: string[];
98
+ /**
99
+ * The cookie name collides with Atlas's own (`__session`): the middleware
100
+ * only treats it as the old vendor's when the token's `iss` is the vendor's.
101
+ */
102
+ sharesAtlasCookie?: boolean;
103
+ /** Integrator-facing notes (what must be configured at the vendor, caveats). */
104
+ notes?: string;
105
+ }
106
+ /** How a `remote` preset asks the vendor about a token. */
107
+ export interface MigrationBridgeRemote {
108
+ /** URL template (`{var}` from the preset variables, `{token}` at call time). */
109
+ url: string;
110
+ method: 'GET' | 'POST';
111
+ /** Header templates, e.g. `{ authorization: 'Bearer {token}' }`. */
112
+ headers?: Record<string, string>;
113
+ /** Body template (POST). */
114
+ body?: string;
115
+ /** Dot path into the JSON answer holding the source user id (`record.id`, `$id`). */
116
+ subjectPath: string;
117
+ emailPath?: string;
118
+ emailVerifiedPath?: string;
119
+ namePath?: string;
120
+ }
121
+ export declare function registerMigrationBridgePreset(preset: MigrationBridgePreset, options?: {
122
+ replace?: boolean;
123
+ }): void;
124
+ export declare function getMigrationBridgePreset(id: string): MigrationBridgePreset | undefined;
125
+ export declare function listMigrationBridgePresets(): MigrationBridgePreset[];
126
+ /** The bridge settings a preset resolves to, every template filled in. */
127
+ export interface ResolvedBridgePreset {
128
+ preset: string;
129
+ mode: 'jwt' | 'session_table' | 'remote';
130
+ issuer: string | null;
131
+ keysUrl: string | null;
132
+ keysFormat: 'jwks' | 'x509';
133
+ audience: string[] | null;
134
+ algorithms: string[];
135
+ claims: MigrationBridgeClaims;
136
+ expiredGraceSeconds: number;
137
+ cookies: string[];
138
+ tokenFormat: TokenFormat;
139
+ bearer: boolean;
140
+ clearCookies: string[];
141
+ sharesAtlasCookie: boolean;
142
+ /** Mode `remote`: the vendor call, preset variables filled, `{token}` left for the server. */
143
+ remote: MigrationBridgeRemote | null;
144
+ }
145
+ export declare class PresetVariableError extends Error {
146
+ readonly variable: string;
147
+ constructor(variable: string, message: string);
148
+ }
149
+ /**
150
+ * Fill a preset's templates. Throws {@link PresetVariableError} for a missing or
151
+ * malformed variable. Values are trimmed; a trailing slash on a URL-ish value
152
+ * is removed (`https://example.com/` → `https://example.com`).
153
+ */
154
+ export declare function resolveMigrationBridgePreset(id: string, rawVars?: Record<string, string>): ResolvedBridgePreset;
155
+ /** Does a cookie name match a preset pattern (`*` = any run of characters)? */
156
+ export declare function cookieNameMatches(pattern: string, name: string): boolean;