@stackframe/js 2.8.32 → 2.8.35
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 +30 -0
- package/dist/esm/lib/auth.js +3 -2
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +21 -8
- 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 +30 -9
- 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 +1 -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 +47 -19
- 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/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/index.d.mts +92 -46
- package/dist/index.d.ts +92 -46
- package/dist/lib/auth.js +3 -2
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +21 -8
- 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 +30 -9
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +47 -19
- 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/customers/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/lib/stack-app/projects/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProductionModeError } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { AdminUserProjectsCrud, ProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\n\nimport { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { StackAdminApp } from \"../apps/interfaces/admin-app\";\nimport { AdminProjectConfig, AdminProjectConfigUpdateOptions, ProjectConfig } from \"../project-configs\";\n\n\nexport type Project = {\n readonly id: string,\n readonly displayName: string,\n readonly config: ProjectConfig,\n};\n\nexport type AdminProject = {\n readonly id: string,\n readonly displayName: string,\n readonly description: string | null,\n readonly createdAt: Date,\n readonly isProductionMode: boolean,\n readonly ownerTeamId: string | null,\n readonly logoUrl: string | null | undefined,\n readonly fullLogoUrl: string | null | undefined,\n\n readonly config: AdminProjectConfig,\n\n update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>,\n delete(this: AdminProject): Promise<void>,\n\n getConfig(this: AdminProject): Promise<CompleteConfig>,\n updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>,\n\n getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>,\n} & Project;\n\nexport type AdminOwnedProject = {\n readonly app: StackAdminApp<false>,\n} & AdminProject;\n\nexport type AdminProjectUpdateOptions = {\n displayName?: string,\n description?: string,\n isProductionMode?: boolean,\n logoUrl?: string | null,\n fullLogoUrl?: string | null,\n config?: AdminProjectConfigUpdateOptions,\n};\nexport function adminProjectUpdateOptionsToCrud(options: AdminProjectUpdateOptions): ProjectsCrud[\"Admin\"][\"Update\"] {\n return {\n display_name: options.displayName,\n description: options.description,\n is_production_mode: options.isProductionMode,\n logo_url: options.logoUrl,\n full_logo_url: options.fullLogoUrl,\n config: {\n domains: options.config?.domains?.map((d) => ({\n domain: d.domain,\n handler_path: d.handlerPath\n })),\n oauth_providers: options.config?.oauthProviders?.map((p) => ({\n id: p.id as any,\n type: p.type,\n ...(p.type === 'standard' && {\n client_id: p.clientId,\n client_secret: p.clientSecret,\n facebook_config_id: p.facebookConfigId,\n microsoft_tenant_id: p.microsoftTenantId,\n }),\n })),\n email_config: options.config?.emailConfig && (\n options.config.emailConfig.type === 'shared' ? {\n type: 'shared',\n } : {\n type: 'standard',\n host: options.config.emailConfig.host,\n port: options.config.emailConfig.port,\n username: options.config.emailConfig.username,\n password: options.config.emailConfig.password,\n sender_name: options.config.emailConfig.senderName,\n sender_email: options.config.emailConfig.senderEmail,\n }\n ),\n email_theme: options.config?.emailTheme,\n sign_up_enabled: options.config?.signUpEnabled,\n credential_enabled: options.config?.credentialEnabled,\n magic_link_enabled: options.config?.magicLinkEnabled,\n passkey_enabled: options.config?.passkeyEnabled,\n allow_localhost: options.config?.allowLocalhost,\n create_team_on_sign_up: options.config?.createTeamOnSignUp,\n client_team_creation_enabled: options.config?.clientTeamCreationEnabled,\n client_user_deletion_enabled: options.config?.clientUserDeletionEnabled,\n team_creator_default_permissions: options.config?.teamCreatorDefaultPermissions,\n team_member_default_permissions: options.config?.teamMemberDefaultPermissions,\n user_default_permissions: options.config?.userDefaultPermissions,\n oauth_account_merge_strategy: options.config?.oauthAccountMergeStrategy,\n allow_user_api_keys: options.config?.allowUserApiKeys,\n allow_team_api_keys: options.config?.allowTeamApiKeys,\n },\n };\n}\n\nexport type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'> & {\n displayName: string,\n teamId: string,\n};\nexport function adminProjectCreateOptionsToCrud(options: AdminProjectCreateOptions): AdminUserProjectsCrud[\"Server\"][\"Create\"] {\n return {\n ...adminProjectUpdateOptionsToCrud(options),\n display_name: options.displayName,\n owner_team_id: options.teamId,\n };\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../../../src/lib/stack-app/projects/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProductionModeError } from \"@stackframe/stack-shared/dist/helpers/production-mode\";\nimport { AdminUserProjectsCrud, ProjectsCrud } from \"@stackframe/stack-shared/dist/interface/crud/projects\";\n\nimport { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { CurrentUser } from \"..\";\nimport { StackAdminApp } from \"../apps/interfaces/admin-app\";\nimport { AdminProjectConfig, AdminProjectConfigUpdateOptions, ProjectConfig } from \"../project-configs\";\n\n\nexport type Project = {\n readonly id: string,\n readonly displayName: string,\n readonly config: ProjectConfig,\n};\n\nexport type AdminProject = {\n readonly id: string,\n readonly displayName: string,\n readonly description: string | null,\n readonly createdAt: Date,\n readonly isProductionMode: boolean,\n readonly ownerTeamId: string | null,\n readonly logoUrl: string | null | undefined,\n readonly fullLogoUrl: string | null | undefined,\n\n readonly config: AdminProjectConfig,\n\n update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>,\n delete(this: AdminProject): Promise<void>,\n transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>,\n\n getConfig(this: AdminProject): Promise<CompleteConfig>,\n updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>,\n\n getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>,\n} & Project;\n\nexport type AdminOwnedProject = {\n readonly app: StackAdminApp<false>,\n} & AdminProject;\n\nexport type AdminProjectUpdateOptions = {\n displayName?: string,\n description?: string,\n isProductionMode?: boolean,\n logoUrl?: string | null,\n fullLogoUrl?: string | null,\n config?: AdminProjectConfigUpdateOptions,\n};\nexport function adminProjectUpdateOptionsToCrud(options: AdminProjectUpdateOptions): ProjectsCrud[\"Admin\"][\"Update\"] {\n return {\n display_name: options.displayName,\n description: options.description,\n is_production_mode: options.isProductionMode,\n logo_url: options.logoUrl,\n full_logo_url: options.fullLogoUrl,\n config: {\n domains: options.config?.domains?.map((d) => ({\n domain: d.domain,\n handler_path: d.handlerPath\n })),\n oauth_providers: options.config?.oauthProviders?.map((p) => ({\n id: p.id as any,\n type: p.type,\n ...(p.type === 'standard' && {\n client_id: p.clientId,\n client_secret: p.clientSecret,\n facebook_config_id: p.facebookConfigId,\n microsoft_tenant_id: p.microsoftTenantId,\n }),\n })),\n email_config: options.config?.emailConfig && (\n options.config.emailConfig.type === 'shared' ? {\n type: 'shared',\n } : {\n type: 'standard',\n host: options.config.emailConfig.host,\n port: options.config.emailConfig.port,\n username: options.config.emailConfig.username,\n password: options.config.emailConfig.password,\n sender_name: options.config.emailConfig.senderName,\n sender_email: options.config.emailConfig.senderEmail,\n }\n ),\n email_theme: options.config?.emailTheme,\n sign_up_enabled: options.config?.signUpEnabled,\n credential_enabled: options.config?.credentialEnabled,\n magic_link_enabled: options.config?.magicLinkEnabled,\n passkey_enabled: options.config?.passkeyEnabled,\n allow_localhost: options.config?.allowLocalhost,\n create_team_on_sign_up: options.config?.createTeamOnSignUp,\n client_team_creation_enabled: options.config?.clientTeamCreationEnabled,\n client_user_deletion_enabled: options.config?.clientUserDeletionEnabled,\n team_creator_default_permissions: options.config?.teamCreatorDefaultPermissions,\n team_member_default_permissions: options.config?.teamMemberDefaultPermissions,\n user_default_permissions: options.config?.userDefaultPermissions,\n oauth_account_merge_strategy: options.config?.oauthAccountMergeStrategy,\n allow_user_api_keys: options.config?.allowUserApiKeys,\n allow_team_api_keys: options.config?.allowTeamApiKeys,\n },\n };\n}\n\nexport type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'> & {\n displayName: string,\n teamId: string,\n};\nexport function adminProjectCreateOptionsToCrud(options: AdminProjectCreateOptions): AdminUserProjectsCrud[\"Server\"][\"Create\"] {\n return {\n ...adminProjectUpdateOptionsToCrud(options),\n display_name: options.displayName,\n owner_team_id: options.teamId,\n };\n}\n"],"mappings":";AAqDO,SAAS,gCAAgC,SAAqE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,aAAa,QAAQ;AAAA,IACrB,oBAAoB,QAAQ;AAAA,IAC5B,UAAU,QAAQ;AAAA,IAClB,eAAe,QAAQ;AAAA,IACvB,QAAQ;AAAA,MACN,SAAS,QAAQ,QAAQ,SAAS,IAAI,CAAC,OAAO;AAAA,QAC5C,QAAQ,EAAE;AAAA,QACV,cAAc,EAAE;AAAA,MAClB,EAAE;AAAA,MACF,iBAAiB,QAAQ,QAAQ,gBAAgB,IAAI,CAAC,OAAO;AAAA,QAC3D,IAAI,EAAE;AAAA,QACN,MAAM,EAAE;AAAA,QACR,GAAI,EAAE,SAAS,cAAc;AAAA,UAC3B,WAAW,EAAE;AAAA,UACb,eAAe,EAAE;AAAA,UACjB,oBAAoB,EAAE;AAAA,UACtB,qBAAqB,EAAE;AAAA,QACzB;AAAA,MACF,EAAE;AAAA,MACF,cAAc,QAAQ,QAAQ,gBAC5B,QAAQ,OAAO,YAAY,SAAS,WAAW;AAAA,QAC7C,MAAM;AAAA,MACR,IAAI;AAAA,QACF,MAAM;AAAA,QACN,MAAM,QAAQ,OAAO,YAAY;AAAA,QACjC,MAAM,QAAQ,OAAO,YAAY;AAAA,QACjC,UAAU,QAAQ,OAAO,YAAY;AAAA,QACrC,UAAU,QAAQ,OAAO,YAAY;AAAA,QACrC,aAAa,QAAQ,OAAO,YAAY;AAAA,QACxC,cAAc,QAAQ,OAAO,YAAY;AAAA,MAC3C;AAAA,MAEF,aAAa,QAAQ,QAAQ;AAAA,MAC7B,iBAAiB,QAAQ,QAAQ;AAAA,MACjC,oBAAoB,QAAQ,QAAQ;AAAA,MACpC,oBAAoB,QAAQ,QAAQ;AAAA,MACpC,iBAAiB,QAAQ,QAAQ;AAAA,MACjC,iBAAiB,QAAQ,QAAQ;AAAA,MACjC,wBAAwB,QAAQ,QAAQ;AAAA,MACxC,8BAA8B,QAAQ,QAAQ;AAAA,MAC9C,8BAA8B,QAAQ,QAAQ;AAAA,MAC9C,kCAAkC,QAAQ,QAAQ;AAAA,MAClD,iCAAiC,QAAQ,QAAQ;AAAA,MACjD,0BAA0B,QAAQ,QAAQ;AAAA,MAC1C,8BAA8B,QAAQ,QAAQ;AAAA,MAC9C,qBAAqB,QAAQ,QAAQ;AAAA,MACrC,qBAAqB,QAAQ,QAAQ;AAAA,IACvC;AAAA,EACF;AACF;AAMO,SAAS,gCAAgC,SAA+E;AAC7H,SAAO;AAAA,IACL,GAAG,gCAAgC,OAAO;AAAA,IAC1C,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/lib/stack-app/teams/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\n\nimport { ApiKeyCreationOptions, TeamApiKey, TeamApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/lib/stack-app/teams/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\n\nimport { ApiKeyCreationOptions, TeamApiKey, TeamApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport { Customer } from \"../customers\";\nimport { ServerUser } from \"../users\";\n\n\nexport type TeamMemberProfile = {\n displayName: string | null,\n profileImageUrl: string | null,\n}\n\nexport type TeamMemberProfileUpdateOptions = {\n displayName?: string,\n profileImageUrl?: string | null,\n};\n\nexport type EditableTeamMemberProfile = TeamMemberProfile & {\n update(update: TeamMemberProfileUpdateOptions): Promise<void>,\n}\n\nexport type TeamUser = {\n id: string,\n teamProfile: TeamMemberProfile,\n}\n\nexport type TeamInvitation = {\n id: string,\n recipientEmail: string | null,\n expiresAt: Date,\n revoke(): Promise<void>,\n}\n\nexport type Team = {\n id: string,\n displayName: string,\n profileImageUrl: string | null,\n clientMetadata: any,\n clientReadOnlyMetadata: any,\n inviteUser(options: { email: string, callbackUrl?: string }): Promise<void>,\n listUsers(): Promise<TeamUser[]>,\n listInvitations(): Promise<TeamInvitation[]>,\n update(update: TeamUpdateOptions): Promise<void>,\n delete(): Promise<void>,\n createApiKey(options: ApiKeyCreationOptions<\"team\">): Promise<TeamApiKeyFirstView>,\n} & AsyncStoreProperty<\"apiKeys\", [], TeamApiKey[], true> & Customer;\n\nexport type TeamUpdateOptions = {\n displayName?: string,\n profileImageUrl?: string | null,\n clientMetadata?: ReadonlyJson,\n};\nexport function teamUpdateOptionsToCrud(options: TeamUpdateOptions): TeamsCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n profile_image_url: options.profileImageUrl,\n client_metadata: options.clientMetadata,\n };\n}\n\nexport type TeamCreateOptions = {\n displayName: string,\n profileImageUrl?: string,\n}\nexport function teamCreateOptionsToCrud(options: TeamCreateOptions, creatorUserId: string): TeamsCrud[\"Client\"][\"Create\"] {\n return {\n display_name: options.displayName,\n profile_image_url: options.profileImageUrl,\n creator_user_id: creatorUserId,\n };\n}\n\n\nexport type ServerTeamMemberProfile = TeamMemberProfile;\n\nexport type ServerTeamUser = ServerUser & {\n teamProfile: ServerTeamMemberProfile,\n}\n\nexport type ServerTeam = {\n createdAt: Date,\n serverMetadata: any,\n listUsers(): Promise<ServerTeamUser[]>,\n update(update: ServerTeamUpdateOptions): Promise<void>,\n delete(): Promise<void>,\n addUser(userId: string): Promise<void>,\n inviteUser(options: { email: string, callbackUrl?: string }): Promise<void>,\n removeUser(userId: string): Promise<void>,\n} & Team;\n\nexport type ServerListUsersOptions = {\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt',\n desc?: boolean,\n query?: string,\n includeAnonymous?: boolean,\n};\n\nexport type ServerTeamCreateOptions = TeamCreateOptions & {\n creatorUserId?: string,\n};\nexport function serverTeamCreateOptionsToCrud(options: ServerTeamCreateOptions): TeamsCrud[\"Server\"][\"Create\"] {\n return {\n display_name: options.displayName,\n profile_image_url: options.profileImageUrl,\n creator_user_id: options.creatorUserId,\n };\n}\n\nexport type ServerTeamUpdateOptions = TeamUpdateOptions & {\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n};\nexport function serverTeamUpdateOptionsToCrud(options: ServerTeamUpdateOptions): TeamsCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n profile_image_url: options.profileImageUrl,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AA0DO,SAAS,wBAAwB,SAA2D;AACjG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ;AAAA,IAC3B,iBAAiB,QAAQ;AAAA,EAC3B;AACF;AAMO,SAAS,wBAAwB,SAA4B,eAAsD;AACxH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ;AAAA,IAC3B,iBAAiB;AAAA,EACnB;AACF;AAgCO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ;AAAA,IAC3B,iBAAiB,QAAQ;AAAA,EAC3B;AACF;AAMO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ;AAAA,IAC3B,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,8 @@ import { KnownErrors } from '@stackframe/stack-shared';
|
|
|
2
2
|
import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
|
+
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
6
|
+
import * as yup from 'yup';
|
|
5
7
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
8
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
7
9
|
import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
|
|
@@ -10,8 +12,6 @@ import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/cru
|
|
|
10
12
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
11
13
|
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
12
14
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
13
|
-
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
14
|
-
import * as yup from 'yup';
|
|
15
15
|
|
|
16
16
|
type RedirectToOptions = {
|
|
17
17
|
replace?: boolean;
|
|
@@ -33,7 +33,7 @@ type RedirectMethod = "window" | "none" | {
|
|
|
33
33
|
navigate?: (to: string) => void;
|
|
34
34
|
};
|
|
35
35
|
type GetUserOptions<HasTokenStore> = {
|
|
36
|
-
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
|
|
36
|
+
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
37
37
|
tokenStore?: TokenStoreInit;
|
|
38
38
|
} & (HasTokenStore extends false ? {
|
|
39
39
|
tokenStore: TokenStoreInit;
|
|
@@ -72,6 +72,44 @@ type OAuthScopesOnSignIn = {
|
|
|
72
72
|
/** @internal */
|
|
73
73
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
74
74
|
|
|
75
|
+
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
76
|
+
type Item = {
|
|
77
|
+
displayName: string;
|
|
78
|
+
/**
|
|
79
|
+
* May be negative.
|
|
80
|
+
*/
|
|
81
|
+
quantity: number;
|
|
82
|
+
/**
|
|
83
|
+
* Equal to Math.max(0, quantity).
|
|
84
|
+
*/
|
|
85
|
+
nonNegativeQuantity: number;
|
|
86
|
+
};
|
|
87
|
+
type ServerItem = Item & {
|
|
88
|
+
increaseQuantity(amount: number): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Decreases the quantity by the given amount.
|
|
91
|
+
*
|
|
92
|
+
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
93
|
+
*/
|
|
94
|
+
decreaseQuantity(amount: number): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
97
|
+
*
|
|
98
|
+
* Most useful for pre-paid credits.
|
|
99
|
+
*/
|
|
100
|
+
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
101
|
+
};
|
|
102
|
+
type Customer<IsServer extends boolean = false> = {
|
|
103
|
+
readonly id: string;
|
|
104
|
+
createCheckoutUrl(options: ({
|
|
105
|
+
offerId: string;
|
|
106
|
+
} | (IsServer extends true ? {
|
|
107
|
+
offer: InlineOffer;
|
|
108
|
+
} : never))): Promise<string>;
|
|
109
|
+
} & AsyncStoreProperty<"item", [
|
|
110
|
+
itemId: string
|
|
111
|
+
], IsServer extends true ? ServerItem : Item, false>;
|
|
112
|
+
|
|
75
113
|
type AdminSentEmail = {
|
|
76
114
|
id: string;
|
|
77
115
|
to: string[];
|
|
@@ -251,40 +289,6 @@ type NotificationCategory = {
|
|
|
251
289
|
setEnabled(enabled: boolean): Promise<void>;
|
|
252
290
|
};
|
|
253
291
|
|
|
254
|
-
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
255
|
-
type Item = {
|
|
256
|
-
displayName: string;
|
|
257
|
-
/**
|
|
258
|
-
* May be negative.
|
|
259
|
-
*/
|
|
260
|
-
quantity: number;
|
|
261
|
-
/**
|
|
262
|
-
* Equal to Math.max(0, quantity).
|
|
263
|
-
*/
|
|
264
|
-
nonNegativeQuantity: number;
|
|
265
|
-
};
|
|
266
|
-
type ServerItem = Item & {
|
|
267
|
-
increaseQuantity(amount: number): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Decreases the quantity by the given amount.
|
|
270
|
-
*
|
|
271
|
-
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
272
|
-
*/
|
|
273
|
-
decreaseQuantity(amount: number): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
276
|
-
*
|
|
277
|
-
* Most useful for pre-paid credits.
|
|
278
|
-
*/
|
|
279
|
-
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
280
|
-
};
|
|
281
|
-
type Customer<IsServer extends boolean = false> = {
|
|
282
|
-
readonly id: string;
|
|
283
|
-
createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
|
|
284
|
-
} & AsyncStoreProperty<"item", [
|
|
285
|
-
itemId: string
|
|
286
|
-
], IsServer extends true ? ServerItem : Item, false>;
|
|
287
|
-
|
|
288
292
|
type Session = {
|
|
289
293
|
getTokens(): Promise<{
|
|
290
294
|
accessToken: string | null;
|
|
@@ -642,6 +646,7 @@ type ServerListUsersOptions = {
|
|
|
642
646
|
orderBy?: 'signedUpAt';
|
|
643
647
|
desc?: boolean;
|
|
644
648
|
query?: string;
|
|
649
|
+
includeAnonymous?: boolean;
|
|
645
650
|
};
|
|
646
651
|
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
647
652
|
creatorUserId?: string;
|
|
@@ -687,7 +692,18 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
687
692
|
nextCursor: string | null;
|
|
688
693
|
}>;
|
|
689
694
|
sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
|
|
690
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> &
|
|
695
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
|
|
696
|
+
{
|
|
697
|
+
itemId: string;
|
|
698
|
+
userId: string;
|
|
699
|
+
} | {
|
|
700
|
+
itemId: string;
|
|
701
|
+
teamId: string;
|
|
702
|
+
} | {
|
|
703
|
+
itemId: string;
|
|
704
|
+
customCustomerId: string;
|
|
705
|
+
}
|
|
706
|
+
], ServerItem, false> & StackClientApp<HasTokenStore, ProjectId>);
|
|
691
707
|
declare const StackServerApp: StackServerAppConstructor;
|
|
692
708
|
|
|
693
709
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -712,7 +728,12 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
712
728
|
displayName: string;
|
|
713
729
|
themeId?: string;
|
|
714
730
|
tsxSource: string;
|
|
715
|
-
}[], true> & {
|
|
731
|
+
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
732
|
+
account_id: string;
|
|
733
|
+
charges_enabled: boolean;
|
|
734
|
+
details_submitted: boolean;
|
|
735
|
+
payouts_enabled: boolean;
|
|
736
|
+
} | null, false> & {
|
|
716
737
|
listEmailTemplates(): Promise<{
|
|
717
738
|
id: string;
|
|
718
739
|
displayName: string;
|
|
@@ -759,16 +780,29 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
759
780
|
createStripeWidgetAccountSession(): Promise<{
|
|
760
781
|
client_secret: string;
|
|
761
782
|
}>;
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
offerId: string;
|
|
765
|
-
}): Promise<string>;
|
|
766
|
-
createItemQuantityChange(options: {
|
|
767
|
-
customerId: string;
|
|
783
|
+
createItemQuantityChange(options: ({
|
|
784
|
+
userId: string;
|
|
768
785
|
itemId: string;
|
|
769
786
|
quantity: number;
|
|
770
787
|
expiresAt?: string;
|
|
771
788
|
description?: string;
|
|
789
|
+
} | {
|
|
790
|
+
teamId: string;
|
|
791
|
+
itemId: string;
|
|
792
|
+
quantity: number;
|
|
793
|
+
expiresAt?: string;
|
|
794
|
+
description?: string;
|
|
795
|
+
} | {
|
|
796
|
+
customCustomerId: string;
|
|
797
|
+
itemId: string;
|
|
798
|
+
quantity: number;
|
|
799
|
+
expiresAt?: string;
|
|
800
|
+
description?: string;
|
|
801
|
+
})): Promise<void>;
|
|
802
|
+
testModePurchase(options: {
|
|
803
|
+
priceId: string;
|
|
804
|
+
fullCode: string;
|
|
805
|
+
quantity?: number;
|
|
772
806
|
}): Promise<void>;
|
|
773
807
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
774
808
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
@@ -880,6 +914,7 @@ type AdminProject = {
|
|
|
880
914
|
readonly config: AdminProjectConfig;
|
|
881
915
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
882
916
|
delete(this: AdminProject): Promise<void>;
|
|
917
|
+
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
883
918
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
884
919
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
885
920
|
getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
|
|
@@ -990,7 +1025,18 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
990
1025
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
991
1026
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
992
1027
|
};
|
|
993
|
-
} & AsyncStoreProperty<"project", [], Project, false> &
|
|
1028
|
+
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1029
|
+
{
|
|
1030
|
+
itemId: string;
|
|
1031
|
+
userId: string;
|
|
1032
|
+
} | {
|
|
1033
|
+
itemId: string;
|
|
1034
|
+
teamId: string;
|
|
1035
|
+
} | {
|
|
1036
|
+
itemId: string;
|
|
1037
|
+
customCustomerId: string;
|
|
1038
|
+
}
|
|
1039
|
+
], Item, false> & {
|
|
994
1040
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
995
1041
|
});
|
|
996
1042
|
declare const StackClientApp: StackClientAppConstructor;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { KnownErrors } from '@stackframe/stack-shared';
|
|
|
2
2
|
import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
|
+
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
6
|
+
import * as yup from 'yup';
|
|
5
7
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
8
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
7
9
|
import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
|
|
@@ -10,8 +12,6 @@ import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/cru
|
|
|
10
12
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
11
13
|
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
12
14
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
13
|
-
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
14
|
-
import * as yup from 'yup';
|
|
15
15
|
|
|
16
16
|
type RedirectToOptions = {
|
|
17
17
|
replace?: boolean;
|
|
@@ -33,7 +33,7 @@ type RedirectMethod = "window" | "none" | {
|
|
|
33
33
|
navigate?: (to: string) => void;
|
|
34
34
|
};
|
|
35
35
|
type GetUserOptions<HasTokenStore> = {
|
|
36
|
-
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
|
|
36
|
+
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
37
37
|
tokenStore?: TokenStoreInit;
|
|
38
38
|
} & (HasTokenStore extends false ? {
|
|
39
39
|
tokenStore: TokenStoreInit;
|
|
@@ -72,6 +72,44 @@ type OAuthScopesOnSignIn = {
|
|
|
72
72
|
/** @internal */
|
|
73
73
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
74
74
|
|
|
75
|
+
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
76
|
+
type Item = {
|
|
77
|
+
displayName: string;
|
|
78
|
+
/**
|
|
79
|
+
* May be negative.
|
|
80
|
+
*/
|
|
81
|
+
quantity: number;
|
|
82
|
+
/**
|
|
83
|
+
* Equal to Math.max(0, quantity).
|
|
84
|
+
*/
|
|
85
|
+
nonNegativeQuantity: number;
|
|
86
|
+
};
|
|
87
|
+
type ServerItem = Item & {
|
|
88
|
+
increaseQuantity(amount: number): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Decreases the quantity by the given amount.
|
|
91
|
+
*
|
|
92
|
+
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
93
|
+
*/
|
|
94
|
+
decreaseQuantity(amount: number): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
97
|
+
*
|
|
98
|
+
* Most useful for pre-paid credits.
|
|
99
|
+
*/
|
|
100
|
+
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
101
|
+
};
|
|
102
|
+
type Customer<IsServer extends boolean = false> = {
|
|
103
|
+
readonly id: string;
|
|
104
|
+
createCheckoutUrl(options: ({
|
|
105
|
+
offerId: string;
|
|
106
|
+
} | (IsServer extends true ? {
|
|
107
|
+
offer: InlineOffer;
|
|
108
|
+
} : never))): Promise<string>;
|
|
109
|
+
} & AsyncStoreProperty<"item", [
|
|
110
|
+
itemId: string
|
|
111
|
+
], IsServer extends true ? ServerItem : Item, false>;
|
|
112
|
+
|
|
75
113
|
type AdminSentEmail = {
|
|
76
114
|
id: string;
|
|
77
115
|
to: string[];
|
|
@@ -251,40 +289,6 @@ type NotificationCategory = {
|
|
|
251
289
|
setEnabled(enabled: boolean): Promise<void>;
|
|
252
290
|
};
|
|
253
291
|
|
|
254
|
-
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
255
|
-
type Item = {
|
|
256
|
-
displayName: string;
|
|
257
|
-
/**
|
|
258
|
-
* May be negative.
|
|
259
|
-
*/
|
|
260
|
-
quantity: number;
|
|
261
|
-
/**
|
|
262
|
-
* Equal to Math.max(0, quantity).
|
|
263
|
-
*/
|
|
264
|
-
nonNegativeQuantity: number;
|
|
265
|
-
};
|
|
266
|
-
type ServerItem = Item & {
|
|
267
|
-
increaseQuantity(amount: number): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Decreases the quantity by the given amount.
|
|
270
|
-
*
|
|
271
|
-
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
272
|
-
*/
|
|
273
|
-
decreaseQuantity(amount: number): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
276
|
-
*
|
|
277
|
-
* Most useful for pre-paid credits.
|
|
278
|
-
*/
|
|
279
|
-
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
280
|
-
};
|
|
281
|
-
type Customer<IsServer extends boolean = false> = {
|
|
282
|
-
readonly id: string;
|
|
283
|
-
createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
|
|
284
|
-
} & AsyncStoreProperty<"item", [
|
|
285
|
-
itemId: string
|
|
286
|
-
], IsServer extends true ? ServerItem : Item, false>;
|
|
287
|
-
|
|
288
292
|
type Session = {
|
|
289
293
|
getTokens(): Promise<{
|
|
290
294
|
accessToken: string | null;
|
|
@@ -642,6 +646,7 @@ type ServerListUsersOptions = {
|
|
|
642
646
|
orderBy?: 'signedUpAt';
|
|
643
647
|
desc?: boolean;
|
|
644
648
|
query?: string;
|
|
649
|
+
includeAnonymous?: boolean;
|
|
645
650
|
};
|
|
646
651
|
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
647
652
|
creatorUserId?: string;
|
|
@@ -687,7 +692,18 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
687
692
|
nextCursor: string | null;
|
|
688
693
|
}>;
|
|
689
694
|
sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
|
|
690
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> &
|
|
695
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
|
|
696
|
+
{
|
|
697
|
+
itemId: string;
|
|
698
|
+
userId: string;
|
|
699
|
+
} | {
|
|
700
|
+
itemId: string;
|
|
701
|
+
teamId: string;
|
|
702
|
+
} | {
|
|
703
|
+
itemId: string;
|
|
704
|
+
customCustomerId: string;
|
|
705
|
+
}
|
|
706
|
+
], ServerItem, false> & StackClientApp<HasTokenStore, ProjectId>);
|
|
691
707
|
declare const StackServerApp: StackServerAppConstructor;
|
|
692
708
|
|
|
693
709
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -712,7 +728,12 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
712
728
|
displayName: string;
|
|
713
729
|
themeId?: string;
|
|
714
730
|
tsxSource: string;
|
|
715
|
-
}[], true> & {
|
|
731
|
+
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
732
|
+
account_id: string;
|
|
733
|
+
charges_enabled: boolean;
|
|
734
|
+
details_submitted: boolean;
|
|
735
|
+
payouts_enabled: boolean;
|
|
736
|
+
} | null, false> & {
|
|
716
737
|
listEmailTemplates(): Promise<{
|
|
717
738
|
id: string;
|
|
718
739
|
displayName: string;
|
|
@@ -759,16 +780,29 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
759
780
|
createStripeWidgetAccountSession(): Promise<{
|
|
760
781
|
client_secret: string;
|
|
761
782
|
}>;
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
offerId: string;
|
|
765
|
-
}): Promise<string>;
|
|
766
|
-
createItemQuantityChange(options: {
|
|
767
|
-
customerId: string;
|
|
783
|
+
createItemQuantityChange(options: ({
|
|
784
|
+
userId: string;
|
|
768
785
|
itemId: string;
|
|
769
786
|
quantity: number;
|
|
770
787
|
expiresAt?: string;
|
|
771
788
|
description?: string;
|
|
789
|
+
} | {
|
|
790
|
+
teamId: string;
|
|
791
|
+
itemId: string;
|
|
792
|
+
quantity: number;
|
|
793
|
+
expiresAt?: string;
|
|
794
|
+
description?: string;
|
|
795
|
+
} | {
|
|
796
|
+
customCustomerId: string;
|
|
797
|
+
itemId: string;
|
|
798
|
+
quantity: number;
|
|
799
|
+
expiresAt?: string;
|
|
800
|
+
description?: string;
|
|
801
|
+
})): Promise<void>;
|
|
802
|
+
testModePurchase(options: {
|
|
803
|
+
priceId: string;
|
|
804
|
+
fullCode: string;
|
|
805
|
+
quantity?: number;
|
|
772
806
|
}): Promise<void>;
|
|
773
807
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
774
808
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
@@ -880,6 +914,7 @@ type AdminProject = {
|
|
|
880
914
|
readonly config: AdminProjectConfig;
|
|
881
915
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
882
916
|
delete(this: AdminProject): Promise<void>;
|
|
917
|
+
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
883
918
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
884
919
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
885
920
|
getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
|
|
@@ -990,7 +1025,18 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
990
1025
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
991
1026
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
992
1027
|
};
|
|
993
|
-
} & AsyncStoreProperty<"project", [], Project, false> &
|
|
1028
|
+
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1029
|
+
{
|
|
1030
|
+
itemId: string;
|
|
1031
|
+
userId: string;
|
|
1032
|
+
} | {
|
|
1033
|
+
itemId: string;
|
|
1034
|
+
teamId: string;
|
|
1035
|
+
} | {
|
|
1036
|
+
itemId: string;
|
|
1037
|
+
customCustomerId: string;
|
|
1038
|
+
}
|
|
1039
|
+
], Item, false> & {
|
|
994
1040
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
995
1041
|
});
|
|
996
1042
|
declare const StackClientApp: StackClientAppConstructor;
|
package/dist/lib/auth.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_results = require("@stackframe/stack-shared/dist/utils/results");
|
|
|
32
32
|
var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
33
33
|
var import_url = require("../utils/url.js");
|
|
34
34
|
var import_cookie = require("./cookie.js");
|
|
35
|
-
async function signInWithOAuth(iface, options) {
|
|
35
|
+
async function signInWithOAuth(iface, options, session) {
|
|
36
36
|
const { codeChallenge, state } = await (0, import_cookie.saveVerifierAndState)();
|
|
37
37
|
const location = await iface.getOAuthUrl({
|
|
38
38
|
provider: options.provider,
|
|
@@ -41,7 +41,8 @@ async function signInWithOAuth(iface, options) {
|
|
|
41
41
|
codeChallenge,
|
|
42
42
|
state,
|
|
43
43
|
type: "authenticate",
|
|
44
|
-
providerScope: options.providerScope
|
|
44
|
+
providerScope: options.providerScope,
|
|
45
|
+
session
|
|
45
46
|
});
|
|
46
47
|
window.location.assign(location);
|
|
47
48
|
await (0, import_promises.neverResolve)();
|
package/dist/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n }
|
|
1
|
+
{"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl, \"redirectUrl\"),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl, \"errorRedirectUrl\"),\n codeChallenge,\n state,\n type: \"authenticate\",\n providerScope: options.providerScope,\n session,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\nexport async function addNewOAuthProviderOrScope(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl, \"redirectUrl\"),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl, \"errorRedirectUrl\"),\n afterCallbackRedirectUrl: constructRedirectUrl(window.location.href, \"afterCallbackRedirectUrl\"),\n codeChallenge,\n state,\n type: \"link\",\n session,\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\n/**\n * Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.\n *\n * Must be synchronous for the logic in callOAuthCallback to work without race conditions.\n */\nfunction consumeOAuthCallbackQueryParams() {\n const requiredParams = [\"code\", \"state\"];\n const originalUrl = new URL(window.location.href);\n for (const param of requiredParams) {\n if (!originalUrl.searchParams.has(param)) {\n console.warn(new Error(`Missing required query parameter on OAuth callback: ${param}. Maybe you opened or reloaded the oauth-callback page from your history?`));\n return null;\n }\n }\n\n const expectedState = originalUrl.searchParams.get(\"state\") ?? throwErr(\"This should never happen; isn't state required above?\");\n const cookieResult = consumeVerifierAndStateCookie(expectedState);\n\n if (!cookieResult) {\n // If the state can't be found in the cookies, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\n console.warn(deindent`\n Stack found an outer OAuth callback state in the query parameters, but not in cookies.\n \n This could have multiple reasons:\n - The cookie expired, because the OAuth flow took too long.\n - The user's browser deleted the cookie, either manually or because of a very strict cookie policy.\n - The cookie was already consumed by this page, and the user already logged in.\n - You are using another OAuth client library with the same callback URL as Stack.\n - The user opened the OAuth callback page from their history.\n\n Either way, it is probably safe to ignore this warning unless you are debugging an OAuth issue.\n `);\n return null;\n }\n\n\n const newUrl = new URL(originalUrl);\n for (const param of requiredParams) {\n newUrl.searchParams.delete(param);\n }\n\n // let's get rid of the authorization code in the history as we\n // don't redirect to `redirectUrl` if there's a validation error\n // (as the redirectUrl might be malicious!).\n //\n // We use history.replaceState instead of location.assign(...) to\n // prevent an unnecessary reload\n window.history.replaceState({}, \"\", newUrl.toString());\n\n return {\n originalUrl,\n codeVerifier: cookieResult.codeVerifier,\n state: expectedState,\n };\n}\n\nexport async function callOAuthCallback(\n iface: StackClientInterface,\n redirectUrl: string,\n) {\n // note: this part of the function (until the return) needs\n // to be synchronous, to prevent race conditions when\n // callOAuthCallback is called multiple times in parallel\n const consumed = consumeOAuthCallbackQueryParams();\n if (!consumed) return Result.ok(undefined);\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback, and the only instance\n // of callOAuthCallback that's running)\n try {\n return Result.ok(await iface.callOAuthCallback({\n oauthParams: consumed.originalUrl.searchParams,\n redirectUri: constructRedirectUrl(redirectUrl, \"redirectUri\"),\n codeVerifier: consumed.codeVerifier,\n state: consumed.state,\n }));\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n throw e;\n }\n throw new StackAssertionError(\"Error signing in during OAuth callback. Please try again.\", { cause: e });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAiD;AAEjD,oBAA8C;AAC9C,sBAA6B;AAC7B,qBAAuB;AACvB,qBAAyB;AACzB,iBAAqC;AACrC,oBAAoE;AAEpE,eAAsB,gBACpB,OACA,SAMA,SACA;AACA,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM,YAAY;AAAA,IACvC,UAAU,QAAQ;AAAA,IAClB,iBAAa,iCAAqB,QAAQ,aAAa,aAAa;AAAA,IACpE,sBAAkB,iCAAqB,QAAQ,kBAAkB,kBAAkB;AAAA,IACnF;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,eAAe,QAAQ;AAAA,IACvB;AAAA,EACF,CAAC;AACD,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAEA,eAAsB,2BACpB,OACA,SAMA,SACA;AACA,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM,YAAY;AAAA,IACvC,UAAU,QAAQ;AAAA,IAClB,iBAAa,iCAAqB,QAAQ,aAAa,aAAa;AAAA,IACpE,sBAAkB,iCAAqB,QAAQ,kBAAkB,kBAAkB;AAAA,IACnF,8BAA0B,iCAAqB,OAAO,SAAS,MAAM,0BAA0B;AAAA,IAC/F;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,eAAe,QAAQ;AAAA,EACzB,CAAC;AACD,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAOA,SAAS,kCAAkC;AACzC,QAAM,iBAAiB,CAAC,QAAQ,OAAO;AACvC,QAAM,cAAc,IAAI,IAAI,OAAO,SAAS,IAAI;AAChD,aAAW,SAAS,gBAAgB;AAClC,QAAI,CAAC,YAAY,aAAa,IAAI,KAAK,GAAG;AACxC,cAAQ,KAAK,IAAI,MAAM,uDAAuD,KAAK,2EAA2E,CAAC;AAC/J,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,aAAa,IAAI,OAAO,SAAK,wBAAS,uDAAuD;AAC/H,QAAM,mBAAe,6CAA8B,aAAa;AAEhE,MAAI,CAAC,cAAc;AAGjB,YAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWZ;AACD,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,IAAI,IAAI,WAAW;AAClC,aAAW,SAAS,gBAAgB;AAClC,WAAO,aAAa,OAAO,KAAK;AAAA,EAClC;AAQA,SAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,OAAO,SAAS,CAAC;AAErD,SAAO;AAAA,IACL;AAAA,IACA,cAAc,aAAa;AAAA,IAC3B,OAAO;AAAA,EACT;AACF;AAEA,eAAsB,kBACpB,OACA,aACA;AAIA,QAAM,WAAW,gCAAgC;AACjD,MAAI,CAAC,SAAU,QAAO,sBAAO,GAAG,MAAS;AAKzC,MAAI;AACF,WAAO,sBAAO,GAAG,MAAM,MAAM,kBAAkB;AAAA,MAC7C,aAAa,SAAS,YAAY;AAAA,MAClC,iBAAa,iCAAqB,aAAa,aAAa;AAAA,MAC5D,cAAc,SAAS;AAAA,MACvB,OAAO,SAAS;AAAA,IAClB,CAAC,CAAC;AAAA,EACJ,SAAS,GAAG;AACV,QAAI,+BAAW,aAAa,CAAC,GAAG;AAC9B,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
|
|
@@ -92,6 +92,16 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
92
92
|
this._configOverridesCache = (0, import_common2.createCache)(async () => {
|
|
93
93
|
return await this._interface.getConfig();
|
|
94
94
|
});
|
|
95
|
+
this._stripeAccountInfoCache = (0, import_common2.createCache)(async () => {
|
|
96
|
+
try {
|
|
97
|
+
return await this._interface.getStripeAccountInfo();
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (error?.status === 404) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
95
105
|
}
|
|
96
106
|
_adminConfigFromCrud(data) {
|
|
97
107
|
return JSON.parse(data.config_string);
|
|
@@ -177,6 +187,10 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
177
187
|
async delete() {
|
|
178
188
|
await app._interface.deleteProject();
|
|
179
189
|
},
|
|
190
|
+
async transfer(user, newTeamId) {
|
|
191
|
+
await app._interface.transferProject(user._internalSession, newTeamId);
|
|
192
|
+
await onRefresh();
|
|
193
|
+
},
|
|
180
194
|
async getProductionModeErrors() {
|
|
181
195
|
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
182
196
|
}
|
|
@@ -373,16 +387,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
373
387
|
async createStripeWidgetAccountSession() {
|
|
374
388
|
return await this._interface.createStripeWidgetAccountSession();
|
|
375
389
|
}
|
|
376
|
-
async createPurchaseUrl(options) {
|
|
377
|
-
return await this._interface.createPurchaseUrl({
|
|
378
|
-
customer_id: options.customerId,
|
|
379
|
-
offer_id: options.offerId
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
390
|
async createItemQuantityChange(options) {
|
|
383
391
|
await this._interface.updateItemQuantity(
|
|
384
|
-
options.
|
|
385
|
-
options.itemId,
|
|
392
|
+
{ itemId: options.itemId, ..."userId" in options ? { userId: options.userId } : "teamId" in options ? { teamId: options.teamId } : { customCustomerId: options.customCustomerId } },
|
|
386
393
|
{
|
|
387
394
|
delta: options.quantity,
|
|
388
395
|
expires_at: options.expiresAt,
|
|
@@ -390,6 +397,12 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
390
397
|
}
|
|
391
398
|
);
|
|
392
399
|
}
|
|
400
|
+
async testModePurchase(options) {
|
|
401
|
+
await this._interface.testModePurchase({ price_id: options.priceId, full_code: options.fullCode, quantity: options.quantity });
|
|
402
|
+
}
|
|
403
|
+
async getStripeAccountInfo() {
|
|
404
|
+
return await this._interface.getStripeAccountInfo();
|
|
405
|
+
}
|
|
393
406
|
};
|
|
394
407
|
// Annotate the CommonJS export names for ESM import in node:
|
|
395
408
|
0 && (module.exports = {
|