@atlasauth/backend 0.15.0 → 0.17.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 (56) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/better-auth.d.ts +157 -0
  3. package/dist/better-auth.js +245 -0
  4. package/dist/better-auth.js.map +1 -0
  5. package/dist/botid.d.ts +70 -0
  6. package/dist/botid.js +88 -0
  7. package/dist/botid.js.map +1 -0
  8. package/dist/client/action-gallery.d.ts +215 -0
  9. package/dist/client/action-gallery.js +66 -0
  10. package/dist/client/action-gallery.js.map +1 -0
  11. package/dist/client/actions.d.ts +21 -0
  12. package/dist/client/actions.js.map +1 -1
  13. package/dist/client/attack-protection.d.ts +33 -1
  14. package/dist/client/attack-protection.js.map +1 -1
  15. package/dist/client/better-auth-imports.d.ts +205 -0
  16. package/dist/client/better-auth-imports.js +107 -0
  17. package/dist/client/better-auth-imports.js.map +1 -0
  18. package/dist/client/billing-plans.d.ts +93 -0
  19. package/dist/client/billing-plans.js +31 -0
  20. package/dist/client/billing-plans.js.map +1 -1
  21. package/dist/client/custom-oauth-providers.d.ts +243 -0
  22. package/dist/client/custom-oauth-providers.js +60 -0
  23. package/dist/client/custom-oauth-providers.js.map +1 -0
  24. package/dist/client/email-templates.d.ts +1 -1
  25. package/dist/client/email-templates.js.map +1 -1
  26. package/dist/client/index.d.ts +154 -0
  27. package/dist/client/index.js +11 -0
  28. package/dist/client/index.js.map +1 -1
  29. package/dist/client/instance-security.d.ts +70 -0
  30. package/dist/client/instance-security.js +20 -0
  31. package/dist/client/instance-security.js.map +1 -1
  32. package/dist/client/oauth-clients.d.ts +29 -2
  33. package/dist/client/oauth-clients.js.map +1 -1
  34. package/dist/client/resource-servers.d.ts +22 -2
  35. package/dist/client/resource-servers.js.map +1 -1
  36. package/dist/client/risk-based-mfa.d.ts +3 -0
  37. package/dist/client/risk-based-mfa.js.map +1 -1
  38. package/dist/client/sessions.d.ts +16 -0
  39. package/dist/client/sessions.js +15 -0
  40. package/dist/client/sessions.js.map +1 -1
  41. package/dist/client/sso-connections.d.ts +83 -0
  42. package/dist/client/sso-connections.js +29 -0
  43. package/dist/client/sso-connections.js.map +1 -1
  44. package/dist/index.d.ts +6 -2
  45. package/dist/index.js +11 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/legacy-issuers.d.ts +65 -0
  48. package/dist/legacy-issuers.js +140 -0
  49. package/dist/legacy-issuers.js.map +1 -0
  50. package/dist/oauth-resource.d.ts +81 -1
  51. package/dist/oauth-resource.js +204 -29
  52. package/dist/oauth-resource.js.map +1 -1
  53. package/dist/verify.d.ts +22 -0
  54. package/dist/verify.js +32 -0
  55. package/dist/verify.js.map +1 -1
  56. package/package.json +3 -3
