@finueva/auth 0.8.1 → 0.9.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.
@@ -1,123 +0,0 @@
1
- //#region src/errors.d.ts
2
- type AuthErrorCode = "invalid_credentials" | "invalid_auth_input" | "account_conflict" | "password_reset_invalid" | "authentication_required" | "request_origin_denied" | "invalid_invitation" | "invitation_unavailable" | "invitation_recipient_mismatch" | "email_verification_required" | "invalid_workspace_selection" | "organization_context_too_large" | "credential_rate_limited" | "auth_request_rate_limited" | "state_conflict" | "access_denied" | "identity_authority_unavailable";
3
- type AuthErrorStatus = 401 | 403 | 409 | 422 | 429 | 503;
4
- declare class AuthError extends Error {
5
- readonly code: AuthErrorCode;
6
- readonly status: AuthErrorStatus;
7
- readonly retryAfterSeconds?: number;
8
- constructor(code: AuthErrorCode, status: AuthErrorStatus, retryAfterSeconds?: number);
9
- }
10
- //#endregion
11
- //#region src/types.d.ts
12
- interface AuthUser {
13
- id: string;
14
- name: string;
15
- email: string;
16
- emailVerified: boolean;
17
- image: string | null;
18
- }
19
- interface AuthSession {
20
- id: string;
21
- expiresAt: Date;
22
- user: AuthUser;
23
- }
24
- interface AuthOrganization {
25
- id: string;
26
- name: string;
27
- slug: string;
28
- }
29
- interface AcceptInvitationInput {
30
- invitationId: string;
31
- }
32
- interface InvitationAcceptance {
33
- organizationId: string;
34
- }
35
- type AuthState = {
36
- status: "loading";
37
- } | {
38
- status: "cached";
39
- session: AuthSession;
40
- authoritative: false;
41
- } | {
42
- status: "authenticated";
43
- session: AuthSession;
44
- authoritative: true;
45
- } | {
46
- status: "unauthenticated";
47
- session: null;
48
- authoritative: true;
49
- } | {
50
- status: "unavailable";
51
- session: AuthSession | null;
52
- authoritative: false;
53
- };
54
- interface AuthPersistenceDriver {
55
- getItem(key: string): string | null | Promise<string | null>;
56
- setItem(key: string, value: string): void | Promise<void>;
57
- removeItem(key: string): void | Promise<void>;
58
- }
59
- type AuthPersistence = "local" | "session" | "memory" | AuthPersistenceDriver;
60
- interface PersonalWorkspaceSelection {
61
- type: "personal";
62
- }
63
- interface OrganizationWorkspaceSelection {
64
- type: "organization";
65
- organizationId: string;
66
- }
67
- type WorkspaceSelection = PersonalWorkspaceSelection | OrganizationWorkspaceSelection;
68
- interface DriveCredential {
69
- tokenType: "Bearer";
70
- token: string;
71
- expiresAt: Date;
72
- }
73
- interface SignInInput {
74
- email: string;
75
- password: string;
76
- }
77
- type SocialIdTokenProvider = "google" | "apple";
78
- interface SocialIdTokenInput {
79
- provider: SocialIdTokenProvider;
80
- idToken: string;
81
- nonce?: string;
82
- signUp: boolean;
83
- }
84
- interface UpdateProfileInput {
85
- name?: string;
86
- image?: string | null;
87
- }
88
- interface SendVerificationEmailInput {
89
- email: string;
90
- callbackURL?: string;
91
- }
92
- interface DriveCredentialInput {
93
- workspace: WorkspaceSelection;
94
- forceRefresh?: boolean;
95
- }
96
- interface AuthClientOptions {
97
- authOrigin: string;
98
- appOrigin: string;
99
- fetch?: typeof globalThis.fetch;
100
- now?: () => number;
101
- persistence?: AuthPersistence;
102
- timeoutMs?: number;
103
- }
104
- interface FinuevaAuthClient {
105
- readonly _type: "browser";
106
- acceptInvitation(input: AcceptInvitationInput): Promise<InvitationAcceptance>;
107
- getSession(): Promise<AuthSession | null>;
108
- listOrganizations(): Promise<AuthOrganization[]>;
109
- sendVerificationEmail(input: SendVerificationEmailInput): Promise<void>;
110
- signUp(email: string, password: string, name: string): Promise<AuthSession>;
111
- signIn(input: SignInInput): Promise<AuthSession>;
112
- signInWithSocialIdToken(input: SocialIdTokenInput): Promise<AuthSession>;
113
- updateProfile(input: UpdateProfileInput): Promise<AuthSession>;
114
- changePassword(currentPassword: string, newPassword: string, revokeOtherSessions?: boolean): Promise<AuthSession>;
115
- requestPasswordReset(email: string, redirectTo: string): Promise<void>;
116
- resetPassword(token: string, newPassword: string): Promise<void>;
117
- signOut(): Promise<void>;
118
- getDriveCredential(input: DriveCredentialInput): Promise<DriveCredential>;
119
- onAuthStateChange(listener: (state: AuthState) => void): () => void;
120
- onSessionChange(listener: (session: AuthSession | null) => void): () => void;
121
- }
122
- //#endregion
123
- export { AuthErrorStatus as C, AuthErrorCode as S, SocialIdTokenInput as _, AuthPersistenceDriver as a, WorkspaceSelection as b, AuthUser as c, FinuevaAuthClient as d, InvitationAcceptance as f, SignInInput as g, SendVerificationEmailInput as h, AuthPersistence as i, DriveCredential as l, PersonalWorkspaceSelection as m, AuthClientOptions as n, AuthSession as o, OrganizationWorkspaceSelection as p, AuthOrganization as r, AuthState as s, AcceptInvitationInput as t, DriveCredentialInput as u, SocialIdTokenProvider as v, AuthError as x, UpdateProfileInput as y };