@stackframe/stack 2.7.21 → 2.7.23

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 (145) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -2
  3. package/dist/admin-app-impl-CTQhv9tV.d.ts +395 -0
  4. package/dist/admin-app-impl-DpyRKp1e.d.mts +395 -0
  5. package/dist/components/selected-team-switcher.d.mts +18 -6
  6. package/dist/components/selected-team-switcher.d.ts +18 -6
  7. package/dist/components/team-icon.d.mts +18 -6
  8. package/dist/components/team-icon.d.ts +18 -6
  9. package/dist/components-page/stack-handler.d.mts +18 -6
  10. package/dist/components-page/stack-handler.d.ts +18 -6
  11. package/dist/esm/lib/stack-app/api-keys/index.js +14 -0
  12. package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -0
  13. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +291 -0
  14. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
  15. package/dist/esm/lib/{stack-app.js → stack-app/apps/implementations/client-app-impl.js} +37 -1109
  16. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
  17. package/dist/esm/lib/stack-app/apps/implementations/common.js +142 -0
  18. package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -0
  19. package/dist/esm/lib/stack-app/apps/implementations/index.js +24 -0
  20. package/dist/esm/lib/stack-app/apps/implementations/index.js.map +1 -0
  21. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +527 -0
  22. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
  23. package/dist/esm/lib/stack-app/apps/index.js +16 -0
  24. package/dist/esm/lib/stack-app/apps/index.js.map +1 -0
  25. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +7 -0
  26. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
  27. package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +7 -0
  28. package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
  29. package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +7 -0
  30. package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
  31. package/dist/esm/lib/stack-app/common.js +6 -0
  32. package/dist/esm/lib/stack-app/common.js.map +1 -0
  33. package/dist/esm/lib/stack-app/connected-accounts/index.js +1 -0
  34. package/dist/esm/lib/stack-app/connected-accounts/index.js.map +1 -0
  35. package/dist/esm/lib/stack-app/contact-channels/index.js +39 -0
  36. package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -0
  37. package/dist/esm/lib/stack-app/email-templates/index.js +11 -0
  38. package/dist/esm/lib/stack-app/email-templates/index.js.map +1 -0
  39. package/dist/esm/lib/stack-app/index.js +16 -0
  40. package/dist/esm/lib/stack-app/index.js.map +1 -0
  41. package/dist/esm/lib/stack-app/permissions/index.js +20 -0
  42. package/dist/esm/lib/stack-app/permissions/index.js.map +1 -0
  43. package/dist/esm/lib/stack-app/project-configs/index.js +1 -0
  44. package/dist/esm/lib/stack-app/project-configs/index.js.map +1 -0
  45. package/dist/esm/lib/stack-app/projects/index.js +57 -0
  46. package/dist/esm/lib/stack-app/projects/index.js.map +1 -0
  47. package/dist/esm/lib/stack-app/teams/index.js +38 -0
  48. package/dist/esm/lib/stack-app/teams/index.js.map +1 -0
  49. package/dist/esm/lib/stack-app/users/index.js +47 -0
  50. package/dist/esm/lib/stack-app/users/index.js.map +1 -0
  51. package/dist/generated/quetzal-translations.d.mts +2 -2
  52. package/dist/generated/quetzal-translations.d.ts +2 -2
  53. package/dist/{lib/stack-app.d.mts → index-C7D6Vt7X.d.mts} +138 -354
  54. package/dist/{lib/stack-app.d.ts → index-DQk7XJpU.d.ts} +138 -354
  55. package/dist/index.d.mts +17 -5
  56. package/dist/index.d.ts +17 -5
  57. package/dist/lib/hooks.d.mts +17 -5
  58. package/dist/lib/hooks.d.ts +17 -5
  59. package/dist/lib/stack-app/api-keys/index.d.mts +40 -0
  60. package/dist/lib/stack-app/api-keys/index.d.ts +40 -0
  61. package/dist/lib/stack-app/api-keys/index.js +39 -0
  62. package/dist/lib/stack-app/api-keys/index.js.map +1 -0
  63. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.mts +30 -0
  64. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +30 -0
  65. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +316 -0
  66. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
  67. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.mts +30 -0
  68. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +30 -0
  69. package/dist/lib/{stack-app.js → stack-app/apps/implementations/client-app-impl.js} +75 -1152
  70. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
  71. package/dist/lib/stack-app/apps/implementations/common.d.mts +45 -0
  72. package/dist/lib/stack-app/apps/implementations/common.d.ts +45 -0
  73. package/dist/lib/stack-app/apps/implementations/common.js +187 -0
  74. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -0
  75. package/dist/lib/stack-app/apps/implementations/index.d.mts +36 -0
  76. package/dist/lib/stack-app/apps/implementations/index.d.ts +36 -0
  77. package/dist/lib/stack-app/apps/implementations/index.js +51 -0
  78. package/dist/lib/stack-app/apps/implementations/index.js.map +1 -0
  79. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.mts +30 -0
  80. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts +30 -0
  81. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +552 -0
  82. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
  83. package/dist/lib/stack-app/apps/index.d.mts +23 -0
  84. package/dist/lib/stack-app/apps/index.d.ts +23 -0
  85. package/dist/lib/stack-app/apps/index.js +37 -0
  86. package/dist/lib/stack-app/apps/index.js.map +1 -0
  87. package/dist/lib/stack-app/apps/interfaces/admin-app.d.mts +23 -0
  88. package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +23 -0
  89. package/dist/lib/stack-app/apps/interfaces/admin-app.js +32 -0
  90. package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
  91. package/dist/lib/stack-app/apps/interfaces/client-app.d.mts +23 -0
  92. package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +23 -0
  93. package/dist/lib/stack-app/apps/interfaces/client-app.js +32 -0
  94. package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
  95. package/dist/lib/stack-app/apps/interfaces/server-app.d.mts +23 -0
  96. package/dist/lib/stack-app/apps/interfaces/server-app.d.ts +23 -0
  97. package/dist/lib/stack-app/apps/interfaces/server-app.js +32 -0
  98. package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
  99. package/dist/lib/stack-app/common.d.mts +63 -0
  100. package/dist/lib/stack-app/common.d.ts +63 -0
  101. package/dist/lib/stack-app/common.js +31 -0
  102. package/dist/lib/stack-app/common.js.map +1 -0
  103. package/dist/lib/stack-app/connected-accounts/index.d.mts +13 -0
  104. package/dist/lib/stack-app/connected-accounts/index.d.ts +13 -0
  105. package/dist/lib/stack-app/connected-accounts/index.js +19 -0
  106. package/dist/lib/stack-app/connected-accounts/index.js.map +1 -0
  107. package/dist/lib/stack-app/contact-channels/index.d.mts +38 -0
  108. package/dist/lib/stack-app/contact-channels/index.d.ts +38 -0
  109. package/dist/lib/stack-app/contact-channels/index.js +67 -0
  110. package/dist/lib/stack-app/contact-channels/index.js.map +1 -0
  111. package/dist/lib/stack-app/email-templates/index.d.mts +15 -0
  112. package/dist/lib/stack-app/email-templates/index.d.ts +15 -0
  113. package/dist/lib/stack-app/email-templates/index.js +36 -0
  114. package/dist/lib/stack-app/email-templates/index.js.map +1 -0
  115. package/dist/lib/stack-app/index.d.mts +23 -0
  116. package/dist/lib/stack-app/index.d.ts +23 -0
  117. package/dist/lib/stack-app/index.js +38 -0
  118. package/dist/lib/stack-app/index.js.map +1 -0
  119. package/dist/lib/stack-app/permissions/index.d.mts +21 -0
  120. package/dist/lib/stack-app/permissions/index.d.ts +21 -0
  121. package/dist/lib/stack-app/permissions/index.js +46 -0
  122. package/dist/lib/stack-app/permissions/index.js.map +1 -0
  123. package/dist/lib/stack-app/project-configs/index.d.mts +82 -0
  124. package/dist/lib/stack-app/project-configs/index.d.ts +82 -0
  125. package/dist/lib/stack-app/project-configs/index.js +19 -0
  126. package/dist/lib/stack-app/project-configs/index.js.map +1 -0
  127. package/dist/lib/stack-app/projects/index.d.mts +23 -0
  128. package/dist/lib/stack-app/projects/index.d.ts +23 -0
  129. package/dist/lib/stack-app/projects/index.js +83 -0
  130. package/dist/lib/stack-app/projects/index.js.map +1 -0
  131. package/dist/lib/stack-app/teams/index.d.mts +23 -0
  132. package/dist/lib/stack-app/teams/index.d.ts +23 -0
  133. package/dist/lib/stack-app/teams/index.js +66 -0
  134. package/dist/lib/stack-app/teams/index.js.map +1 -0
  135. package/dist/lib/stack-app/users/index.d.mts +23 -0
  136. package/dist/lib/stack-app/users/index.d.ts +23 -0
  137. package/dist/lib/stack-app/users/index.js +74 -0
  138. package/dist/lib/stack-app/users/index.js.map +1 -0
  139. package/dist/providers/stack-provider-client.d.mts +17 -5
  140. package/dist/providers/stack-provider-client.d.ts +17 -5
  141. package/dist/providers/stack-provider.d.mts +18 -6
  142. package/dist/providers/stack-provider.d.ts +18 -6
  143. package/package.json +4 -4
  144. package/dist/esm/lib/stack-app.js.map +0 -1
  145. package/dist/lib/stack-app.js.map +0 -1