@@ -0,0 +1,215 @@
1
+ import { type RequestFn } from './request';
2
+ import type { Action, ActionTrigger } from './actions';
3
+ import type { ListPage } from './types';
4
+ /**
5
+ * §actions gallery — browse reusable Action templates (first-party and
6
+ * community), install one into the instance as a DISABLED action, keep installed
7
+ * actions up to date, and publish your own templates for review.
8
+ */
9
+ /** Every trigger a template can target (a superset of the classic three). */
10
+ export type GalleryTrigger = ActionTrigger | 'pre_organization_create' | 'pre_member_add' | 'pre_invitation_create';
11
+ /** A secret a template reads, declared by NAME; values are never part of a template. */
12
+ export interface ActionTemplateSecret {
13
+ name: string;
14
+ description: string;
15
+ required: boolean;
16
+ }
17
+ export interface ActionGalleryEntry {
18
+ object: 'action_template';
19
+ source: 'builtin' | 'community';
20
+ slug: string;
21
+ name: string;
22
+ summary: string;
23
+ trigger: GalleryTrigger;
24
+ category: string;
25
+ tags: string[];
26
+ /** SPDX licence id. */
27
+ license: string;
28
+ author: {
29
+ name: string;
30
+ first_party: boolean;
31
+ };
32
+ verified: boolean;
33
+ featured: boolean;
34
+ install_count: number;
35
+ latest_version: string;
36
+ /** The code sends outbound requests with `api.http`. */
37
+ uses_http: boolean;
38
+ secrets: ActionTemplateSecret[];
39
+ updated_at: number | null;
40
+ }
41
+ export interface ActionGalleryDetail extends ActionGalleryEntry {
42
+ /** Markdown. */
43
+ description: string;
44
+ code: string;
45
+ changelog: string | null;
46
+ repository_url: string | null;
47
+ versions: Array<{
48
+ version: string;
49
+ changelog: string | null;
50
+ released_at: number | null;
51
+ }>;
52
+ }
53
+ export interface ActionGalleryFilter {
54
+ q?: string;
55
+ category?: string;
56
+ trigger?: GalleryTrigger;
57
+ source?: 'builtin' | 'community';
58
+ }
59
+ export interface InstallTemplateBody {
60
+ /** A specific approved version (default: the latest). */
61
+ version?: string;
62
+ /** The action's name (default: the template's). */
63
+ name?: string;
64
+ /** Values for the secrets the template declares. Write-only. */
65
+ secrets?: Record<string, string>;
66
+ }
67
+ export interface ActionGalleryInstallResult {
68
+ object: 'action_gallery_install';
69
+ /** The new action: disabled and not bound to any flow yet. */
70
+ action: Action;
71
+ template: {
72
+ slug: string;
73
+ source: 'builtin' | 'community';
74
+ version: string;
75
+ };
76
+ install_id: string;
77
+ /** Required secrets you have not supplied yet. */
78
+ missing_secrets: string[];
79
+ }
80
+ export interface ActionGalleryInstallation {
81
+ object: 'action_gallery_installation';
82
+ action_id: string;
83
+ action_name: string;
84
+ enabled: boolean;
85
+ trigger: string;
86
+ source: 'builtin' | 'community';
87
+ template_slug: string;
88
+ installed_version: string;
89
+ latest_version: string | null;
90
+ update_available: boolean;
91
+ missing_secrets: string[];
92
+ update_requires_secrets: string[];
93
+ installed_at: number;
94
+ updated_at: number;
95
+ }
96
+ export interface ActionGalleryUpdateResult {
97
+ object: 'action_gallery_update';
98
+ /** false when the action already runs the latest version. */
99
+ updated: boolean;
100
+ action: Action;
101
+ from_version?: string;
102
+ version: string;
103
+ }
104
+ export type ActionTemplateStatus = 'draft' | 'in_review' | 'published' | 'unlisted' | 'rejected' | 'banned';
105
+ export interface ActionTemplateVersion {
106
+ object: 'action_template_version';
107
+ version: string;
108
+ status: 'draft' | 'pending_review' | 'approved' | 'rejected';
109
+ trigger: GalleryTrigger;
110
+ secrets: ActionTemplateSecret[];
111
+ changelog: string | null;
112
+ /** Why staff rejected it, when they did. */
113
+ review_note: string | null;
114
+ code: string;
115
+ submitted_at: number | null;
116
+ reviewed_at: number | null;
117
+ created_at: number;
118
+ }
119
+ /** A template this instance publishes. */
120
+ export interface ActionTemplate {
121
+ object: 'action_template';
122
+ id: string;
123
+ slug: string;
124
+ name: string;
125
+ author_name: string;
126
+ summary: string;
127
+ description: string | null;
128
+ category: string;
129
+ tags: string[];
130
+ trigger: GalleryTrigger;
131
+ license: string;
132
+ repository_url: string | null;
133
+ status: ActionTemplateStatus;
134
+ latest_version: string | null;
135
+ verified: boolean;
136
+ featured: boolean;
137
+ install_count: number;
138
+ view_count: number;
139
+ published_at: number | null;
140
+ created_at: number;
141
+ updated_at: number;
142
+ versions: ActionTemplateVersion[];
143
+ }
144
+ export interface ActionTemplateListing {
145
+ slug?: string;
146
+ name?: string;
147
+ /** Shown as the author on the gallery. */
148
+ author_name?: string;
149
+ summary?: string;
150
+ /** Markdown. */
151
+ description?: string;
152
+ category?: string;
153
+ tags?: string[];
154
+ trigger?: GalleryTrigger;
155
+ /** SPDX id (MIT, Apache-2.0, BSD-3-Clause, ISC, MPL-2.0, …). */
156
+ license?: string;
157
+ repository_url?: string | null;
158
+ }
159
+ export interface NewTemplateVersion {
160
+ /** MAJOR.MINOR.PATCH, higher than every existing version. */
161
+ version: string;
162
+ code: string;
163
+ secrets?: ActionTemplateSecret[];
164
+ changelog?: string;
165
+ /** Send to review right away. */
166
+ submit?: boolean;
167
+ }
168
+ export interface CreateActionTemplateBody extends ActionTemplateListing {
169
+ slug: string;
170
+ name: string;
171
+ author_name: string;
172
+ trigger: GalleryTrigger;
173
+ /** Optionally the first version in the same call. */
174
+ version?: string;
175
+ code?: string;
176
+ secrets?: ActionTemplateSecret[];
177
+ changelog?: string;
178
+ submit?: boolean;
179
+ }
180
+ export declare function actionGalleryResource(request: RequestFn): {
181
+ /** The gallery, best first. */
182
+ list(filter?: ActionGalleryFilter): Promise<ListPage<ActionGalleryEntry>>;
183
+ /** One template with its code, secret names and versions. */
184
+ get(slug: string): Promise<ActionGalleryDetail>;
185
+ /** Install as a new, disabled action. Supply secrets, bind it, then enable it. */
186
+ install(slug: string, body?: InstallTemplateBody, idempotencyKey?: string): Promise<ActionGalleryInstallResult>;
187
+ /** Actions installed from the gallery, with update status. */
188
+ installs(): Promise<ListPage<ActionGalleryInstallation>>;
189
+ /** Move an installed action to its template's latest version. */
190
+ update(actionId: string, body?: {
191
+ secrets?: Record<string, string>;
192
+ }): Promise<ActionGalleryUpdateResult>;
193
+ };
194
+ export declare function actionTemplatesResource(request: RequestFn): {
195
+ list(): Promise<ListPage<ActionTemplate>>;
196
+ create(body: CreateActionTemplateBody, idempotencyKey?: string): Promise<ActionTemplate>;
197
+ get(id: string): Promise<ActionTemplate>;
198
+ update(id: string, body: ActionTemplateListing): Promise<ActionTemplate>;
199
+ delete(id: string): Promise<{
200
+ object: "action_template";
201
+ id: string;
202
+ deleted: true;
203
+ }>;
204
+ addVersion(id: string, body: NewTemplateVersion): Promise<ActionTemplateVersion>;
205
+ submitVersion(id: string, version: string): Promise<ActionTemplateVersion>;
206
+ deleteVersion(id: string, version: string): Promise<{
207
+ object: "action_template_version";
208
+ version: string;
209
+ deleted: true;
210
+ }>;
211
+ /** List an approved template again after unlisting it. */
212
+ publish(id: string): Promise<ActionTemplate>;
213
+ /** Hide a template from the gallery (installs keep working). */
214
+ unlist(id: string): Promise<ActionTemplate>;
215
+ };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionGalleryResource = actionGalleryResource;
4
+ exports.actionTemplatesResource = actionTemplatesResource;
5
+ const request_1 = require("./request");
6
+ function actionGalleryResource(request) {
7
+ return {
8
+ /** The gallery, best first. */
9
+ list(filter = {}) {
10
+ return request({ method: 'GET', path: '/v1/action_gallery', query: { ...filter } });
11
+ },
12
+ /** One template with its code, secret names and versions. */
13
+ get(slug) {
14
+ return request({ method: 'GET', path: `/v1/action_gallery/${(0, request_1.enc)(slug)}` });
15
+ },
16
+ /** Install as a new, disabled action. Supply secrets, bind it, then enable it. */
17
+ install(slug, body = {}, idempotencyKey) {
18
+ return request({ method: 'POST', path: `/v1/action_gallery/${(0, request_1.enc)(slug)}/install`, body, idempotencyKey });
19
+ },
20
+ /** Actions installed from the gallery, with update status. */
21
+ installs() {
22
+ return request({ method: 'GET', path: '/v1/action_gallery_installs' });
23
+ },
24
+ /** Move an installed action to its template's latest version. */
25
+ update(actionId, body = {}) {
26
+ return request({ method: 'POST', path: `/v1/actions/${(0, request_1.enc)(actionId)}/gallery_update`, body });
27
+ },
28
+ };
29
+ }
30
+ function actionTemplatesResource(request) {
31
+ return {
32
+ list() {
33
+ return request({ method: 'GET', path: '/v1/action_templates' });
34
+ },
35
+ create(body, idempotencyKey) {
36
+ return request({ method: 'POST', path: '/v1/action_templates', body, idempotencyKey });
37
+ },
38
+ get(id) {
39
+ return request({ method: 'GET', path: `/v1/action_templates/${(0, request_1.enc)(id)}` });
40
+ },
41
+ update(id, body) {
42
+ return request({ method: 'PATCH', path: `/v1/action_templates/${(0, request_1.enc)(id)}`, body });
43
+ },
44
+ delete(id) {
45
+ return request({ method: 'DELETE', path: `/v1/action_templates/${(0, request_1.enc)(id)}` });
46
+ },
47
+ addVersion(id, body) {
48
+ return request({ method: 'POST', path: `/v1/action_templates/${(0, request_1.enc)(id)}/versions`, body });
49
+ },
50
+ submitVersion(id, version) {
51
+ return request({ method: 'POST', path: `/v1/action_templates/${(0, request_1.enc)(id)}/versions/${(0, request_1.enc)(version)}/submit` });
52
+ },
53
+ deleteVersion(id, version) {
54
+ return request({ method: 'DELETE', path: `/v1/action_templates/${(0, request_1.enc)(id)}/versions/${(0, request_1.enc)(version)}` });
55
+ },
56
+ /** List an approved template again after unlisting it. */
57
+ publish(id) {
58
+ return request({ method: 'POST', path: `/v1/action_templates/${(0, request_1.enc)(id)}/publish` });
59
+ },
60
+ /** Hide a template from the gallery (installs keep working). */
61
+ unlist(id) {
62
+ return request({ method: 'POST', path: `/v1/action_templates/${(0, request_1.enc)(id)}/unlist` });
63
+ },
64
+ };
65
+ }
66
+ //# sourceMappingURL=action-gallery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-gallery.js","sourceRoot":"","sources":["../../src/client/action-gallery.ts"],"names":[],"mappings":";;AA6LA,sDAuBC;AAED,0DAmCC;AAzPD,uCAAgD;AA6LhD,SAAgB,qBAAqB,CAAC,OAAkB;IACtD,OAAO;QACL,+BAA+B;QAC/B,IAAI,CAAC,SAA8B,EAAE;YACnC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC;QACtF,CAAC;QACD,6DAA6D;QAC7D,GAAG,CAAC,IAAY;YACd,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,IAAA,aAAG,EAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,kFAAkF;QAClF,OAAO,CAAC,IAAY,EAAE,OAA4B,EAAE,EAAE,cAAuB;YAC3E,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,IAAA,aAAG,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QAC5G,CAAC;QACD,8DAA8D;QAC9D,QAAQ;YACN,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,iEAAiE;QACjE,MAAM,CAAC,QAAgB,EAAE,OAA6C,EAAE;YACtE,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,QAAQ,CAAC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,EAAC,EAAE,CAAC,aAAa,IAAA,aAAG,EAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC9G,CAAC;QACD,aAAa,CAAC,EAAU,EAAE,OAAe;YACvC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,wBAAwB,IAAA,aAAG,EAAC,EAAE,CAAC,aAAa,IAAA,aAAG,EAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACzG,CAAC;QACD,0DAA0D;QAC1D,OAAO,CAAC,EAAU;YAChB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,IAAA,aAAG,EAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC;QACtF,CAAC;QACD,gEAAgE;QAChE,MAAM,CAAC,EAAU;YACf,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,IAAA,aAAG,EAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;QACrF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -40,15 +40,34 @@ export interface ActionTestEvent {
40
40
  email?: string;
