@stackframe/stack 2.8.31 → 2.8.34

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/team-switcher.js +1 -1
  3. package/dist/components/team-switcher.js.map +1 -1
  4. package/dist/esm/components/team-switcher.js +3 -3
  5. package/dist/esm/components/team-switcher.js.map +1 -1
  6. package/dist/esm/generated/global-css.js +1 -1
  7. package/dist/esm/generated/global-css.js.map +1 -1
  8. package/dist/esm/lib/auth.js +3 -2
  9. package/dist/esm/lib/auth.js.map +1 -1
  10. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +13 -8
  11. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  12. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +53 -12
  13. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  14. package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
  15. package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
  16. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +68 -8
  17. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  18. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  19. package/dist/esm/lib/stack-app/common.js.map +1 -1
  20. package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
  21. package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
  22. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  23. package/dist/esm/providers/stack-provider.js +1 -1
  24. package/dist/esm/providers/stack-provider.js.map +1 -1
  25. package/dist/generated/global-css.js +1 -1
  26. package/dist/generated/global-css.js.map +1 -1
  27. package/dist/index.d.mts +43 -7
  28. package/dist/index.d.ts +43 -7
  29. package/dist/lib/auth.js +3 -2
  30. package/dist/lib/auth.js.map +1 -1
  31. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +13 -8
  32. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  33. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +53 -12
  34. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  35. package/dist/lib/stack-app/apps/implementations/common.js +1 -1
  36. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
  37. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +68 -8
  38. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  39. package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  40. package/dist/lib/stack-app/common.js.map +1 -1
  41. package/dist/lib/stack-app/customers/index.js.map +1 -1
  42. package/dist/lib/stack-app/projects/index.js.map +1 -1
  43. package/dist/lib/stack-app/teams/index.js.map +1 -1
  44. package/dist/lib/stack-app/users/index.js.map +1 -1
  45. package/dist/providers/stack-provider.js +1 -1
  46. package/dist/providers/stack-provider.js.map +1 -1
  47. package/package.json +4 -4
package/dist/index.d.mts CHANGED
@@ -9,6 +9,8 @@ import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
9
9
  import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
10
10
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
11
11
  import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
12
+ import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
13
+ import * as yup from 'yup';
12
14
  import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
13
15
  import * as react_jsx_runtime from 'react/jsx-runtime';
14
16
  import * as lucide_react from 'lucide-react';
@@ -36,7 +38,7 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
36
38
  navigate?: (to: string) => void;
37
39
  };