@@ -1,111 +1,22 @@
1
1
  import { KnownErrors } from '@stackframe/stack-shared';
2
- import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
3
- import { ApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/api-keys';
4
2
  import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
3
+ import { Result } from '@stackframe/stack-shared/dist/utils/results';
4
+ import { AsyncStoreProperty, GetUserOptions, EmailConfig, HandlerUrls, OAuthScopesOnSignIn, TokenStoreInit, RedirectMethod, stackAppInternalsSymbol, RedirectToOptions } from './lib/stack-app/common.mjs';
5
+ import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
6
+ import { ProjectsCrud, InternalProjectsCrud } from '@stackframe/stack-shared/dist/interface/crud/projects';
5
7
  import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
6
- import { TeamPermissionDefinitionsCrud } from '@stackframe/stack-shared/dist/interface/crud/team-permissions';
7
8
  import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
9
+ import { ApiKey, ApiKeyCreateOptions, ApiKeyFirstView } from './lib/stack-app/api-keys/index.mjs';
10
+ import { AdminEmailTemplate, AdminEmailTemplateUpdateOptions } from './lib/stack-app/email-templates/index.mjs';
11
+ import { TeamPermission, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from './lib/stack-app/permissions/index.mjs';
12
+ import { TeamsCrud } from '@stackframe/stack-shared/dist/interface/crud/teams';
8
13
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
14
+ import { UsersCrud } from '@stackframe/stack-shared/dist/interface/crud/users';
9
15
  import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
10
- import { Result } from '@stackframe/stack-shared/dist/utils/results';
16
+ import { OAuthConnection } from './lib/stack-app/connected-accounts/index.mjs';
17
+ import { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from './lib/stack-app/contact-channels/index.mjs';
18
+ import { ProjectConfig, AdminProjectConfig, AdminProjectConfigUpdateOptions } from './lib/stack-app/project-configs/index.mjs';
11
19
 
12
- type RequestLike = {
13
- headers: {
14
- get: (name: string) => string | null;
15
- };
16
- };
17
- type RedirectMethod = "window" | "nextjs" | "none" | {
18
- useNavigate: () => (to: string) => void;
19
- navigate?: (to: string) => void;
20
- };
21
- type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
22
- accessToken: string;
23
- refreshToken: string;
24
- }) : HasTokenStore extends false ? null : TokenStoreInit<true> | TokenStoreInit<false>;
25
- type HandlerUrls = {
26
- handler: string;
27
- signIn: string;
28
- signUp: string;
29
- afterSignIn: string;
30
- afterSignUp: string;
31
- signOut: string;
32
- afterSignOut: string;
33
- emailVerification: string;
34
- passwordReset: string;
35
- forgotPassword: string;
36
- home: string;
37
- oauthCallback: string;
38
- magicLinkCallback: string;
39
- accountSettings: string;
40
- teamInvitation: string;
41
- error: string;
42
- };
43
- type OAuthScopesOnSignIn = {
44
- [key in ProviderType]: string[];
45
- };
46
- type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
47
- type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
48
- type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
49
- baseUrl?: string | {
50
- browser: string;
51
- server: string;
52
- };
53
- projectId?: ProjectId;
54
- publishableClientKey?: string;
55
- urls?: Partial<HandlerUrls>;
56
- oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
57
- tokenStore: TokenStoreInit<HasTokenStore>;
58
- redirectMethod?: RedirectMethod;
59
- /**
60
- * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
61
- * constructed. This improves the performance of your app, but will create network requests that are unnecessary if
62
- * the app is never used or disposed of immediately. To disable this behavior, set this option to true.
63
- */
64
- noAutomaticPrefetch?: boolean;
65
- };
66
- type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
67
- secretServerKey?: string;
68
- };
69
- type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
70
- superSecretAdminKey?: string;
71
- }) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
72
- projectOwnerSession: InternalSession;
73
- }));
74
- type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
75
- uniqueIdentifier: string;
76
- };
77
- /** @internal */
78
- declare const stackAppInternalsSymbol: unique symbol;
79
- type ContactChannel = {
80
- id: string;
81
- value: string;
82
- type: 'email';
83
- isPrimary: boolean;
84
- isVerified: boolean;
85
- usedForAuth: boolean;
86
- sendVerificationEmail(): Promise<void>;
87
- update(data: ContactChannelUpdateOptions): Promise<void>;
88
- delete(): Promise<void>;
89
- };
90
- type ContactChannelCreateOptions = {
91
- value: string;
92
- type: 'email';
93
- usedForAuth: boolean;
94
- };
95
- type ContactChannelUpdateOptions = {
96
- usedForAuth?: boolean;
97
- value?: string;
98
- isPrimary?: boolean;
99
- };
100
- type ServerContactChannel = ContactChannel & {
101
- update(data: ServerContactChannelUpdateOptions): Promise<void>;
102
- };
103
- type ServerContactChannelUpdateOptions = ContactChannelUpdateOptions & {
104
- isVerified?: boolean;
105
- };
106
- type ServerContactChannelCreateOptions = ContactChannelCreateOptions & {
107
- isVerified?: boolean;
108
- };
109
20
  type Session = {
110
21
  getTokens(): Promise<{
111
22
  accessToken: string | null;
@@ -302,11 +213,12 @@ type UserExtra = {
302
213
  type InternalUserExtra = {
303
214
  createProject(newProject: AdminProjectUpdateOptions & {
304
215
  displayName: string;
305
- }): Promise<AdminProject>;
216
+ }): Promise<AdminOwnedProject>;
306
217
  } & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
307
218
  type User = BaseUser;
308
219
  type CurrentUser = BaseUser & Auth & UserExtra;
309
220
  type CurrentInternalUser = CurrentUser & InternalUserExtra;
221
+ type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
310
222
  type UserUpdateOptions = {
311
223
  displayName?: string;
312
224
  clientMetadata?: ReadonlyJson;
@@ -316,6 +228,7 @@ type UserUpdateOptions = {
316
228
  otpAuthEnabled?: boolean;
317
229
  passkeyAuthEnabled?: boolean;
318
230
  };
231
+ declare function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud["Client"]["Update"];
319
232
  type ServerBaseUser = {
320
233
  setPrimaryEmail(email: string | null, options?: {
321
234
  verified?: boolean | undefined;
@@ -349,6 +262,7 @@ type ServerBaseUser = {
349
262
  type ServerUser = ServerBaseUser & BaseUser & UserExtra;
350
263
  type CurrentServerUser = Auth & ServerUser;
351
264
  type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
265
+ type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
352
266
  type ServerUserUpdateOptions = {
353
267
  primaryEmail?: string | null;
354
268
  primaryEmailVerified?: boolean;
@@ -357,6 +271,7 @@ type ServerUserUpdateOptions = {
357
271
  serverMetadata?: ReadonlyJson;
358
272
  password?: string;
359
273
  } & UserUpdateOptions;
274
+ declare function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud["Server"]["Update"];
360
275
  type ServerUserCreateOptions = {
361
276
  primaryEmail?: string | null;
362
277
  primaryEmailAuthEnabled?: boolean;
@@ -368,147 +283,8 @@ type ServerUserCreateOptions = {
368
283
  clientReadOnlyMetadata?: any;
369
284
  serverMetadata?: any;
370
285
  };
371
- type Project = {
372
- readonly id: string;
373
- readonly displayName: string;
374
- readonly config: ProjectConfig;
375
- };
376
- type AdminProject = {
377
- readonly id: string;
378
- readonly displayName: string;
379
- readonly description: string | null;
380
- readonly createdAt: Date;
381
- readonly userCount: number;
382
- readonly isProductionMode: boolean;
383
- readonly config: AdminProjectConfig;
384
- update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
385
- delete(this: AdminProject): Promise<void>;
386
- getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
387
- useProductionModeErrors(this: AdminProject): ProductionModeError[];
388
- } & Project;
389
- type AdminOwnedProject = {
390
- readonly app: StackAdminApp<false>;
391
- } & AdminProject;
392
- type AdminProjectUpdateOptions = {
393
- displayName?: string;
394
- description?: string;
395
- isProductionMode?: boolean;
396
- config?: AdminProjectConfigUpdateOptions;
397
- };
398
- type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'> & {
399
- displayName: string;
400
- };
401
- type ProjectConfig = {
402
- readonly signUpEnabled: boolean;
403
- readonly credentialEnabled: boolean;
404
- readonly magicLinkEnabled: boolean;
405
- readonly passkeyEnabled: boolean;
406
- readonly clientTeamCreationEnabled: boolean;
407
- readonly clientUserDeletionEnabled: boolean;
408
- readonly oauthProviders: OAuthProviderConfig[];
409
- };
410
- type OAuthProviderConfig = {
411
- readonly id: string;
412
- };
413
- type AdminProjectConfig = {
414
- readonly id: string;
415
- readonly signUpEnabled: boolean;
416
- readonly credentialEnabled: boolean;
417
- readonly magicLinkEnabled: boolean;
418
- readonly passkeyEnabled: boolean;
419
- readonly clientTeamCreationEnabled: boolean;
420
- readonly clientUserDeletionEnabled: boolean;
421
- readonly allowLocalhost: boolean;
422
- readonly oauthProviders: AdminOAuthProviderConfig[];
423
- readonly emailConfig?: AdminEmailConfig;
424
- readonly domains: AdminDomainConfig[];
425
- readonly createTeamOnSignUp: boolean;
426
- readonly teamCreatorDefaultPermissions: AdminTeamPermission[];
427
- readonly teamMemberDefaultPermissions: AdminTeamPermission[];
428
- };
429
- type AdminEmailConfig = ({
430
- type: "standard";
431
- senderName: string;
432
- senderEmail: string;
433
- host: string;
434
- port: number;
435
- username: string;
436
- password: string;
437
- } | {
438
- type: "shared";
439
- });
440
- type AdminDomainConfig = {
441
- domain: string;
442
- handlerPath: string;
443
- };
444
- type AdminOAuthProviderConfig = {
445
- id: string;
446
- enabled: boolean;
447
- } & ({
448
- type: 'shared';
449
- } | {
450
- type: 'standard';
451
- clientId: string;
452
- clientSecret: string;
453
- facebookConfigId?: string;
454
- microsoftTenantId?: string;
455
- }) & OAuthProviderConfig;
456
- type AdminProjectConfigUpdateOptions = {
457
- domains?: {
458
- domain: string;
459
- handlerPath: string;
460
- }[];
461
- oauthProviders?: AdminOAuthProviderConfig[];
462
- signUpEnabled?: boolean;
463
- credentialEnabled?: boolean;
464
- magicLinkEnabled?: boolean;
465
- passkeyEnabled?: boolean;
466
- clientTeamCreationEnabled?: boolean;
467
- clientUserDeletionEnabled?: boolean;
468
- allowLocalhost?: boolean;
469
- createTeamOnSignUp?: boolean;
470
- emailConfig?: AdminEmailConfig;
471
- teamCreatorDefaultPermissions?: {
472
- id: string;
473
- }[];
474
- teamMemberDefaultPermissions?: {
475
- id: string;
476
- }[];
477
- };
478
- type ApiKeyBase = {
479
- id: string;
480
- description: string;
481
- expiresAt: Date;
482
- manuallyRevokedAt: Date | null;
483
- createdAt: Date;
484
- isValid(): boolean;
485
- whyInvalid(): "expired" | "manually-revoked" | null;
486
- revoke(): Promise<void>;
487
- };
488
- type ApiKeyBaseCrudRead = Pick<ApiKeysCrud["Admin"]["Read"], "id" | "created_at_millis" | "description" | "expires_at_millis" | "manually_revoked_at_millis">;
489
- type ApiKeyFirstView = {
490
- publishableClientKey?: string;
491
- secretServerKey?: string;
492
- superSecretAdminKey?: string;
493
- } & ApiKeyBase;
494
- type ApiKey = {
495
- publishableClientKey: null | {
496
- lastFour: string;
497
- };
498
- secretServerKey: null | {
499
- lastFour: string;
500
- };
501
- superSecretAdminKey: null | {
502
- lastFour: string;
503
- };
504
- } & ApiKeyBase;
505
- type ApiKeyCreateOptions = {
506
- description: string;
507
- expiresAt: Date;
508
- hasPublishableClientKey: boolean;
509
- hasSecretServerKey: boolean;
510
- hasSuperSecretAdminKey: boolean;
511
- };
286
+ declare function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud["Server"]["Create"];
287
+
512
288
  type TeamMemberProfile = {
513
289
  displayName: string | null;
514
290
  profileImageUrl: string | null;
@@ -552,10 +328,12 @@ type TeamUpdateOptions = {
552
328
  profileImageUrl?: string | null;
553
329
  clientMetadata?: ReadonlyJson;
554
330
  };
331
+ declare function teamUpdateOptionsToCrud(options: TeamUpdateOptions): TeamsCrud["Client"]["Update"];
555
332
  type TeamCreateOptions = {
556
333
  displayName: string;
557
334
  profileImageUrl?: string;
558
335
  };
336
+ declare function teamCreateOptionsToCrud(options: TeamCreateOptions, creatorUserId: string): TeamsCrud["Client"]["Create"];
559
337
  type ServerTeamMemberProfile = TeamMemberProfile;
560
338
  type ServerTeamUser = ServerUser & {
561
339
  teamProfile: ServerTeamMemberProfile;
@@ -584,44 +362,132 @@ type ServerListUsersOptions = {
584
362
  type ServerTeamCreateOptions = TeamCreateOptions & {
585
363
  creatorUserId?: string;
586
364
  };
365
+ declare function serverTeamCreateOptionsToCrud(options: ServerTeamCreateOptions): TeamsCrud["Server"]["Create"];
587
366
  type ServerTeamUpdateOptions = TeamUpdateOptions & {
588
367
  clientReadOnlyMetadata?: ReadonlyJson;
589
368
  serverMetadata?: ReadonlyJson;
590
369
  };
591
- type TeamPermission = {
592
- id: string;
370
+ declare function serverTeamUpdateOptionsToCrud(options: ServerTeamUpdateOptions): TeamsCrud["Server"]["Update"];
371
+
372
+ type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
373
+ secretServerKey?: string;
593
374
  };
594
- type AdminTeamPermission = TeamPermission;
595
- type AdminTeamPermissionDefinition = {
596
- id: string;
597
- description?: string;
598
- containedPermissionIds: string[];
375
+ type StackServerAppConstructor = {
376
+ new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>;
377
+ new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>;
599
378
  };
600
- type AdminTeamPermissionDefinitionCreateOptions = {
601
- id: string;
379
+ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
380
+ createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam>;
381
+ /**
382
+ * @deprecated use `getUser()` instead
383
+ */
384
+ getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
385
+ createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
386
+ useUser(options: GetUserOptions<HasTokenStore> & {
387
+ or: 'redirect';
388
+ }): ProjectCurrentServerUser<ProjectId>;
389
+ useUser(options: GetUserOptions<HasTokenStore> & {
390
+ or: 'throw';
391
+ }): ProjectCurrentServerUser<ProjectId>;
392
+ useUser(options?: GetUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;
393
+ getUser(options: GetUserOptions<HasTokenStore> & {
394
+ or: 'redirect';
395
+ }): Promise<ProjectCurrentServerUser<ProjectId>>;
396
+ getUser(options: GetUserOptions<HasTokenStore> & {
397
+ or: 'throw';
398
+ }): Promise<ProjectCurrentServerUser<ProjectId>>;
399
+ getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
400
+ useUsers(options?: ServerListUsersOptions): ServerUser[] & {
401
+ nextCursor: string | null;
402
+ };
403
+ listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
404
+ nextCursor: string | null;
405
+ }>;
406
+ } & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
407
+ declare const StackServerApp: StackServerAppConstructor;
408
+
409
+ type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
410
+ superSecretAdminKey?: string;
411
+ }) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
412
+ projectOwnerSession: InternalSession;
413
+ }));
414
+ type StackAdminAppConstructor = {
415
+ new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
416
+ new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
417
+ };
418
+ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"apiKeys", [], ApiKey[], true> & AsyncStoreProperty<"teamPermissionDefinitions", [], AdminTeamPermissionDefinition[], true> & {
419
+ useEmailTemplates(): AdminEmailTemplate[];
420
+ listEmailTemplates(): Promise<AdminEmailTemplate[]>;
421
+ updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void>;
422
+ resetEmailTemplate(type: EmailTemplateType): Promise<void>;
423
+ createApiKey(options: ApiKeyCreateOptions): Promise<ApiKeyFirstView>;
424
+ createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
425
+ updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
426
+ deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
427
+ useSvixToken(): string;
428
+ sendTestEmail(options: {
429
+ recipientEmail: string;
430
+ emailConfig: EmailConfig;
431
+ }): Promise<Result<undefined, {
432
+ errorMessage: string;
433
+ }>>;
434
+ } & StackServerApp<HasTokenStore, ProjectId>);
435
+ declare const StackAdminApp: StackAdminAppConstructor;
436
+
437
+ type Project = {
438
+ readonly id: string;
439
+ readonly displayName: string;
440
+ readonly config: ProjectConfig;
441
+ };
442
+ type AdminProject = {
443
+ readonly id: string;
444
+ readonly displayName: string;
445
+ readonly description: string | null;
446
+ readonly createdAt: Date;
447
+ readonly userCount: number;
448
+ readonly isProductionMode: boolean;
449
+ readonly config: AdminProjectConfig;
450
+ update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
451
+ delete(this: AdminProject): Promise<void>;
452
+ getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
453
+ useProductionModeErrors(this: AdminProject): ProductionModeError[];
454
+ } & Project;
455
+ type AdminOwnedProject = {
456
+ readonly app: StackAdminApp<false>;
457
+ } & AdminProject;
458
+ type AdminProjectUpdateOptions = {
459
+ displayName?: string;
602
460
  description?: string;
603
- containedPermissionIds: string[];
461
+ isProductionMode?: boolean;
462
+ config?: AdminProjectConfigUpdateOptions;
604
463
  };
605
- declare function serverTeamPermissionDefinitionCreateOptionsToCrud(options: AdminTeamPermissionDefinitionCreateOptions): TeamPermissionDefinitionsCrud["Admin"]["Create"];
606
- type AdminTeamPermissionDefinitionUpdateOptions = Partial<AdminTeamPermissionDefinitionCreateOptions>;
607
- declare function serverTeamPermissionDefinitionUpdateOptionsToCrud(options: AdminTeamPermissionDefinitionUpdateOptions): TeamPermissionDefinitionsCrud["Admin"]["Update"];
608
- type Connection = {
609
- id: string;
464
+ declare function adminProjectUpdateOptionsToCrud(options: AdminProjectUpdateOptions): ProjectsCrud["Admin"]["Update"];
465
+ type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'> & {
466
+ displayName: string;
610
467
  };
611
- type OAuthConnection = {
612
- getAccessToken(): Promise<{
613
- accessToken: string;
614
- }>;
615
- useAccessToken(): {
616
- accessToken: string;
468
+ declare function adminProjectCreateOptionsToCrud(options: AdminProjectCreateOptions): InternalProjectsCrud["Server"]["Create"];
469
+
470
+ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
471
+ baseUrl?: string | {
472
+ browser: string;
473
+ server: string;
617
474
  };
618
- } & Connection;
619
- type GetUserOptions<HasTokenStore> = {
620
- or?: 'redirect' | 'throw' | 'return-null';
621
- tokenStore?: TokenStoreInit;
622
- } & (HasTokenStore extends false ? {
623
- tokenStore: TokenStoreInit;
624
- } : {});
475
+ projectId?: ProjectId;
476
+ publishableClientKey?: string;
477
+ urls?: Partial<HandlerUrls>;
478
+ oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
479
+ tokenStore: TokenStoreInit<HasTokenStore>;
480
+ redirectMethod?: RedirectMethod;
481
+ /**
482
+ * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
483
+ * constructed. This improves the performance of your app, but will create network requests that are unnecessary if
484
+ * the app is never used or disposed of immediately. To disable this behavior, set this option to true.
485
+ */
486
+ noAutomaticPrefetch?: boolean;
487
+ };
488
+ type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
489
+ uniqueIdentifier: string;
490
+ };
625
491
  type StackClientAppConstructor = {
626
492
  new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>;
627
493
  new (options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>;
@@ -690,87 +556,5 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
690
556
  [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
691
557
  });
692
558
  declare const StackClientApp: StackClientAppConstructor;
693
- type StackServerAppConstructor = {
694
- new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>;
695
- new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>;
696
- };
697
- type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
698
- createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam>;
699
- /**
700
- * @deprecated use `getUser()` instead
701
- */
702
- getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
703
- createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
704
- useUser(options: GetUserOptions<HasTokenStore> & {
705
- or: 'redirect';
706
- }): ProjectCurrentServerUser<ProjectId>;
707
- useUser(options: GetUserOptions<HasTokenStore> & {
708
- or: 'throw';
709
- }): ProjectCurrentServerUser<ProjectId>;
710
- useUser(options?: GetUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;
711
- getUser(options: GetUserOptions<HasTokenStore> & {
712
- or: 'redirect';
713
- }): Promise<ProjectCurrentServerUser<ProjectId>>;
714
- getUser(options: GetUserOptions<HasTokenStore> & {
715
- or: 'throw';
716
- }): Promise<ProjectCurrentServerUser<ProjectId>>;
717
- getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
718
- useUsers(options?: ServerListUsersOptions): ServerUser[] & {
719
- nextCursor: string | null;
720
- };
721
- listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
722
- nextCursor: string | null;
723
- }>;
724
- } & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
725
- declare const StackServerApp: StackServerAppConstructor;
726
- type StackAdminAppConstructor = {
727
- new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
728
- new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
729
- };
730
- type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"apiKeys", [], ApiKey[], true> & AsyncStoreProperty<"teamPermissionDefinitions", [], AdminTeamPermissionDefinition[], true> & {
731
- useEmailTemplates(): AdminEmailTemplate[];
732
- listEmailTemplates(): Promise<AdminEmailTemplate[]>;
733
- updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void>;
734
- resetEmailTemplate(type: EmailTemplateType): Promise<void>;
735
- createApiKey(options: ApiKeyCreateOptions): Promise<ApiKeyFirstView>;
736
- createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
737
- updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
738
- deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
739
- useSvixToken(): string;
740
- sendTestEmail(options: {
741
- recipientEmail: string;
742
- emailConfig: EmailConfig;
743
- }): Promise<Result<undefined, {
744
- errorMessage: string;
745
- }>>;
746
- } & StackServerApp<HasTokenStore, ProjectId>);
747
- declare const StackAdminApp: StackAdminAppConstructor;
748
- type AdminEmailTemplate = {
749
- type: EmailTemplateType;
750
- subject: string;
751
- content: any;
752
- isDefault: boolean;
753
- };
754
- type AdminEmailTemplateUpdateOptions = {
755
- subject?: string;
756
- content?: any;
757
- };
758
- type RedirectToOptions = {
759
- replace?: boolean;
760
- noRedirectBack?: boolean;
761
- };
762
- type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultiple extends boolean> = {
763
- [key in `${IsMultiple extends true ? "list" : "get"}${Capitalize<Name>}`]: (...args: Args) => Promise<Value>;
764
- } & {
765
- [key in `use${Capitalize<Name>}`]: (...args: Args) => Value;
766
- };
767
- type EmailConfig = {
768
- host: string;
769
- port: number;
770
- username: string;
771
- password: string;
772
- senderEmail: string;
773
- senderName: string;
774
- };
775
559
 
776
- export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Connection, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type TokenStoreInit, type User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol };
560
+ export { adminProjectUpdateOptionsToCrud as $, type AdminOwnedProject as A, type CurrentUser as B, type CurrentInternalServerUser as C, type ServerUser as D, type EditableTeamMemberProfile as E, type Session as F, type BaseUser as G, type UserExtra as H, type InternalUserExtra as I, type ProjectCurrentUser as J, type UserUpdateOptions as K, type ProjectCurrentServerUser as L, type ServerUserCreateOptions as M, userUpdateOptionsToCrud as N, type ServerBaseUser as O, type Project as P, type ServerUserUpdateOptions as Q, serverUserUpdateOptionsToCrud as R, StackAdminApp as S, type Team as T, type User as U, serverUserCreateOptionsToCrud as V, type TeamMemberProfileUpdateOptions as W, teamUpdateOptionsToCrud as X, teamCreateOptionsToCrud as Y, serverTeamCreateOptionsToCrud as Z, serverTeamUpdateOptionsToCrud as _, StackClientApp as a, adminProjectCreateOptionsToCrud as a0, StackServerApp as b, type StackAdminAppConstructor as c, type StackAdminAppConstructorOptions as d, type StackClientAppConstructor as e, type StackClientAppConstructorOptions as f, type StackClientAppJson as g, type StackServerAppConstructor as h, type StackServerAppConstructorOptions as i, type AdminProject as j, type AdminProjectCreateOptions as k, type AdminProjectUpdateOptions as l, type ServerListUsersOptions as m, type ServerTeam as n, type ServerTeamCreateOptions as o, type ServerTeamMemberProfile as p, type ServerTeamUpdateOptions as q, type ServerTeamUser as r, type TeamCreateOptions as s, type TeamInvitation as t, type TeamMemberProfile as u, type TeamUpdateOptions as v, type TeamUser as w, type Auth as x, type CurrentInternalUser as y, type CurrentServerUser as z };