41
41
  emailVerified?: boolean;
42
42
  metadata?: Record<string, unknown>;
43
+ /** The user's organization memberships, as `event.user.organizations`. */
44
+ organizations?: Array<{
45
+ id: string;
46
+ slug: string;
47
+ name: string;
48
+ role: string;
49
+ }>;
43
50
  };
44
51
  connection?: {
45
52
  strategy?: string;
46
53
  };
54
+ /** `country` is the ISO code `event.request.country` should carry. */
47
55
  request?: {
48
56
  ip?: string;
49
57
  user_agent?: string;
58
+ country?: string;
50
59
  };
51
60
  }
61
+ /** An outbound request the code queued with `api.http` (a dry run sends nothing). */
62
+ export interface ActionTestHttpRequest {
63
+ method: 'GET' | 'POST';
64
+ /** Query values are masked. */
65
+ url: string;
66
+ /** Header names only; values are never echoed. */
67
+ header_names: string[];
68
+ has_body: boolean;
69
+ save_response_as: string | null;
70
+ }
52
71
  /** What an action produced against a sample event — no real data is touched. */
53
72
  export interface ActionTestResult {
54
73
  object: 'action_test_result';
@@ -59,6 +78,8 @@ export interface ActionTestResult {
59
78
  id_token_claims: Record<string, unknown>;
60
79
  app_metadata: Record<string, unknown>;
61
80
  logs: string[];
81
+ /** What the code queued with `api.http`; sent only on a real post_login / post_user_registration run. */
82
+ http_requests?: ActionTestHttpRequest[];
62
83
  error: string | null;
63
84
  }
64
85
  /** The ordered binding list for a trigger, replaced atomically as a set. */
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/client/actions.ts"],"names":[],"mappings":";;AAwEA,0CAkCC;AA1GD,uCAAgD;AAwEhD,SAAgB,eAAe,CAAC,OAAkB;IAChD,OAAO;QACL,IAAI;YACF,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,CAAC,IAAsB,EAAE,cAAuB;YACpD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,GAAG,CAAC,EAAU;YACZ,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,CAAC,EAAU,EAAE,IAAsB;YACvC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,MAAM,CAAC,EAAU;YACf,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,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AG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,CAAC,EAAU,EAAE,IAAsB;YACvC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,MAAM,CAAC,EAAU;YACf,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,2EAA2E;QAC3E,IAAI,CAAC,EAAU,EAAE,QAAyB,EAAE;YAC1C,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,IAAA,aAAG,EAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3F,CAAC;QACD,oDAAoD;QACpD,WAAW,CAAC,OAAsB;YAChC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,wBAAwB,IAAA,aAAG,EAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,+CAA+C;QAC/C,WAAW,CAAC,OAAsB,EAAE,SAAmB;YACrD,OAAO,OAAO,CAAC;gBACb,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,wBAAwB,IAAA,aAAG,EAAC,OAAO,CAAC,EAAE;gBAC5C,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE;aAChC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -25,8 +25,39 @@ export interface AttackProtection {
25
25
  secret_set: boolean;
26
26
  managed_by: 'auth_config_and_captcha_secret';
27
27
  };
28
+ /** Read-only reflections of auth_config.attackProtection. */
29
+ country_restrictions?: {
30
+ mode: 'off' | 'allow' | 'deny';
31
+ countries: string[];
32
+ sign_up: boolean;
33
+ sign_in: boolean;
34
+ block_unknown: boolean;
35
+ managed_by: 'auth_config';
36
+ };
37
+ device_accounts?: {
38
+ enabled: boolean;
39
+ max_accounts: number;
40
+ window_days: number;
41
+ managed_by: 'auth_config';
42
+ };
43
+ /** Dormant-account reactivation alerts (writable). */
44
+ dormant_accounts?: DormantAccountsSettings;
45
+ }
46
+ /**
47
+ * When an account idle for `threshold_days` signs in again: an audit entry, the
48
+ * `user.reactivated` webhook, an optional security notice to the user, and —
49
+ * with `require_mfa` — a second-factor step-up (`on_no_factor` decides for an
50
+ * account without one).
51
+ */
52
+ export interface DormantAccountsSettings {
53
+ enabled: boolean;
54
+ /** 1–3650; default 90. */
55
+ threshold_days: number;
56
+ require_mfa: boolean;
57
+ on_no_factor: 'allow' | 'require_enroll' | 'block';
58
+ notify_user: boolean;
28
59
  }