38
40
  type GetUserOptions$1<HasTokenStore> = {
39
- or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
41
+ or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
40
42
  tokenStore?: TokenStoreInit;
41
43
  } & (HasTokenStore extends false ? {
42
44
  tokenStore: TokenStoreInit;
@@ -203,6 +205,40 @@ type ApiKeyUpdateOptions<Type extends ApiKeyType = ApiKeyType> = {
203
205
  revoked?: boolean;
204
206
  };
205
207
 
208
+ type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
209
+ type Item = {
210
+ displayName: string;
211
+ /**
212
+ * May be negative.
213
+ */
214
+ quantity: number;
215
+ /**
216
+ * Equal to Math.max(0, quantity).
217
+ */
218
+ nonNegativeQuantity: number;
219
+ };
220
+ type ServerItem = Item & {
221
+ increaseQuantity(amount: number): Promise<void>;
222
+ /**
223
+ * Decreases the quantity by the given amount.
224
+ *
225
+ * 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.
226
+ */
227
+ decreaseQuantity(amount: number): Promise<void>;
228
+ /**
229
+ * 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.
230
+ *
231
+ * Most useful for pre-paid credits.
232
+ */
233
+ tryDecreaseQuantity(amount: number): Promise<boolean>;
234
+ };
235
+ type Customer<IsServer extends boolean = false> = {
236
+ readonly id: string;
237
+ createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
238
+ } & AsyncStoreProperty<"item", [
239
+ itemId: string
240
+ ], IsServer extends true ? ServerItem : Item, false>;
241
+
206
242
  type Connection = {
207
243
  id: string;
208
244
  };
@@ -477,7 +513,7 @@ type InternalUserExtra = {
477
513
  createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>;
478
514
  } & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
479
515
  type User = BaseUser;
480
- type CurrentUser = BaseUser & Auth & UserExtra;
516
+ type CurrentUser = BaseUser & Auth & UserExtra & Customer;
481
517
  type CurrentInternalUser = CurrentUser & InternalUserExtra;
482
518
  type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
483
519
  type ActiveSession = {
@@ -549,7 +585,7 @@ type ServerBaseUser = {
549
585
  * A user including sensitive fields that should only be used on the server, never sent to the client
550
586
  * (such as sensitive information and serverMetadata).
551
587
  */
552
- type ServerUser = ServerBaseUser & BaseUser & UserExtra;
588
+ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
553
589
  type CurrentServerUser = Auth & ServerUser;
554
590
  type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
555
591
  type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
@@ -611,7 +647,7 @@ type Team = {
611
647
  update(update: TeamUpdateOptions): Promise<void>;
612
648
  delete(): Promise<void>;
613
649
  createApiKey(options: ApiKeyCreationOptions<"team">): Promise<TeamApiKeyFirstView>;
614
- } & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true>;
650
+ } & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true> & Customer;
615
651
  type TeamUpdateOptions = {
616
652
  displayName?: string;
617
653
  profileImageUrl?: string | null;
@@ -645,6 +681,7 @@ type ServerListUsersOptions = {
645
681
  orderBy?: 'signedUpAt';
646
682
  desc?: boolean;
647
683
  query?: string;
684
+ includeAnonymous?: boolean;
648
685
  };
649
686
  type ServerTeamCreateOptions = TeamCreateOptions & {
650
687
  creatorUserId?: string;
@@ -803,9 +840,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
803
840
  quantity: number;
804
841
  expiresAt?: string;
805
842
  description?: string;
806
- }): Promise<{
807
- id: string;
808
- }>;
843
+ }): Promise<void>;
809
844
  } & StackServerApp<HasTokenStore, ProjectId>);
810
845
  declare const StackAdminApp: StackAdminAppConstructor;
811
846
 
@@ -916,6 +951,7 @@ type AdminProject = {
916
951
  readonly config: AdminProjectConfig;
917
952
  update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
918
953
  delete(this: AdminProject): Promise<void>;
954
+ transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
919
955
  getConfig(this: AdminProject): Promise<CompleteConfig>;
920
956
  useConfig(this: AdminProject): CompleteConfig;
921
957
  updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
9
9
  import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
10
10
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
11
11
  import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
12
+ import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
13
+ import * as yup from 'yup';
12
14
  import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
13
15
  import * as react_jsx_runtime from 'react/jsx-runtime';
14
16
  import * as lucide_react from 'lucide-react';
@@ -36,7 +38,7 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
36
38
  navigate?: (to: string) => void;
37
39
  };
