@finueva/auth 0.8.1 → 0.10.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/README.md +90 -4
- package/dist/device.d.ts +15 -2
- package/dist/device.js +509 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +447 -28
- package/dist/server.d.ts +15 -3
- package/dist/server.js +445 -24
- package/dist/types-Byw9JQwL.d.ts +235 -0
- package/package.json +1 -1
- package/dist/types-DDopQNZR.d.ts +0 -123
|
@@ -0,0 +1,235 @@
|
|
|
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_request" | "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 = 400 | 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
|
+
logo: string | null;
|
|
29
|
+
lifecycle: "ordinary" | "managed";
|
|
30
|
+
role: "owner" | "admin" | "member";
|
|
31
|
+
capabilities: {
|
|
32
|
+
readMembers: true;
|
|
33
|
+
readTeams: true;
|
|
34
|
+
readInvitations: boolean;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface OrganizationDisplay {
|
|
38
|
+
name: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
logo: string | null;
|
|
41
|
+
}
|
|
42
|
+
type UpdateOrganizationDisplayInput = OrganizationDisplay;
|
|
43
|
+
interface OrganizationTeamDisplay {
|
|
44
|
+
name: string;
|
|
45
|
+
}
|
|
46
|
+
type UpdateOrganizationTeamDisplayInput = OrganizationTeamDisplay;
|
|
47
|
+
interface OrganizationPageInput {
|
|
48
|
+
limit?: number;
|
|
49
|
+
cursor?: string;
|
|
50
|
+
}
|
|
51
|
+
interface OrganizationPage {
|
|
52
|
+
organizations: AuthOrganization[];
|
|
53
|
+
nextCursor: string | null;
|
|
54
|
+
}
|
|
55
|
+
interface OrganizationMember {
|
|
56
|
+
id: string;
|
|
57
|
+
userId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
email: string;
|
|
60
|
+
image: string | null;
|
|
61
|
+
role: "owner" | "admin" | "member";
|
|
62
|
+
owner: boolean;
|
|
63
|
+
joinedAt: Date;
|
|
64
|
+
teamIds: string[];
|
|
65
|
+
}
|
|
66
|
+
interface OrganizationMemberPage {
|
|
67
|
+
members: OrganizationMember[];
|
|
68
|
+
nextCursor: string | null;
|
|
69
|
+
}
|
|
70
|
+
interface OrganizationTeam {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
category: "manual" | "managed";
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
}
|
|
76
|
+
interface CreatedOrganizationTeam {
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
}
|
|
80
|
+
interface CreateOrganizationMemberInvitationInput {
|
|
81
|
+
email: string;
|
|
82
|
+
teamIds?: string[];
|
|
83
|
+
idempotencyKey: string;
|
|
84
|
+
}
|
|
85
|
+
interface CreatedOrganizationMemberInvitation {
|
|
86
|
+
id: string;
|
|
87
|
+
expiresAt: Date;
|
|
88
|
+
}
|
|
89
|
+
interface OrganizationTeamPage {
|
|
90
|
+
teams: OrganizationTeam[];
|
|
91
|
+
nextCursor: string | null;
|
|
92
|
+
}
|
|
93
|
+
interface OrganizationTeamMemberPage {
|
|
94
|
+
memberIds: string[];
|
|
95
|
+
nextCursor: string | null;
|
|
96
|
+
}
|
|
97
|
+
interface OrganizationInvitation {
|
|
98
|
+
id: string;
|
|
99
|
+
email: string;
|
|
100
|
+
role: "owner" | "admin" | "member";
|
|
101
|
+
teamIds: string[];
|
|
102
|
+
inviter: {
|
|
103
|
+
membershipId: string;
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
expiresAt: Date;
|
|
108
|
+
status: "pending";
|
|
109
|
+
}
|
|
110
|
+
interface OrganizationInvitationPage {
|
|
111
|
+
invitations: OrganizationInvitation[];
|
|
112
|
+
nextCursor: string | null;
|
|
113
|
+
}
|
|
114
|
+
interface ReceivedOrganizationInvitation {
|
|
115
|
+
id: string;
|
|
116
|
+
organization: Pick<AuthOrganization, "id" | "name" | "slug" | "logo">;
|
|
117
|
+
role: "owner" | "admin" | "member";
|
|
118
|
+
teams: Array<{
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
}>;
|
|
122
|
+
inviterName: string;
|
|
123
|
+
expiresAt: Date;
|
|
124
|
+
}
|
|
125
|
+
interface ReceivedOrganizationInvitationPage {
|
|
126
|
+
invitations: ReceivedOrganizationInvitation[];
|
|
127
|
+
nextCursor: string | null;
|
|
128
|
+
}
|
|
129
|
+
interface AcceptInvitationInput {
|
|
130
|
+
invitationId: string;
|
|
131
|
+
}
|
|
132
|
+
interface InvitationAcceptance {
|
|
133
|
+
organizationId: string;
|
|
134
|
+
}
|
|
135
|
+
type AuthState = {
|
|
136
|
+
status: "loading";
|
|
137
|
+
} | {
|
|
138
|
+
status: "cached";
|
|
139
|
+
session: AuthSession;
|
|
140
|
+
authoritative: false;
|
|
141
|
+
} | {
|
|
142
|
+
status: "authenticated";
|
|
143
|
+
session: AuthSession;
|
|
144
|
+
authoritative: true;
|
|
145
|
+
} | {
|
|
146
|
+
status: "unauthenticated";
|
|
147
|
+
session: null;
|
|
148
|
+
authoritative: true;
|
|
149
|
+
} | {
|
|
150
|
+
status: "unavailable";
|
|
151
|
+
session: AuthSession | null;
|
|
152
|
+
authoritative: false;
|
|
153
|
+
};
|
|
154
|
+
interface AuthPersistenceDriver {
|
|
155
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
156
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
157
|
+
removeItem(key: string): void | Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
type AuthPersistence = "local" | "session" | "memory" | AuthPersistenceDriver;
|
|
160
|
+
interface PersonalWorkspaceSelection {
|
|
161
|
+
type: "personal";
|
|
162
|
+
}
|
|
163
|
+
interface OrganizationWorkspaceSelection {
|
|
164
|
+
type: "organization";
|
|
165
|
+
organizationId: string;
|
|
166
|
+
}
|
|
167
|
+
type WorkspaceSelection = PersonalWorkspaceSelection | OrganizationWorkspaceSelection;
|
|
168
|
+
interface DriveCredential {
|
|
169
|
+
tokenType: "Bearer";
|
|
170
|
+
token: string;
|
|
171
|
+
expiresAt: Date;
|
|
172
|
+
}
|
|
173
|
+
interface SignInInput {
|
|
174
|
+
email: string;
|
|
175
|
+
password: string;
|
|
176
|
+
}
|
|
177
|
+
type SocialIdTokenProvider = "google" | "apple";
|
|
178
|
+
interface SocialIdTokenInput {
|
|
179
|
+
provider: SocialIdTokenProvider;
|
|
180
|
+
idToken: string;
|
|
181
|
+
nonce?: string;
|
|
182
|
+
signUp: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface UpdateProfileInput {
|
|
185
|
+
name?: string;
|
|
186
|
+
image?: string | null;
|
|
187
|
+
}
|
|
188
|
+
interface SendVerificationEmailInput {
|
|
189
|
+
email: string;
|
|
190
|
+
callbackURL?: string;
|
|
191
|
+
}
|
|
192
|
+
interface DriveCredentialInput {
|
|
193
|
+
workspace: WorkspaceSelection;
|
|
194
|
+
forceRefresh?: boolean;
|
|
195
|
+
}
|
|
196
|
+
interface AuthClientOptions {
|
|
197
|
+
authOrigin: string;
|
|
198
|
+
appOrigin: string;
|
|
199
|
+
fetch?: typeof globalThis.fetch;
|
|
200
|
+
now?: () => number;
|
|
201
|
+
persistence?: AuthPersistence;
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
}
|
|
204
|
+
interface FinuevaAuthClient {
|
|
205
|
+
readonly _type: "browser";
|
|
206
|
+
acceptInvitation(input: AcceptInvitationInput): Promise<InvitationAcceptance>;
|
|
207
|
+
getSession(): Promise<AuthSession | null>;
|
|
208
|
+
listOrganizations(input?: OrganizationPageInput): Promise<OrganizationPage>;
|
|
209
|
+
getOrganization(organizationId: string): Promise<AuthOrganization>;
|
|
210
|
+
createOrganizationTeam(organizationId: string, name: string, idempotencyKey: string): Promise<CreatedOrganizationTeam>;
|
|
211
|
+
createOrganizationMemberInvitation(organizationId: string, input: CreateOrganizationMemberInvitationInput): Promise<CreatedOrganizationMemberInvitation>;
|
|
212
|
+
updateOrganizationDisplay(organizationId: string, input: UpdateOrganizationDisplayInput): Promise<OrganizationDisplay>;
|
|
213
|
+
updateOrganizationTeamDisplay(organizationId: string, teamId: string, input: UpdateOrganizationTeamDisplayInput): Promise<OrganizationTeamDisplay>;
|
|
214
|
+
listOrganizationMembers(organizationId: string, input?: OrganizationPageInput): Promise<OrganizationMemberPage>;
|
|
215
|
+
listOrganizationTeams(organizationId: string, input?: OrganizationPageInput): Promise<OrganizationTeamPage>;
|
|
216
|
+
listOrganizationTeamMembers(organizationId: string, teamId: string, input?: OrganizationPageInput): Promise<OrganizationTeamMemberPage>;
|
|
217
|
+
listOrganizationInvitations(organizationId: string, input?: OrganizationPageInput): Promise<OrganizationInvitationPage>;
|
|
218
|
+
getOrganizationInvitation(organizationId: string, invitationId: string): Promise<OrganizationInvitation>;
|
|
219
|
+
listReceivedInvitations(input?: OrganizationPageInput): Promise<ReceivedOrganizationInvitationPage>;
|
|
220
|
+
getReceivedInvitation(invitationId: string): Promise<ReceivedOrganizationInvitation>;
|
|
221
|
+
sendVerificationEmail(input: SendVerificationEmailInput): Promise<void>;
|
|
222
|
+
signUp(email: string, password: string, name: string): Promise<AuthSession>;
|
|
223
|
+
signIn(input: SignInInput): Promise<AuthSession>;
|
|
224
|
+
signInWithSocialIdToken(input: SocialIdTokenInput): Promise<AuthSession>;
|
|
225
|
+
updateProfile(input: UpdateProfileInput): Promise<AuthSession>;
|
|
226
|
+
changePassword(currentPassword: string, newPassword: string, revokeOtherSessions?: boolean): Promise<AuthSession>;
|
|
227
|
+
requestPasswordReset(email: string, redirectTo: string): Promise<void>;
|
|
228
|
+
resetPassword(token: string, newPassword: string): Promise<void>;
|
|
229
|
+
signOut(): Promise<void>;
|
|
230
|
+
getDriveCredential(input: DriveCredentialInput): Promise<DriveCredential>;
|
|
231
|
+
onAuthStateChange(listener: (state: AuthState) => void): () => void;
|
|
232
|
+
onSessionChange(listener: (session: AuthSession | null) => void): () => void;
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
export { ReceivedOrganizationInvitationPage as A, AuthErrorCode as B, OrganizationTeam as C, OrganizationWorkspaceSelection as D, OrganizationTeamPage as E, UpdateOrganizationDisplayInput as F, UpdateOrganizationTeamDisplayInput as I, UpdateProfileInput as L, SignInInput as M, SocialIdTokenInput as N, PersonalWorkspaceSelection as O, SocialIdTokenProvider as P, WorkspaceSelection as R, OrganizationPageInput as S, OrganizationTeamMemberPage as T, AuthErrorStatus as V, OrganizationInvitation as _, AuthPersistenceDriver as a, OrganizationMemberPage as b, AuthUser as c, CreatedOrganizationTeam as d, DriveCredential as f, OrganizationDisplay as g, InvitationAcceptance as h, AuthPersistence as i, SendVerificationEmailInput as j, ReceivedOrganizationInvitation as k, CreateOrganizationMemberInvitationInput as l, FinuevaAuthClient as m, AuthClientOptions as n, AuthSession as o, DriveCredentialInput as p, AuthOrganization as r, AuthState as s, AcceptInvitationInput as t, CreatedOrganizationMemberInvitation as u, OrganizationInvitationPage as v, OrganizationTeamDisplay as w, OrganizationPage as x, OrganizationMember as y, AuthError as z };
|
package/package.json
CHANGED
package/dist/types-DDopQNZR.d.ts
DELETED
|
@@ -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 };
|