@stackframe/stack 2.5.16 → 2.5.18
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 +19 -0
- package/dist/components/credential-sign-in.js +6 -1
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/elements/user-avatar.d.mts +1 -0
- package/dist/components/elements/user-avatar.d.ts +1 -0
- package/dist/components/message-cards/predefined-message-card.d.mts +1 -1
- package/dist/components/message-cards/predefined-message-card.d.ts +1 -1
- package/dist/components/message-cards/predefined-message-card.js +8 -0
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/selected-team-switcher.d.mts +1 -0
- package/dist/components/selected-team-switcher.d.ts +1 -0
- package/dist/components-page/account-settings.js +110 -16
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.d.mts +1 -0
- package/dist/components-page/auth-page.d.ts +1 -0
- package/dist/components-page/auth-page.js +4 -1
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/forgot-password.d.mts +4 -1
- package/dist/components-page/forgot-password.d.ts +4 -1
- package/dist/components-page/forgot-password.js +55 -7
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/password-reset.d.mts +6 -2
- package/dist/components-page/password-reset.d.ts +6 -2
- package/dist/components-page/password-reset.js +100 -8
- package/dist/components-page/password-reset.js.map +1 -1
- package/dist/components-page/stack-handler.d.mts +1 -0
- package/dist/components-page/stack-handler.d.ts +1 -0
- package/dist/components-page/stack-handler.js +12 -6
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-invitation.d.mts +8 -0
- package/dist/components-page/team-invitation.d.ts +8 -0
- package/dist/components-page/team-invitation.js +141 -0
- package/dist/components-page/team-invitation.js.map +1 -0
- package/dist/esm/components/credential-sign-in.js +6 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/message-cards/predefined-message-card.js +8 -0
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +90 -6
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js +4 -1
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js +52 -5
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/password-reset.js +101 -9
- package/dist/esm/components-page/password-reset.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +12 -6
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-invitation.js +107 -0
- package/dist/esm/components-page/team-invitation.js.map +1 -0
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/auth.js +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app.js +115 -12
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/generated/global-css.d.mts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/lib/auth.js +1 -1
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/hooks.d.mts +1 -0
- package/dist/lib/hooks.d.ts +1 -0
- package/dist/lib/stack-app.d.mts +29 -0
- package/dist/lib/stack-app.d.ts +29 -0
- package/dist/lib/stack-app.js +115 -12
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/stack-provider-client.d.mts +1 -0
- package/dist/providers/stack-provider-client.d.ts +1 -0
- package/dist/providers/stack-provider.d.mts +1 -0
- package/dist/providers/stack-provider.d.ts +1 -0
- package/package.json +7 -4
- package/dist/components/forgot-password-form.d.mts +0 -7
- package/dist/components/forgot-password-form.d.ts +0 -7
- package/dist/components/forgot-password-form.js +0 -83
- package/dist/components/forgot-password-form.js.map +0 -1
- package/dist/components/password-reset-form.d.mts +0 -8
- package/dist/components/password-reset-form.d.ts +0 -8
- package/dist/components/password-reset-form.js +0 -135
- package/dist/components/password-reset-form.js.map +0 -1
- package/dist/esm/components/forgot-password-form.js +0 -59
- package/dist/esm/components/forgot-password-form.js.map +0 -1
- package/dist/esm/components/password-reset-form.js +0 -105
- package/dist/esm/components/password-reset-form.js.map +0 -1
package/dist/lib/stack-app.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { TeamPermissionDefinitionsCrud } from '@stackframe/stack-shared/dist/int
|
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
8
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
9
9
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
10
|
+
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
10
11
|
|
|
11
12
|
type RequestLike = {
|
|
12
13
|
headers: {
|
|
@@ -32,6 +33,7 @@ type HandlerUrls = {
|
|
|
32
33
|
oauthCallback: string;
|
|
33
34
|
magicLinkCallback: string;
|
|
34
35
|
accountSettings: string;
|
|
36
|
+
teamInvitation: string;
|
|
35
37
|
error: string;
|
|
36
38
|
};
|
|
37
39
|
type OAuthScopesOnSignIn = {
|
|
@@ -193,9 +195,13 @@ type BaseUser = {
|
|
|
193
195
|
* Whether the user has a password set.
|
|
194
196
|
*/
|
|
195
197
|
readonly hasPassword: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated
|
|
200
|
+
*/
|
|
196
201
|
readonly oauthProviders: readonly {
|
|
197
202
|
id: string;
|
|
198
203
|
}[];
|
|
204
|
+
readonly isMultiFactorRequired: boolean;
|
|
199
205
|
/**
|
|
200
206
|
* A shorthand method to update multiple fields of the user at once.
|
|
201
207
|
*/
|
|
@@ -250,6 +256,7 @@ type UserUpdateOptions = {
|
|
|
250
256
|
displayName?: string;
|
|
251
257
|
clientMetadata?: ReadonlyJson;
|
|
252
258
|
selectedTeamId?: string | null;
|
|
259
|
+
totpMultiFactorSecret?: Uint8Array | null;
|
|
253
260
|
};
|
|
254
261
|
type ServerBaseUser = {
|
|
255
262
|
setPrimaryEmail(email: string, options?: {
|
|
@@ -291,8 +298,15 @@ type ServerUserUpdateOptions = {
|
|
|
291
298
|
serverMetadata?: ReadonlyJson;
|
|
292
299
|
password?: string;
|
|
293
300
|
} & UserUpdateOptions;
|
|
301
|
+
type ServerUserCreateOptions = {
|
|
302
|
+
primaryEmail: string;
|
|
303
|
+
password: string;
|
|
304
|
+
displayName?: string;
|
|
305
|
+
primaryEmailVerified?: boolean;
|
|
306
|
+
};
|
|
294
307
|
type Project = {
|
|
295
308
|
readonly id: string;
|
|
309
|
+
readonly displayName: string;
|
|
296
310
|
readonly config: ProjectConfig;
|
|
297
311
|
};
|
|
298
312
|
type AdminProject = {
|
|
@@ -320,6 +334,7 @@ type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'>
|
|
|
320
334
|
displayName: string;
|
|
321
335
|
};
|
|
322
336
|
type ProjectConfig = {
|
|
337
|
+
readonly signUpEnabled: boolean;
|
|
323
338
|
readonly credentialEnabled: boolean;
|
|
324
339
|
readonly magicLinkEnabled: boolean;
|
|
325
340
|
readonly oauthProviders: OAuthProviderConfig[];
|
|
@@ -328,6 +343,7 @@ type OAuthProviderConfig = {
|
|
|
328
343
|
readonly id: string;
|
|
329
344
|
};
|
|
330
345
|
type AdminProjectConfig = {
|
|
346
|
+
readonly signUpEnabled: boolean;
|
|
331
347
|
readonly credentialEnabled: boolean;
|
|
332
348
|
readonly magicLinkEnabled: boolean;
|
|
333
349
|
readonly allowLocalhost: boolean;
|
|
@@ -370,6 +386,7 @@ type AdminProjectConfigUpdateOptions = {
|
|
|
370
386
|
handlerPath: string;
|
|
371
387
|
}[];
|
|
372
388
|
oauthProviders?: AdminOAuthProviderConfig[];
|
|
389
|
+
signUpEnabled?: boolean;
|
|
373
390
|
credentialEnabled?: boolean;
|
|
374
391
|
magicLinkEnabled?: boolean;
|
|
375
392
|
allowLocalhost?: boolean;
|
|
@@ -420,6 +437,9 @@ type Team = {
|
|
|
420
437
|
id: string;
|
|
421
438
|
displayName: string;
|
|
422
439
|
profileImageUrl: string | null;
|
|
440
|
+
inviteUser(options: {
|
|
441
|
+
email: string;
|
|
442
|
+
}): Promise<Result<undefined, KnownErrors["TeamPermissionRequired"]>>;
|
|
423
443
|
};
|
|
424
444
|
type TeamCreateOptions = {
|
|
425
445
|
displayName: string;
|
|
@@ -432,6 +452,9 @@ type ServerTeam = {
|
|
|
432
452
|
update(update: ServerTeamUpdateOptions): Promise<void>;
|
|
433
453
|
delete(): Promise<void>;
|
|
434
454
|
addUser(userId: string): Promise<void>;
|
|
455
|
+
inviteUser(options: {
|
|
456
|
+
email: string;
|
|
457
|
+
}): Promise<Result<undefined, KnownErrors["TeamPermissionRequired"]>>;
|
|
435
458
|
removeUser(userId: string): Promise<void>;
|
|
436
459
|
} & Team;
|
|
437
460
|
type ServerTeamCreateOptions = TeamCreateOptions;
|
|
@@ -500,6 +523,11 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
500
523
|
password: string;
|
|
501
524
|
}): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
502
525
|
verifyPasswordResetCode(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
526
|
+
verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
527
|
+
acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
528
|
+
getTeamInvitationDetails(code: string): Promise<Result<{
|
|
529
|
+
teamDisplayName: string;
|
|
530
|
+
}, KnownErrors["VerificationCodeError"]>>;
|
|
503
531
|
verifyEmail(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
504
532
|
signInWithMagicLink(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
505
533
|
redirectToOAuthCallback(): Promise<void>;
|
|
@@ -535,6 +563,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
535
563
|
* @deprecated use `getUser()` instead
|
|
536
564
|
*/
|
|
537
565
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
566
|
+
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
538
567
|
useUser(options: GetUserOptions<HasTokenStore> & {
|
|
539
568
|
or: 'redirect';
|
|
540
569
|
}): ProjectCurrentServerUser<ProjectId>;
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { TeamPermissionDefinitionsCrud } from '@stackframe/stack-shared/dist/int
|
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
8
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
9
9
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
10
|
+
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
10
11
|
|
|
11
12
|
type RequestLike = {
|
|
12
13
|
headers: {
|
|
@@ -32,6 +33,7 @@ type HandlerUrls = {
|
|
|
32
33
|
oauthCallback: string;
|
|
33
34
|
magicLinkCallback: string;
|
|
34
35
|
accountSettings: string;
|
|
36
|
+
teamInvitation: string;
|
|
35
37
|
error: string;
|
|
36
38
|
};
|
|
37
39
|
type OAuthScopesOnSignIn = {
|
|
@@ -193,9 +195,13 @@ type BaseUser = {
|
|
|
193
195
|
* Whether the user has a password set.
|
|
194
196
|
*/
|
|
195
197
|
readonly hasPassword: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated
|
|
200
|
+
*/
|
|
196
201
|
readonly oauthProviders: readonly {
|
|
197
202
|
id: string;
|
|
198
203
|
}[];
|
|
204
|
+
readonly isMultiFactorRequired: boolean;
|
|
199
205
|
/**
|
|
200
206
|
* A shorthand method to update multiple fields of the user at once.
|
|
201
207
|
*/
|
|
@@ -250,6 +256,7 @@ type UserUpdateOptions = {
|
|
|
250
256
|
displayName?: string;
|
|
251
257
|
clientMetadata?: ReadonlyJson;
|
|
252
258
|
selectedTeamId?: string | null;
|
|
259
|
+
totpMultiFactorSecret?: Uint8Array | null;
|
|
253
260
|
};
|
|
254
261
|
type ServerBaseUser = {
|
|
255
262
|
setPrimaryEmail(email: string, options?: {
|
|
@@ -291,8 +298,15 @@ type ServerUserUpdateOptions = {
|
|
|
291
298
|
serverMetadata?: ReadonlyJson;
|
|
292
299
|
password?: string;
|
|
293
300
|
} & UserUpdateOptions;
|
|
301
|
+
type ServerUserCreateOptions = {
|
|
302
|
+
primaryEmail: string;
|
|
303
|
+
password: string;
|
|
304
|
+
displayName?: string;
|
|
305
|
+
primaryEmailVerified?: boolean;
|
|
306
|
+
};
|
|
294
307
|
type Project = {
|
|
295
308
|
readonly id: string;
|
|
309
|
+
readonly displayName: string;
|
|
296
310
|
readonly config: ProjectConfig;
|
|
297
311
|
};
|
|
298
312
|
type AdminProject = {
|
|
@@ -320,6 +334,7 @@ type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'>
|
|
|
320
334
|
displayName: string;
|
|
321
335
|
};
|
|
322
336
|
type ProjectConfig = {
|
|
337
|
+
readonly signUpEnabled: boolean;
|
|
323
338
|
readonly credentialEnabled: boolean;
|
|
324
339
|
readonly magicLinkEnabled: boolean;
|
|
325
340
|
readonly oauthProviders: OAuthProviderConfig[];
|
|
@@ -328,6 +343,7 @@ type OAuthProviderConfig = {
|
|
|
328
343
|
readonly id: string;
|
|
329
344
|
};
|
|
330
345
|
type AdminProjectConfig = {
|
|
346
|
+
readonly signUpEnabled: boolean;
|
|
331
347
|
readonly credentialEnabled: boolean;
|
|
332
348
|
readonly magicLinkEnabled: boolean;
|
|
333
349
|
readonly allowLocalhost: boolean;
|
|
@@ -370,6 +386,7 @@ type AdminProjectConfigUpdateOptions = {
|
|
|
370
386
|
handlerPath: string;
|
|
371
387
|
}[];
|
|
372
388
|
oauthProviders?: AdminOAuthProviderConfig[];
|
|
389
|
+
signUpEnabled?: boolean;
|
|
373
390
|
credentialEnabled?: boolean;
|
|
374
391
|
magicLinkEnabled?: boolean;
|
|
375
392
|
allowLocalhost?: boolean;
|
|
@@ -420,6 +437,9 @@ type Team = {
|
|
|
420
437
|
id: string;
|
|
421
438
|
displayName: string;
|
|
422
439
|
profileImageUrl: string | null;
|
|
440
|
+
inviteUser(options: {
|
|
441
|
+
email: string;
|
|
442
|
+
}): Promise<Result<undefined, KnownErrors["TeamPermissionRequired"]>>;
|
|
423
443
|
};
|
|
424
444
|
type TeamCreateOptions = {
|
|
425
445
|
displayName: string;
|
|
@@ -432,6 +452,9 @@ type ServerTeam = {
|
|
|
432
452
|
update(update: ServerTeamUpdateOptions): Promise<void>;
|
|
433
453
|
delete(): Promise<void>;
|
|
434
454
|
addUser(userId: string): Promise<void>;
|
|
455
|
+
inviteUser(options: {
|
|
456
|
+
email: string;
|
|
457
|
+
}): Promise<Result<undefined, KnownErrors["TeamPermissionRequired"]>>;
|
|
435
458
|
removeUser(userId: string): Promise<void>;
|
|
436
459
|
} & Team;
|
|
437
460
|
type ServerTeamCreateOptions = TeamCreateOptions;
|
|
@@ -500,6 +523,11 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
500
523
|
password: string;
|
|
501
524
|
}): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
502
525
|
verifyPasswordResetCode(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
526
|
+
verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
527
|
+
acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
528
|
+
getTeamInvitationDetails(code: string): Promise<Result<{
|
|
529
|
+
teamDisplayName: string;
|
|
530
|
+
}, KnownErrors["VerificationCodeError"]>>;
|
|
503
531
|
verifyEmail(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
504
532
|
signInWithMagicLink(code: string): Promise<KnownErrors["VerificationCodeError"] | void>;
|
|
505
533
|
redirectToOAuthCallback(): Promise<void>;
|
|
@@ -535,6 +563,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
535
563
|
* @deprecated use `getUser()` instead
|
|
536
564
|
*/
|
|
537
565
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
566
|
+
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
538
567
|
useUser(options: GetUserOptions<HasTokenStore> & {
|
|
539
568
|
or: 'redirect';
|
|
540
569
|
}): ProjectCurrentServerUser<ProjectId>;
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -42,6 +42,7 @@ var import_stack_sc = require("@stackframe/stack-sc");
|
|
|
42
42
|
var import_stack_shared = require("@stackframe/stack-shared");
|
|
43
43
|
var import_production_mode = require("@stackframe/stack-shared/dist/helpers/production-mode");
|
|
44
44
|
var import_sessions = require("@stackframe/stack-shared/dist/sessions");
|
|
45
|
+
var import_bytes = require("@stackframe/stack-shared/dist/utils/bytes");
|
|
45
46
|
var import_caches = require("@stackframe/stack-shared/dist/utils/caches");
|
|
46
47
|
var import_compile_time = require("@stackframe/stack-shared/dist/utils/compile-time");
|
|
47
48
|
var import_env = require("@stackframe/stack-shared/dist/utils/env");
|
|
@@ -62,7 +63,7 @@ var import_url = require("../utils/url");
|
|
|
62
63
|
var import_auth = require("./auth");
|
|
63
64
|
var import_cookie = require("./cookie");
|
|
64
65
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
65
|
-
var clientVersion = "js @stackframe/stack@2.5.
|
|
66
|
+
var clientVersion = "js @stackframe/stack@2.5.18";
|
|
66
67
|
function getUrls(partial) {
|
|
67
68
|
const handler = partial.handler ?? "/handler";
|
|
68
69
|
const home = partial.home ?? "/";
|
|
@@ -83,6 +84,7 @@ function getUrls(partial) {
|
|
|
83
84
|
home,
|
|
84
85
|
accountSettings: `${handler}/account-settings`,
|
|
85
86
|
error: `${handler}/error`,
|
|
87
|
+
teamInvitation: `${handler}/team-invitation`,
|
|
86
88
|
...(0, import_objects.filterUndefined)(partial)
|
|
87
89
|
};
|
|
88
90
|
}
|
|
@@ -517,7 +519,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
517
519
|
_clientProjectFromCrud(crud) {
|
|
518
520
|
return {
|
|
519
521
|
id: crud.id,
|
|
522
|
+
displayName: crud.display_name,
|
|
520
523
|
config: {
|
|
524
|
+
signUpEnabled: crud.config.sign_up_enabled,
|
|
521
525
|
credentialEnabled: crud.config.credential_enabled,
|
|
522
526
|
magicLinkEnabled: crud.config.magic_link_enabled,
|
|
523
527
|
oauthProviders: crud.config.enabled_oauth_providers.map((p) => ({
|
|
@@ -532,10 +536,19 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
532
536
|
};
|
|
533
537
|
}
|
|
534
538
|
_clientTeamFromCrud(crud) {
|
|
539
|
+
const app = this;
|
|
535
540
|
return {
|
|
536
541
|
id: crud.id,
|
|
537
542
|
displayName: crud.display_name,
|
|
538
|
-
profileImageUrl: crud.profile_image_url
|
|
543
|
+
profileImageUrl: crud.profile_image_url,
|
|
544
|
+
async inviteUser(options) {
|
|
545
|
+
return await app._interface.sendTeamInvitation({
|
|
546
|
+
teamId: crud.id,
|
|
547
|
+
email: options.email,
|
|
548
|
+
session: app._getSession(),
|
|
549
|
+
callbackUrl: (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
|
|
550
|
+
});
|
|
551
|
+
}
|
|
539
552
|
};
|
|
540
553
|
}
|
|
541
554
|
_createAuth(session) {
|
|
@@ -581,6 +594,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
581
594
|
emailAuthEnabled: crud.auth_with_email,
|
|
582
595
|
oauthProviders: crud.oauth_providers,
|
|
583
596
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team),
|
|
597
|
+
isMultiFactorRequired: crud.requires_totp_mfa,
|
|
584
598
|
toClientJson() {
|
|
585
599
|
return crud;
|
|
586
600
|
}
|
|
@@ -652,17 +666,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
652
666
|
async hasPermission(scope, permissionId) {
|
|
653
667
|
return await this.getPermission(scope, permissionId) !== null;
|
|
654
668
|
},
|
|
655
|
-
update(update) {
|
|
656
|
-
return app._updateClientUser(update, session);
|
|
669
|
+
async update(update) {
|
|
670
|
+
return await app._updateClientUser(update, session);
|
|
657
671
|
},
|
|
658
|
-
sendVerificationEmail() {
|
|
672
|
+
async sendVerificationEmail() {
|
|
659
673
|
if (!crud?.primary_email) {
|
|
660
674
|
throw new import_errors.StackAssertionError("User does not have a primary email");
|
|
661
675
|
}
|
|
662
|
-
return app._sendVerificationEmail(crud.primary_email, session);
|
|
676
|
+
return await app._sendVerificationEmail(crud.primary_email, session);
|
|
663
677
|
},
|
|
664
|
-
updatePassword(options) {
|
|
665
|
-
return app._updatePassword(options, session);
|
|
678
|
+
async updatePassword(options) {
|
|
679
|
+
return await app._updatePassword(options, session);
|
|
666
680
|
}
|
|
667
681
|
};
|
|
668
682
|
}
|
|
@@ -796,6 +810,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
796
810
|
async redirectToError(options) {
|
|
797
811
|
return await this._redirectToHandler("error", options);
|
|
798
812
|
}
|
|
813
|
+
async redirectToTeamInvitation(options) {
|
|
814
|
+
return await this._redirectToHandler("teamInvitation", options);
|
|
815
|
+
}
|
|
799
816
|
async sendForgotPasswordEmail(email) {
|
|
800
817
|
const redirectUrl = (0, import_url.constructRedirectUrl)(this.urls.passwordReset);
|
|
801
818
|
const error = await this._interface.sendForgotPasswordEmail(email, redirectUrl);
|
|
@@ -813,6 +830,42 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
813
830
|
async verifyPasswordResetCode(code) {
|
|
814
831
|
return await this._interface.verifyPasswordResetCode(code);
|
|
815
832
|
}
|
|
833
|
+
async verifyTeamInvitationCode(code) {
|
|
834
|
+
const result = await this._interface.acceptTeamInvitation({
|
|
835
|
+
type: "check",
|
|
836
|
+
code,
|
|
837
|
+
session: this._getSession()
|
|
838
|
+
});
|
|
839
|
+
if (result.status === "ok") {
|
|
840
|
+
return import_results.Result.ok(void 0);
|
|
841
|
+
} else {
|
|
842
|
+
return import_results.Result.error(result.error);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
async acceptTeamInvitation(code) {
|
|
846
|
+
const result = await this._interface.acceptTeamInvitation({
|
|
847
|
+
type: "use",
|
|
848
|
+
code,
|
|
849
|
+
session: this._getSession()
|
|
850
|
+
});
|
|
851
|
+
if (result.status === "ok") {
|
|
852
|
+
return import_results.Result.ok(void 0);
|
|
853
|
+
} else {
|
|
854
|
+
return import_results.Result.error(result.error);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async getTeamInvitationDetails(code) {
|
|
858
|
+
const result = await this._interface.acceptTeamInvitation({
|
|
859
|
+
type: "details",
|
|
860
|
+
code,
|
|
861
|
+
session: this._getSession()
|
|
862
|
+
});
|
|
863
|
+
if (result.status === "ok") {
|
|
864
|
+
return import_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
865
|
+
} else {
|
|
866
|
+
return import_results.Result.error(result.error);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
816
869
|
async verifyEmail(code) {
|
|
817
870
|
return await this._interface.verifyEmail(code);
|
|
818
871
|
}
|
|
@@ -880,7 +933,31 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
880
933
|
async signInWithCredential(options) {
|
|
881
934
|
this._ensurePersistentTokenStore();
|
|
882
935
|
const session = this._getSession();
|
|
883
|
-
|
|
936
|
+
let result;
|
|
937
|
+
try {
|
|
938
|
+
result = await this._interface.signInWithCredential(options.email, options.password, session);
|
|
939
|
+
} catch (e) {
|
|
940
|
+
if (options.__experimental_mfa && e instanceof import_stack_shared.KnownErrors.MultiFactorAuthenticationRequired) {
|
|
941
|
+
const otp = prompt("Please enter the six-digit TOTP code from your authenticator app.");
|
|
942
|
+
try {
|
|
943
|
+
if (!otp) {
|
|
944
|
+
throw new import_stack_shared.KnownErrors.InvalidTotpCode();
|
|
945
|
+
}
|
|
946
|
+
result = await this._interface.totpMfa(
|
|
947
|
+
e.details?.attempt_code ?? (0, import_errors.throwErr)("attempt code missing"),
|
|
948
|
+
otp,
|
|
949
|
+
session
|
|
950
|
+
);
|
|
951
|
+
} catch (e2) {
|
|
952
|
+
if (e2 instanceof import_stack_shared.KnownErrors.InvalidTotpCode) {
|
|
953
|
+
return e2;
|
|
954
|
+
}
|
|
955
|
+
throw e2;
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
throw e;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
884
961
|
if (!(result instanceof import_stack_shared.KnownError)) {
|
|
885
962
|
await this._signInToAccountWithTokens(result);
|
|
886
963
|
return await this.redirectToAfterSignIn({ replace: true });
|
|
@@ -1079,7 +1156,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1079
1156
|
return await this._interface.listServerTeamUsers(teamId);
|
|
1080
1157
|
});
|
|
1081
1158
|
this._serverTeamUserPermissionsCache = createCache(async ([teamId, userId, recursive]) => {
|
|
1082
|
-
return await this._interface.
|
|
1159
|
+
return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);
|
|
1083
1160
|
});
|
|
1084
1161
|
this._serverUserOAuthConnectionAccessTokensCache = createCache(
|
|
1085
1162
|
async ([userId, providerId, scope]) => {
|
|
@@ -1268,9 +1345,22 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1268
1345
|
userId
|
|
1269
1346
|
});
|
|
1270
1347
|
await app._serverTeamUsersCache.refresh([crud.id]);
|
|
1348
|
+
},
|
|
1349
|
+
async inviteUser(options) {
|
|
1350
|
+
return await app._interface.sendTeamInvitation({
|
|
1351
|
+
teamId: crud.id,
|
|
1352
|
+
email: options.email,
|
|
1353
|
+
session: null,
|
|
1354
|
+
callbackUrl: (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
|
|
1355
|
+
});
|
|
1271
1356
|
}
|
|
1272
1357
|
};
|
|
1273
1358
|
}
|
|
1359
|
+
async createUser(options) {
|
|
1360
|
+
const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));
|
|
1361
|
+
await this._refreshUsers();
|
|
1362
|
+
return this._serverUserFromCrud(crud);
|
|
1363
|
+
}
|
|
1274
1364
|
async getUser(options) {
|
|
1275
1365
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1276
1366
|
const session = this._getSession(options?.tokenStore);
|
|
@@ -1448,6 +1538,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1448
1538
|
isProductionMode: data.is_production_mode,
|
|
1449
1539
|
config: {
|
|
1450
1540
|
id: data.config.id,
|
|
1541
|
+
signUpEnabled: data.config.sign_up_enabled,
|
|
1451
1542
|
credentialEnabled: data.config.credential_enabled,
|
|
1452
1543
|
magicLinkEnabled: data.config.magic_link_enabled,
|
|
1453
1544
|
allowLocalhost: data.config.allow_localhost,
|
|
@@ -1628,7 +1719,8 @@ function userUpdateOptionsToCrud(options) {
|
|
|
1628
1719
|
return {
|
|
1629
1720
|
display_name: options.displayName,
|
|
1630
1721
|
client_metadata: options.clientMetadata,
|
|
1631
|
-
selected_team_id: options.selectedTeamId
|
|
1722
|
+
selected_team_id: options.selectedTeamId,
|
|
1723
|
+
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret
|
|
1632
1724
|
};
|
|
1633
1725
|
}
|
|
1634
1726
|
function serverUserUpdateOptionsToCrud(options) {
|
|
@@ -1640,7 +1732,17 @@ function serverUserUpdateOptionsToCrud(options) {
|
|
|
1640
1732
|
selected_team_id: options.selectedTeamId,
|
|
1641
1733
|
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
1642
1734
|
primary_email_verified: options.primaryEmailVerified,
|
|
1643
|
-
password: options.password
|
|
1735
|
+
password: options.password,
|
|
1736
|
+
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
function serverUserCreateOptionsToCrud(options) {
|
|
1740
|
+
return {
|
|
1741
|
+
primary_email: options.primaryEmail,
|
|
1742
|
+
password: options.password,
|
|
1743
|
+
primary_email_auth_enabled: true,
|
|
1744
|
+
display_name: options.displayName,
|
|
1745
|
+
primary_email_verified: options.primaryEmailVerified
|
|
1644
1746
|
};
|
|
1645
1747
|
}
|
|
1646
1748
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
@@ -1674,6 +1776,7 @@ function adminProjectUpdateOptionsToCrud(options) {
|
|
|
1674
1776
|
sender_name: options.config.emailConfig.senderName,
|
|
1675
1777
|
sender_email: options.config.emailConfig.senderEmail
|
|
1676
1778
|
}),
|
|
1779
|
+
sign_up_enabled: options.config?.signUpEnabled,
|
|
1677
1780
|
credential_enabled: options.config?.credentialEnabled,
|
|
1678
1781
|
magic_link_enabled: options.config?.magicLinkEnabled,
|
|
1679
1782
|
allow_localhost: options.config?.allowLocalhost,
|