38
40
  type GetUserOptions$1<HasTokenStore> = {
39
- or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
41
+ or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
40
42
  tokenStore?: TokenStoreInit;
41
43
  } & (HasTokenStore extends false ? {
42
44
  tokenStore: TokenStoreInit;
@@ -203,6 +205,40 @@ type ApiKeyUpdateOptions<Type extends ApiKeyType = ApiKeyType> = {
203
205
  revoked?: boolean;
204
206
  };
205
207
 
208
+ type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
209
+ type Item = {
210
+ displayName: string;
211
+ /**
212
+ * May be negative.
213
+ */
214
+ quantity: number;
215
+ /**
216
+ * Equal to Math.max(0, quantity).
217
+ */
218
+ nonNegativeQuantity: number;
219
+ };
220
+ type ServerItem = Item & {
221
+ increaseQuantity(amount: number): Promise<void>;
222
+ /**
223
+ * Decreases the quantity by the given amount.
224
+ *
225
+ * 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.
226
+ */
227
+ decreaseQuantity(amount: number): Promise<void>;
228
+ /**
229
+ * 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.
230
+ *
231
+ * Most useful for pre-paid credits.
232
+ */
233
+ tryDecreaseQuantity(amount: number): Promise<boolean>;
234
+ };
235
+ type Customer<IsServer extends boolean = false> = {
236
+ readonly id: string;
237
+ createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
238
+ } & AsyncStoreProperty<"item", [
239
+ itemId: string
240
+ ], IsServer extends true ? ServerItem : Item, false>;
241
+
206
242
  type Connection = {
207
243
  id: string;
208
244
  };
@@ -477,7 +513,7 @@ type InternalUserExtra = {
477
513
  createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>;
478
514
  } & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
479
515
  type User = BaseUser;
480
- type CurrentUser = BaseUser & Auth & UserExtra;
516
+ type CurrentUser = BaseUser & Auth & UserExtra & Customer;
481
517
  type CurrentInternalUser = CurrentUser & InternalUserExtra;
482
518
  type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
483
519
  type ActiveSession = {
@@ -549,7 +585,7 @@ type ServerBaseUser = {
549
585
  * A user including sensitive fields that should only be used on the server, never sent to the client
550
586
  * (such as sensitive information and serverMetadata).
551
587
  */
552
- type ServerUser = ServerBaseUser & BaseUser & UserExtra;
588
+ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
553
589
  type CurrentServerUser = Auth & ServerUser;
554
590
  type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
555
591
  type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
@@ -611,7 +647,7 @@ type Team = {
611
647
  update(update: TeamUpdateOptions): Promise<void>;
612
648
  delete(): Promise<void>;
613
649
  createApiKey(options: ApiKeyCreationOptions<"team">): Promise<TeamApiKeyFirstView>;
614
- } & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true>;
650
+ } & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true> & Customer;
615
651
  type TeamUpdateOptions = {
616
652
  displayName?: string;
617
653
  profileImageUrl?: string | null;
@@ -645,6 +681,7 @@ type ServerListUsersOptions = {
645
681
  orderBy?: 'signedUpAt';
646
682
  desc?: boolean;
647
683
  query?: string;
684
+ includeAnonymous?: boolean;
648
685
  };
649
686
  type ServerTeamCreateOptions = TeamCreateOptions & {
650
687
  creatorUserId?: string;
@@ -803,9 +840,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
803
840
  quantity: number;
804
841
  expiresAt?: string;
805
842
  description?: string;
806
- }): Promise<{
807
- id: string;
808
- }>;
843
+ }): Promise<void>;
809
844
  } & StackServerApp<HasTokenStore, ProjectId>);
810
845
  declare const StackAdminApp: StackAdminAppConstructor;
811
846
 
@@ -916,6 +951,7 @@ type AdminProject = {
916
951
  readonly config: AdminProjectConfig;
917
952
  update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
918
953
  delete(this: AdminProject): Promise<void>;
954
+ transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
919
955
  getConfig(this: AdminProject): Promise<CompleteConfig>;
920
956
  useConfig(this: AdminProject): CompleteConfig;
921
957
  updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
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)();
@@ -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 }\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 });\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;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,EACzB,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,QA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AKzC,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":[]}
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,8BA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EA,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":[]}
@@ -183,6 +183,10 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
183
183
  async delete() {
184
184
  await app._interface.deleteProject();
185
185
  },
186
+ async transfer(user, newTeamId) {
187
+ await app._interface.transferProject(user._internalSession, newTeamId);
188
+ await onRefresh();
189
+ },
186
190
  async getProductionModeErrors() {
187
191
  return (0, import_production_mode.getProductionModeErrors)(data);
188
192
  },
@@ -452,14 +456,15 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
452
456
  });
453
457
  }
454
458
  async createItemQuantityChange(options) {
455
- const res = await this._interface.createItemQuantityChange({
456
- customer_id: options.customerId,
457
- item_id: options.itemId,
458
- quantity: options.quantity,
459
- expires_at: options.expiresAt,
460
- description: options.description
461
- });
462
- return res;
459
+ await this._interface.updateItemQuantity(
460
+ options.customerId,
461
+ options.itemId,
462
+ {
463
+ delta: options.quantity,
464
+ expires_at: options.expiresAt,
465
+ description: options.description
466
+ }
467
+ );
463
468
  }
464
469
  };
465
470
  // Annotate the CommonJS export names for ESM import in node:
