@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.
- package/CHANGELOG.md +14 -0
- package/dist/auth0-session.d.ts +23 -0
- package/dist/auth0-session.js +80 -0
- package/dist/auth0-session.js.map +1 -0
- package/dist/better-auth.d.ts +4 -8
- package/dist/better-auth.js +42 -150
- package/dist/better-auth.js.map +1 -1
- package/dist/client/abac.d.ts +132 -0
- package/dist/client/abac.js +48 -0
- package/dist/client/abac.js.map +1 -0
- package/dist/client/access-policies.d.ts +100 -0
- package/dist/client/access-policies.js +29 -0
- package/dist/client/access-policies.js.map +1 -0
- package/dist/client/action-gallery.d.ts +1 -1
- package/dist/client/action-gallery.js.map +1 -1
- package/dist/client/actions.d.ts +129 -6
- package/dist/client/actions.js +4 -0
- package/dist/client/actions.js.map +1 -1
- package/dist/client/analytics-reports.d.ts +215 -0
- package/dist/client/analytics-reports.js +56 -0
- package/dist/client/analytics-reports.js.map +1 -0
- package/dist/client/app-catalog.d.ts +74 -0
- package/dist/client/app-catalog.js +30 -0
- package/dist/client/app-catalog.js.map +1 -0
- package/dist/client/attack-protection.d.ts +10 -0
- package/dist/client/attack-protection.js +8 -0
- package/dist/client/attack-protection.js.map +1 -1
- package/dist/client/audit-events.d.ts +71 -0
- package/dist/client/audit-events.js +28 -0
- package/dist/client/audit-events.js.map +1 -1
- package/dist/client/credentials.d.ts +8 -0
- package/dist/client/credentials.js.map +1 -1
- package/dist/client/delegated-ui-proxy.d.ts +25 -0
- package/dist/client/delegated-ui-proxy.js +46 -0
- package/dist/client/delegated-ui-proxy.js.map +1 -0
- package/dist/client/devices.d.ts +44 -0
- package/dist/client/devices.js +26 -0
- package/dist/client/devices.js.map +1 -0
- package/dist/client/email-templates.d.ts +1 -1
- package/dist/client/email-templates.js.map +1 -1
- package/dist/client/flags.d.ts +101 -0
- package/dist/client/flags.js +104 -0
- package/dist/client/flags.js.map +1 -0
- package/dist/client/groups.d.ts +146 -0
- package/dist/client/groups.js +67 -0
- package/dist/client/groups.js.map +1 -0
- package/dist/client/identity-verification.d.ts +62 -0
- package/dist/client/identity-verification.js +39 -0
- package/dist/client/identity-verification.js.map +1 -0
- package/dist/client/index.d.ts +997 -2
- package/dist/client/index.js +77 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/journeys.d.ts +108 -0
- package/dist/client/journeys.js +35 -0
- package/dist/client/journeys.js.map +1 -0
- package/dist/client/log-streams.d.ts +1 -1
- package/dist/client/marketing.d.ts +67 -0
- package/dist/client/marketing.js +26 -0
- package/dist/client/marketing.js.map +1 -0
- package/dist/client/mcp-gateways.d.ts +54 -0
- package/dist/client/mcp-gateways.js +25 -0
- package/dist/client/mcp-gateways.js.map +1 -0
- package/dist/client/messaging.d.ts +14 -3
- package/dist/client/messaging.js.map +1 -1
- package/dist/client/mfa-factors.d.ts +120 -0
- package/dist/client/mfa-factors.js +73 -0
- package/dist/client/mfa-factors.js.map +1 -0
- package/dist/client/migrations.d.ts +286 -0
- package/dist/client/migrations.js +103 -0
- package/dist/client/migrations.js.map +1 -0
- package/dist/client/network-acls.d.ts +6 -1
- package/dist/client/network-acls.js.map +1 -1
- package/dist/client/network-zones.d.ts +56 -0
- package/dist/client/network-zones.js +29 -0
- package/dist/client/network-zones.js.map +1 -0
- package/dist/client/notifications.d.ts +1 -1
- package/dist/client/notifications.js.map +1 -1
- package/dist/client/oauth-clients.d.ts +183 -3
- package/dist/client/oauth-clients.js +64 -0
- package/dist/client/oauth-clients.js.map +1 -1
- package/dist/client/org-role-grants.d.ts +57 -0
- package/dist/client/org-role-grants.js +40 -0
- package/dist/client/org-role-grants.js.map +1 -0
- package/dist/client/organizations.d.ts +52 -0
- package/dist/client/organizations.js +44 -0
- package/dist/client/organizations.js.map +1 -1
- package/dist/client/page-templates.d.ts +78 -0
- package/dist/client/page-templates.js +31 -0
- package/dist/client/page-templates.js.map +1 -0
- package/dist/client/passkey-api.d.ts +73 -0
- package/dist/client/passkey-api.js +34 -0
- package/dist/client/passkey-api.js.map +1 -0
- package/dist/client/resources.d.ts +149 -0
- package/dist/client/resources.js +73 -0
- package/dist/client/resources.js.map +1 -0
- package/dist/client/risk-based-mfa.d.ts +147 -0
- package/dist/client/risk-based-mfa.js +30 -0
- package/dist/client/risk-based-mfa.js.map +1 -1
- package/dist/client/roles.d.ts +4 -0
- package/dist/client/roles.js.map +1 -1
- package/dist/client/service-connectors.d.ts +83 -0
- package/dist/client/service-connectors.js +33 -0
- package/dist/client/service-connectors.js.map +1 -0
- package/dist/client/ssf.d.ts +111 -0
- package/dist/client/ssf.js +49 -0
- package/dist/client/ssf.js.map +1 -0
- package/dist/client/sso-onboarding.d.ts +6 -0
- package/dist/client/sso-onboarding.js.map +1 -1
- package/dist/client/users.d.ts +302 -0
- package/dist/client/users.js +125 -0
- package/dist/client/users.js.map +1 -1
- package/dist/client/vault.d.ts +85 -0
- package/dist/client/vault.js +50 -0
- package/dist/client/vault.js.map +1 -0
- package/dist/client/vc.d.ts +128 -0
- package/dist/client/vc.js +43 -0
- package/dist/client/vc.js.map +1 -0
- package/dist/client/webhooks.d.ts +31 -2
- package/dist/client/webhooks.js.map +1 -1
- package/dist/client/workflows.d.ts +131 -0
- package/dist/client/workflows.js +36 -0
- package/dist/client/workflows.js.map +1 -0
- package/dist/framework-bridge.d.ts +98 -0
- package/dist/framework-bridge.js +264 -0
- package/dist/framework-bridge.js.map +1 -0
- package/dist/framework-sessions.d.ts +147 -0
- package/dist/framework-sessions.js +544 -0
- package/dist/framework-sessions.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy-issuer-presets.d.ts +85 -0
- package/dist/legacy-issuer-presets.js +165 -0
- package/dist/legacy-issuer-presets.js.map +1 -0
- package/dist/legacy-issuers.d.ts +16 -2
- package/dist/legacy-issuers.js +16 -1
- package/dist/legacy-issuers.js.map +1 -1
- package/dist/legacy-verify.d.ts +103 -0
- package/dist/legacy-verify.js +244 -0
- package/dist/legacy-verify.js.map +1 -0
- package/dist/magic-did.d.ts +5 -0
- package/dist/magic-did.js +49 -0
- package/dist/magic-did.js.map +1 -0
- package/dist/migration-bridge.d.ts +162 -0
- package/dist/migration-bridge.js +354 -0
- package/dist/migration-bridge.js.map +1 -0
- package/dist/migration-presets-g3.d.ts +2 -0
- package/dist/migration-presets-g3.js +254 -0
- package/dist/migration-presets-g3.js.map +1 -0
- package/dist/migration-presets-g4/authentik.d.ts +14 -0
- package/dist/migration-presets-g4/authentik.js +37 -0
- package/dist/migration-presets-g4/authentik.js.map +1 -0
- package/dist/migration-presets-g4/fusionauth.d.ts +2 -0
- package/dist/migration-presets-g4/fusionauth.js +52 -0
- package/dist/migration-presets-g4/fusionauth.js.map +1 -0
- package/dist/migration-presets-g4/hanko.d.ts +12 -0
- package/dist/migration-presets-g4/hanko.js +46 -0
- package/dist/migration-presets-g4/hanko.js.map +1 -0
- package/dist/migration-presets-g4/keycloak.d.ts +16 -0
- package/dist/migration-presets-g4/keycloak.js +37 -0
- package/dist/migration-presets-g4/keycloak.js.map +1 -0
- package/dist/migration-presets-g4/logto.d.ts +12 -0
- package/dist/migration-presets-g4/logto.js +35 -0
- package/dist/migration-presets-g4/logto.js.map +1 -0
- package/dist/migration-presets-g4/ory.d.ts +2 -0
- package/dist/migration-presets-g4/ory.js +67 -0
- package/dist/migration-presets-g4/ory.js.map +1 -0
- package/dist/migration-presets-g4/supertokens.d.ts +13 -0
- package/dist/migration-presets-g4/supertokens.js +35 -0
- package/dist/migration-presets-g4/supertokens.js.map +1 -0
- package/dist/migration-presets-g4/zitadel.d.ts +2 -0
- package/dist/migration-presets-g4/zitadel.js +36 -0
- package/dist/migration-presets-g4/zitadel.js.map +1 -0
- package/dist/migration-presets-g4.d.ts +10 -0
- package/dist/migration-presets-g4.js +30 -0
- package/dist/migration-presets-g4.js.map +1 -0
- package/dist/migration-presets.d.ts +156 -0
- package/dist/migration-presets.js +536 -0
- package/dist/migration-presets.js.map +1 -0
- package/dist/request-auth.d.ts +32 -0
- package/dist/request-auth.js +72 -0
- package/dist/request-auth.js.map +1 -0
- package/dist/verify.d.ts +2 -0
- package/dist/verify.js.map +1 -1
- package/dist/workos-session.d.ts +30 -0
- package/dist/workos-session.js +123 -0
- package/dist/workos-session.js.map +1 -0
- package/package.json +1 -1
|
@@ -18,9 +18,9 @@ import { type RequestFn } from './request';
|
|
|
18
18
|
* stored secret) stays. So a from-address change need not re-enter the API key.
|
|
19
19
|
*/
|
|
20
20
|
/** Email transports accepted by `PUT /v1/messaging_providers/email`. */
|
|
21
|
-
export type EmailTransport = 'resend' | 'ses' | 'smtp' | 'brevo' | 'mailgun';
|
|
21
|
+
export type EmailTransport = 'resend' | 'ses' | 'smtp' | 'brevo' | 'mailgun' | 'webhook';
|
|
22
22
|
/** SMS transports accepted by `PUT /v1/messaging_providers/sms`. */
|
|
23
|
-
export type SmsTransport = 'twilio' | 'vonage' | 'messagebird' | 'plivo' | 'telnyx' | 'sinch' | 'infobip' | 'clicksend' | 'bandwidth' | 'aws_sns';
|
|
23
|
+
export type SmsTransport = 'twilio' | 'vonage' | 'messagebird' | 'plivo' | 'telnyx' | 'sinch' | 'infobip' | 'clicksend' | 'bandwidth' | 'aws_sns' | 'webhook';
|
|
24
24
|
export type MessagingTransport = EmailTransport | SmsTransport;
|
|
25
25
|
/** Sender number or ID for an SMS provider. `from_address` on the request takes precedence. */
|
|
26
26
|
interface SmsFrom {
|
|
@@ -150,6 +150,15 @@ export interface AwsSnsConfig extends SmsFrom {
|
|
|
150
150
|
/** STS session token, only for temporary credentials. Write-only: never returned. */
|
|
151
151
|
session_token?: string;
|
|
152
152
|
}
|
|
153
|
+
/** Your own delivery endpoint: Atlas POSTs each message, Standard Webhooks signed. */
|
|
154
|
+
export interface WebhookConfig {
|
|
155
|
+
/** Your HTTPS endpoint (port 443). Required on first setup. */
|
|
156
|
+
url: string;
|
|
157
|
+
/** Signing secret (`whsec_…` base64 or any string). Required on first setup. Write-only: never returned. */
|
|
158
|
+
signing_secret: string;
|
|
159
|
+
/** Email only. `rendered` (default) sends the final subject/text/html; `raw` sends the template name and variables. */
|
|
160
|
+
payload?: 'rendered' | 'raw';
|
|
161
|
+
}
|
|
153
162
|
/** The `config` shape for each transport, keyed by transport. */
|
|
154
163
|
export interface MessagingTransportConfigs {
|
|
155
164
|
resend: ResendConfig;
|
|
@@ -167,6 +176,7 @@ export interface MessagingTransportConfigs {
|
|
|
167
176
|
clicksend: ClicksendConfig;
|
|
168
177
|
bandwidth: BandwidthConfig;
|
|
169
178
|
aws_sns: AwsSnsConfig;
|
|
179
|
+
webhook: WebhookConfig;
|
|
170
180
|
}
|
|
171
181
|
/** The write-only (secret) keys of each transport — never present in a response. */
|
|
172
182
|
export interface MessagingSecretKeys {
|
|
@@ -185,6 +195,7 @@ export interface MessagingSecretKeys {
|
|
|
185
195
|
clicksend: 'api_key';
|
|
186
196
|
bandwidth: 'password';
|
|
187
197
|
aws_sns: 'secret_access_key' | 'session_token';
|
|
198
|
+
webhook: 'signing_secret';
|
|
188
199
|
}
|
|
189
200
|
interface ProviderBodyBase<T extends MessagingTransport> {
|
|
190
201
|
transport: T;
|
|
@@ -413,7 +424,7 @@ export type EnableDevelopmentEmailBody = {
|
|
|
413
424
|
provider_id: string;
|
|
414
425
|
from_address?: string;
|
|
415
426
|
} | {
|
|
416
|
-
transport: 'resend' | 'ses' | 'smtp' | 'brevo' | 'mailgun';
|
|
427
|
+
transport: 'resend' | 'ses' | 'smtp' | 'brevo' | 'mailgun' | 'webhook';
|
|
417
428
|
config?: Record<string, string>;
|
|
418
429
|
from_address?: string;
|
|
419
430
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/client/messaging.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/client/messaging.ts"],"names":[],"mappings":";;AAifA,8C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KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type RequestFn } from './request';
|
|
2
|
+
/** An existing second factor to import with a user (`atlas.users.create({ mfa })`). */
|
|
3
|
+
export interface ImportedMfa {
|
|
4
|
+
/** An authenticator-app secret. SHA1, SHA256 or SHA512; 6 or 8 digits; 30 or 60 second step. */
|
|
5
|
+
totp?: {
|
|
6
|
+
secret_base32: string;
|
|
7
|
+
algorithm?: 'SHA1' | 'SHA256' | 'SHA512';
|
|
8
|
+
digits?: 6 | 8;
|
|
9
|
+
period?: 30 | 60;
|
|
10
|
+
verified_at?: number | string;
|
|
11
|
+
};
|
|
12
|
+
/** A counter-based (HOTP) token. Give `totp` or `hotp`, not both. */
|
|
13
|
+
hotp?: {
|
|
14
|
+
secret_base32: string;
|
|
15
|
+
algorithm?: 'SHA1' | 'SHA256' | 'SHA512';
|
|
16
|
+
digits?: 6 | 8;
|
|
17
|
+
/** The next counter the token will produce. Default 0. */
|
|
18
|
+
counter?: number;
|
|
19
|
+
verified_at?: number | string;
|
|
20
|
+
};
|
|
21
|
+
/** Plaintext recovery codes; they are hashed on import. */
|
|
22
|
+
backup_codes?: string[];
|
|
23
|
+
}
|
|
24
|
+
export type SmartCardMappingKind = 'san_email' | 'san_upn' | 'subject_cn' | 'serial' | 'fingerprint';
|
|
25
|
+
export interface Yubikey {
|
|
26
|
+
object: 'yubikey';
|
|
27
|
+
id: string;
|
|
28
|
+
public_id: string;
|
|
29
|
+
label: string | null;
|
|
30
|
+
user_id: string | null;
|
|
31
|
+
has_private_id: boolean;
|
|
32
|
+
last_counter: number | null;
|
|
33
|
+
created_at: number;
|
|
34
|
+
}
|
|
35
|
+
export interface SmartCardMapping {
|
|
36
|
+
object: 'smartcard_mapping';
|
|
37
|
+
id: string;
|
|
38
|
+
user_id: string;
|
|
39
|
+
kind: SmartCardMappingKind;
|
|
40
|
+
value: string;
|
|
41
|
+
label: string | null;
|
|
42
|
+
last_used_at: number | null;
|
|
43
|
+
created_at: number;
|
|
44
|
+
}
|
|
45
|
+
type SecretSet<T extends string> = {
|
|
46
|
+
object: T;
|
|
47
|
+
set: true;
|
|
48
|
+
};
|
|
49
|
+
type SecretDeleted<T extends string> = {
|
|
50
|
+
object: T;
|
|
51
|
+
deleted: true;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The additional authentication factors: the write-only BYOK secrets (Yubico cloud, Duo, the
|
|
55
|
+
* smart card proxy), the self-held Yubico OTP key registry, smart card certificate mappings and
|
|
56
|
+
* the admin reset for security questions. Turn the factors on in the auth config (`mfa.factors`,
|
|
57
|
+
* `mfa.hotp`, `mfa.yubikey`, `mfa.duo`, `mfa.smartCard`, `mfa.securityQuestions`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function mfaFactorsResource(request: RequestFn): {
|
|
60
|
+
/** Store the Yubico cloud API secret key (base64). Write-only. */
|
|
61
|
+
setYubicoSecret(secret: string): Promise<SecretSet<"yubico_secret">>;
|
|
62
|
+
removeYubicoSecret(): Promise<SecretDeleted<"yubico_secret">>;
|
|
63
|
+
/** Store the Duo client secret. Write-only. */
|
|
64
|
+
setDuoSecret(secret: string): Promise<SecretSet<"duo_secret">>;
|
|
65
|
+
removeDuoSecret(): Promise<SecretDeleted<"duo_secret">>;
|
|
66
|
+
/** Ask Duo whether the configured integration key, stored secret and API host are accepted. */
|
|
67
|
+
duoHealthCheck(): Promise<{
|
|
68
|
+
object: "duo_health_check";
|
|
69
|
+
ok: boolean;
|
|
70
|
+
message: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** Store the shared secret your TLS proxy sends so Atlas trusts its certificate headers. Write-only. */
|
|
73
|
+
setSmartCardSecret(secret: string): Promise<SecretSet<"smart_card_secret">>;
|
|
74
|
+
removeSmartCardSecret(): Promise<SecretDeleted<"smart_card_secret">>;
|
|
75
|
+
yubikeys: {
|
|
76
|
+
/** Registered self-held YubiKeys. The AES keys are never returned. */
|
|
77
|
+
list(): Promise<{
|
|
78
|
+
object: "list";
|
|
79
|
+
data: Yubikey[];
|
|
80
|
+
}>;
|
|
81
|
+
/** Register a YubiKey's AES key for self-held Yubico OTP. `userId` assigns it; otherwise the first user to enrol it claims it. */
|
|
82
|
+
register(body: {
|
|
83
|
+
publicId: string;
|
|
84
|
+
aesKey: string;
|
|
85
|
+
privateId?: string;
|
|
86
|
+
label?: string;
|
|
87
|
+
userId?: string;
|
|
88
|
+
}): Promise<Yubikey>;
|
|
89
|
+
remove(id: string): Promise<{
|
|
90
|
+
object: "yubikey";
|
|
91
|
+
id: string;
|
|
92
|
+
deleted: true;
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
smartCardMappings: {
|
|
96
|
+
list(userId: string): Promise<{
|
|
97
|
+
object: "list";
|
|
98
|
+
data: SmartCardMapping[];
|
|
99
|
+
}>;
|
|
100
|
+
/** Pre-register the certificate attribute that signs a user in. A `serial` needs the certificate's `issuer` DN. */
|
|
101
|
+
add(userId: string, body: {
|
|
102
|
+
kind: SmartCardMappingKind;
|
|
103
|
+
value: string;
|
|
104
|
+
issuer?: string;
|
|
105
|
+
label?: string;
|
|
106
|
+
}): Promise<SmartCardMapping>;
|
|
107
|
+
remove(userId: string, mappingId: string): Promise<{
|
|
108
|
+
object: "smartcard_mapping";
|
|
109
|
+
id: string;
|
|
110
|
+
deleted: true;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
/** Clear a user's security-question answers (and any lockout). */
|
|
114
|
+
resetSecurityQuestions(userId: string): Promise<{
|
|
115
|
+
object: "security_questions";
|
|
116
|
+
user_id: string;
|
|
117
|
+
deleted: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
};
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mfaFactorsResource = mfaFactorsResource;
|
|
4
|
+
const request_1 = require("./request");
|
|
5
|
+
/**
|
|
6
|
+
* The additional authentication factors: the write-only BYOK secrets (Yubico cloud, Duo, the
|
|
7
|
+
* smart card proxy), the self-held Yubico OTP key registry, smart card certificate mappings and
|
|
8
|
+
* the admin reset for security questions. Turn the factors on in the auth config (`mfa.factors`,
|
|
9
|
+
* `mfa.hotp`, `mfa.yubikey`, `mfa.duo`, `mfa.smartCard`, `mfa.securityQuestions`).
|
|
10
|
+
*/
|
|
11
|
+
function mfaFactorsResource(request) {
|
|
12
|
+
return {
|
|
13
|
+
/** Store the Yubico cloud API secret key (base64). Write-only. */
|
|
14
|
+
setYubicoSecret(secret) {
|
|
15
|
+
return request({ method: 'PUT', path: '/v1/instance/yubico_secret', body: { secret } });
|
|
16
|
+
},
|
|
17
|
+
removeYubicoSecret() {
|
|
18
|
+
return request({ method: 'DELETE', path: '/v1/instance/yubico_secret' });
|
|
19
|
+
},
|
|
20
|
+
/** Store the Duo client secret. Write-only. */
|
|
21
|
+
setDuoSecret(secret) {
|
|
22
|
+
return request({ method: 'PUT', path: '/v1/instance/duo_secret', body: { secret } });
|
|
23
|
+
},
|
|
24
|
+
removeDuoSecret() {
|
|
25
|
+
return request({ method: 'DELETE', path: '/v1/instance/duo_secret' });
|
|
26
|
+
},
|
|
27
|
+
/** Ask Duo whether the configured integration key, stored secret and API host are accepted. */
|
|
28
|
+
duoHealthCheck() {
|
|
29
|
+
return request({ method: 'POST', path: '/v1/instance/duo_health_check' });
|
|
30
|
+
},
|
|
31
|
+
/** Store the shared secret your TLS proxy sends so Atlas trusts its certificate headers. Write-only. */
|
|
32
|
+
setSmartCardSecret(secret) {
|
|
33
|
+
return request({ method: 'PUT', path: '/v1/instance/smart_card_secret', body: { secret } });
|
|
34
|
+
},
|
|
35
|
+
removeSmartCardSecret() {
|
|
36
|
+
return request({ method: 'DELETE', path: '/v1/instance/smart_card_secret' });
|
|
37
|
+
},
|
|
38
|
+
yubikeys: {
|
|
39
|
+
/** Registered self-held YubiKeys. The AES keys are never returned. */
|
|
40
|
+
list() {
|
|
41
|
+
return request({ method: 'GET', path: '/v1/yubikeys' });
|
|
42
|
+
},
|
|
43
|
+
/** Register a YubiKey's AES key for self-held Yubico OTP. `userId` assigns it; otherwise the first user to enrol it claims it. */
|
|
44
|
+
register(body) {
|
|
45
|
+
return request({
|
|
46
|
+
method: 'POST',
|
|
47
|
+
path: '/v1/yubikeys',
|
|
48
|
+
body: { public_id: body.publicId, aes_key: body.aesKey, private_id: body.privateId, label: body.label, user_id: body.userId },
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
remove(id) {
|
|
52
|
+
return request({ method: 'DELETE', path: `/v1/yubikeys/${(0, request_1.enc)(id)}` });
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
smartCardMappings: {
|
|
56
|
+
list(userId) {
|
|
57
|
+
return request({ method: 'GET', path: `/v1/users/${(0, request_1.enc)(userId)}/smartcard_mappings` });
|
|
58
|
+
},
|
|
59
|
+
/** Pre-register the certificate attribute that signs a user in. A `serial` needs the certificate's `issuer` DN. */
|
|
60
|
+
add(userId, body) {
|
|
61
|
+
return request({ method: 'POST', path: `/v1/users/${(0, request_1.enc)(userId)}/smartcard_mappings`, body });
|
|
62
|
+
},
|
|
63
|
+
remove(userId, mappingId) {
|
|
64
|
+
return request({ method: 'DELETE', path: `/v1/users/${(0, request_1.enc)(userId)}/smartcard_mappings/${(0, request_1.enc)(mappingId)}` });
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
/** Clear a user's security-question answers (and any lockout). */
|
|
68
|
+
resetSecurityQuestions(userId) {
|
|
69
|
+
return request({ method: 'DELETE', path: `/v1/users/${(0, request_1.enc)(userId)}/security_questions` });
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=mfa-factors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa-factors.js","sourceRoot":"","sources":["../../src/client/mfa-factors.ts"],"names":[],"mappings":";;AA0DA,gDAgEC;A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,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC5F,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { type BetterAuthImportActionItem } from './better-auth-imports';
|
|
2
|
+
import { type RequestFn } from './request';
|
|
3
|
+
import type { CursorPage, CursorParams } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Migrate to Atlas from any source: the vendor-neutral surface every vendor
|
|
6
|
+
* plugs into (`{source}`: `auth0`, `clerk`, `cognito`, `firebase`, …,
|
|
7
|
+
* `better_auth`, `custom`).
|
|
8
|
+
*
|
|
9
|
+
* imports `/v1/migrations/{source}/imports` — a sealed migration bundle
|
|
10
|
+
* (`@atlasauth/migrate`, or `atlas migrate export <vendor>`):
|
|
11
|
+
* `getPublicKey()`, `upload()` (create + parts + finalize), read the
|
|
12
|
+
* `report`, `apply()`; applying again after a failure resumes.
|
|
13
|
+
* bridge `/v1/migrations/{source}/bridge` — the zero-logout bridge settings
|
|
14
|
+
* (a vendor JWT preset, or imported sessions).
|
|
15
|
+
* sources `/v1/migrations/sources` — what each source supports.
|
|
16
|
+
*/
|
|
17
|
+
export type MigrationSourceId = 'better_auth' | 'auth0' | 'clerk' | 'cognito' | 'firebase' | 'supabase' | 'workos' | 'authjs' | 'okta' | 'stytch' | 'keycloak' | 'fusionauth' | 'kinde' | 'descope' | 'lucia' | 'ory' | 'frontegg' | 'propelauth' | 'magic' | 'userfront' | 'corbado' | 'custom';
|
|
18
|
+
export type MigrationImportStatus = 'uploading' | 'analyzing' | 'ready' | 'invalid' | 'queued' | 'applying' | 'completed' | 'failed';
|
|
19
|
+
export interface MigrationImportKey {
|
|
20
|
+
object: 'migration_import_key';
|
|
21
|
+
kid: string;
|
|
22
|
+
/** base64url raw X25519 public key. One key serves every source. */
|
|
23
|
+
public_key: string;
|
|
24
|
+
alg: 'X25519-HKDF-SHA256-A256GCM';
|
|
25
|
+
status: 'active' | 'retired';
|
|
26
|
+
fingerprint: string;
|
|
27
|
+
/** `kid:public_key`, the form the exporters take. */
|
|
28
|
+
compact: string;
|
|
29
|
+
created_at: number;
|
|
30
|
+
retired_at: number | null;
|
|
31
|
+
}
|
|
32
|
+
/** Options of a non-Better-Auth import (a `better_auth` import takes {@link BetterAuthImportOptions}). */
|
|
33
|
+
export interface MigrationImportOptions {
|
|
34
|
+
models?: Array<'organization' | 'role' | 'user' | 'identity' | 'mfa_factor' | 'passkey' | 'membership' | 'invitation' | 'api_key' | 'sso_connection' | 'jwks' | 'session'>;
|
|
35
|
+
on_email_conflict?: 'skip' | 'link';
|
|
36
|
+
create_app_roles?: boolean;
|
|
37
|
+
import_oauth_tokens?: boolean;
|
|
38
|
+
passkeys_on_rp_mismatch?: 'skip' | 'import';
|
|
39
|
+
import_sessions?: boolean;
|
|
40
|
+
import_jwks?: boolean;
|
|
41
|
+
jwks_cutover_days?: number;
|
|
42
|
+
/** Source provider name → Atlas provider key. */
|
|
43
|
+
provider_map?: Record<string, string>;
|
|
44
|
+
/** Hash parameters that live outside the export, per algorithm id (Firebase signer key …). */
|
|
45
|
+
password_hash_params?: Record<string, Record<string, string | number | boolean>>;
|
|
46
|
+
retain_bundle?: boolean;
|
|
47
|
+
[option: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface MigrationReportCommon {
|
|
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
|
+
}>;
|
|
66
|
+
conflicts_total: number;
|
|
67
|
+
action_items: BetterAuthImportActionItem[];
|
|
68
|
+
warnings: string[];
|
|
69
|
+
notes: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
export interface MigrationImportReport extends MigrationReportCommon {
|
|
72
|
+
models: Array<{
|
|
73
|
+
model: string;
|
|
74
|
+
label: string;
|
|
75
|
+
found: number;
|
|
76
|
+
will_create: number;
|
|
77
|
+
will_update: number;
|
|
78
|
+
will_skip: number;
|
|
79
|
+
}>;
|
|
80
|
+
/** Users per password-hash algorithm. */
|
|
81
|
+
password_algorithms?: Record<string, number>;
|
|
82
|
+
}
|
|
83
|
+
export interface MigrationImportResult extends MigrationReportCommon {
|
|
84
|
+
models: Array<{
|
|
85
|
+
model: string;
|
|
86
|
+
label: string;
|
|
87
|
+
found: number;
|
|
88
|
+
created: number;
|
|
89
|
+
updated: number;
|
|
90
|
+
unchanged: number;
|
|
91
|
+
skipped: number;
|
|
92
|
+
failed: number;
|
|
93
|
+
}>;
|
|
94
|
+
completed_at: number | null;
|
|
95
|
+
}
|
|
96
|
+
export interface MigrationImport {
|
|
97
|
+
object: 'migration_import';
|
|
98
|
+
id: string;
|
|
99
|
+
source: MigrationSourceId;
|
|
100
|
+
format: 'atlas-migration-bundle' | 'atlas-better-auth-bundle';
|
|
101
|
+
status: MigrationImportStatus;
|
|
102
|
+
key_id: string | null;
|
|
103
|
+
parts: number;
|
|
104
|
+
bytes: number;
|
|
105
|
+
bundle_sha256: string | null;
|
|
106
|
+
bundle_purged: boolean;
|
|
107
|
+
options: Record<string, unknown>;
|
|
108
|
+
manifest: {
|
|
109
|
+
exported_at: string;
|
|
110
|
+
exporter: {
|
|
111
|
+
name: string;
|
|
112
|
+
version: string;
|
|
113
|
+
};
|
|
114
|
+
origin: string | null;
|
|
115
|
+
source_version: string | null;
|
|
116
|
+
models: string[];
|
|
117
|
+
providers: string[];
|
|
118
|
+
rp_id: string | null;
|
|
119
|
+
warnings: string[];
|
|
120
|
+
} | null;
|
|
121
|
+
total: number;
|
|
122
|
+
progress: {
|
|
123
|
+
total: number;
|
|
124
|
+
processed: number;
|
|
125
|
+
succeeded: number;
|
|
126
|
+
failed: number;
|
|
127
|
+
percent: number;
|
|
128
|
+
} | null;
|
|
129
|
+
report: MigrationImportReport | null;
|
|
130
|
+
result: MigrationImportResult | null;
|
|
131
|
+
error: {
|
|
132
|
+
code: string;
|
|
133
|
+
message: string;
|
|
134
|
+
} | null;
|
|
135
|
+
created_at: number;
|
|
136
|
+
updated_at: number;
|
|
137
|
+
analyzed_at: number | null;
|
|
138
|
+
apply_started_at: number | null;
|
|
139
|
+
completed_at: number | null;
|
|
140
|
+
}
|
|
141
|
+
export interface MigrationClaimMap {
|
|
142
|
+
subject?: string;
|
|
143
|
+
email?: string;
|
|
144
|
+
email_verified?: string;
|
|
145
|
+
name?: string;
|
|
146
|
+
session_key?: string;
|
|
147
|
+
mfa?: string;
|
|
148
|
+
}
|
|
149
|
+
/** PUT body of the bridge settings; every field optional, merged onto the stored ones. */
|
|
150
|
+
export interface MigrationBridgeSettingsUpdate {
|
|
151
|
+
enabled?: boolean;
|
|
152
|
+
ends_at?: string | number | null;
|
|
153
|
+
mode?: 'jwt' | 'session_table' | 'remote';
|
|
154
|
+
preset?: string | null;
|
|
155
|
+
preset_vars?: Record<string, string>;
|
|
156
|
+
issuer?: string | null;
|
|
157
|
+
jwks_url?: string | null;
|
|
158
|
+
audience?: string[] | null;
|
|
159
|
+
algorithms?: string[] | null;
|
|
160
|
+
claim_map?: MigrationClaimMap;
|
|
161
|
+
expired_grace_seconds?: number;
|
|
162
|
+
cookie_names?: string[];
|
|
163
|
+
create_users?: boolean;
|
|
164
|
+
/** Write-only HS256 secret; omit to keep, null to clear. */
|
|
165
|
+
shared_secret?: string | null;
|
|
166
|
+
}
|
|
167
|
+
export interface MigrationBridgeSettings {
|
|
168
|
+
object: 'migration_bridge';
|
|
169
|
+
source: MigrationSourceId;
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
ends_at: number | null;
|
|
172
|
+
mode: 'jwt' | 'session_table' | 'remote';
|
|
173
|
+
preset: string | null;
|
|
174
|
+
preset_vars: Record<string, string>;
|
|
175
|
+
issuer: string | null;
|
|
176
|
+
jwks_url: string | null;
|
|
177
|
+
audience: string[] | null;
|
|
178
|
+
algorithms: string[];
|
|
179
|
+
claim_map: Record<string, string>;
|
|
180
|
+
expired_grace_seconds: number;
|
|
181
|
+
cookie_names: string[];
|
|
182
|
+
create_users: boolean;
|
|
183
|
+
has_shared_secret: boolean;
|
|
184
|
+
exchange_path: string;
|
|
185
|
+
stats: {
|
|
186
|
+
exchanged: number;
|
|
187
|
+
from_import: number;
|
|
188
|
+
from_jwt: number;
|
|
189
|
+
};
|
|
190
|
+
created_at: number | null;
|
|
191
|
+
updated_at: number | null;
|
|
192
|
+
}
|
|
193
|
+
export interface MigrationSourceView {
|
|
194
|
+
object: 'migration_source';
|
|
195
|
+
source: MigrationSourceId;
|
|
196
|
+
label: string;
|
|
197
|
+
models: string[];
|
|
198
|
+
passwords: 'export' | 'ticket' | 'lazy' | 'none';
|
|
199
|
+
export_via: Array<'api' | 'file' | 'database' | 'support_ticket'>;
|
|
200
|
+
bridge: {
|
|
201
|
+
mode: 'jwt' | 'session_table' | 'remote' | 'none';
|
|
202
|
+
preset: string | null;
|
|
203
|
+
vars: Record<string, string>;
|
|
204
|
+
cookies: string[];
|
|
205
|
+
};
|
|
206
|
+
lazy_migration: {
|
|
207
|
+
preset: string;
|
|
208
|
+
config: Record<string, {
|
|
209
|
+
label: string;
|
|
210
|
+
required: boolean;
|
|
211
|
+
}>;
|
|
212
|
+
secret: {
|
|
213
|
+
label: string;
|
|
214
|
+
required: boolean;
|
|
215
|
+
} | null;
|
|
216
|
+
} | null;
|
|
217
|
+
password_algorithms: string[];
|
|
218
|
+
limits: string | null;
|
|
219
|
+
}
|
|
220
|
+
export declare function migrationsResource(request: RequestFn): {
|
|
221
|
+
/** Every migration source and what it supports. */
|
|
222
|
+
sources(): Promise<CursorPage<MigrationSourceView>>;
|
|
223
|
+
/** The import surface of one source: `migrations.imports('auth0').upload(text)`. */
|
|
224
|
+
imports: (source: MigrationSourceId | string) => {
|
|
225
|
+
/** The import public key (created on first read; shared by every source). */
|
|
226
|
+
getPublicKey(): Promise<MigrationImportKey>;
|
|
227
|
+
/** Replace the import key; bundles sealed to the old one no longer finalize. */
|
|
228
|
+
rotatePublicKey(): Promise<MigrationImportKey>;
|
|
229
|
+
create(body?: {
|
|
230
|
+
options?: MigrationImportOptions;
|
|
231
|
+
}, idempotencyKey?: string): Promise<MigrationImport>;
|
|
232
|
+
list(params?: CursorParams): Promise<CursorPage<MigrationImport>>;
|
|
233
|
+
get(id: string): Promise<MigrationImport>;
|
|
234
|
+
/** Upload part `part` (1-based) of the sealed bundle text. */
|
|
235
|
+
uploadPart(id: string, part: number, data: string): Promise<{
|
|
236
|
+
object: "migration_import_part";
|
|
237
|
+
import_id: string;
|
|
238
|
+
part: number;
|
|
239
|
+
bytes: number;
|
|
240
|
+
sha256: string;
|
|
241
|
+
}>;
|
|
242
|
+
/** Close the upload; Atlas checks the key and the format, then runs the dry run. */
|
|
243
|
+
finalize(id: string): Promise<MigrationImport>;
|
|
244
|
+
dryRun(id: string, body?: {
|
|
245
|
+
options?: MigrationImportOptions;
|
|
246
|
+
}): Promise<MigrationImport>;
|
|
247
|
+
/** Import (or resume). Pass confirm_conflicts when the dry run reported conflicts. */
|
|
248
|
+
apply(id: string, body?: {
|
|
249
|
+
confirm_conflicts?: boolean;
|
|
250
|
+
}): Promise<MigrationImport>;
|
|
251
|
+
delete(id: string): Promise<{
|
|
252
|
+
object: "migration_import";
|
|
253
|
+
id: string;
|
|
254
|
+
deleted: true;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Create an import (or continue `importId`), upload the sealed bundle text
|
|
258
|
+
* in parts from `resumeFrom` (1-based) and finalize it.
|
|
259
|
+
*/
|
|
260
|
+
upload(bundleText: string, opts?: {
|
|
261
|
+
options?: MigrationImportOptions;
|
|
262
|
+
partBytes?: number;
|
|
263
|
+
importId?: string;
|
|
264
|
+
resumeFrom?: number;
|
|
265
|
+
onPart?: (n: number, of: number) => void;
|
|
266
|
+
}): Promise<MigrationImport>;
|
|
267
|
+
/** Poll until the import leaves analyzing / queued / applying. */
|
|
268
|
+
waitFor(id: string, opts?: {
|
|
269
|
+
intervalMs?: number;
|
|
270
|
+
timeoutMs?: number;
|
|
271
|
+
onProgress?: (imp: MigrationImport) => void;
|
|
272
|
+
sleep?: (ms: number) => Promise<void>;
|
|
273
|
+
}): Promise<MigrationImport>;
|
|
274
|
+
};
|
|
275
|
+
/** The zero-logout bridge settings of one source. */
|
|
276
|
+
bridge: (source: MigrationSourceId | string) => {
|
|
277
|
+
get(): Promise<MigrationBridgeSettings>;
|
|
278
|
+
update(body: MigrationBridgeSettingsUpdate): Promise<MigrationBridgeSettings>;
|
|
279
|
+
delete(): Promise<{
|
|
280
|
+
object: "migration_bridge";
|
|
281
|
+
source: string;
|
|
282
|
+
deleted: true;
|
|
283
|
+
}>;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrationsResource = migrationsResource;
|
|
4
|
+
const better_auth_imports_1 = require("./better-auth-imports");
|
|
5
|
+
const request_1 = require("./request");
|
|
6
|
+
const TERMINAL = ['ready', 'invalid', 'completed', 'failed'];
|
|
7
|
+
function migrationsResource(request) {
|
|
8
|
+
const importsFor = (source) => {
|
|
9
|
+
const base = `/v1/migrations/${(0, request_1.enc)(source)}/imports`;
|
|
10
|
+
const self = {
|
|
11
|
+
/** The import public key (created on first read; shared by every source). */
|
|
12
|
+
getPublicKey() {
|
|
13
|
+
return request({ method: 'GET', path: `${base}/public_key` });
|
|
14
|
+
},
|
|
15
|
+
/** Replace the import key; bundles sealed to the old one no longer finalize. */
|
|
16
|
+
rotatePublicKey() {
|
|
17
|
+
return request({ method: 'POST', path: `${base}/public_key/rotate` });
|
|
18
|
+
},
|
|
19
|
+
create(body = {}, idempotencyKey) {
|
|
20
|
+
return request({ method: 'POST', path: base, body, idempotencyKey });
|
|
21
|
+
},
|
|
22
|
+
list(params = {}) {
|
|
23
|
+
return request({ method: 'GET', path: base, query: { ...params } });
|
|
24
|
+
},
|
|
25
|
+
get(id) {
|
|
26
|
+
return request({ method: 'GET', path: `${base}/${(0, request_1.enc)(id)}` });
|
|
27
|
+
},
|
|
28
|
+
/** Upload part `part` (1-based) of the sealed bundle text. */
|
|
29
|
+
uploadPart(id, part, data) {
|
|
30
|
+
return request({ method: 'PUT', path: `${base}/${(0, request_1.enc)(id)}/parts/${part}`, body: { data } });
|
|
31
|
+
},
|
|
32
|
+
/** Close the upload; Atlas checks the key and the format, then runs the dry run. */
|
|
33
|
+
finalize(id) {
|
|
34
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/finalize` });
|
|
35
|
+
},
|
|
36
|
+
dryRun(id, body = {}) {
|
|
37
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/dry_run`, body });
|
|
38
|
+
},
|
|
39
|
+
/** Import (or resume). Pass confirm_conflicts when the dry run reported conflicts. */
|
|
40
|
+
apply(id, body = {}) {
|
|
41
|
+
return request({ method: 'POST', path: `${base}/${(0, request_1.enc)(id)}/apply`, body });
|
|
42
|
+
},
|
|
43
|
+
delete(id) {
|
|
44
|
+
return request({ method: 'DELETE', path: `${base}/${(0, request_1.enc)(id)}` });
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Create an import (or continue `importId`), upload the sealed bundle text
|
|
48
|
+
* in parts from `resumeFrom` (1-based) and finalize it.
|
|
49
|
+
*/
|
|
50
|
+
async upload(bundleText, opts = {}) {
|
|
51
|
+
const parts = (0, better_auth_imports_1.splitBundleParts)(bundleText, opts.partBytes);
|
|
52
|
+
if (parts.length === 0)
|
|
53
|
+
throw new Error('The bundle is empty.');
|
|
54
|
+
const id = opts.importId ?? (await self.create(opts.options ? { options: opts.options } : {})).id;
|
|
55
|
+
for (let i = Math.max(0, (opts.resumeFrom ?? 1) - 1); i < parts.length; i++) {
|
|
56
|
+
await self.uploadPart(id, i + 1, parts[i]);
|
|
57
|
+
opts.onPart?.(i + 1, parts.length);
|
|
58
|
+
}
|
|
59
|
+
return self.finalize(id);
|
|
60
|
+
},
|
|
61
|
+
/** Poll until the import leaves analyzing / queued / applying. */
|
|
62
|
+
async waitFor(id, opts = {}) {
|
|
63
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
64
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 6 * 3600_000);
|
|
65
|
+
for (;;) {
|
|
66
|
+
const imp = await self.get(id);
|
|
67
|
+
opts.onProgress?.(imp);
|
|
68
|
+
if (TERMINAL.includes(imp.status) || imp.status === 'uploading')
|
|
69
|
+
return imp;
|
|
70
|
+
if (Date.now() > deadline)
|
|
71
|
+
throw new Error(`Timed out waiting for migration import ${id} (status ${imp.status}).`);
|
|
72
|
+
await sleep(opts.intervalMs ?? 2000);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
return self;
|
|
77
|
+
};
|
|
78
|
+
const bridgeFor = (source) => {
|
|
79
|
+
const path = `/v1/migrations/${(0, request_1.enc)(source)}/bridge`;
|
|
80
|
+
return {
|
|
81
|
+
get() {
|
|
82
|
+
return request({ method: 'GET', path });
|
|
83
|
+
},
|
|
84
|
+
update(body) {
|
|
85
|
+
return request({ method: 'PUT', path, body });
|
|
86
|
+
},
|
|
87
|
+
delete() {
|
|
88
|
+
return request({ method: 'DELETE', path });
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
/** Every migration source and what it supports. */
|
|
94
|
+
sources() {
|
|
95
|
+
return request({ method: 'GET', path: '/v1/migrations/sources' });
|
|
96
|
+
},
|
|
97
|
+
/** The import surface of one source: `migrations.imports('auth0').upload(text)`. */
|
|
98
|
+
imports: importsFor,
|
|
99
|
+
/** The zero-logout bridge settings of one source. */
|
|
100
|
+
bridge: bridgeFor,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/client/migrations.ts"],"names":[],"mappings":";;AAsMA,gDAkGC;AAxSD,+DAA0F;AAC1F,uCAAgD;AAmMhD,MAAM,QAAQ,GAAqC,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAE/F,SAAgB,kBAAkB,CAAC,OAAkB;IACnD,MAAM,UAAU,GAAG,CAAC,MAAkC,EAAE,EAAE;QACxD,MAAM,IAAI,GAAG,kBAAkB,IAAA,aAAG,EAAC,MAAM,CAAC,UAAU,CAAC;QACrD,MAAM,IAAI,GAAG;YACX,6EAA6E;YAC7E,YAAY;gBACV,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,aAAa,EAAE,CAAC,CAAC;YAChE,CAAC;YACD,gFAAgF;YAChF,eAAe;gBACb,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,oBAAoB,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,MAAM,CAAC,OAA6C,EAAE,EAAE,cAAuB;gBAC7E,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;YACvE,CAAC;YACD,IAAI,CAAC,SAAuB,EAAE;gBAC5B,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE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