@kaiz11/stack-client 0.0.14
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/LICENSE +32 -0
- package/README.md +586 -0
- package/dist/accounts/accounts-client.d.ts +188 -0
- package/dist/accounts/accounts-client.d.ts.map +1 -0
- package/dist/accounts/accounts-client.js +264 -0
- package/dist/accounts/accounts-client.js.map +1 -0
- package/dist/accounts/index.d.ts +8 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +8 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/mock-accounts.d.ts +90 -0
- package/dist/accounts/mock-accounts.d.ts.map +1 -0
- package/dist/accounts/mock-accounts.js +434 -0
- package/dist/accounts/mock-accounts.js.map +1 -0
- package/dist/accounts/types.d.ts +180 -0
- package/dist/accounts/types.d.ts.map +1 -0
- package/dist/accounts/types.js +59 -0
- package/dist/accounts/types.js.map +1 -0
- package/dist/auth/auth-client.d.ts +224 -0
- package/dist/auth/auth-client.d.ts.map +1 -0
- package/dist/auth/auth-client.js +230 -0
- package/dist/auth/auth-client.js.map +1 -0
- package/dist/auth/base-auth.d.ts +44 -0
- package/dist/auth/base-auth.d.ts.map +1 -0
- package/dist/auth/base-auth.js +55 -0
- package/dist/auth/base-auth.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/methods/admin.d.ts +59 -0
- package/dist/auth/methods/admin.d.ts.map +1 -0
- package/dist/auth/methods/admin.js +55 -0
- package/dist/auth/methods/admin.js.map +1 -0
- package/dist/auth/methods/index.d.ts +9 -0
- package/dist/auth/methods/index.d.ts.map +1 -0
- package/dist/auth/methods/index.js +8 -0
- package/dist/auth/methods/index.js.map +1 -0
- package/dist/auth/methods/magic-link.d.ts +27 -0
- package/dist/auth/methods/magic-link.d.ts.map +1 -0
- package/dist/auth/methods/magic-link.js +37 -0
- package/dist/auth/methods/magic-link.js.map +1 -0
- package/dist/auth/methods/mfa.d.ts +92 -0
- package/dist/auth/methods/mfa.d.ts.map +1 -0
- package/dist/auth/methods/mfa.js +153 -0
- package/dist/auth/methods/mfa.js.map +1 -0
- package/dist/auth/methods/oauth.d.ts +62 -0
- package/dist/auth/methods/oauth.d.ts.map +1 -0
- package/dist/auth/methods/oauth.js +165 -0
- package/dist/auth/methods/oauth.js.map +1 -0
- package/dist/auth/methods/otp.d.ts +43 -0
- package/dist/auth/methods/otp.d.ts.map +1 -0
- package/dist/auth/methods/otp.js +66 -0
- package/dist/auth/methods/otp.js.map +1 -0
- package/dist/auth/methods/password.d.ts +64 -0
- package/dist/auth/methods/password.d.ts.map +1 -0
- package/dist/auth/methods/password.js +116 -0
- package/dist/auth/methods/password.js.map +1 -0
- package/dist/auth/methods/recovery.d.ts +62 -0
- package/dist/auth/methods/recovery.d.ts.map +1 -0
- package/dist/auth/methods/recovery.js +100 -0
- package/dist/auth/methods/recovery.js.map +1 -0
- package/dist/auth/mock-auth.d.ts +135 -0
- package/dist/auth/mock-auth.d.ts.map +1 -0
- package/dist/auth/mock-auth.js +417 -0
- package/dist/auth/mock-auth.js.map +1 -0
- package/dist/auth/server/helpers.d.ts +215 -0
- package/dist/auth/server/helpers.d.ts.map +1 -0
- package/dist/auth/server/helpers.js +241 -0
- package/dist/auth/server/helpers.js.map +1 -0
- package/dist/auth/server/index.d.ts +24 -0
- package/dist/auth/server/index.d.ts.map +1 -0
- package/dist/auth/server/index.js +40 -0
- package/dist/auth/server/index.js.map +1 -0
- package/dist/auth/server/middleware.d.ts +305 -0
- package/dist/auth/server/middleware.d.ts.map +1 -0
- package/dist/auth/server/middleware.js +405 -0
- package/dist/auth/server/middleware.js.map +1 -0
- package/dist/auth/server/verify.d.ts +184 -0
- package/dist/auth/server/verify.d.ts.map +1 -0
- package/dist/auth/server/verify.js +222 -0
- package/dist/auth/server/verify.js.map +1 -0
- package/dist/auth/token-manager.d.ts +94 -0
- package/dist/auth/token-manager.d.ts.map +1 -0
- package/dist/auth/token-manager.js +231 -0
- package/dist/auth/token-manager.js.map +1 -0
- package/dist/auth/types.d.ts +412 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +66 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/user/identities.d.ts +62 -0
- package/dist/auth/user/identities.d.ts.map +1 -0
- package/dist/auth/user/identities.js +88 -0
- package/dist/auth/user/identities.js.map +1 -0
- package/dist/auth/user/index.d.ts +4 -0
- package/dist/auth/user/index.d.ts.map +1 -0
- package/dist/auth/user/index.js +4 -0
- package/dist/auth/user/index.js.map +1 -0
- package/dist/auth/user/user.d.ts +64 -0
- package/dist/auth/user/user.d.ts.map +1 -0
- package/dist/auth/user/user.js +105 -0
- package/dist/auth/user/user.js.map +1 -0
- package/dist/auth/user/verification.d.ts +49 -0
- package/dist/auth/user/verification.d.ts.map +1 -0
- package/dist/auth/user/verification.js +71 -0
- package/dist/auth/user/verification.js.map +1 -0
- package/dist/cli/browser.d.ts +11 -0
- package/dist/cli/browser.d.ts.map +1 -0
- package/dist/cli/browser.js +35 -0
- package/dist/cli/browser.js.map +1 -0
- package/dist/cli/callback-server.d.ts +30 -0
- package/dist/cli/callback-server.d.ts.map +1 -0
- package/dist/cli/callback-server.js +100 -0
- package/dist/cli/callback-server.js.map +1 -0
- package/dist/cli/file-token-store.d.ts +79 -0
- package/dist/cli/file-token-store.d.ts.map +1 -0
- package/dist/cli/file-token-store.js +138 -0
- package/dist/cli/file-token-store.js.map +1 -0
- package/dist/cli/index.d.ts +33 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +38 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/oauth.d.ts +67 -0
- package/dist/cli/oauth.d.ts.map +1 -0
- package/dist/cli/oauth.js +101 -0
- package/dist/cli/oauth.js.map +1 -0
- package/dist/cli/pkce.d.ts +35 -0
- package/dist/cli/pkce.d.ts.map +1 -0
- package/dist/cli/pkce.js +43 -0
- package/dist/cli/pkce.js.map +1 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +99 -0
- package/dist/client.js.map +1 -0
- package/dist/db/client.d.ts +9 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +19 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/errors.d.ts +19 -0
- package/dist/db/errors.d.ts.map +1 -0
- package/dist/db/errors.js +57 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +5 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/mock.d.ts +28 -0
- package/dist/db/mock.d.ts.map +1 -0
- package/dist/db/mock.js +459 -0
- package/dist/db/mock.js.map +1 -0
- package/dist/db/types.d.ts +73 -0
- package/dist/db/types.d.ts.map +1 -0
- package/dist/db/types.js +2 -0
- package/dist/db/types.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/errors.d.ts +33 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +76 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/http.d.ts +81 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +163 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/keys.d.ts +87 -0
- package/dist/lib/keys.d.ts.map +1 -0
- package/dist/lib/keys.js +147 -0
- package/dist/lib/keys.js.map +1 -0
- package/dist/lib/paths.d.ts +37 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +49 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/token-store.d.ts +42 -0
- package/dist/lib/token-store.d.ts.map +1 -0
- package/dist/lib/token-store.js +75 -0
- package/dist/lib/token-store.js.map +1 -0
- package/dist/mocks/handlers.d.ts +29 -0
- package/dist/mocks/handlers.d.ts.map +1 -0
- package/dist/mocks/handlers.js +79 -0
- package/dist/mocks/handlers.js.map +1 -0
- package/dist/mocks/index.d.ts +5 -0
- package/dist/mocks/index.d.ts.map +1 -0
- package/dist/mocks/index.js +9 -0
- package/dist/mocks/index.js.map +1 -0
- package/dist/mocks/responses.d.ts +76 -0
- package/dist/mocks/responses.d.ts.map +1 -0
- package/dist/mocks/responses.js +91 -0
- package/dist/mocks/responses.js.map +1 -0
- package/dist/mocks/server.d.ts +7 -0
- package/dist/mocks/server.d.ts.map +1 -0
- package/dist/mocks/server.js +9 -0
- package/dist/mocks/server.js.map +1 -0
- package/dist/mocks/state.d.ts +86 -0
- package/dist/mocks/state.d.ts.map +1 -0
- package/dist/mocks/state.js +77 -0
- package/dist/mocks/state.js.map +1 -0
- package/dist/storage/bucket-ref.d.ts +183 -0
- package/dist/storage/bucket-ref.d.ts.map +1 -0
- package/dist/storage/bucket-ref.js +529 -0
- package/dist/storage/bucket-ref.js.map +1 -0
- package/dist/storage/errors.d.ts +27 -0
- package/dist/storage/errors.d.ts.map +1 -0
- package/dist/storage/errors.js +89 -0
- package/dist/storage/errors.js.map +1 -0
- package/dist/storage/index.d.ts +13 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +11 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/interface.d.ts +245 -0
- package/dist/storage/interface.d.ts.map +1 -0
- package/dist/storage/interface.js +2 -0
- package/dist/storage/interface.js.map +1 -0
- package/dist/storage/mock-storage.d.ts +67 -0
- package/dist/storage/mock-storage.d.ts.map +1 -0
- package/dist/storage/mock-storage.js +478 -0
- package/dist/storage/mock-storage.js.map +1 -0
- package/dist/storage/policies-client.d.ts +77 -0
- package/dist/storage/policies-client.d.ts.map +1 -0
- package/dist/storage/policies-client.js +115 -0
- package/dist/storage/policies-client.js.map +1 -0
- package/dist/storage/policy-templates.d.ts +6 -0
- package/dist/storage/policy-templates.d.ts.map +1 -0
- package/dist/storage/policy-templates.js +290 -0
- package/dist/storage/policy-templates.js.map +1 -0
- package/dist/storage/policy-types.d.ts +98 -0
- package/dist/storage/policy-types.d.ts.map +1 -0
- package/dist/storage/policy-types.js +20 -0
- package/dist/storage/policy-types.js.map +1 -0
- package/dist/storage/storage-client.d.ts +32 -0
- package/dist/storage/storage-client.d.ts.map +1 -0
- package/dist/storage/storage-client.js +94 -0
- package/dist/storage/storage-client.js.map +1 -0
- package/dist/storage/tus-upload.d.ts +56 -0
- package/dist/storage/tus-upload.d.ts.map +1 -0
- package/dist/storage/tus-upload.js +236 -0
- package/dist/storage/tus-upload.js.map +1 -0
- package/dist/storage/types.d.ts +335 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +39 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/test/auth/helpers.d.ts +33 -0
- package/dist/test/auth/helpers.d.ts.map +1 -0
- package/dist/test/auth/helpers.js +80 -0
- package/dist/test/auth/helpers.js.map +1 -0
- package/dist/test/helpers/jwt.d.ts +61 -0
- package/dist/test/helpers/jwt.d.ts.map +1 -0
- package/dist/test/helpers/jwt.js +132 -0
- package/dist/test/helpers/jwt.js.map +1 -0
- package/dist/test/helpers/mailpit.d.ts +61 -0
- package/dist/test/helpers/mailpit.d.ts.map +1 -0
- package/dist/test/helpers/mailpit.js +107 -0
- package/dist/test/helpers/mailpit.js.map +1 -0
- package/dist/test/setup.d.ts +2 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +17 -0
- package/dist/test/setup.js.map +1 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2DlD,iCAAiC;AACjC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { HttpClient } from "../../lib/http.js";
|
|
2
|
+
import type { User } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Admin invite options
|
|
5
|
+
*/
|
|
6
|
+
export interface AdminInviteOptions {
|
|
7
|
+
/** Email address of the user to invite */
|
|
8
|
+
email: string;
|
|
9
|
+
/** Custom user data to include with the invitation */
|
|
10
|
+
data?: Record<string, unknown>;
|
|
11
|
+
/** URL to redirect to after the user accepts the invite */
|
|
12
|
+
redirectTo?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Invited user response
|
|
16
|
+
*/
|
|
17
|
+
export interface InvitedUser extends User {
|
|
18
|
+
/** Timestamp when the invitation was sent */
|
|
19
|
+
invitedAt: string | null;
|
|
20
|
+
/** Timestamp when the confirmation email was sent */
|
|
21
|
+
confirmationSentAt: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Admin authentication methods
|
|
25
|
+
*
|
|
26
|
+
* These methods require a service_role JWT and are for server-side use only.
|
|
27
|
+
*/
|
|
28
|
+
export declare class AdminMethods {
|
|
29
|
+
private readonly http;
|
|
30
|
+
private readonly tenantId;
|
|
31
|
+
constructor(http: HttpClient, tenantId: string);
|
|
32
|
+
/**
|
|
33
|
+
* Invite a new user by email
|
|
34
|
+
*
|
|
35
|
+
* Sends an invitation email to the specified address. The user will receive
|
|
36
|
+
* a link to complete their account setup.
|
|
37
|
+
*
|
|
38
|
+
* **Requires service_role JWT** - This method will fail with a 403 error
|
|
39
|
+
* if called with a regular user token.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Server-side with service role token
|
|
44
|
+
* const adminClient = createTenantClient({
|
|
45
|
+
* baseUrl: "https://stack.example.com",
|
|
46
|
+
* tenantId: "my-tenant",
|
|
47
|
+
* tokenStore: "memory",
|
|
48
|
+
* accessToken: process.env.SERVICE_ROLE_TOKEN,
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const invitedUser = await adminClient.auth.admin.inviteUserByEmail({
|
|
52
|
+
* email: "newuser@example.com",
|
|
53
|
+
* data: { role: "admin", department: "Engineering" },
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
inviteUserByEmail(options: AdminInviteOptions): Promise<InvitedUser>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../src/auth/methods/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,aAAa,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI;IACvC,6CAA6C;IAC7C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,qDAAqD;IACrD,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAUD;;;;GAIG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM;IAGnC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAe3E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { authPath } from "../../lib/paths.js";
|
|
2
|
+
import { normalizeUser } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Admin authentication methods
|
|
5
|
+
*
|
|
6
|
+
* These methods require a service_role JWT and are for server-side use only.
|
|
7
|
+
*/
|
|
8
|
+
export class AdminMethods {
|
|
9
|
+
http;
|
|
10
|
+
tenantId;
|
|
11
|
+
constructor(http, tenantId) {
|
|
12
|
+
this.http = http;
|
|
13
|
+
this.tenantId = tenantId;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Invite a new user by email
|
|
17
|
+
*
|
|
18
|
+
* Sends an invitation email to the specified address. The user will receive
|
|
19
|
+
* a link to complete their account setup.
|
|
20
|
+
*
|
|
21
|
+
* **Requires service_role JWT** - This method will fail with a 403 error
|
|
22
|
+
* if called with a regular user token.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Server-side with service role token
|
|
27
|
+
* const adminClient = createTenantClient({
|
|
28
|
+
* baseUrl: "https://stack.example.com",
|
|
29
|
+
* tenantId: "my-tenant",
|
|
30
|
+
* tokenStore: "memory",
|
|
31
|
+
* accessToken: process.env.SERVICE_ROLE_TOKEN,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const invitedUser = await adminClient.auth.admin.inviteUserByEmail({
|
|
35
|
+
* email: "newuser@example.com",
|
|
36
|
+
* data: { role: "admin", department: "Engineering" },
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
async inviteUserByEmail(options) {
|
|
41
|
+
const path = authPath(this.tenantId, "/invite");
|
|
42
|
+
const response = await this.http.post(path, {
|
|
43
|
+
email: options.email,
|
|
44
|
+
data: options.data,
|
|
45
|
+
redirect_to: options.redirectTo,
|
|
46
|
+
});
|
|
47
|
+
const user = normalizeUser(response);
|
|
48
|
+
return {
|
|
49
|
+
...user,
|
|
50
|
+
invitedAt: response.invited_at ?? null,
|
|
51
|
+
confirmationSentAt: response.confirmation_sent_at ?? null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/auth/methods/admin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgC5C;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAEJ;IACA;IAFnB,YACmB,IAAgB,EAChB,QAAgB;QADhB,SAAI,GAAJ,IAAI,CAAY;QAChB,aAAQ,GAAR,QAAQ,CAAQ;IAChC,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,iBAAiB,CAAC,OAA2B;QACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAuB,IAAI,EAAE;YAChE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,UAAU;SAChC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO;YACL,GAAG,IAAI;YACP,SAAS,EAAE,QAAQ,CAAC,UAAU,IAAI,IAAI;YACtC,kBAAkB,EAAE,QAAQ,CAAC,oBAAoB,IAAI,IAAI;SAC1D,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { PasswordMethods } from "./password.js";
|
|
2
|
+
export { OAuthMethods } from "./oauth.js";
|
|
3
|
+
export { MagicLinkMethods } from "./magic-link.js";
|
|
4
|
+
export { OtpMethods } from "./otp.js";
|
|
5
|
+
export { RecoveryMethods } from "./recovery.js";
|
|
6
|
+
export { MfaMethods } from "./mfa.js";
|
|
7
|
+
export { AdminMethods } from "./admin.js";
|
|
8
|
+
export type { AdminInviteOptions, InvitedUser } from "./admin.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/methods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { PasswordMethods } from "./password.js";
|
|
2
|
+
export { OAuthMethods } from "./oauth.js";
|
|
3
|
+
export { MagicLinkMethods } from "./magic-link.js";
|
|
4
|
+
export { OtpMethods } from "./otp.js";
|
|
5
|
+
export { RecoveryMethods } from "./recovery.js";
|
|
6
|
+
export { MfaMethods } from "./mfa.js";
|
|
7
|
+
export { AdminMethods } from "./admin.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/methods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpClient } from "../../lib/http.js";
|
|
2
|
+
import type { MagicLinkOptions } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Magic link authentication methods
|
|
5
|
+
*/
|
|
6
|
+
export declare class MagicLinkMethods {
|
|
7
|
+
private readonly http;
|
|
8
|
+
private readonly tenantId;
|
|
9
|
+
constructor(http: HttpClient, tenantId: string);
|
|
10
|
+
/**
|
|
11
|
+
* Send a magic link to the user's email
|
|
12
|
+
*
|
|
13
|
+
* The user will receive an email with a link to sign in.
|
|
14
|
+
* When they click the link, they'll be redirected to your app with a session.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* await client.auth.signInWithMagicLink({
|
|
19
|
+
* email: "user@example.com",
|
|
20
|
+
* redirectTo: "https://myapp.com/auth/callback",
|
|
21
|
+
* });
|
|
22
|
+
* // User receives email, clicks link, lands on callback URL with session
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
signInWithMagicLink(options: MagicLinkOptions): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=magic-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-link.d.ts","sourceRoot":"","sources":["../../../src/auth/methods/magic-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD;;GAEG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM;IAGnC;;;;;;;;;;;;;;OAcG;IACG,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { authPath } from "../../lib/paths.js";
|
|
2
|
+
/**
|
|
3
|
+
* Magic link authentication methods
|
|
4
|
+
*/
|
|
5
|
+
export class MagicLinkMethods {
|
|
6
|
+
http;
|
|
7
|
+
tenantId;
|
|
8
|
+
constructor(http, tenantId) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
this.tenantId = tenantId;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Send a magic link to the user's email
|
|
14
|
+
*
|
|
15
|
+
* The user will receive an email with a link to sign in.
|
|
16
|
+
* When they click the link, they'll be redirected to your app with a session.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* await client.auth.signInWithMagicLink({
|
|
21
|
+
* email: "user@example.com",
|
|
22
|
+
* redirectTo: "https://myapp.com/auth/callback",
|
|
23
|
+
* });
|
|
24
|
+
* // User receives email, clicks link, lands on callback URL with session
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async signInWithMagicLink(options) {
|
|
28
|
+
const path = authPath(this.tenantId, "/magiclink");
|
|
29
|
+
await this.http.post(path, {
|
|
30
|
+
email: options.email,
|
|
31
|
+
redirect_to: options.redirectTo,
|
|
32
|
+
create_user: options.shouldCreateUser ?? false,
|
|
33
|
+
data: options.data,
|
|
34
|
+
}, { noAuth: true });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=magic-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-link.js","sourceRoot":"","sources":["../../../src/auth/methods/magic-link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAU9C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAER;IACA;IAFnB,YACmB,IAAgB,EAChB,QAAgB;QADhB,SAAI,GAAJ,IAAI,CAAY;QAChB,aAAQ,GAAR,QAAQ,CAAQ;IAChC,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAyB;QACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEnD,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAClB,IAAI,EACJ;YACE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,UAAU;YAC/B,WAAW,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;YAC9C,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { HttpClient } from "../../lib/http.js";
|
|
2
|
+
import type { TokenManager } from "../token-manager.js";
|
|
3
|
+
import type { EnrollFactorOptions, EnrollFactorResult, ChallengeFactorOptions, ChallengeFactorResult, VerifyFactorOptions, Factor, Session } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* MFA (Multi-Factor Authentication) methods
|
|
6
|
+
*/
|
|
7
|
+
export declare class MfaMethods {
|
|
8
|
+
private readonly http;
|
|
9
|
+
private readonly tokenManager;
|
|
10
|
+
private readonly tenantId;
|
|
11
|
+
constructor(http: HttpClient, tokenManager: TokenManager, tenantId: string);
|
|
12
|
+
/**
|
|
13
|
+
* Enroll a new MFA factor
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Enroll TOTP (authenticator app)
|
|
18
|
+
* const { id, totpUri, qrCode } = await client.auth.mfa.enroll({
|
|
19
|
+
* type: "totp",
|
|
20
|
+
* friendlyName: "My Authenticator",
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Display QR code for user to scan
|
|
24
|
+
* // Then verify with challenge/verify flow
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
enroll(options: EnrollFactorOptions): Promise<EnrollFactorResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a challenge for an MFA factor
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const { id: challengeId, expiresAt } = await client.auth.mfa.challenge({
|
|
34
|
+
* factorId: "factor-id",
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // User enters code from authenticator app
|
|
38
|
+
* const session = await client.auth.mfa.verify({
|
|
39
|
+
* factorId: "factor-id",
|
|
40
|
+
* challengeId,
|
|
41
|
+
* code: "123456",
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
challenge(options: ChallengeFactorOptions): Promise<ChallengeFactorResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Verify an MFA challenge
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const session = await client.auth.mfa.verify({
|
|
52
|
+
* factorId: "factor-id",
|
|
53
|
+
* challengeId: "challenge-id",
|
|
54
|
+
* code: "123456",
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
verify(options: VerifyFactorOptions): Promise<Session>;
|
|
59
|
+
/**
|
|
60
|
+
* Unenroll (remove) an MFA factor
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* await client.auth.mfa.unenroll("factor-id");
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
unenroll(factorId: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* List all enrolled MFA factors
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const factors = await client.auth.mfa.listFactors();
|
|
74
|
+
* for (const factor of factors) {
|
|
75
|
+
* console.log(factor.type, factor.friendlyName, factor.status);
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
listFactors(): Promise<Factor[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Get the authenticator assurance level
|
|
82
|
+
*
|
|
83
|
+
* Returns the current AAL (Authenticator Assurance Level):
|
|
84
|
+
* - aal1: Single factor (password only)
|
|
85
|
+
* - aal2: Two factors (password + MFA)
|
|
86
|
+
*/
|
|
87
|
+
getAuthenticatorAssuranceLevel(): {
|
|
88
|
+
currentLevel: "aal1" | "aal2" | null;
|
|
89
|
+
nextLevel: "aal1" | "aal2" | null;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=mfa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa.d.ts","sourceRoot":"","sources":["../../../src/auth/methods/mfa.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,EAEN,OAAO,EAGR,MAAM,aAAa,CAAC;AAwBrB;;GAEG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFR,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM;IAGnC;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiBvE;;;;;;;;;;;;;;;;OAgBG;IACG,SAAS,CACb,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC;IAgBjC;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAa5D;;;;;;;OAOG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;;;;;;;;OAUG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAMtC;;;;;;OAMG;IACH,8BAA8B,IAAI;QAChC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QACrC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;KACnC;CA0BF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { authPath } from "../../lib/paths.js";
|
|
2
|
+
import { normalizeSession, normalizeFactor } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* MFA (Multi-Factor Authentication) methods
|
|
5
|
+
*/
|
|
6
|
+
export class MfaMethods {
|
|
7
|
+
http;
|
|
8
|
+
tokenManager;
|
|
9
|
+
tenantId;
|
|
10
|
+
constructor(http, tokenManager, tenantId) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.tokenManager = tokenManager;
|
|
13
|
+
this.tenantId = tenantId;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enroll a new MFA factor
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Enroll TOTP (authenticator app)
|
|
21
|
+
* const { id, totpUri, qrCode } = await client.auth.mfa.enroll({
|
|
22
|
+
* type: "totp",
|
|
23
|
+
* friendlyName: "My Authenticator",
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Display QR code for user to scan
|
|
27
|
+
* // Then verify with challenge/verify flow
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
async enroll(options) {
|
|
31
|
+
const path = authPath(this.tenantId, "/factors");
|
|
32
|
+
const response = await this.http.post(path, {
|
|
33
|
+
factor_type: options.type,
|
|
34
|
+
friendly_name: options.friendlyName,
|
|
35
|
+
phone: options.phone,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
id: response.id,
|
|
39
|
+
type: options.type,
|
|
40
|
+
totpUri: response.totp?.uri,
|
|
41
|
+
qrCode: response.totp?.qr_code,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a challenge for an MFA factor
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const { id: challengeId, expiresAt } = await client.auth.mfa.challenge({
|
|
50
|
+
* factorId: "factor-id",
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // User enters code from authenticator app
|
|
54
|
+
* const session = await client.auth.mfa.verify({
|
|
55
|
+
* factorId: "factor-id",
|
|
56
|
+
* challengeId,
|
|
57
|
+
* code: "123456",
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async challenge(options) {
|
|
62
|
+
const path = authPath(this.tenantId, `/factors/${options.factorId}/challenge`);
|
|
63
|
+
const response = await this.http.post(path, {
|
|
64
|
+
channel: options.channel,
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
id: response.id,
|
|
68
|
+
expiresAt: response.expires_at,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Verify an MFA challenge
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const session = await client.auth.mfa.verify({
|
|
77
|
+
* factorId: "factor-id",
|
|
78
|
+
* challengeId: "challenge-id",
|
|
79
|
+
* code: "123456",
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async verify(options) {
|
|
84
|
+
const path = authPath(this.tenantId, `/factors/${options.factorId}/verify`);
|
|
85
|
+
const response = await this.http.post(path, {
|
|
86
|
+
challenge_id: options.challengeId,
|
|
87
|
+
code: options.code,
|
|
88
|
+
});
|
|
89
|
+
const session = normalizeSession(response);
|
|
90
|
+
this.tokenManager.setSession(session, "MFA_CHALLENGE_VERIFIED");
|
|
91
|
+
return session;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Unenroll (remove) an MFA factor
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* await client.auth.mfa.unenroll("factor-id");
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
async unenroll(factorId) {
|
|
102
|
+
const path = authPath(this.tenantId, `/factors/${factorId}`);
|
|
103
|
+
await this.http.delete(path);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* List all enrolled MFA factors
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const factors = await client.auth.mfa.listFactors();
|
|
111
|
+
* for (const factor of factors) {
|
|
112
|
+
* console.log(factor.type, factor.friendlyName, factor.status);
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
async listFactors() {
|
|
117
|
+
const path = authPath(this.tenantId, "/factors");
|
|
118
|
+
const response = await this.http.get(path);
|
|
119
|
+
return response.map(normalizeFactor);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get the authenticator assurance level
|
|
123
|
+
*
|
|
124
|
+
* Returns the current AAL (Authenticator Assurance Level):
|
|
125
|
+
* - aal1: Single factor (password only)
|
|
126
|
+
* - aal2: Two factors (password + MFA)
|
|
127
|
+
*/
|
|
128
|
+
getAuthenticatorAssuranceLevel() {
|
|
129
|
+
const session = this.tokenManager.getSession();
|
|
130
|
+
if (!session) {
|
|
131
|
+
return { currentLevel: null, nextLevel: null };
|
|
132
|
+
}
|
|
133
|
+
// Decode JWT to check AAL claim
|
|
134
|
+
try {
|
|
135
|
+
const parts = session.accessToken.split(".");
|
|
136
|
+
if (parts.length !== 3) {
|
|
137
|
+
return { currentLevel: "aal1", nextLevel: null };
|
|
138
|
+
}
|
|
139
|
+
const payload = JSON.parse(atob(parts[1]));
|
|
140
|
+
const currentLevel = payload.aal || "aal1";
|
|
141
|
+
const factors = session.user.factors || [];
|
|
142
|
+
const hasVerifiedFactor = factors.some((f) => f.status === "verified");
|
|
143
|
+
return {
|
|
144
|
+
currentLevel,
|
|
145
|
+
nextLevel: currentLevel === "aal1" && hasVerifiedFactor ? "aal2" : null,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return { currentLevel: "aal1", nextLevel: null };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=mfa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa.js","sourceRoot":"","sources":["../../../src/auth/methods/mfa.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { HttpClient } from "../../lib/http.js";
|
|
2
|
+
import type { TokenManager } from "../token-manager.js";
|
|
3
|
+
import type { OAuthSignInOptions, Session } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* OAuth authentication methods
|
|
6
|
+
*/
|
|
7
|
+
export declare class OAuthMethods {
|
|
8
|
+
private readonly http;
|
|
9
|
+
private readonly tokenManager;
|
|
10
|
+
private readonly tenantId;
|
|
11
|
+
constructor(http: HttpClient, tokenManager: TokenManager, tenantId: string);
|
|
12
|
+
/**
|
|
13
|
+
* Get the base URL for OAuth redirects
|
|
14
|
+
*/
|
|
15
|
+
private getBaseUrl;
|
|
16
|
+
/**
|
|
17
|
+
* Sign in with OAuth provider
|
|
18
|
+
*
|
|
19
|
+
* In browser: Redirects to provider's auth page
|
|
20
|
+
* With skipBrowserRedirect: Returns URL for manual redirect
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Browser redirect
|
|
25
|
+
* await client.auth.signInWithOAuth({
|
|
26
|
+
* provider: "google",
|
|
27
|
+
* redirectTo: "https://myapp.com/auth/callback",
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Get URL without redirect
|
|
31
|
+
* const { url } = await client.auth.signInWithOAuth({
|
|
32
|
+
* provider: "github",
|
|
33
|
+
* skipBrowserRedirect: true,
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
signInWithOAuth(options: OAuthSignInOptions): Promise<{
|
|
38
|
+
url: string;
|
|
39
|
+
provider: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Handle OAuth callback
|
|
43
|
+
*
|
|
44
|
+
* Call this on your callback page to exchange the authorization code for a session.
|
|
45
|
+
* Also handles email verification callbacks which use URL hash fragments.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // On /auth/callback page or in AuthProvider on mount
|
|
50
|
+
* const session = await client.auth.handleOAuthCallback();
|
|
51
|
+
* if (session) {
|
|
52
|
+
* router.push("/dashboard");
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
handleOAuthCallback(): Promise<Session | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Exchange authorization code for session (PKCE flow)
|
|
59
|
+
*/
|
|
60
|
+
private exchangeCodeForSession;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/auth/methods/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EAER,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFR,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM;IAGnC;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,eAAe,CACnB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IA2B7C;;;;;;;;;;;;;;OAcG;IACG,mBAAmB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAkFpD;;OAEG;YACW,sBAAsB;CAcrC"}
|