@@ -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 { InternalApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { EmailTemplateCrud } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/internal-api-keys\";\nimport { ProjectsCrud } 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 { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate } from \"../../email-templates\";\nimport { InternalApiKey, InternalApiKeyBase, InternalApiKeyBaseCrudRead, InternalApiKeyCreateOptions, InternalApiKeyFirstView, internalApiKeyCreateOptionsToCrud } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminProjectPermissionDefinitionCreateOptionsToCrud, adminProjectPermissionDefinitionUpdateOptionsToCrud, 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 { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { ConfigCrud } from \"@stackframe/stack-shared/dist/interface/crud/config\";\nimport { useAsyncCache } from \"./common\"; // THIS_LINE_PLATFORM react-like\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 _internalApiKeysCache = createCache(async () => {\n const res = await this._interface.listInternalApiKeys();\n return res;\n });\n private readonly _adminEmailThemeCache = createCache(async ([id]: [string]) => {\n return await this._interface.getEmailTheme(id);\n });\n private readonly _adminEmailThemesCache = createCache(async () => {\n return await this._interface.listEmailThemes();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listInternalEmailTemplates();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listTeamPermissionDefinitions();\n });\n private readonly _adminProjectPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listProjectPermissionDefinitions();\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 private readonly _emailPreviewCache = createCache(async ([themeId, themeTsxSource, templateId, templateTsxSource]: [string | null | false | undefined, string | undefined, string | undefined, string | undefined]) => {\n return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });\n });\n private readonly _configOverridesCache = createCache(async () => {\n return await this._interface.getConfig();\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 _adminConfigFromCrud(data: ConfigCrud['Admin']['Read']): CompleteConfig {\n return JSON.parse(data.config_string);\n }\n\n _adminOwnedProjectFromCrud(data: ProjectsCrud['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: ProjectsCrud['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 isProductionMode: data.is_production_mode,\n ownerTeamId: data.owner_team_id,\n logoUrl: data.logo_url,\n fullLogoUrl: data.full_logo_url,\n config: {\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 allowUserApiKeys: data.config.allow_user_api_keys,\n allowTeamApiKeys: data.config.allow_team_api_keys,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n type: 'shared',\n } as const : {\n id: p.id,\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 emailTheme: data.config.email_theme,\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 userDefaultPermissions: data.config.user_default_permissions,\n },\n async getConfig() {\n return app._adminConfigFromCrud(await app._interface.getConfig());\n },\n useConfig() {\n const config = useAsyncCache(app._configOverridesCache, [], \"useConfig()\");\n return useMemo(() => app._adminConfigFromCrud(config), [config]);\n },\n async updateConfig(configOverride: EnvironmentConfigOverrideOverride) {\n await app._interface.updateConfig({ configOverride });\n await app._configOverridesCache.refresh([]);\n },\n async update(update: AdminProjectUpdateOptions) {\n const updateOptions = adminProjectUpdateOptionsToCrud(update);\n await app._interface.updateProject(updateOptions);\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 _createInternalApiKeyBaseFromCrud(data: InternalApiKeyBaseCrudRead): InternalApiKeyBase {\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.revokeInternalApiKeyById(data.id);\n await app._refreshInternalApiKeys();\n return res;\n }\n };\n }\n\n protected _createInternalApiKeyFromCrud(data: InternalApiKeysCrud[\"Admin\"][\"Read\"]): InternalApiKey {\n return {\n ...this._createInternalApiKeyBaseFromCrud(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 _createInternalApiKeyFirstViewFromCrud(data: InternalApiKeyCreateCrudResponse): InternalApiKeyFirstView {\n return {\n ...this._createInternalApiKeyBaseFromCrud(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 listInternalApiKeys(): Promise<InternalApiKey[]> {\n const crud = Result.orThrow(await this._internalApiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }\n\n useInternalApiKeys(): InternalApiKey[] {\n const crud = useAsyncCache(this._internalApiKeysCache, [], \"useInternalApiKeys()\");\n return useMemo(() => {\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }, [crud]);\n }\n\n async createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView> {\n const crud = await this._interface.createInternalApiKey(internalApiKeyCreateOptionsToCrud(options));\n await this._refreshInternalApiKeys();\n return this._createInternalApiKeyFirstViewFromCrud(crud);\n }\n\n\n useEmailThemes(): { id: string, displayName: string }[] {\n const crud = useAsyncCache(this._adminEmailThemesCache, [], \"useEmailThemes()\");\n return useMemo(() => {\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }, [crud]);\n }\n useEmailTemplates(): { id: string, displayName: string, themeId?: string, tsxSource: string }[] {\n const crud = useAsyncCache(this._adminEmailTemplatesCache, [], \"useEmailTemplates()\");\n return useMemo(() => {\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }, [crud]);\n }\n async listEmailThemes(): Promise<{ id: string, displayName: string }[]> {\n const crud = Result.orThrow(await this._adminEmailThemesCache.getOrWait([], \"write-only\"));\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }\n\n async listEmailTemplates(): Promise<{ id: string, displayName: string, themeId?: string, tsxSource: string }[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }\n\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>{\n const crud = await this._interface.createTeamPermissionDefinition(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.updateTeamPermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteTeamPermissionDefinition(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\n async createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission> {\n const crud = await this._interface.createProjectPermissionDefinition(adminProjectPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n return this._serverProjectPermissionDefinitionFromCrud(crud);\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions) {\n await this._interface.updateProjectPermissionDefinition(permissionId, adminProjectPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteProjectPermissionDefinition(permissionId);\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async listProjectPermissionDefinitions(): Promise<AdminProjectPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminProjectPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));\n }\n\n useProjectPermissionDefinitions(): AdminProjectPermissionDefinition[] {\n const crud = useAsyncCache(this._adminProjectPermissionDefinitionsCache, [], \"useProjectPermissions()\");\n return useMemo(() => {\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(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 _refreshInternalApiKeys() {\n await this._internalApiKeysCache.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 async sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void> {\n await this._interface.sendSignInInvitationEmail(email, callbackUrl);\n }\n\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTemplate(displayName);\n await this._adminEmailTemplatesCache.refresh([]);\n return result;\n }\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this._interface.saveChatMessage(threadId, message);\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n return await this._interface.listChatMessages(threadId);\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTheme(displayName);\n await this._adminEmailThemesCache.refresh([]);\n return result;\n }\n\n async getEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<string> {\n return (await this._interface.renderEmailPreview(options)).html;\n }\n useEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): string {\n const crud = useAsyncCache(this._emailPreviewCache, [options.themeId, options.themeTsxSource, options.templateId, options.templateTsxSource] as const, \"useEmailPreview()\");\n return crud.html;\n }\n useEmailTheme(id: string): { displayName: string, tsxSource: string } {\n const crud = useAsyncCache(this._adminEmailThemeCache, [id] as const, \"useEmailTheme()\");\n return {\n displayName: crud.display_name,\n tsxSource: crud.tsx_source,\n };\n }\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this._interface.updateEmailTheme(id, tsxSource);\n }\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }> {\n const result = await this._interface.updateEmailTemplate(id, tsxSource, themeId);\n await this._adminEmailTemplatesCache.refresh([]);\n return { renderedHtml: result.rendered_html };\n }\n\n async setupPayments(): Promise<{ url: string }> {\n return await this._interface.setupPayments();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n return await this._interface.createStripeWidgetAccountSession();\n }\n\n async createPurchaseUrl(options: { customerId: string, offerId: string }): Promise<string> {\n return await this._interface.createPurchaseUrl({\n customer_id: options.customerId,\n offer_id: options.offerId,\n });\n }\n\n async createItemQuantityChange(options: { customerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }): Promise<{ id: string }> {\n const res = await this._interface.createItemQuantityChange({\n customer_id: options.customerId,\n item_id: options.itemId,\n quantity: options.quantity,\n expires_at: options.expiresAt,\n description: options.description,\n });\n return res;\n }\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAoC;AACpC,6BAAwC;AAKxC,oBAA8C;AAC9C,qBAAqB;AACrB,qBAAuB;AACvB,mBAAwB;AAExB,oBAAqD;AAErD,+BAAwK;AACxK,yBAAigB;AACjgB,sBAA4G;AAE5G,IAAAA,iBAAsK;AACtK,6BAA8C;AAK9C,IAAAA,iBAA8B;AAEvB,IAAM,+BAAN,cAAoG,qDAC3G;AAAA,EAsCE,YAAY,SAAoE;AAC9E,UAAM;AAAA,MACJ,WAAW,IAAI,wCAAoB;AAAA,QACjC,YAAY,UAAM,2BAAW,QAAQ,OAAO;AAAA,QAC5C,WAAW,QAAQ,iBAAa,oCAAoB;AAAA,QACpD,qBAAqB,QAAQ,uBAAuB,CAAC;AAAA,QACrD;AAAA,QACA,GAAG,yBAAyB,UAAU;AAAA,UACpC,qBAAqB,QAAQ;AAAA,QAC/B,IAAI;AAAA,UACF,sBAAsB,QAAQ,4BAAwB,+CAA+B;AAAA,UACrF,iBAAiB,QAAQ,uBAAmB,0CAA0B;AAAA,UACtE,qBAAqB,QAA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AK,WAAW,kBAAkB;AAAA,MAC7C,aAAa,QAAQ;AAAA,MACrB,UAAU,QAAQ;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,yBAAyB,SAAsI;AACnK,UAAM,MAAM,MAAM,KAAK,WAAW,yBAAyB;AAAA,MACzD,aAAa,QAAQ;AAAA,MACrB,SAAS,QAAQ;AAAA,MACjB,UAAU,QAAQ;AAAA,MAClB,YAAY,QAAQ;AAAA,MACpB,aAAa,QAAQ;AAAA,IACvB,CAAC;AACD,WAAO;AAAA,EACT;AAEF;","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 { InternalApiKeyCreateCrudResponse } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { EmailTemplateCrud } from \"@stackframe/stack-shared/dist/interface/crud/email-templates\";\nimport { InternalApiKeysCrud } from \"@stackframe/stack-shared/dist/interface/crud/internal-api-keys\";\nimport { ProjectsCrud } 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, CurrentUser } from \"../..\";\nimport { EmailConfig, stackAppInternalsSymbol } from \"../../common\";\nimport { AdminEmailTemplate } from \"../../email-templates\";\nimport { InternalApiKey, InternalApiKeyBase, InternalApiKeyBaseCrudRead, InternalApiKeyCreateOptions, InternalApiKeyFirstView, internalApiKeyCreateOptionsToCrud } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, adminProjectPermissionDefinitionCreateOptionsToCrud, adminProjectPermissionDefinitionUpdateOptionsToCrud, 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 { CompleteConfig, EnvironmentConfigOverrideOverride } from \"@stackframe/stack-shared/dist/config/schema\";\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { ConfigCrud } from \"@stackframe/stack-shared/dist/interface/crud/config\";\nimport { useAsyncCache } from \"./common\"; // THIS_LINE_PLATFORM react-like\n\nexport class _StackAdminAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackServerAppImplIncomplete<HasTokenStore, ProjectId> implements StackAdminApp<HasTokenStore, ProjectId> {\n declare protected _interface: StackAdminInterface;\n\n private readonly _adminProjectCache = createCache(async () => {\n return await this._interface.getProject();\n });\n private readonly _internalApiKeysCache = createCache(async () => {\n const res = await this._interface.listInternalApiKeys();\n return res;\n });\n private readonly _adminEmailThemeCache = createCache(async ([id]: [string]) => {\n return await this._interface.getEmailTheme(id);\n });\n private readonly _adminEmailThemesCache = createCache(async () => {\n return await this._interface.listEmailThemes();\n });\n private readonly _adminEmailTemplatesCache = createCache(async () => {\n return await this._interface.listInternalEmailTemplates();\n });\n private readonly _adminTeamPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listTeamPermissionDefinitions();\n });\n private readonly _adminProjectPermissionDefinitionsCache = createCache(async () => {\n return await this._interface.listProjectPermissionDefinitions();\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 private readonly _emailPreviewCache = createCache(async ([themeId, themeTsxSource, templateId, templateTsxSource]: [string | null | false | undefined, string | undefined, string | undefined, string | undefined]) => {\n return await this._interface.renderEmailPreview({ themeId, themeTsxSource, templateId, templateTsxSource });\n });\n private readonly _configOverridesCache = createCache(async () => {\n return await this._interface.getConfig();\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 _adminConfigFromCrud(data: ConfigCrud['Admin']['Read']): CompleteConfig {\n return JSON.parse(data.config_string);\n }\n\n _adminOwnedProjectFromCrud(data: ProjectsCrud['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: ProjectsCrud['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 isProductionMode: data.is_production_mode,\n ownerTeamId: data.owner_team_id,\n logoUrl: data.logo_url,\n fullLogoUrl: data.full_logo_url,\n config: {\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 allowUserApiKeys: data.config.allow_user_api_keys,\n allowTeamApiKeys: data.config.allow_team_api_keys,\n oauthProviders: data.config.oauth_providers.map((p) => ((p.type === 'shared' ? {\n id: p.id,\n type: 'shared',\n } as const : {\n id: p.id,\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 emailTheme: data.config.email_theme,\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 userDefaultPermissions: data.config.user_default_permissions,\n },\n async getConfig() {\n return app._adminConfigFromCrud(await app._interface.getConfig());\n },\n useConfig() {\n const config = useAsyncCache(app._configOverridesCache, [], \"useConfig()\");\n return useMemo(() => app._adminConfigFromCrud(config), [config]);\n },\n async updateConfig(configOverride: EnvironmentConfigOverrideOverride) {\n await app._interface.updateConfig({ configOverride });\n await app._configOverridesCache.refresh([]);\n },\n async update(update: AdminProjectUpdateOptions) {\n const updateOptions = adminProjectUpdateOptionsToCrud(update);\n await app._interface.updateProject(updateOptions);\n await onRefresh();\n },\n async delete() {\n await app._interface.deleteProject();\n },\n async transfer(user: CurrentUser, newTeamId: string) {\n await app._interface.transferProject(user._internalSession, newTeamId);\n await onRefresh();\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 _createInternalApiKeyBaseFromCrud(data: InternalApiKeyBaseCrudRead): InternalApiKeyBase {\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.revokeInternalApiKeyById(data.id);\n await app._refreshInternalApiKeys();\n return res;\n }\n };\n }\n\n protected _createInternalApiKeyFromCrud(data: InternalApiKeysCrud[\"Admin\"][\"Read\"]): InternalApiKey {\n return {\n ...this._createInternalApiKeyBaseFromCrud(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 _createInternalApiKeyFirstViewFromCrud(data: InternalApiKeyCreateCrudResponse): InternalApiKeyFirstView {\n return {\n ...this._createInternalApiKeyBaseFromCrud(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 listInternalApiKeys(): Promise<InternalApiKey[]> {\n const crud = Result.orThrow(await this._internalApiKeysCache.getOrWait([], \"write-only\"));\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }\n\n useInternalApiKeys(): InternalApiKey[] {\n const crud = useAsyncCache(this._internalApiKeysCache, [], \"useInternalApiKeys()\");\n return useMemo(() => {\n return crud.map((j) => this._createInternalApiKeyFromCrud(j));\n }, [crud]);\n }\n\n async createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView> {\n const crud = await this._interface.createInternalApiKey(internalApiKeyCreateOptionsToCrud(options));\n await this._refreshInternalApiKeys();\n return this._createInternalApiKeyFirstViewFromCrud(crud);\n }\n\n\n useEmailThemes(): { id: string, displayName: string }[] {\n const crud = useAsyncCache(this._adminEmailThemesCache, [], \"useEmailThemes()\");\n return useMemo(() => {\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }, [crud]);\n }\n useEmailTemplates(): { id: string, displayName: string, themeId?: string, tsxSource: string }[] {\n const crud = useAsyncCache(this._adminEmailTemplatesCache, [], \"useEmailTemplates()\");\n return useMemo(() => {\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }, [crud]);\n }\n async listEmailThemes(): Promise<{ id: string, displayName: string }[]> {\n const crud = Result.orThrow(await this._adminEmailThemesCache.getOrWait([], \"write-only\"));\n return crud.map((theme) => ({\n id: theme.id,\n displayName: theme.display_name,\n }));\n }\n\n async listEmailTemplates(): Promise<{ id: string, displayName: string, themeId?: string, tsxSource: string }[]> {\n const crud = Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], \"write-only\"));\n return crud.map((template) => ({\n id: template.id,\n displayName: template.display_name,\n themeId: template.theme_id,\n tsxSource: template.tsx_source,\n }));\n }\n\n\n async createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission> {\n const crud = await this._interface.createTeamPermissionDefinition(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.updateTeamPermissionDefinition(permissionId, adminTeamPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminTeamPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteTeamPermissionDefinition(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\n async createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission> {\n const crud = await this._interface.createProjectPermissionDefinition(adminProjectPermissionDefinitionCreateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n return this._serverProjectPermissionDefinitionFromCrud(crud);\n }\n\n async updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions) {\n await this._interface.updateProjectPermissionDefinition(permissionId, adminProjectPermissionDefinitionUpdateOptionsToCrud(data));\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {\n await this._interface.deleteProjectPermissionDefinition(permissionId);\n await this._adminProjectPermissionDefinitionsCache.refresh([]);\n }\n\n async listProjectPermissionDefinitions(): Promise<AdminProjectPermissionDefinition[]> {\n const crud = Result.orThrow(await this._adminProjectPermissionDefinitionsCache.getOrWait([], \"write-only\"));\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(p));\n }\n\n useProjectPermissionDefinitions(): AdminProjectPermissionDefinition[] {\n const crud = useAsyncCache(this._adminProjectPermissionDefinitionsCache, [], \"useProjectPermissions()\");\n return useMemo(() => {\n return crud.map((p) => this._serverProjectPermissionDefinitionFromCrud(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 _refreshInternalApiKeys() {\n await this._internalApiKeysCache.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 async sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void> {\n await this._interface.sendSignInInvitationEmail(email, callbackUrl);\n }\n\n async createEmailTemplate(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTemplate(displayName);\n await this._adminEmailTemplatesCache.refresh([]);\n return result;\n }\n\n async sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }> {\n return await this._interface.sendChatMessage(threadId, contextType, messages, abortSignal);\n }\n\n async saveChatMessage(threadId: string, message: any): Promise<void> {\n await this._interface.saveChatMessage(threadId, message);\n }\n\n async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {\n return await this._interface.listChatMessages(threadId);\n }\n\n async createEmailTheme(displayName: string): Promise<{ id: string }> {\n const result = await this._interface.createEmailTheme(displayName);\n await this._adminEmailThemesCache.refresh([]);\n return result;\n }\n\n async getEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): Promise<string> {\n return (await this._interface.renderEmailPreview(options)).html;\n }\n useEmailPreview(options: { themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }): string {\n const crud = useAsyncCache(this._emailPreviewCache, [options.themeId, options.themeTsxSource, options.templateId, options.templateTsxSource] as const, \"useEmailPreview()\");\n return crud.html;\n }\n useEmailTheme(id: string): { displayName: string, tsxSource: string } {\n const crud = useAsyncCache(this._adminEmailThemeCache, [id] as const, \"useEmailTheme()\");\n return {\n displayName: crud.display_name,\n tsxSource: crud.tsx_source,\n };\n }\n async updateEmailTheme(id: string, tsxSource: string): Promise<void> {\n await this._interface.updateEmailTheme(id, tsxSource);\n }\n async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }> {\n const result = await this._interface.updateEmailTemplate(id, tsxSource, themeId);\n await this._adminEmailTemplatesCache.refresh([]);\n return { renderedHtml: result.rendered_html };\n }\n\n async setupPayments(): Promise<{ url: string }> {\n return await this._interface.setupPayments();\n }\n\n async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {\n return await this._interface.createStripeWidgetAccountSession();\n }\n\n async createPurchaseUrl(options: { customerId: string, offerId: string }): Promise<string> {\n return await this._interface.createPurchaseUrl({\n customer_id: options.customerId,\n offer_id: options.offerId,\n });\n }\n\n async createItemQuantityChange(options: { customerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }): Promise<void> {\n await this._interface.updateItemQuantity(\n options.customerId,\n options.itemId,\n {\n delta: options.quantity,\n expires_at: options.expiresAt,\n description: options.description,\n }\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAoC;AACpC,6BAAwC;AAKxC,oBAA8C;AAC9C,qBAAqB;AACrB,qBAAuB;AACvB,mBAAwB;AAExB,oBAAqD;AAErD,+BAAwK;AACxK,yBAA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