@stackframe/react 2.7.26 → 2.7.28
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 +20 -0
- package/dist/components/oauth-button-group.js +9 -1
- package/dist/components/oauth-button-group.js.map +1 -1
- package/dist/components/oauth-button.js +3 -2
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components-page/account-settings.js +131 -0
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.js +123 -0
- package/dist/components-page/cli-auth-confirm.js.map +1 -0
- package/dist/components-page/forgot-password.js +1 -1
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/stack-handler.js +11 -0
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components/oauth-button-group.js +9 -1
- package/dist/esm/components/oauth-button-group.js.map +1 -1
- package/dist/esm/components/oauth-button.js +3 -2
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +132 -1
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.js +99 -0
- package/dist/esm/components-page/cli-auth-confirm.js.map +1 -0
- package/dist/esm/components-page/forgot-password.js +1 -1
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +11 -0
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +14 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +23 -2
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +5 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +26 -5
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/contact-channels/index.js +5 -2
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -1
- package/dist/esm/lib/stack-app/email/index.js +1 -0
- package/dist/esm/lib/stack-app/email/index.js.map +1 -0
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +14 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +22 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +6 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +26 -5
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/connected-accounts/index.js.map +1 -1
- package/dist/lib/stack-app/contact-channels/index.js +5 -2
- package/dist/lib/stack-app/contact-channels/index.js.map +1 -1
- package/dist/lib/stack-app/email/index.js +19 -0
- package/dist/lib/stack-app/email/index.js.map +1 -0
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/
|
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
8
|
import { ApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/api-keys';
|
|
9
9
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
10
|
+
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
10
11
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
12
|
import { icons } from 'lucide-react';
|
|
12
13
|
import React$1 from 'react';
|
|
@@ -106,6 +107,15 @@ type ApiKeyCreateOptions = {
|
|
|
106
107
|
hasSuperSecretAdminKey: boolean;
|
|
107
108
|
};
|
|
108
109
|
|
|
110
|
+
type AdminSentEmail = {
|
|
111
|
+
id: string;
|
|
112
|
+
to: string[];
|
|
113
|
+
subject: string;
|
|
114
|
+
recipient: string;
|
|
115
|
+
sentAt: Date;
|
|
116
|
+
error?: unknown;
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
type AdminEmailTemplate = {
|
|
110
120
|
type: EmailTemplateType;
|
|
111
121
|
subject: string;
|
|
@@ -160,6 +170,7 @@ type ContactChannelCreateOptions = {
|
|
|
160
170
|
value: string;
|
|
161
171
|
type: 'email';
|
|
162
172
|
usedForAuth: boolean;
|
|
173
|
+
isPrimary?: boolean;
|
|
163
174
|
};
|
|
164
175
|
type ContactChannelUpdateOptions = {
|
|
165
176
|
usedForAuth?: boolean;
|
|
@@ -362,6 +373,8 @@ type UserExtra = {
|
|
|
362
373
|
setSelectedTeam(team: Team | null): Promise<void>;
|
|
363
374
|
createTeam(data: TeamCreateOptions): Promise<Team>;
|
|
364
375
|
leaveTeam(team: Team): Promise<void>;
|
|
376
|
+
getActiveSessions(): Promise<ActiveSession[]>;
|
|
377
|
+
revokeSession(sessionId: string): Promise<void>;
|
|
365
378
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
366
379
|
useTeamProfile(team: Team): EditableTeamMemberProfile;
|
|
367
380
|
} & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
@@ -378,6 +391,15 @@ type User = BaseUser;
|
|
|
378
391
|
type CurrentUser = BaseUser & Auth & UserExtra;
|
|
379
392
|
type CurrentInternalUser = CurrentUser & InternalUserExtra;
|
|
380
393
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
394
|
+
type ActiveSession = {
|
|
395
|
+
id: string;
|
|
396
|
+
userId: string;
|
|
397
|
+
createdAt: Date;
|
|
398
|
+
isImpersonation: boolean;
|
|
399
|
+
lastUsedAt: Date | undefined;
|
|
400
|
+
isCurrentSession: boolean;
|
|
401
|
+
geoInfo?: GeoInfo;
|
|
402
|
+
};
|
|
381
403
|
type UserUpdateOptions = {
|
|
382
404
|
displayName?: string;
|
|
383
405
|
clientMetadata?: ReadonlyJson;
|
|
@@ -407,6 +429,7 @@ type ServerBaseUser = {
|
|
|
407
429
|
*/
|
|
408
430
|
createSession(options?: {
|
|
409
431
|
expiresInMillis?: number;
|
|
432
|
+
isImpersonation?: boolean;
|
|
410
433
|
}): Promise<Session>;
|
|
411
434
|
} & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
412
435
|
direct?: boolean;
|
|
@@ -549,6 +572,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
549
572
|
or: 'throw';
|
|
550
573
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
551
574
|
getUser(options?: GetUserOptions$1<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
575
|
+
getUser(id: string): Promise<ServerUser | null>;
|
|
552
576
|
useUsers(options?: ServerListUsersOptions): ServerUser[] & {
|
|
553
577
|
nextCursor: string | null;
|
|
554
578
|
};
|
|
@@ -583,6 +607,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
583
607
|
}): Promise<Result<undefined, {
|
|
584
608
|
errorMessage: string;
|
|
585
609
|
}>>;
|
|
610
|
+
listSentEmails(): Promise<AdminSentEmail[]>;
|
|
586
611
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
587
612
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
588
613
|
|
|
@@ -702,6 +727,7 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
702
727
|
browser: string;
|
|
703
728
|
server: string;
|
|
704
729
|
};
|
|
730
|
+
extraRequestHeaders?: Record<string, string>;
|
|
705
731
|
projectId?: ProjectId;
|
|
706
732
|
publishableClientKey?: string;
|
|
707
733
|
urls?: Partial<HandlerUrls>;
|
|
@@ -800,6 +826,10 @@ declare function AccountSettings(props: {
|
|
|
800
826
|
}))[];
|
|
801
827
|
}): react_jsx_runtime.JSX.Element;
|
|
802
828
|
|
|
829
|
+
declare function CliAuthConfirmation({ fullPage }: {
|
|
830
|
+
fullPage?: boolean;
|
|
831
|
+
}): react_jsx_runtime.JSX.Element;
|
|
832
|
+
|
|
803
833
|
declare function EmailVerification(props: {
|
|
804
834
|
searchParams?: Record<string, string>;
|
|
805
835
|
fullPage?: boolean;
|
|
@@ -849,6 +879,7 @@ type Components = {
|
|
|
849
879
|
TeamInvitation: typeof TeamInvitation;
|
|
850
880
|
ErrorPage: typeof ErrorPage;
|
|
851
881
|
AccountSettings: typeof AccountSettings;
|
|
882
|
+
CliAuthConfirmation: typeof CliAuthConfirmation;
|
|
852
883
|
};
|
|
853
884
|
type BaseHandlerProps = {
|
|
854
885
|
fullPage: boolean;
|
|
@@ -1010,9 +1041,10 @@ declare function MessageCard({ fullPage, ...props }: {
|
|
|
1010
1041
|
secondaryAction?: () => Promise<void> | void;
|
|
1011
1042
|
}): react_jsx_runtime.JSX.Element;
|
|
1012
1043
|
|
|
1013
|
-
declare function OAuthButton({ provider, type, }: {
|
|
1044
|
+
declare function OAuthButton({ provider, type, isMock, }: {
|
|
1014
1045
|
provider: string;
|
|
1015
1046
|
type: 'sign-in' | 'sign-up';
|
|
1047
|
+
isMock?: boolean;
|
|
1016
1048
|
}): react_jsx_runtime.JSX.Element;
|
|
1017
1049
|
|
|
1018
1050
|
declare function OAuthButtonGroup({ type, mockProject, }: {
|
|
@@ -1044,4 +1076,4 @@ type UserButtonProps = {
|
|
|
1044
1076
|
};
|
|
1045
1077
|
declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
|
|
1046
1078
|
|
|
1047
|
-
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Auth, AuthPage, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, ReactStackHandler as StackHandler, ReactStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
|
|
1079
|
+
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Auth, AuthPage, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, ReactStackHandler as StackHandler, ReactStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/
|
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
8
|
import { ApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/api-keys';
|
|
9
9
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
10
|
+
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
10
11
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
12
|
import { icons } from 'lucide-react';
|
|
12
13
|
import React$1 from 'react';
|
|
@@ -106,6 +107,15 @@ type ApiKeyCreateOptions = {
|
|
|
106
107
|
hasSuperSecretAdminKey: boolean;
|
|
107
108
|
};
|
|
108
109
|
|
|
110
|
+
type AdminSentEmail = {
|
|
111
|
+
id: string;
|
|
112
|
+
to: string[];
|
|
113
|
+
subject: string;
|
|
114
|
+
recipient: string;
|
|
115
|
+
sentAt: Date;
|
|
116
|
+
error?: unknown;
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
type AdminEmailTemplate = {
|
|
110
120
|
type: EmailTemplateType;
|
|
111
121
|
subject: string;
|
|
@@ -160,6 +170,7 @@ type ContactChannelCreateOptions = {
|
|
|
160
170
|
value: string;
|
|
161
171
|
type: 'email';
|
|
162
172
|
usedForAuth: boolean;
|
|
173
|
+
isPrimary?: boolean;
|
|
163
174
|
};
|
|
164
175
|
type ContactChannelUpdateOptions = {
|
|
165
176
|
usedForAuth?: boolean;
|
|
@@ -362,6 +373,8 @@ type UserExtra = {
|
|
|
362
373
|
setSelectedTeam(team: Team | null): Promise<void>;
|
|
363
374
|
createTeam(data: TeamCreateOptions): Promise<Team>;
|
|
364
375
|
leaveTeam(team: Team): Promise<void>;
|
|
376
|
+
getActiveSessions(): Promise<ActiveSession[]>;
|
|
377
|
+
revokeSession(sessionId: string): Promise<void>;
|
|
365
378
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
366
379
|
useTeamProfile(team: Team): EditableTeamMemberProfile;
|
|
367
380
|
} & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
@@ -378,6 +391,15 @@ type User = BaseUser;
|
|
|
378
391
|
type CurrentUser = BaseUser & Auth & UserExtra;
|
|
379
392
|
type CurrentInternalUser = CurrentUser & InternalUserExtra;
|
|
380
393
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
394
|
+
type ActiveSession = {
|
|
395
|
+
id: string;
|
|
396
|
+
userId: string;
|
|
397
|
+
createdAt: Date;
|
|
398
|
+
isImpersonation: boolean;
|
|
399
|
+
lastUsedAt: Date | undefined;
|
|
400
|
+
isCurrentSession: boolean;
|
|
401
|
+
geoInfo?: GeoInfo;
|
|
402
|
+
};
|
|
381
403
|
type UserUpdateOptions = {
|
|
382
404
|
displayName?: string;
|
|
383
405
|
clientMetadata?: ReadonlyJson;
|
|
@@ -407,6 +429,7 @@ type ServerBaseUser = {
|
|
|
407
429
|
*/
|
|
408
430
|
createSession(options?: {
|
|
409
431
|
expiresInMillis?: number;
|
|
432
|
+
isImpersonation?: boolean;
|
|
410
433
|
}): Promise<Session>;
|
|
411
434
|
} & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
412
435
|
direct?: boolean;
|
|
@@ -549,6 +572,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
549
572
|
or: 'throw';
|
|
550
573
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
551
574
|
getUser(options?: GetUserOptions$1<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
575
|
+
getUser(id: string): Promise<ServerUser | null>;
|
|
552
576
|
useUsers(options?: ServerListUsersOptions): ServerUser[] & {
|
|
553
577
|
nextCursor: string | null;
|
|
554
578
|
};
|
|
@@ -583,6 +607,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
583
607
|
}): Promise<Result<undefined, {
|
|
584
608
|
errorMessage: string;
|
|
585
609
|
}>>;
|
|
610
|
+
listSentEmails(): Promise<AdminSentEmail[]>;
|
|
586
611
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
587
612
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
588
613
|
|
|
@@ -702,6 +727,7 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
702
727
|
browser: string;
|
|
703
728
|
server: string;
|
|
704
729
|
};
|
|
730
|
+
extraRequestHeaders?: Record<string, string>;
|
|
705
731
|
projectId?: ProjectId;
|
|
706
732
|
publishableClientKey?: string;
|
|
707
733
|
urls?: Partial<HandlerUrls>;
|
|
@@ -800,6 +826,10 @@ declare function AccountSettings(props: {
|
|
|
800
826
|
}))[];
|
|
801
827
|
}): react_jsx_runtime.JSX.Element;
|
|
802
828
|
|
|
829
|
+
declare function CliAuthConfirmation({ fullPage }: {
|
|
830
|
+
fullPage?: boolean;
|
|
831
|
+
}): react_jsx_runtime.JSX.Element;
|
|
832
|
+
|
|
803
833
|
declare function EmailVerification(props: {
|
|
804
834
|
searchParams?: Record<string, string>;
|
|
805
835
|
fullPage?: boolean;
|
|
@@ -849,6 +879,7 @@ type Components = {
|
|
|
849
879
|
TeamInvitation: typeof TeamInvitation;
|
|
850
880
|
ErrorPage: typeof ErrorPage;
|
|
851
881
|
AccountSettings: typeof AccountSettings;
|
|
882
|
+
CliAuthConfirmation: typeof CliAuthConfirmation;
|
|
852
883
|
};
|
|
853
884
|
type BaseHandlerProps = {
|
|
854
885
|
fullPage: boolean;
|
|
@@ -1010,9 +1041,10 @@ declare function MessageCard({ fullPage, ...props }: {
|
|
|
1010
1041
|
secondaryAction?: () => Promise<void> | void;
|
|
1011
1042
|
}): react_jsx_runtime.JSX.Element;
|
|
1012
1043
|
|
|
1013
|
-
declare function OAuthButton({ provider, type, }: {
|
|
1044
|
+
declare function OAuthButton({ provider, type, isMock, }: {
|
|
1014
1045
|
provider: string;
|
|
1015
1046
|
type: 'sign-in' | 'sign-up';
|
|
1047
|
+
isMock?: boolean;
|
|
1016
1048
|
}): react_jsx_runtime.JSX.Element;
|
|
1017
1049
|
|
|
1018
1050
|
declare function OAuthButtonGroup({ type, mockProject, }: {
|
|
@@ -1044,4 +1076,4 @@ type UserButtonProps = {
|
|
|
1044
1076
|
};
|
|
1045
1077
|
declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
|
|
1046
1078
|
|
|
1047
|
-
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Auth, AuthPage, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, ReactStackHandler as StackHandler, ReactStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
|
|
1079
|
+
export { AccountSettings, type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Auth, AuthPage, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, ReactStackHandler as StackHandler, ReactStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
|
|
@@ -35,14 +35,15 @@ var import_email_templates = require("../../email-templates");
|
|
|
35
35
|
var import_permissions = require("../../permissions");
|
|
36
36
|
var import_projects = require("../../projects");
|
|
37
37
|
var import_common2 = require("./common");
|
|
38
|
-
var import_common3 = require("./common");
|
|
39
38
|
var import_server_app_impl = require("./server-app-impl");
|
|
39
|
+
var import_common3 = require("./common");
|
|
40
40
|
var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackServerAppImplIncomplete {
|
|
41
41
|
constructor(options) {
|
|
42
42
|
super({
|
|
43
43
|
interface: new import_stack_shared.StackAdminInterface({
|
|
44
44
|
getBaseUrl: () => (0, import_common2.getBaseUrl)(options.baseUrl),
|
|
45
45
|
projectId: options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
46
|
+
extraRequestHeaders: options.extraRequestHeaders ?? {},
|
|
46
47
|
clientVersion: import_common2.clientVersion,
|
|
47
48
|
..."projectOwnerSession" in options ? {
|
|
48
49
|
projectOwnerSession: options.projectOwnerSession
|
|
@@ -53,6 +54,7 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
53
54
|
}
|
|
54
55
|
}),
|
|
55
56
|
baseUrl: options.baseUrl,
|
|
57
|
+
extraRequestHeaders: options.extraRequestHeaders,
|
|
56
58
|
projectId: options.projectId,
|
|
57
59
|
tokenStore: options.tokenStore,
|
|
58
60
|
urls: options.urls,
|
|
@@ -309,6 +311,17 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
309
311
|
return import_results.Result.error({ errorMessage: response.error_message ?? (0, import_errors.throwErr)("Email test error not specified") });
|
|
310
312
|
}
|
|
311
313
|
}
|
|
314
|
+
async listSentEmails() {
|
|
315
|
+
const response = await this._interface.listSentEmails();
|
|
316
|
+
return response.items.map((email) => ({
|
|
317
|
+
id: email.id,
|
|
318
|
+
to: email.to ?? [],
|
|
319
|
+
subject: email.subject,
|
|
320
|
+
recipient: email.to?.[0] ?? "",
|
|
321
|
+
sentAt: new Date(email.sent_at_millis),
|
|
322
|
+
error: email.error
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
312
325
|
};
|
|
313
326
|
// Annotate the CommonJS export names for ESM import in node:
|
|
314
327
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/lib/stack-app/apps/implementations/admin-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAdminInterface } from \"@stackframe/stack-shared\";\nimport { getProductionModeErrors } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { ApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/adminInterface\";\nimport { ApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/api-keys\";\nimport { EmailTemplateCrud, EmailTemplateType } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { pick } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\";\nimport { ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, apiKeyCreateOptionsToCrud } from \"../../api-keys\";\nimport { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate, AdminEmailTemplateUpdateOptions, adminEmailTemplateUpdateOptionsToCrud } from \"../../email-templates\";\nimport { AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminTeamPermissionDefinitionCreateOptionsToCrud, adminTeamPermissionDefinitionUpdateOptionsToCrud } from \"../../permissions\";\nimport { AdminOwnedProject, AdminProject, AdminProjectUpdateOptions, adminProjectUpdateOptionsToCrud } from \"../../projects\";\nimport { StackAdminApp, StackAdminAppConstructorOptions } from \"../interfaces/admin-app\";\nimport { clientVersion, createCache, getBaseUrl, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, getDefaultSuperSecretAdminKey } from \"./common\";\nimport { useAsyncCache } from \"./common\";\nimport { _StackServerAppImplIncomplete } from \"./server-app-impl\";\n\n\nexport class _StackAdminAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackServerAppImplIncomplete<HasTokenStore, ProjectId>\n{\n declare protected _interface: StackAdminInterface;\n\n private readonly _adminProjectCache = createCache(async () => {\n return await this._interface.getProject();\n });\n private readonly _apiKeysCache = createCache(async () => {\n return await this._interface.listApiKeys();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listEmailTemplates();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listPermissionDefinitions();\n });\n private readonly _svixTokenCache = createCache(async () => {\n return await this._interface.getSvixToken();\n });\n private readonly _metricsCache = createCache(async () => {\n return await this._interface.getMetrics();\n });\n\n constructor(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>) {\n super({\n interface: new StackAdminInterface({\n getBaseUrl: () => getBaseUrl(options.baseUrl),\n projectId: options.projectId ?? getDefaultProjectId(),\n clientVersion,\n ...\"projectOwnerSession\" in options ? {\n projectOwnerSession: options.projectOwnerSession,\n } : {\n publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),\n superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey(),\n },\n }),\n baseUrl: options.baseUrl,\n projectId: options.projectId,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n redirectMethod: options.redirectMethod,\n });\n }\n\n _adminOwnedProjectFromCrud(data: InternalProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminOwnedProject {\n if (this._tokenStoreInit !== null) {\n throw new StackAssertionError(\"Owned apps must always have tokenStore === null — did you not create this project with app._createOwnedApp()?\");;\n }\n return {\n ...this._adminProjectFromCrud(data, onRefresh),\n app: this as StackAdminApp<false>,\n };\n }\n\n _adminProjectFromCrud(data: InternalProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminProject {\n if (data.id !== this.projectId) {\n throw new StackAssertionError(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${this.projectId})!`);\n }\n\n const app = this;\n return {\n id: data.id,\n displayName: data.display_name,\n description: data.description,\n createdAt: new Date(data.created_at_millis),\n userCount: data.user_count,\n isProductionMode: data.is_production_mode,\n config: {\n id: data.config.id,\n signUpEnabled: data.config.sign_up_enabled,\n credentialEnabled: data.config.credential_enabled,\n magicLinkEnabled: data.config.magic_link_enabled,\n passkeyEnabled: data.config.passkey_enabled,\n clientTeamCreationEnabled: data.config.client_team_creation_enabled,\n clientUserDeletionEnabled: data.config.client_user_deletion_enabled,\n allowLocalhost: data.config.allow_localhost,\n oauthAccountMergeStrategy: data.config.oauth_account_merge_strategy,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n enabled: p.enabled,\n type: 'shared',\n } as const : {\n id: p.id,\n enabled: p.enabled,\n type: 'standard',\n clientId: p.client_id ?? throwErr(\"Client ID is missing\"),\n clientSecret: p.client_secret ?? throwErr(\"Client secret is missing\"),\n facebookConfigId: p.facebook_config_id,\n microsoftTenantId: p.microsoft_tenant_id,\n } as const))),\n emailConfig: data.config.email_config.type === 'shared' ? {\n type: 'shared'\n } : {\n type: 'standard',\n host: data.config.email_config.host ?? throwErr(\"Email host is missing\"),\n port: data.config.email_config.port ?? throwErr(\"Email port is missing\"),\n username: data.config.email_config.username ?? throwErr(\"Email username is missing\"),\n password: data.config.email_config.password ?? throwErr(\"Email password is missing\"),\n senderName: data.config.email_config.sender_name ?? throwErr(\"Email sender name is missing\"),\n senderEmail: data.config.email_config.sender_email ?? throwErr(\"Email sender email is missing\"),\n },\n domains: data.config.domains.map((d) => ({\n domain: d.domain,\n handlerPath: d.handler_path,\n })),\n createTeamOnSignUp: data.config.create_team_on_sign_up,\n teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,\n teamMemberDefaultPermissions: data.config.team_member_default_permissions,\n },\n\n async update(update: AdminProjectUpdateOptions) {\n await app._interface.updateProject(adminProjectUpdateOptionsToCrud(update));\n await onRefresh();\n },\n async delete() {\n await app._interface.deleteProject();\n },\n async getProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n useProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n };\n }\n\n _adminEmailTemplateFromCrud(data: EmailTemplateCrud['Admin']['Read']): AdminEmailTemplate {\n return {\n type: data.type,\n subject: data.subject,\n content: data.content,\n isDefault: data.is_default,\n };\n }\n\n override async getProject(): Promise<AdminProject> {\n return this._adminProjectFromCrud(\n Result.orThrow(await this._adminProjectCache.getOrWait([], \"write-only\")),\n () => this._refreshProject()\n );\n }\n\n override useProject(): AdminProject {\n const crud = useAsyncCache(this._adminProjectCache, [], \"useProjectAdmin()\");\n return useMemo(() => this._adminProjectFromCrud(\n crud,\n () => this._refreshProject()\n ), [crud]);\n }\n\n protected _createApiKeyBaseFromCrud(data: ApiKeyBaseCrudRead): ApiKeyBase {\n const app = this;\n return {\n id: data.id,\n description: data.description,\n expiresAt: new Date(data.expires_at_millis),\n manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,\n createdAt: new Date(data.created_at_millis),\n isValid() {\n return this.whyInvalid() === null;\n },\n whyInvalid() {\n if (this.expiresAt.getTime() < Date.now()) return \"expired\";\n if (this.manuallyRevokedAt) return \"manually-revoked\";\n return null;\n },\n async revoke() {\n const res = await app._interface.revokeApiKeyById(data.id);\n await app._refreshApiKeys();\n return res;\n }\n };\n }\n\n protected _createApiKeyFromCrud(data: ApiKeysCrud[\"Admin\"][\"Read\"]): ApiKey {\n return {\n ...this._createApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,\n secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,\n superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null,\n };\n }\n\n protected _createApiKeyFirstViewFromCrud(data: ApiKeyCreateCrudResponse): ApiKeyFirstView {\n return {\n ...this._createApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key,\n secretServerKey: data.secret_server_key,\n superSecretAdminKey: data.super_secret_admin_key,\n };\n }\n\n async listApiKeys(): Promise<ApiKey[]> {\n const crud = Result.orThrow(await this._apiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createApiKeyFromCrud(j));\n }\n\n useApiKeys(): ApiKey[] {\n const crud = useAsyncCache(this._apiKeysCache, [], \"useApiKeys()\");\n return useMemo(() => {\n return crud.map((j) => this._createApiKeyFromCrud(j));\n }, [crud]);\n }\n\n async createApiKey(options: ApiKeyCreateOptions): Promise<ApiKeyFirstView> {\n const crud = await this._interface.createApiKey(apiKeyCreateOptionsToCrud(options));\n await this._refreshApiKeys();\n return this._createApiKeyFirstViewFromCrud(crud);\n }\n\n useEmailTemplates(): AdminEmailTemplate[] {\n const crud = useAsyncCache(this._adminEmailTemplatesCache, [], \"useEmailTemplates()\");\n return useMemo(() => {\n return crud.map((j) => this._adminEmailTemplateFromCrud(j));\n }, [crud]);\n }\n async listEmailTemplates(): Promise<AdminEmailTemplate[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._adminEmailTemplateFromCrud(j));\n }\n\n async updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void> {\n await this._interface.updateEmailTemplate(type, adminEmailTemplateUpdateOptionsToCrud(data));\n await this._adminEmailTemplatesCache.refresh([]);\n }\n\n async resetEmailTemplate(type: EmailTemplateType) {\n await this._interface.resetEmailTemplate(type);\n await this._adminEmailTemplatesCache.refresh([]);\n }\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>{\n const crud = await this._interface.createPermissionDefinition(adminTeamPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n return this._serverTeamPermissionDefinitionFromCrud(crud);\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions) {\n await this._interface.updatePermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deletePermissionDefinition(permissionId);\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async listTeamPermissionDefinitions(): Promise<AdminTeamPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }\n\n useTeamPermissionDefinitions(): AdminTeamPermissionDefinition[] {\n const crud = useAsyncCache(this._adminTeamPermissionDefinitionsCache, [], \"usePermissions()\");\n return useMemo(() => {\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }, [crud]);\n }\n useSvixToken(): string {\n const crud = useAsyncCache(this._svixTokenCache, [], \"useSvixToken()\");\n return crud.token;\n }\n\n protected override async _refreshProject() {\n await Promise.all([\n super._refreshProject(),\n this._adminProjectCache.refresh([]),\n ]);\n }\n\n protected async _refreshApiKeys() {\n await this._apiKeysCache.refresh([]);\n }\n\n get [stackAppInternalsSymbol]() {\n return {\n ...super[stackAppInternalsSymbol],\n useMetrics: (): any => {\n return useAsyncCache(this._metricsCache, [], \"useMetrics()\");\n }\n };\n }\n\n async sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestEmail({\n recipient_email: options.recipientEmail,\n email_config: {\n ...(pick(options.emailConfig, ['host', 'port', 'username', 'password'])),\n sender_email: options.emailConfig.senderEmail,\n sender_name: options.emailConfig.senderName,\n },\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Email test error not specified\") });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAoC;AACpC,6BAAwC;AAKxC,oBAA8C;AAC9C,qBAAqB;AACrB,qBAAuB;AACvB,mBAAwB;AACxB,sBAAwH;AACxH,oBAAqD;AACrD,6BAA2G;AAC3G,yBAA+P;AAC/P,sBAA4G;AAE5G,IAAAA,iBAAsK;AACtK,IAAAA,iBAA8B;AAC9B,6BAA8C;AAGvC,IAAM,+BAAN,cAAoG,qDAC3G;AAAA,EAsBE,YAAY,SAAoE;AAC9E,UAAM;AAAA,MACJ,WAAW,IAAI,wCAAoB;AAAA,QACjC,YAAY,UAAM,2BAAW,QAAQ,OAAO;AAAA,QAC5C,WAAW,QAAQ,iBAAa,oCAAoB;AAAA,QACpD;AAAA,QACA,GAAG,yBAAyB,UAAU;AAAA,UACpC,qBAAqB,QAAQ;AAAA,QAC/B,IAAI;AAAA,UACF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C,YAAY,MAAW;AACrB,mBAAO,8BAAc,KAAK,eAAe,CAAC,GAAG,cAAc;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,SAGqC;AACvD,UAAM,WAAW,MAAM,KAAK,WAAW,cAAc;AAAA,MACnD,iBAAiB,QAAQ;AAAA,MACzB,cAAc;AAAA,QACZ,OAAI,qBAAK,QAAQ,aAAa,CAAC,QAAQ,QAAQ,YAAY,UAAU,CAAC;AAAA,QACtE,cAAc,QAAQ,YAAY;AAAA,QAClC,aAAa,QAAQ,YAAY;AAAA,MACnC;AAAA,IACF,CAAC;AAED,QAAI,SAAS,SAAS;AACpB,aAAO,sBAAO,GAAG,MAAS;AAAA,IAC5B,OAAO;AACL,aAAO,sBAAO,MAAM,EAAE,cAAc,SAAS,qBAAiB,wBAAS,gCAAgC,EAAE,CAAC;AAAA,IAC5G;AAAA,EACF;AACF;","names":["import_common"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/lib/stack-app/apps/implementations/admin-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAdminInterface } from \"@stackframe/stack-shared\";\nimport { getProductionModeErrors } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { ApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/adminInterface\";\nimport { ApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/api-keys\";\nimport { EmailTemplateCrud, EmailTemplateType } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { pick } from \"@stackframe/stack-shared/dist/utils/objects\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport { AdminSentEmail } from \"../..\";\nimport { ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, apiKeyCreateOptionsToCrud } from \"../../api-keys\";\nimport { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate, AdminEmailTemplateUpdateOptions, adminEmailTemplateUpdateOptionsToCrud } from \"../../email-templates\";\nimport { AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminTeamPermissionDefinitionCreateOptionsToCrud, adminTeamPermissionDefinitionUpdateOptionsToCrud } from \"../../permissions\";\nimport { AdminOwnedProject, AdminProject, AdminProjectUpdateOptions, adminProjectUpdateOptionsToCrud } from \"../../projects\";\nimport { StackAdminApp, StackAdminAppConstructorOptions } from \"../interfaces/admin-app\";\nimport { clientVersion, createCache, getBaseUrl, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, getDefaultSuperSecretAdminKey } from \"./common\";\nimport { _StackServerAppImplIncomplete } from \"./server-app-impl\";\n\nimport { useAsyncCache } from \"./common\";\n\nexport class _StackAdminAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackServerAppImplIncomplete<HasTokenStore, ProjectId> implements StackAdminApp<HasTokenStore, ProjectId>\n{\n declare protected _interface: StackAdminInterface;\n\n private readonly _adminProjectCache = createCache(async () => {\n return await this._interface.getProject();\n });\n private readonly _apiKeysCache = createCache(async () => {\n return await this._interface.listApiKeys();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listEmailTemplates();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listPermissionDefinitions();\n });\n private readonly _svixTokenCache = createCache(async () => {\n return await this._interface.getSvixToken();\n });\n private readonly _metricsCache = createCache(async () => {\n return await this._interface.getMetrics();\n });\n\n constructor(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>) {\n super({\n interface: new StackAdminInterface({\n getBaseUrl: () => getBaseUrl(options.baseUrl),\n projectId: options.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: options.extraRequestHeaders ?? {},\n clientVersion,\n ...\"projectOwnerSession\" in options ? {\n projectOwnerSession: options.projectOwnerSession,\n } : {\n publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),\n superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey(),\n },\n }),\n baseUrl: options.baseUrl,\n extraRequestHeaders: options.extraRequestHeaders,\n projectId: options.projectId,\n tokenStore: options.tokenStore,\n urls: options.urls,\n oauthScopesOnSignIn: options.oauthScopesOnSignIn,\n redirectMethod: options.redirectMethod,\n });\n }\n\n _adminOwnedProjectFromCrud(data: InternalProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminOwnedProject {\n if (this._tokenStoreInit !== null) {\n throw new StackAssertionError(\"Owned apps must always have tokenStore === null — did you not create this project with app._createOwnedApp()?\");;\n }\n return {\n ...this._adminProjectFromCrud(data, onRefresh),\n app: this as StackAdminApp<false>,\n };\n }\n\n _adminProjectFromCrud(data: InternalProjectsCrud['Admin']['Read'], onRefresh: () => Promise<void>): AdminProject {\n if (data.id !== this.projectId) {\n throw new StackAssertionError(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${this.projectId})!`);\n }\n\n const app = this;\n return {\n id: data.id,\n displayName: data.display_name,\n description: data.description,\n createdAt: new Date(data.created_at_millis),\n userCount: data.user_count,\n isProductionMode: data.is_production_mode,\n config: {\n id: data.config.id,\n signUpEnabled: data.config.sign_up_enabled,\n credentialEnabled: data.config.credential_enabled,\n magicLinkEnabled: data.config.magic_link_enabled,\n passkeyEnabled: data.config.passkey_enabled,\n clientTeamCreationEnabled: data.config.client_team_creation_enabled,\n clientUserDeletionEnabled: data.config.client_user_deletion_enabled,\n allowLocalhost: data.config.allow_localhost,\n oauthAccountMergeStrategy: data.config.oauth_account_merge_strategy,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n enabled: p.enabled,\n type: 'shared',\n } as const : {\n id: p.id,\n enabled: p.enabled,\n type: 'standard',\n clientId: p.client_id ?? throwErr(\"Client ID is missing\"),\n clientSecret: p.client_secret ?? throwErr(\"Client secret is missing\"),\n facebookConfigId: p.facebook_config_id,\n microsoftTenantId: p.microsoft_tenant_id,\n } as const))),\n emailConfig: data.config.email_config.type === 'shared' ? {\n type: 'shared'\n } : {\n type: 'standard',\n host: data.config.email_config.host ?? throwErr(\"Email host is missing\"),\n port: data.config.email_config.port ?? throwErr(\"Email port is missing\"),\n username: data.config.email_config.username ?? throwErr(\"Email username is missing\"),\n password: data.config.email_config.password ?? throwErr(\"Email password is missing\"),\n senderName: data.config.email_config.sender_name ?? throwErr(\"Email sender name is missing\"),\n senderEmail: data.config.email_config.sender_email ?? throwErr(\"Email sender email is missing\"),\n },\n domains: data.config.domains.map((d) => ({\n domain: d.domain,\n handlerPath: d.handler_path,\n })),\n createTeamOnSignUp: data.config.create_team_on_sign_up,\n teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,\n teamMemberDefaultPermissions: data.config.team_member_default_permissions,\n },\n\n async update(update: AdminProjectUpdateOptions) {\n await app._interface.updateProject(adminProjectUpdateOptionsToCrud(update));\n await onRefresh();\n },\n async delete() {\n await app._interface.deleteProject();\n },\n async getProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n useProductionModeErrors() {\n return getProductionModeErrors(data);\n },\n };\n }\n\n _adminEmailTemplateFromCrud(data: EmailTemplateCrud['Admin']['Read']): AdminEmailTemplate {\n return {\n type: data.type,\n subject: data.subject,\n content: data.content,\n isDefault: data.is_default,\n };\n }\n\n override async getProject(): Promise<AdminProject> {\n return this._adminProjectFromCrud(\n Result.orThrow(await this._adminProjectCache.getOrWait([], \"write-only\")),\n () => this._refreshProject()\n );\n }\n\n override useProject(): AdminProject {\n const crud = useAsyncCache(this._adminProjectCache, [], \"useProjectAdmin()\");\n return useMemo(() => this._adminProjectFromCrud(\n crud,\n () => this._refreshProject()\n ), [crud]);\n }\n\n protected _createApiKeyBaseFromCrud(data: ApiKeyBaseCrudRead): ApiKeyBase {\n const app = this;\n return {\n id: data.id,\n description: data.description,\n expiresAt: new Date(data.expires_at_millis),\n manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,\n createdAt: new Date(data.created_at_millis),\n isValid() {\n return this.whyInvalid() === null;\n },\n whyInvalid() {\n if (this.expiresAt.getTime() < Date.now()) return \"expired\";\n if (this.manuallyRevokedAt) return \"manually-revoked\";\n return null;\n },\n async revoke() {\n const res = await app._interface.revokeApiKeyById(data.id);\n await app._refreshApiKeys();\n return res;\n }\n };\n }\n\n protected _createApiKeyFromCrud(data: ApiKeysCrud[\"Admin\"][\"Read\"]): ApiKey {\n return {\n ...this._createApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,\n secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,\n superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null,\n };\n }\n\n protected _createApiKeyFirstViewFromCrud(data: ApiKeyCreateCrudResponse): ApiKeyFirstView {\n return {\n ...this._createApiKeyBaseFromCrud(data),\n publishableClientKey: data.publishable_client_key,\n secretServerKey: data.secret_server_key,\n superSecretAdminKey: data.super_secret_admin_key,\n };\n }\n\n async listApiKeys(): Promise<ApiKey[]> {\n const crud = Result.orThrow(await this._apiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createApiKeyFromCrud(j));\n }\n\n useApiKeys(): ApiKey[] {\n const crud = useAsyncCache(this._apiKeysCache, [], \"useApiKeys()\");\n return useMemo(() => {\n return crud.map((j) => this._createApiKeyFromCrud(j));\n }, [crud]);\n }\n\n async createApiKey(options: ApiKeyCreateOptions): Promise<ApiKeyFirstView> {\n const crud = await this._interface.createApiKey(apiKeyCreateOptionsToCrud(options));\n await this._refreshApiKeys();\n return this._createApiKeyFirstViewFromCrud(crud);\n }\n\n useEmailTemplates(): AdminEmailTemplate[] {\n const crud = useAsyncCache(this._adminEmailTemplatesCache, [], \"useEmailTemplates()\");\n return useMemo(() => {\n return crud.map((j) => this._adminEmailTemplateFromCrud(j));\n }, [crud]);\n }\n async listEmailTemplates(): Promise<AdminEmailTemplate[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._adminEmailTemplateFromCrud(j));\n }\n\n async updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void> {\n await this._interface.updateEmailTemplate(type, adminEmailTemplateUpdateOptionsToCrud(data));\n await this._adminEmailTemplatesCache.refresh([]);\n }\n\n async resetEmailTemplate(type: EmailTemplateType) {\n await this._interface.resetEmailTemplate(type);\n await this._adminEmailTemplatesCache.refresh([]);\n }\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>{\n const crud = await this._interface.createPermissionDefinition(adminTeamPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n return this._serverTeamPermissionDefinitionFromCrud(crud);\n }\n\n async updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions) {\n await this._interface.updatePermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deletePermissionDefinition(permissionId);\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async listTeamPermissionDefinitions(): Promise<AdminTeamPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }\n\n useTeamPermissionDefinitions(): AdminTeamPermissionDefinition[] {\n const crud = useAsyncCache(this._adminTeamPermissionDefinitionsCache, [], \"usePermissions()\");\n return useMemo(() => {\n return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));\n }, [crud]);\n }\n useSvixToken(): string {\n const crud = useAsyncCache(this._svixTokenCache, [], \"useSvixToken()\");\n return crud.token;\n }\n\n protected override async _refreshProject() {\n await Promise.all([\n super._refreshProject(),\n this._adminProjectCache.refresh([]),\n ]);\n }\n\n protected async _refreshApiKeys() {\n await this._apiKeysCache.refresh([]);\n }\n\n get [stackAppInternalsSymbol]() {\n return {\n ...super[stackAppInternalsSymbol],\n useMetrics: (): any => {\n return useAsyncCache(this._metricsCache, [], \"useMetrics()\");\n }\n };\n }\n\n async sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>> {\n const response = await this._interface.sendTestEmail({\n recipient_email: options.recipientEmail,\n email_config: {\n ...(pick(options.emailConfig, ['host', 'port', 'username', 'password'])),\n sender_email: options.emailConfig.senderEmail,\n sender_name: options.emailConfig.senderName,\n },\n });\n\n if (response.success) {\n return Result.ok(undefined);\n } else {\n return Result.error({ errorMessage: response.error_message ?? throwErr(\"Email test error not specified\") });\n }\n }\n\n async listSentEmails(): Promise<AdminSentEmail[]> {\n const response = await this._interface.listSentEmails();\n return response.items.map((email) => ({\n id: email.id,\n to: email.to ?? [],\n subject: email.subject,\n recipient: email.to?.[0] ?? \"\",\n sentAt: new Date(email.sent_at_millis),\n error: email.error,\n }));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAoC;AACpC,6BAAwC;AAKxC,oBAA8C;AAC9C,qBAAqB;AACrB,qBAAuB;AACvB,mBAAwB;AAExB,sBAAwH;AACxH,oBAAqD;AACrD,6BAA2G;AAC3G,yBAA+P;AAC/P,sBAA4G;AAE5G,IAAAA,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AI,KAAK,MAAM,cAAc;AAAA,MACrC,OAAO,MAAM;AAAA,IACf,EAAE;AAAA,EACJ;AACF;","names":["import_common"]}
|
|
@@ -156,6 +156,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
156
156
|
} else {
|
|
157
157
|
this._interface = new import_stack_shared.StackClientInterface({
|
|
158
158
|
getBaseUrl: () => (0, import_common2.getBaseUrl)(_options.baseUrl),
|
|
159
|
+
extraRequestHeaders: _options.extraRequestHeaders ?? (0, import_common2.getDefaultExtraRequestHeaders)(),
|
|
159
160
|
projectId: _options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
160
161
|
clientVersion: import_common2.clientVersion,
|
|
161
162
|
publishableClientKey: _options.publishableClientKey ?? (0, import_common2.getDefaultPublishableClientKey)(),
|
|
@@ -672,6 +673,13 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
672
673
|
return (0, import_common3.useAsyncCache)(app._currentUserOAuthConnectionCache, [session, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
673
674
|
}
|
|
674
675
|
return {
|
|
676
|
+
async getActiveSessions() {
|
|
677
|
+
const sessions = await app._interface.listSessions(session);
|
|
678
|
+
return sessions.items.map((crud2) => app._clientSessionFromCrud(crud2));
|
|
679
|
+
},
|
|
680
|
+
async revokeSession(sessionId) {
|
|
681
|
+
await app._interface.deleteSession(sessionId, session);
|
|
682
|
+
},
|
|
675
683
|
setDisplayName(displayName) {
|
|
676
684
|
return this.update({ displayName });
|
|
677
685
|
},
|
|
@@ -683,6 +691,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
683
691
|
},
|
|
684
692
|
getConnectedAccount,
|
|
685
693
|
useConnectedAccount,
|
|
694
|
+
// THIS_LINE_PLATFORM react-like
|
|
686
695
|
async getTeam(teamId) {
|
|
687
696
|
const teams = await this.listTeams();
|
|
688
697
|
return teams.find((t) => t.id === teamId) ?? null;
|
|
@@ -805,6 +814,17 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
805
814
|
Object.freeze(currentUser);
|
|
806
815
|
return currentUser;
|
|
807
816
|
}
|
|
817
|
+
_clientSessionFromCrud(crud) {
|
|
818
|
+
return {
|
|
819
|
+
id: crud.id,
|
|
820
|
+
userId: crud.user_id,
|
|
821
|
+
createdAt: new Date(crud.created_at),
|
|
822
|
+
isImpersonation: crud.is_impersonation,
|
|
823
|
+
lastUsedAt: crud.last_used_at ? new Date(crud.last_used_at) : void 0,
|
|
824
|
+
isCurrentSession: crud.is_current_session ?? false,
|
|
825
|
+
geoInfo: crud.last_used_at_end_user_ip_info
|
|
826
|
+
};
|
|
827
|
+
}
|
|
808
828
|
_getOwnedAdminApp(forProjectId, session) {
|
|
809
829
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
810
830
|
this._ownedAdminApps.set([session, forProjectId], new __StackClientAppImplIncomplete.LazyStackAdminAppImpl.value({
|
|
@@ -1327,7 +1347,8 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1327
1347
|
urls: this._urlOptions,
|
|
1328
1348
|
oauthScopesOnSignIn: this._oauthScopesOnSignIn,
|
|
1329
1349
|
uniqueIdentifier: this._getUniqueIdentifier(),
|
|
1330
|
-
redirectMethod: this._redirectMethod
|
|
1350
|
+
redirectMethod: this._redirectMethod,
|
|
1351
|
+
extraRequestHeaders: this._options.extraRequestHeaders
|
|
1331
1352
|
};
|
|
1332
1353
|
},
|
|
1333
1354
|
setCurrentUser: (userJsonPromise) => {
|