@bagelink/auth 1.9.61 → 1.9.63
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/dist/api.d.ts +36 -32
- package/dist/index.cjs +101 -127
- package/dist/index.mjs +101 -127
- package/dist/sso.d.ts +2 -2
- package/dist/types.d.ts +70 -24
- package/dist/useAuth.d.ts +19 -20
- package/package.json +1 -1
- package/src/api.ts +81 -82
- package/src/sso.ts +26 -24
- package/src/types.ts +77 -28
- package/src/useAuth.ts +19 -51
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RegisterRequest, UpdateAccountRequest, ChangePasswordRequest, ResetPasswordRequest, SendVerificationRequest, AuthenticationAccount,
|
|
1
|
+
import { RegisterRequest, UpdateAccountRequest, ChangePasswordRequest, ForgotPasswordRequest, ResetPasswordRequest, SendVerificationRequest, VerifyEmailRequest, AuthenticationAccount, PasswordLoginRequest, EmailTokenSendRequest, EmailTokenVerifyRequest, OTPSendRequest, OTPVerifyRequest, SSOLoginRequest, LoginResponse, RegisterResponse, LogoutResponse, GetMeResponse, UpdateMeResponse, DeleteMeResponse, ChangePasswordResponse, ForgotPasswordResponse, ResetPasswordResponse, VerifyResetTokenResponse, SendVerificationResponse, VerifyEmailResponse, RefreshSessionResponse, GetSessionsResponse, DeleteSessionResponse, DeleteAllSessionsResponse, CleanupSessionsResponse, GetMethodsResponse, GetAuthStatusResponse, SendEmailTokenResponse, VerifyEmailTokenResponse, SendOTPResponse, VerifyOTPResponse, LegacySSOLoginResponse, SSOProvider, SSOInitiateRequest, SSOCallbackRequest, SSOLinkRequest, InitiateSSOResponse, CallbackSSOResponse, LinkSSOResponse, UnlinkSSOResponse, GetTenantsResponse } from './types';
|
|
2
2
|
export declare class AuthApi {
|
|
3
3
|
private api;
|
|
4
4
|
private currentTenantId;
|
|
@@ -12,6 +12,10 @@ export declare class AuthApi {
|
|
|
12
12
|
*/
|
|
13
13
|
getTenantId(): string | null;
|
|
14
14
|
private setupInterceptors;
|
|
15
|
+
/**
|
|
16
|
+
* Get authentication status
|
|
17
|
+
*/
|
|
18
|
+
getAuthStatus(): Promise<GetAuthStatusResponse>;
|
|
15
19
|
/**
|
|
16
20
|
* Get available authentication methods
|
|
17
21
|
*/
|
|
@@ -23,7 +27,27 @@ export declare class AuthApi {
|
|
|
23
27
|
/**
|
|
24
28
|
* Login with password
|
|
25
29
|
*/
|
|
26
|
-
login(
|
|
30
|
+
login(data: PasswordLoginRequest): Promise<LoginResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Send email token to user
|
|
33
|
+
*/
|
|
34
|
+
sendEmailToken(data: EmailTokenSendRequest): Promise<SendEmailTokenResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Verify email token and login
|
|
37
|
+
*/
|
|
38
|
+
verifyEmailToken(data: EmailTokenVerifyRequest): Promise<VerifyEmailTokenResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Send OTP code to phone number
|
|
41
|
+
*/
|
|
42
|
+
sendOTP(data: OTPSendRequest): Promise<SendOTPResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Verify OTP code and login
|
|
45
|
+
*/
|
|
46
|
+
verifyOTP(data: OTPVerifyRequest): Promise<VerifyOTPResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Login with SSO provider (legacy endpoint without PKCE)
|
|
49
|
+
*/
|
|
50
|
+
loginWithSSO(provider: SSOProvider, data: SSOLoginRequest): Promise<LegacySSOLoginResponse>;
|
|
27
51
|
/**
|
|
28
52
|
* Logout and clear session
|
|
29
53
|
*/
|
|
@@ -36,19 +60,19 @@ export declare class AuthApi {
|
|
|
36
60
|
* Initiate SSO login flow
|
|
37
61
|
* Returns authorization URL to redirect user to
|
|
38
62
|
*/
|
|
39
|
-
initiateSSO(data: SSOInitiateRequest): Promise<
|
|
63
|
+
initiateSSO(provider: SSOProvider, data: SSOInitiateRequest): Promise<InitiateSSOResponse>;
|
|
40
64
|
/**
|
|
41
65
|
* Complete SSO login after callback from provider
|
|
42
66
|
*/
|
|
43
|
-
ssoCallback(data: SSOCallbackRequest): Promise<
|
|
67
|
+
ssoCallback(provider: SSOProvider, data: SSOCallbackRequest): Promise<CallbackSSOResponse>;
|
|
44
68
|
/**
|
|
45
69
|
* Link an SSO provider to existing account
|
|
46
70
|
*/
|
|
47
|
-
linkSSOProvider(data: SSOLinkRequest): Promise<
|
|
71
|
+
linkSSOProvider(provider: SSOProvider, data: SSOLinkRequest): Promise<LinkSSOResponse>;
|
|
48
72
|
/**
|
|
49
73
|
* Unlink an SSO provider from account
|
|
50
74
|
*/
|
|
51
|
-
unlinkSSOProvider(provider: SSOProvider): Promise<
|
|
75
|
+
unlinkSSOProvider(provider: SSOProvider): Promise<UnlinkSSOResponse>;
|
|
52
76
|
/**
|
|
53
77
|
* Get current user account info
|
|
54
78
|
*/
|
|
@@ -61,26 +85,6 @@ export declare class AuthApi {
|
|
|
61
85
|
* Delete current user account
|
|
62
86
|
*/
|
|
63
87
|
deleteCurrentUser(): Promise<DeleteMeResponse>;
|
|
64
|
-
/**
|
|
65
|
-
* Get account information by ID
|
|
66
|
-
*/
|
|
67
|
-
getAccount(accountId: string): Promise<GetAccountResponse>;
|
|
68
|
-
/**
|
|
69
|
-
* Update account by ID
|
|
70
|
-
*/
|
|
71
|
-
updateAccount(accountId: string, data: UpdateAccountRequest): Promise<UpdateAccountResponse>;
|
|
72
|
-
/**
|
|
73
|
-
* Delete account by ID
|
|
74
|
-
*/
|
|
75
|
-
deleteAccount(accountId: string): Promise<DeleteAccountResponse>;
|
|
76
|
-
/**
|
|
77
|
-
* Activate account by ID
|
|
78
|
-
*/
|
|
79
|
-
activateAccount(accountId: string): Promise<ActivateAccountResponse>;
|
|
80
|
-
/**
|
|
81
|
-
* Deactivate account by ID
|
|
82
|
-
*/
|
|
83
|
-
deactivateAccount(accountId: string): Promise<DeactivateAccountResponse>;
|
|
84
88
|
/**
|
|
85
89
|
* Change password (requires current password)
|
|
86
90
|
*/
|
|
@@ -88,7 +92,7 @@ export declare class AuthApi {
|
|
|
88
92
|
/**
|
|
89
93
|
* Initiate forgot password flow
|
|
90
94
|
*/
|
|
91
|
-
forgotPassword(
|
|
95
|
+
forgotPassword(data: ForgotPasswordRequest): Promise<ForgotPasswordResponse>;
|
|
92
96
|
/**
|
|
93
97
|
* Verify password reset token
|
|
94
98
|
*/
|
|
@@ -104,19 +108,19 @@ export declare class AuthApi {
|
|
|
104
108
|
/**
|
|
105
109
|
* Verify email with token
|
|
106
110
|
*/
|
|
107
|
-
verifyEmail(
|
|
111
|
+
verifyEmail(data: VerifyEmailRequest): Promise<VerifyEmailResponse>;
|
|
108
112
|
/**
|
|
109
|
-
* Get sessions for
|
|
113
|
+
* Get active sessions for current identity
|
|
110
114
|
*/
|
|
111
|
-
getSessions(
|
|
115
|
+
getSessions(): Promise<GetSessionsResponse>;
|
|
112
116
|
/**
|
|
113
117
|
* Revoke a specific session
|
|
114
118
|
*/
|
|
115
119
|
revokeSession(sessionToken: string): Promise<DeleteSessionResponse>;
|
|
116
120
|
/**
|
|
117
|
-
* Revoke all sessions for
|
|
121
|
+
* Revoke all sessions for current identity
|
|
118
122
|
*/
|
|
119
|
-
revokeAllSessions(
|
|
123
|
+
revokeAllSessions(): Promise<DeleteAllSessionsResponse>;
|
|
120
124
|
/**
|
|
121
125
|
* Cleanup expired sessions (admin)
|
|
122
126
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -97,6 +97,12 @@ class AuthApi {
|
|
|
97
97
|
// ============================================
|
|
98
98
|
// Authentication Methods
|
|
99
99
|
// ============================================
|
|
100
|
+
/**
|
|
101
|
+
* Get authentication status
|
|
102
|
+
*/
|
|
103
|
+
async getAuthStatus() {
|
|
104
|
+
return this.api.get("authentication/status");
|
|
105
|
+
}
|
|
100
106
|
/**
|
|
101
107
|
* Get available authentication methods
|
|
102
108
|
*/
|
|
@@ -115,12 +121,42 @@ class AuthApi {
|
|
|
115
121
|
/**
|
|
116
122
|
* Login with password
|
|
117
123
|
*/
|
|
118
|
-
async login(
|
|
124
|
+
async login(data) {
|
|
119
125
|
return this.api.post("authentication/login/password", {
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
...data,
|
|
127
|
+
email: data.email.toLowerCase()
|
|
122
128
|
});
|
|
123
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Send email token to user
|
|
132
|
+
*/
|
|
133
|
+
async sendEmailToken(data) {
|
|
134
|
+
return this.api.post("authentication/login/email-token/send", data);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Verify email token and login
|
|
138
|
+
*/
|
|
139
|
+
async verifyEmailToken(data) {
|
|
140
|
+
return this.api.post("authentication/login/email-token/verify", data);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Send OTP code to phone number
|
|
144
|
+
*/
|
|
145
|
+
async sendOTP(data) {
|
|
146
|
+
return this.api.post("authentication/login/otp/send", data);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Verify OTP code and login
|
|
150
|
+
*/
|
|
151
|
+
async verifyOTP(data) {
|
|
152
|
+
return this.api.post("authentication/login/otp/verify", data);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Login with SSO provider (legacy endpoint without PKCE)
|
|
156
|
+
*/
|
|
157
|
+
async loginWithSSO(provider, data) {
|
|
158
|
+
return this.api.post(`authentication/login/sso/${provider}`, data);
|
|
159
|
+
}
|
|
124
160
|
/**
|
|
125
161
|
* Logout and clear session
|
|
126
162
|
*/
|
|
@@ -140,29 +176,20 @@ class AuthApi {
|
|
|
140
176
|
* Initiate SSO login flow
|
|
141
177
|
* Returns authorization URL to redirect user to
|
|
142
178
|
*/
|
|
143
|
-
async initiateSSO(data) {
|
|
144
|
-
return this.api.post(`authentication/sso/${
|
|
145
|
-
redirect_uri: data.redirect_uri,
|
|
146
|
-
state: data.state
|
|
147
|
-
});
|
|
179
|
+
async initiateSSO(provider, data) {
|
|
180
|
+
return this.api.post(`authentication/sso/${provider}/initiate`, data);
|
|
148
181
|
}
|
|
149
182
|
/**
|
|
150
183
|
* Complete SSO login after callback from provider
|
|
151
184
|
*/
|
|
152
|
-
async ssoCallback(data) {
|
|
153
|
-
return this.api.post(`authentication/sso/${
|
|
154
|
-
code: data.code,
|
|
155
|
-
state: data.state
|
|
156
|
-
});
|
|
185
|
+
async ssoCallback(provider, data) {
|
|
186
|
+
return this.api.post(`authentication/sso/${provider}/callback`, data);
|
|
157
187
|
}
|
|
158
188
|
/**
|
|
159
189
|
* Link an SSO provider to existing account
|
|
160
190
|
*/
|
|
161
|
-
async linkSSOProvider(data) {
|
|
162
|
-
return this.api.post(`authentication/sso/${
|
|
163
|
-
code: data.code,
|
|
164
|
-
state: data.state
|
|
165
|
-
});
|
|
191
|
+
async linkSSOProvider(provider, data) {
|
|
192
|
+
return this.api.post(`authentication/sso/${provider}/link`, data);
|
|
166
193
|
}
|
|
167
194
|
/**
|
|
168
195
|
* Unlink an SSO provider from account
|
|
@@ -192,39 +219,6 @@ class AuthApi {
|
|
|
192
219
|
return this.api.delete("authentication/me");
|
|
193
220
|
}
|
|
194
221
|
// ============================================
|
|
195
|
-
// Account Management (Admin)
|
|
196
|
-
// ============================================
|
|
197
|
-
/**
|
|
198
|
-
* Get account information by ID
|
|
199
|
-
*/
|
|
200
|
-
async getAccount(accountId) {
|
|
201
|
-
return this.api.get(`authentication/account/${accountId}`);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Update account by ID
|
|
205
|
-
*/
|
|
206
|
-
async updateAccount(accountId, data) {
|
|
207
|
-
return this.api.patch(`authentication/account/${accountId}`, data);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Delete account by ID
|
|
211
|
-
*/
|
|
212
|
-
async deleteAccount(accountId) {
|
|
213
|
-
return this.api.delete(`authentication/account/${accountId}`);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Activate account by ID
|
|
217
|
-
*/
|
|
218
|
-
async activateAccount(accountId) {
|
|
219
|
-
return this.api.post(`authentication/account/${accountId}/activate`, {});
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Deactivate account by ID
|
|
223
|
-
*/
|
|
224
|
-
async deactivateAccount(accountId) {
|
|
225
|
-
return this.api.post(`authentication/account/${accountId}/deactivate`, {});
|
|
226
|
-
}
|
|
227
|
-
// ============================================
|
|
228
222
|
// Password Management
|
|
229
223
|
// ============================================
|
|
230
224
|
/**
|
|
@@ -236,9 +230,10 @@ class AuthApi {
|
|
|
236
230
|
/**
|
|
237
231
|
* Initiate forgot password flow
|
|
238
232
|
*/
|
|
239
|
-
async forgotPassword(
|
|
233
|
+
async forgotPassword(data) {
|
|
240
234
|
return this.api.post("authentication/password/forgot", {
|
|
241
|
-
|
|
235
|
+
...data,
|
|
236
|
+
email: data.email.toLowerCase()
|
|
242
237
|
});
|
|
243
238
|
}
|
|
244
239
|
/**
|
|
@@ -267,17 +262,17 @@ class AuthApi {
|
|
|
267
262
|
/**
|
|
268
263
|
* Verify email with token
|
|
269
264
|
*/
|
|
270
|
-
async verifyEmail(
|
|
271
|
-
return this.api.post("authentication/verify/email",
|
|
265
|
+
async verifyEmail(data) {
|
|
266
|
+
return this.api.post("authentication/verify/email", data);
|
|
272
267
|
}
|
|
273
268
|
// ============================================
|
|
274
269
|
// Session Management
|
|
275
270
|
// ============================================
|
|
276
271
|
/**
|
|
277
|
-
* Get sessions for
|
|
272
|
+
* Get active sessions for current identity
|
|
278
273
|
*/
|
|
279
|
-
async getSessions(
|
|
280
|
-
return this.api.get(
|
|
274
|
+
async getSessions() {
|
|
275
|
+
return this.api.get("authentication/sessions");
|
|
281
276
|
}
|
|
282
277
|
/**
|
|
283
278
|
* Revoke a specific session
|
|
@@ -286,10 +281,10 @@ class AuthApi {
|
|
|
286
281
|
return this.api.delete(`authentication/sessions/${sessionToken}`);
|
|
287
282
|
}
|
|
288
283
|
/**
|
|
289
|
-
* Revoke all sessions for
|
|
284
|
+
* Revoke all sessions for current identity
|
|
290
285
|
*/
|
|
291
|
-
async revokeAllSessions(
|
|
292
|
-
return this.api.delete(
|
|
286
|
+
async revokeAllSessions() {
|
|
287
|
+
return this.api.delete("authentication/sessions");
|
|
293
288
|
}
|
|
294
289
|
/**
|
|
295
290
|
* Cleanup expired sessions (admin)
|
|
@@ -1638,8 +1633,7 @@ function createSSOProvider(config) {
|
|
|
1638
1633
|
sessionStorage.setItem(getStateKey(), state);
|
|
1639
1634
|
sessionStorage.setItem(`oauth_provider:${state}`, config.id);
|
|
1640
1635
|
}
|
|
1641
|
-
const authUrl = await auth.initiateSSO({
|
|
1642
|
-
provider: config.id,
|
|
1636
|
+
const authUrl = await auth.initiateSSO(config.id, {
|
|
1643
1637
|
redirect_uri: redirectUri,
|
|
1644
1638
|
state,
|
|
1645
1639
|
scopes: options.scopes ?? config.defaultScopes,
|
|
@@ -1663,8 +1657,7 @@ function createSSOProvider(config) {
|
|
|
1663
1657
|
sessionStorage.setItem(getStateKey(), state);
|
|
1664
1658
|
sessionStorage.setItem(`oauth_provider:${state}`, config.id);
|
|
1665
1659
|
}
|
|
1666
|
-
const authUrl = await auth.initiateSSO({
|
|
1667
|
-
provider: config.id,
|
|
1660
|
+
const authUrl = await auth.initiateSSO(config.id, {
|
|
1668
1661
|
redirect_uri: redirectUri,
|
|
1669
1662
|
state,
|
|
1670
1663
|
scopes: options.scopes ?? config.defaultScopes,
|
|
@@ -1676,15 +1669,14 @@ function createSSOProvider(config) {
|
|
|
1676
1669
|
throw new PopupBlockedError();
|
|
1677
1670
|
}
|
|
1678
1671
|
const result = await waitForPopupCallback(popupWindow, config.id, timeout2);
|
|
1679
|
-
return auth.loginWithSSO({
|
|
1680
|
-
provider: config.id,
|
|
1672
|
+
return auth.loginWithSSO(config.id, {
|
|
1681
1673
|
code: result.code,
|
|
1682
|
-
state: result.state
|
|
1674
|
+
state: result.state ?? generateState()
|
|
1683
1675
|
});
|
|
1684
1676
|
},
|
|
1685
1677
|
async callback(code, state) {
|
|
1686
1678
|
const auth = getAuthApi();
|
|
1687
|
-
if (typeof sessionStorage !== "undefined"
|
|
1679
|
+
if (typeof sessionStorage !== "undefined") {
|
|
1688
1680
|
const storedState = sessionStorage.getItem(getStateKey());
|
|
1689
1681
|
sessionStorage.removeItem(getStateKey());
|
|
1690
1682
|
sessionStorage.removeItem(`oauth_provider:${state}`);
|
|
@@ -1692,15 +1684,14 @@ function createSSOProvider(config) {
|
|
|
1692
1684
|
throw new StateMismatchError();
|
|
1693
1685
|
}
|
|
1694
1686
|
}
|
|
1695
|
-
return auth.loginWithSSO({
|
|
1696
|
-
provider: config.id,
|
|
1687
|
+
return auth.loginWithSSO(config.id, {
|
|
1697
1688
|
code,
|
|
1698
|
-
state
|
|
1689
|
+
state: state ?? generateState()
|
|
1699
1690
|
});
|
|
1700
1691
|
},
|
|
1701
1692
|
async link(code, state) {
|
|
1702
1693
|
const auth = getAuthApi();
|
|
1703
|
-
if (typeof sessionStorage !== "undefined"
|
|
1694
|
+
if (typeof sessionStorage !== "undefined") {
|
|
1704
1695
|
const storedState = sessionStorage.getItem(getStateKey());
|
|
1705
1696
|
sessionStorage.removeItem(getStateKey());
|
|
1706
1697
|
sessionStorage.removeItem(`oauth_provider:${state}`);
|
|
@@ -1708,10 +1699,9 @@ function createSSOProvider(config) {
|
|
|
1708
1699
|
throw new StateMismatchError();
|
|
1709
1700
|
}
|
|
1710
1701
|
}
|
|
1711
|
-
await auth.linkSSOProvider({
|
|
1712
|
-
provider: config.id,
|
|
1702
|
+
await auth.linkSSOProvider(config.id, {
|
|
1713
1703
|
code,
|
|
1714
|
-
state
|
|
1704
|
+
state: state ?? generateState()
|
|
1715
1705
|
});
|
|
1716
1706
|
},
|
|
1717
1707
|
async unlink() {
|
|
@@ -1722,8 +1712,7 @@ function createSSOProvider(config) {
|
|
|
1722
1712
|
const auth = getAuthApi();
|
|
1723
1713
|
const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
|
|
1724
1714
|
const state = options.state ?? generateState();
|
|
1725
|
-
return auth.initiateSSO({
|
|
1726
|
-
provider: config.id,
|
|
1715
|
+
return auth.initiateSSO(config.id, {
|
|
1727
1716
|
redirect_uri: redirectUri,
|
|
1728
1717
|
state,
|
|
1729
1718
|
scopes: options.scopes ?? config.defaultScopes,
|
|
@@ -1832,6 +1821,16 @@ const ssoProviders = {
|
|
|
1832
1821
|
authDomain: "www.facebook.com",
|
|
1833
1822
|
buttonText: "Continue with Facebook"
|
|
1834
1823
|
}
|
|
1824
|
+
}),
|
|
1825
|
+
custom: createSSOProvider({
|
|
1826
|
+
id: "custom",
|
|
1827
|
+
name: "Custom",
|
|
1828
|
+
color: "#000000",
|
|
1829
|
+
icon: "custom",
|
|
1830
|
+
defaultScopes: [],
|
|
1831
|
+
metadata: {
|
|
1832
|
+
buttonText: "Continue with Custom"
|
|
1833
|
+
}
|
|
1835
1834
|
})
|
|
1836
1835
|
};
|
|
1837
1836
|
const sso = {
|
|
@@ -1933,13 +1932,13 @@ function accountToUser(account) {
|
|
|
1933
1932
|
id: account.person.id,
|
|
1934
1933
|
accountId: account.id,
|
|
1935
1934
|
name: account.person.name,
|
|
1936
|
-
email: account.person.email
|
|
1935
|
+
email: account.person.email,
|
|
1937
1936
|
type: account.account_type,
|
|
1938
|
-
roles: account.
|
|
1937
|
+
roles: account.roles,
|
|
1939
1938
|
isActive: account.is_active,
|
|
1940
1939
|
isVerified: account.is_verified,
|
|
1941
1940
|
person: account.person,
|
|
1942
|
-
lastLogin: account.last_login
|
|
1941
|
+
lastLogin: account.last_login,
|
|
1943
1942
|
hasPersonLinked: true
|
|
1944
1943
|
};
|
|
1945
1944
|
}
|
|
@@ -1952,9 +1951,10 @@ function accountToUser(account) {
|
|
|
1952
1951
|
name: account.display_name,
|
|
1953
1952
|
email: emailMethod == null ? void 0 : emailMethod.identifier,
|
|
1954
1953
|
type: account.account_type,
|
|
1954
|
+
roles: account.roles,
|
|
1955
1955
|
isActive: account.is_active,
|
|
1956
1956
|
isVerified: account.is_verified,
|
|
1957
|
-
lastLogin: account.last_login
|
|
1957
|
+
lastLogin: account.last_login,
|
|
1958
1958
|
hasPersonLinked: false
|
|
1959
1959
|
};
|
|
1960
1960
|
}
|
|
@@ -2112,20 +2112,20 @@ function useAuth() {
|
|
|
2112
2112
|
const api = authApi;
|
|
2113
2113
|
const emitter = eventEmitter;
|
|
2114
2114
|
const authMethods = {
|
|
2115
|
-
initiateSSO: async (params) => {
|
|
2116
|
-
const { data } = await api.initiateSSO(params);
|
|
2115
|
+
initiateSSO: async (provider, params) => {
|
|
2116
|
+
const { data } = await api.initiateSSO(provider, params);
|
|
2117
2117
|
return data.authorization_url;
|
|
2118
2118
|
},
|
|
2119
|
-
loginWithSSO: async (params) => {
|
|
2120
|
-
const { data } = await api.ssoCallback(params);
|
|
2119
|
+
loginWithSSO: async (provider, params) => {
|
|
2120
|
+
const { data } = await api.ssoCallback(provider, params);
|
|
2121
2121
|
if (data.success === true && data.requires_verification !== true) {
|
|
2122
2122
|
await checkAuth();
|
|
2123
2123
|
}
|
|
2124
2124
|
emitter.emit(AuthState.LOGIN);
|
|
2125
2125
|
return data;
|
|
2126
2126
|
},
|
|
2127
|
-
linkSSOProvider: async (params) => {
|
|
2128
|
-
await api.linkSSOProvider(params);
|
|
2127
|
+
linkSSOProvider: async (provider, params) => {
|
|
2128
|
+
await api.linkSSOProvider(provider, params);
|
|
2129
2129
|
await checkAuth();
|
|
2130
2130
|
},
|
|
2131
2131
|
unlinkSSOProvider: async (provider) => {
|
|
@@ -2169,10 +2169,7 @@ function useAuth() {
|
|
|
2169
2169
|
emitter.emit(AuthState.LOGOUT);
|
|
2170
2170
|
}
|
|
2171
2171
|
async function login(credentials) {
|
|
2172
|
-
const { data } = await api.login(
|
|
2173
|
-
credentials.email.toLowerCase(),
|
|
2174
|
-
credentials.password
|
|
2175
|
-
);
|
|
2172
|
+
const { data } = await api.login(credentials);
|
|
2176
2173
|
if (data.success === true && data.requires_verification !== true) {
|
|
2177
2174
|
await checkAuth();
|
|
2178
2175
|
}
|
|
@@ -2255,7 +2252,7 @@ function useAuth() {
|
|
|
2255
2252
|
return data;
|
|
2256
2253
|
}
|
|
2257
2254
|
async function forgotPassword(email) {
|
|
2258
|
-
await api.forgotPassword(email);
|
|
2255
|
+
await api.forgotPassword({ email });
|
|
2259
2256
|
}
|
|
2260
2257
|
async function verifyResetToken(token) {
|
|
2261
2258
|
await api.verifyResetToken(token);
|
|
@@ -2279,15 +2276,6 @@ function useAuth() {
|
|
|
2279
2276
|
accountInfo.value = data;
|
|
2280
2277
|
emitter.emit(AuthState.PROFILE_UPDATE);
|
|
2281
2278
|
}
|
|
2282
|
-
async function activateAccount(accountId) {
|
|
2283
|
-
await api.activateAccount(accountId);
|
|
2284
|
-
}
|
|
2285
|
-
async function deactivateAccount(accountId) {
|
|
2286
|
-
await api.deactivateAccount(accountId);
|
|
2287
|
-
}
|
|
2288
|
-
async function deleteAccount(accountId) {
|
|
2289
|
-
await api.deleteAccount(accountId);
|
|
2290
|
-
}
|
|
2291
2279
|
async function deleteCurrentUser() {
|
|
2292
2280
|
await api.deleteCurrentUser();
|
|
2293
2281
|
accountInfo.value = null;
|
|
@@ -2296,7 +2284,7 @@ function useAuth() {
|
|
|
2296
2284
|
await api.sendVerification({ email });
|
|
2297
2285
|
}
|
|
2298
2286
|
async function verifyEmail(token) {
|
|
2299
|
-
await api.verifyEmail(token);
|
|
2287
|
+
await api.verifyEmail({ token });
|
|
2300
2288
|
await checkAuth();
|
|
2301
2289
|
emitter.emit(AuthState.EMAIL_VERIFIED);
|
|
2302
2290
|
}
|
|
@@ -2304,39 +2292,29 @@ function useAuth() {
|
|
|
2304
2292
|
await api.refreshSession();
|
|
2305
2293
|
emitter.emit(AuthState.SESSION_REFRESH);
|
|
2306
2294
|
}
|
|
2307
|
-
async function getSessions(
|
|
2308
|
-
|
|
2309
|
-
const id = accountId ?? ((_a = user.value) == null ? void 0 : _a.accountId);
|
|
2310
|
-
if (id === void 0 || id === "") {
|
|
2311
|
-
throw new Error("No account ID available");
|
|
2312
|
-
}
|
|
2313
|
-
return api.getSessions(id);
|
|
2295
|
+
async function getSessions() {
|
|
2296
|
+
return api.getSessions();
|
|
2314
2297
|
}
|
|
2315
2298
|
async function revokeSession(sessionToken) {
|
|
2316
2299
|
await api.revokeSession(sessionToken);
|
|
2317
2300
|
}
|
|
2318
|
-
async function revokeAllSessions(
|
|
2319
|
-
|
|
2320
|
-
const id = accountId ?? ((_a = user.value) == null ? void 0 : _a.accountId);
|
|
2321
|
-
if (id === void 0 || id === "") {
|
|
2322
|
-
throw new Error("No account ID available");
|
|
2323
|
-
}
|
|
2324
|
-
await api.revokeAllSessions(id);
|
|
2301
|
+
async function revokeAllSessions() {
|
|
2302
|
+
await api.revokeAllSessions();
|
|
2325
2303
|
}
|
|
2326
|
-
async function initiateSSO(params) {
|
|
2327
|
-
const { data } = await api.initiateSSO(params);
|
|
2304
|
+
async function initiateSSO(provider, params) {
|
|
2305
|
+
const { data } = await api.initiateSSO(provider, params);
|
|
2328
2306
|
return data.authorization_url;
|
|
2329
2307
|
}
|
|
2330
|
-
async function loginWithSSO(params) {
|
|
2331
|
-
const { data } = await api.ssoCallback(params);
|
|
2308
|
+
async function loginWithSSO(provider, params) {
|
|
2309
|
+
const { data } = await api.ssoCallback(provider, params);
|
|
2332
2310
|
if (data.success === true && data.requires_verification !== true) {
|
|
2333
2311
|
await checkAuth();
|
|
2334
2312
|
}
|
|
2335
2313
|
emitter.emit(AuthState.LOGIN);
|
|
2336
2314
|
return data;
|
|
2337
2315
|
}
|
|
2338
|
-
async function linkSSOProvider(params) {
|
|
2339
|
-
await api.linkSSOProvider(params);
|
|
2316
|
+
async function linkSSOProvider(provider, params) {
|
|
2317
|
+
await api.linkSSOProvider(provider, params);
|
|
2340
2318
|
await checkAuth();
|
|
2341
2319
|
}
|
|
2342
2320
|
async function unlinkSSOProvider(provider) {
|
|
@@ -2384,10 +2362,6 @@ function useAuth() {
|
|
|
2384
2362
|
// Email Verification Actions
|
|
2385
2363
|
sendVerification,
|
|
2386
2364
|
verifyEmail,
|
|
2387
|
-
// Admin Actions
|
|
2388
|
-
activateAccount,
|
|
2389
|
-
deactivateAccount,
|
|
2390
|
-
deleteAccount,
|
|
2391
2365
|
// Session Management
|
|
2392
2366
|
getSessions,
|
|
2393
2367
|
revokeSession,
|