29
- /** Only the two flags are writable; the rest of the object is read-only. */
60
+ /** The writable parts; the rest of the object is read-only. */
30
61
  export interface UpdateAttackProtectionBody {
31
62
  brute_force?: {
32
63
  enabled?: boolean;
@@ -34,6 +65,7 @@ export interface UpdateAttackProtectionBody {
34
65
  breached_password?: {
35
66
  enabled?: boolean;
36
67
  };
68
+ dormant_accounts?: Partial<DormantAccountsSettings>;
37
69
  }
38
70
  export declare function attackProtectionResource(request: RequestFn): {
39
71
  get(): Promise<AttackProtection>;
@@ -1 +1 @@
1
- {"version":3,"file":"attack-protection.js","sourceRoot":"","sources":["../../src/client/attack-protection.ts"],"names":[],"mappings":";;AAkCA,4DASC;AATD,SAAgB,wBAAwB,CAAC,OAAkB;IACzD,OAAO;QACL,GAAG;YACD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,CAAC,IAAgC;YACrC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"attack-protection.js","sourceRoot":"","sources":["../../src/client/attack-protection.ts"],"names":[],"mappings":";;AA8DA,4DASC;AATD,SAAgB,wBAAwB,CAAC,OAAkB;IACzD,OAAO;QACL,GAAG;YACD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,CAAC,IAAgC;YACrC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,205 @@
1
+ import { type RequestFn } from './request';
2
+ import type { CursorPage, CursorParams } from './types';
3
+ /**
4
+ * Migrate from Better Auth: import a sealed bundle made by
5
+ * `@atlasauth/better-auth-migrate` (`npx atlas-better-auth-export`).
6
+ *
7
+ * 1. `getPublicKey()` — the key the exporter seals the bundle to.
8
+ * 2. `create()`, `uploadPart()` for each part, `finalize()` — or `upload()`
9
+ * for all three. Atlas opens the bundle and runs the dry run.
10
+ * 3. Read the import's `report`, then `apply()`. Applying again after a
11
+ * failure resumes where it stopped; every record is an idempotent upsert.
12
+ */
13
+ export type BetterAuthImportStatus = 'uploading' | 'analyzing' | 'ready' | 'invalid' | 'queued' | 'applying' | 'completed' | 'failed';
14
+ export interface BetterAuthImportKey {
15
+ object: 'better_auth_import_key';
16
+ kid: string;
17
+ /** base64url raw X25519 public key. */
18
+ public_key: string;
19
+ alg: 'X25519-HKDF-SHA256-A256GCM';
20
+ status: 'active' | 'retired';
21
+ /** SHA-256 of the raw key, first 16 bytes as hex pairs. */
22
+ fingerprint: string;
23
+ /** `kid:public_key`, the form `--public-key` takes. */
24
+ compact: string;
25
+ created_at: number;
26
+ retired_at: number | null;
27
+ }
28
+ export interface BetterAuthImportOptions {
29
+ models?: string[];
30
+ on_email_conflict?: 'skip' | 'link';
31
+ default_role?: string;
32
+ create_app_roles?: boolean;
33
+ import_oauth_tokens?: boolean;
34
+ passkeys_on_rp_mismatch?: 'skip' | 'import';
35
+ import_subscriptions?: boolean;
36
+ plan_map?: Record<string, string>;
37
+ import_jwks?: boolean;
38
+ jwks_cutover_days?: number;
39
+ import_sessions?: boolean;
40
+ retain_bundle?: boolean;
41
+ }
42
+ export interface BetterAuthImportActionItem {
43
+ code: string;
44
+ severity: 'required' | 'recommended' | 'info';
45
+ message: string;
46
+ count: number;
47
+ items: string[];
48
+ }
49
+ interface ReportCommon {
50
+ skipped: Array<{
51
+ model: string;
52
+ row_id: string | null;
53
+ reason_code: string;
54
+ reason: string;
55
+ }>;
56
+ skipped_total: number;
57
+ skipped_by_code: Record<string, number>;
58
+ conflicts: Array<{
59
+ model: string;
60
+ row_id: string | null;
61
+ code: string;
62
+ message: string;
63
+ resolution: 'merge' | 'skip';
64
+ existing_id: string | null;
65
+ value?: string;
66
+ }>;
67
+ conflicts_total: number;
68
+ action_items: BetterAuthImportActionItem[];
69
+ warnings: string[];
70
+ notes: Record<string, unknown>;
71
+ }
72
+ export interface BetterAuthImportReport extends ReportCommon {
73
+ models: Array<{
74
+ model: string;
75
+ label: string;
76
+ found: number;
77
+ will_create: number;
78
+ will_update: number;
79
+ will_skip: number;
80
+ }>;
81
+ }
82
+ export interface BetterAuthImportResult extends ReportCommon {
83
+ models: Array<{
84
+ model: string;
85
+ label: string;
86
+ found: number;
87
+ created: number;
88
+ updated: number;
89
+ unchanged: number;
90
+ skipped: number;
91
+ failed: number;
92
+ }>;
93
+ completed_at: number | null;
94
+ }
95
+ export interface BetterAuthImport {
96
+ object: 'better_auth_import';
97
+ id: string;
98
+ status: BetterAuthImportStatus;
99
+ key_id: string | null;
100
+ parts: number;
101
+ bytes: number;
102
+ bundle_sha256: string | null;
103
+ bundle_purged: boolean;
104
+ options: BetterAuthImportOptions;
105
+ source: {
106
+ exported_at: string;
107
+ exporter: {
108
+ name: string;
109
+ version: string;
110
+ };
111
+ better_auth_version: string | null;
112
+ base_url: string | null;
113
+ plugins: string[];
114
+ models: string[];
115
+ rp_id: string | null;
116
+ social_providers: string[];
117
+ } | null;
118
+ total: number;
119
+ progress: {
120
+ total: number;
121
+ processed: number;
122
+ succeeded: number;
123
+ failed: number;
124
+ percent: number;
125
+ } | null;
126
+ report: BetterAuthImportReport | null;
127
+ result: BetterAuthImportResult | null;
128
+ error: {
129
+ code: string;
130
+ message: string;
131
+ } | null;
132
+ created_at: number;
133
+ updated_at: number;
134
+ analyzed_at: number | null;
135
+ apply_started_at: number | null;
136
+ completed_at: number | null;
137
+ }
138
+ export interface ImportedJwk {
139
+ object: 'imported_jwk';
140
+ kid: string;
141
+ source: string;
142
+ jwk: Record<string, unknown>;
143
+ import_id: string | null;
144
+ expires_at: number | null;
145
+ created_at: number;
146
+ }
147
+ /** Bytes per uploaded part (the API takes at most 10 MiB). Parts end on a line boundary. */
148
+ export declare const BETTER_AUTH_IMPORT_PART_BYTES: number;
149
+ /** Split a sealed bundle's text into upload parts on line boundaries. */
150
+ export declare function splitBundleParts(text: string, maxBytes?: number): string[];
151
+ export declare function betterAuthImportsResource(request: RequestFn): {
152
+ /** The import public key (created on first read). */
153
+ getPublicKey(): Promise<BetterAuthImportKey>;
154
+ /** Replace the import key; bundles sealed to the old one no longer finalize. */
155
+ rotatePublicKey(): Promise<BetterAuthImportKey>;
156
+ create(body?: {
157
+ options?: BetterAuthImportOptions;
158
+ }, idempotencyKey?: string): Promise<BetterAuthImport>;
159
+ list(params?: CursorParams): Promise<CursorPage<BetterAuthImport>>;
160
+ get(id: string): Promise<BetterAuthImport>;
161
+ /** Upload part `part` (1-based) of the sealed bundle text. */
162
+ uploadPart(id: string, part: number, data: string): Promise<{
163
+ object: "better_auth_import_part";
164
+ import_id: string;
165
+ part: number;
166
+ bytes: number;
167
+ sha256: string;
168
+ }>;
169
+ /** Close the upload; Atlas checks the key and runs the dry run. */
170
+ finalize(id: string): Promise<BetterAuthImport>;
171
+ /** Run the dry run again, optionally with new options. */
172
+ dryRun(id: string, body?: {
173
+ options?: BetterAuthImportOptions;
174
+ }): Promise<BetterAuthImport>;
175
+ /** Import (or resume). Pass confirm_conflicts when the dry run reported conflicts. */
176
+ apply(id: string, body?: {
177
+ confirm_conflicts?: boolean;
178
+ }): Promise<BetterAuthImport>;
179
+ delete(id: string): Promise<{
180
+ object: "better_auth_import";
181
+ id: string;
182
+ deleted: true;
183
+ }>;
184
+ /** Better Auth JWT keys published in the instance JWKS for the cutover. */
185
+ listJwks(): Promise<CursorPage<ImportedJwk>>;
186
+ deleteJwk(kid: string): Promise<{
187
+ object: "imported_jwk";
188
+ kid: string;
189
+ deleted: true;
190
+ }>;
191
+ /** Create an import, upload the sealed bundle text in parts and finalize it. */
192
+ upload(bundleText: string, opts?: {
193
+ options?: BetterAuthImportOptions;
194
+ partBytes?: number;
195
+ onPart?: (n: number, of: number) => void;
196
+ }): Promise<BetterAuthImport>;
197
+ /** Poll until the import leaves analyzing / queued / applying. */
198
+ waitFor(id: string, opts?: {
199
+ intervalMs?: number;
200
+ timeoutMs?: number;
201
+ onProgress?: (imp: BetterAuthImport) => void;
202
+ sleep?: (ms: number) => Promise<void>;
203
+ }): Promise<BetterAuthImport>;
204
+ };
205
+ export {};