@stackframe/js 2.7.23 → 2.7.26

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 (73) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +1 -0
  3. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  4. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +6 -10
  5. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  6. package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
  7. package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
  8. package/dist/esm/lib/stack-app/projects/index.js +2 -1
  9. package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
  10. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  11. package/dist/index.d.mts +748 -23
  12. package/dist/index.d.ts +748 -23
  13. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +1 -0
  14. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  15. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +5 -9
  16. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  17. package/dist/lib/stack-app/apps/implementations/common.js +1 -1
  18. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
  19. package/dist/lib/stack-app/project-configs/index.js.map +1 -1
  20. package/dist/lib/stack-app/projects/index.js +2 -1
  21. package/dist/lib/stack-app/projects/index.js.map +1 -1
  22. package/dist/lib/stack-app/users/index.js.map +1 -1
  23. package/package.json +2 -2
  24. package/dist/admin-app-impl-Co__PI-r.d.ts +0 -357
  25. package/dist/admin-app-impl-s-tPjfRz.d.mts +0 -357
  26. package/dist/index-COYzPcGI.d.mts +0 -526
  27. package/dist/index-CueS5Qbi.d.ts +0 -526
  28. package/dist/lib/auth.d.mts +0 -33
  29. package/dist/lib/auth.d.ts +0 -33
  30. package/dist/lib/cookie.d.mts +0 -33
  31. package/dist/lib/cookie.d.ts +0 -33
  32. package/dist/lib/stack-app/api-keys/index.d.mts +0 -40
  33. package/dist/lib/stack-app/api-keys/index.d.ts +0 -40
  34. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.mts +0 -30
  35. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +0 -30
  36. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.mts +0 -30
  37. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +0 -30
  38. package/dist/lib/stack-app/apps/implementations/common.d.mts +0 -44
  39. package/dist/lib/stack-app/apps/implementations/common.d.ts +0 -44
  40. package/dist/lib/stack-app/apps/implementations/index.d.mts +0 -36
  41. package/dist/lib/stack-app/apps/implementations/index.d.ts +0 -36
  42. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.mts +0 -30
  43. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts +0 -30
  44. package/dist/lib/stack-app/apps/index.d.mts +0 -23
  45. package/dist/lib/stack-app/apps/index.d.ts +0 -23
  46. package/dist/lib/stack-app/apps/interfaces/admin-app.d.mts +0 -23
  47. package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +0 -23
  48. package/dist/lib/stack-app/apps/interfaces/client-app.d.mts +0 -23
  49. package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +0 -23
  50. package/dist/lib/stack-app/apps/interfaces/server-app.d.mts +0 -23
  51. package/dist/lib/stack-app/apps/interfaces/server-app.d.ts +0 -23
  52. package/dist/lib/stack-app/common.d.mts +0 -61
  53. package/dist/lib/stack-app/common.d.ts +0 -61
  54. package/dist/lib/stack-app/connected-accounts/index.d.mts +0 -10
  55. package/dist/lib/stack-app/connected-accounts/index.d.ts +0 -10
  56. package/dist/lib/stack-app/contact-channels/index.d.mts +0 -38
  57. package/dist/lib/stack-app/contact-channels/index.d.ts +0 -38
  58. package/dist/lib/stack-app/email-templates/index.d.mts +0 -15
  59. package/dist/lib/stack-app/email-templates/index.d.ts +0 -15
  60. package/dist/lib/stack-app/index.d.mts +0 -23
  61. package/dist/lib/stack-app/index.d.ts +0 -23
  62. package/dist/lib/stack-app/permissions/index.d.mts +0 -21
  63. package/dist/lib/stack-app/permissions/index.d.ts +0 -21
  64. package/dist/lib/stack-app/project-configs/index.d.mts +0 -82
  65. package/dist/lib/stack-app/project-configs/index.d.ts +0 -82
  66. package/dist/lib/stack-app/projects/index.d.mts +0 -23
  67. package/dist/lib/stack-app/projects/index.d.ts +0 -23
  68. package/dist/lib/stack-app/teams/index.d.mts +0 -23
  69. package/dist/lib/stack-app/teams/index.d.ts +0 -23
  70. package/dist/lib/stack-app/users/index.d.mts +0 -23
  71. package/dist/lib/stack-app/users/index.d.ts +0 -23
  72. package/dist/utils/url.d.mts +0 -3
  73. package/dist/utils/url.d.ts +0 -3
@@ -1,526 +0,0 @@
1
- import { ProjectConfig, AdminProjectConfig, AdminProjectConfigUpdateOptions } from './lib/stack-app/project-configs/index.mjs';
2
- import { ApiKey, ApiKeyCreateOptions, ApiKeyFirstView } from './lib/stack-app/api-keys/index.mjs';
3
- import { AsyncStoreProperty, GetUserOptions, EmailConfig, HandlerUrls, OAuthScopesOnSignIn, TokenStoreInit, RedirectMethod, stackAppInternalsSymbol, RedirectToOptions } from './lib/stack-app/common.mjs';
4
- import { OAuthConnection } from './lib/stack-app/connected-accounts/index.mjs';
5
- import { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from './lib/stack-app/contact-channels/index.mjs';
6
- import { TeamPermission, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from './lib/stack-app/permissions/index.mjs';
7
- import { KnownErrors } from '@stackframe/stack-shared';
8
- import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
9
- import { Result } from '@stackframe/stack-shared/dist/utils/results';
10
- import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
11
- import { ProjectsCrud, InternalProjectsCrud } from '@stackframe/stack-shared/dist/interface/crud/projects';
12
- import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
13
- import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
14
- import { AdminEmailTemplate, AdminEmailTemplateUpdateOptions } from './lib/stack-app/email-templates/index.mjs';
15
- import { TeamsCrud } from '@stackframe/stack-shared/dist/interface/crud/teams';
16
- import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
17
- import { UsersCrud } from '@stackframe/stack-shared/dist/interface/crud/users';
18
- import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
19
-
20
- type Session = {
21
- getTokens(): Promise<{
22
- accessToken: string | null;
23
- refreshToken: string | null;
24
- }>;
25
- };
26
- /**
27
- * Contains everything related to the current user session.
28
- */
29
- type Auth = {
30
- readonly _internalSession: InternalSession;
31
- readonly currentSession: Session;
32
- signOut(options?: {
33
- redirectUrl?: URL | string;
34
- }): Promise<void>;
35
- /**
36
- * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin
37
- * requests. Similar to `getAuthJson`, but specifically for HTTP requests.
38
- *
39
- * If you are using `tokenStore: "cookie"`, you don't need this for same-origin requests. However, most
40
- * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead
41
- * if the client and server are on different hostnames.
42
- *
43
- * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send
44
- * authenticated requests.
45
- *
46
- * On the server, you can then pass in the `Request` object to the `tokenStore` option
47
- * of your Stack app. Please note that CORS does not allow most headers by default, so you
48
- * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)
49
- * of the CORS preflight response.
50
- *
51
- * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function
52
- * instead.
53
- *
54
- * Example:
55
- *
56
- * ```ts
57
- * // client
58
- * const res = await fetch("https://api.example.com", {
59
- * headers: {
60
- * ...await stackApp.getAuthHeaders()
61
- * // you can also add your own headers here
62
- * },
63
- * });
64
- *
65
- * // server
66
- * function handleRequest(req: Request) {
67
- * const user = await stackServerApp.getUser({ tokenStore: req });
68
- * return new Response("Welcome, " + user.displayName);
69
- * }
70
- * ```
71
- */
72
- getAuthHeaders(): Promise<{
73
- "x-stack-auth": string;
74
- }>;
75
- /**
76
- * Creates a JSON-serializable object containing the information to authenticate a user on an external server.
77
- * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just
78
- * HTTP headers.
79
- *
80
- * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use
81
- * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.
82
- *
83
- * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.
84
- *
85
- * Example:
86
- *
87
- * ```ts
88
- * // client
89
- * const res = await rpcCall(rpcEndpoint, {
90
- * data: {
91
- * auth: await stackApp.getAuthJson(),
92
- * },
93
- * });
94
- *
95
- * // server
96
- * function handleRequest(data) {
97
- * const user = await stackServerApp.getUser({ tokenStore: data.auth });
98
- * return new Response("Welcome, " + user.displayName);
99
- * }
100
- * ```
101
- */
102
- getAuthJson(): Promise<{
103
- accessToken: string | null;
104
- refreshToken: string | null;
105
- }>;
106
- registerPasskey(options?: {
107
- hostname?: string;
108
- }): Promise<Result<undefined, KnownErrors["PasskeyRegistrationFailed"] | KnownErrors["PasskeyWebAuthnError"]>>;
109
- };
110
- /**
111
- * ```
112
- * +----------+-------------+-------------------+
113
- * | \ | !Server | Server |
114
- * +----------+-------------+-------------------+
115
- * | !Session | User | ServerUser |
116
- * | Session | CurrentUser | CurrentServerUser |
117
- * +----------+-------------+-------------------+
118
- * ```
119
- *
120
- * The fields on each of these types are available iff:
121
- * BaseUser: true
122
- * Auth: Session
123
- * ServerBaseUser: Server
124
- * UserExtra: Session OR Server
125
- *
126
- * The types are defined as follows (in the typescript manner):
127
- * User = BaseUser
128
- * CurrentUser = BaseUser & Auth & UserExtra
129
- * ServerUser = BaseUser & ServerBaseUser & UserExtra
130
- * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra
131
- **/
132
- type BaseUser = {
133
- readonly id: string;
134
- readonly displayName: string | null;
135
- /**
136
- * The user's email address.
137
- *
138
- * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.
139
- */
140
- readonly primaryEmail: string | null;
141
- readonly primaryEmailVerified: boolean;
142
- readonly profileImageUrl: string | null;
143
- readonly signedUpAt: Date;
144
- readonly clientMetadata: any;
145
- readonly clientReadOnlyMetadata: any;
146
- /**
147
- * Whether the user has a password set.
148
- */
149
- readonly hasPassword: boolean;
150
- readonly otpAuthEnabled: boolean;
151
- readonly passkeyAuthEnabled: boolean;
152
- readonly isMultiFactorRequired: boolean;
153
- toClientJson(): CurrentUserCrud["Client"]["Read"];
154
- /**
155
- * @deprecated, use contact channel's usedForAuth instead
156
- */
157
- readonly emailAuthEnabled: boolean;
158
- /**
159
- * @deprecated
160
- */
161
- readonly oauthProviders: readonly {
162
- id: string;
163
- }[];
164
- };
165
- type UserExtra = {
166
- setDisplayName(displayName: string): Promise<void>;
167
- /** @deprecated Use contact channel's sendVerificationEmail instead */
168
- sendVerificationEmail(): Promise<KnownErrors["EmailAlreadyVerified"] | void>;
169
- setClientMetadata(metadata: any): Promise<void>;
170
- updatePassword(options: {
171
- oldPassword: string;
172
- newPassword: string;
173
- }): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
174
- setPassword(options: {
175
- password: string;
176
- }): Promise<KnownErrors["PasswordRequirementsNotMet"] | void>;
177
- /**
178
- * A shorthand method to update multiple fields of the user at once.
179
- */
180
- update(update: UserUpdateOptions): Promise<void>;
181
- listContactChannels(): Promise<ContactChannel[]>;
182
- createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>;
183
- delete(): Promise<void>;
184
- getConnectedAccount(id: ProviderType, options: {
185
- or: 'redirect';
186
- scopes?: string[];
187
- }): Promise<OAuthConnection>;
188
- getConnectedAccount(id: ProviderType, options?: {
189
- or?: 'redirect' | 'throw' | 'return-null';
190
- scopes?: string[];
191
- }): Promise<OAuthConnection | null>;
192
- hasPermission(scope: Team, permissionId: string): Promise<boolean>;
193
- readonly selectedTeam: Team | null;
194
- setSelectedTeam(team: Team | null): Promise<void>;
195
- createTeam(data: TeamCreateOptions): Promise<Team>;
196
- leaveTeam(team: Team): Promise<void>;
197
- getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
198
- } & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
199
- recursive?: boolean;
200
- }], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
201
- recursive?: boolean;
202
- }], TeamPermission[], true>;
203
- type InternalUserExtra = {
204
- createProject(newProject: AdminProjectUpdateOptions & {
205
- displayName: string;
206
- }): Promise<AdminOwnedProject>;
207
- } & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
208
- type User = BaseUser;
209
- type CurrentUser = BaseUser & Auth & UserExtra;
210
- type CurrentInternalUser = CurrentUser & InternalUserExtra;
211
- type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
212
- type UserUpdateOptions = {
213
- displayName?: string;
214
- clientMetadata?: ReadonlyJson;
215
- selectedTeamId?: string | null;
216
- totpMultiFactorSecret?: Uint8Array | null;
217
- profileImageUrl?: string | null;
218
- otpAuthEnabled?: boolean;
219
- passkeyAuthEnabled?: boolean;
220
- };
221
- declare function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud["Client"]["Update"];
222
- type ServerBaseUser = {
223
- setPrimaryEmail(email: string | null, options?: {
224
- verified?: boolean | undefined;
225
- }): Promise<void>;
226
- readonly lastActiveAt: Date;
227
- readonly serverMetadata: any;
228
- setServerMetadata(metadata: any): Promise<void>;
229
- setClientReadOnlyMetadata(metadata: any): Promise<void>;
230
- createTeam(data: Omit<ServerTeamCreateOptions, "creatorUserId">): Promise<ServerTeam>;
231
- listContactChannels(): Promise<ServerContactChannel[]>;
232
- createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
233
- update(user: ServerUserUpdateOptions): Promise<void>;
234
- grantPermission(scope: Team, permissionId: string): Promise<void>;
235
- revokePermission(scope: Team, permissionId: string): Promise<void>;
236
- /**
237
- * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
238
- */
239
- createSession(options?: {
240
- expiresInMillis?: number;
241
- }): Promise<Session>;
242
- } & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
243
- direct?: boolean;
244
- }], AdminTeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
245
- direct?: boolean;
246
- }], AdminTeamPermission[], true>;
247
- /**
248
- * A user including sensitive fields that should only be used on the server, never sent to the client
249
- * (such as sensitive information and serverMetadata).
250
- */
251
- type ServerUser = ServerBaseUser & BaseUser & UserExtra;
252
- type CurrentServerUser = Auth & ServerUser;
253
- type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
254
- type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
255
- type ServerUserUpdateOptions = {
256
- primaryEmail?: string | null;
257
- primaryEmailVerified?: boolean;
258
- primaryEmailAuthEnabled?: boolean;
259
- clientReadOnlyMetadata?: ReadonlyJson;
260
- serverMetadata?: ReadonlyJson;
261
- password?: string;
262
- } & UserUpdateOptions;
263
- declare function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud["Server"]["Update"];
264
- type ServerUserCreateOptions = {
265
- primaryEmail?: string | null;
266
- primaryEmailAuthEnabled?: boolean;
267
- password?: string;
268
- otpAuthEnabled?: boolean;
269
- displayName?: string;
270
- primaryEmailVerified?: boolean;
271
- clientMetadata?: any;
272
- clientReadOnlyMetadata?: any;
273
- serverMetadata?: any;
274
- };
275
- declare function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud["Server"]["Create"];
276
-
277
- type TeamMemberProfile = {
278
- displayName: string | null;
279
- profileImageUrl: string | null;
280
- };
281
- type TeamMemberProfileUpdateOptions = {
282
- displayName?: string;
283
- profileImageUrl?: string | null;
284
- };
285
- type EditableTeamMemberProfile = TeamMemberProfile & {
286
- update(update: TeamMemberProfileUpdateOptions): Promise<void>;
287
- };
288
- type TeamUser = {
289
- id: string;
290
- teamProfile: TeamMemberProfile;
291
- };
292
- type TeamInvitation = {
293
- id: string;
294
- recipientEmail: string | null;
295
- expiresAt: Date;
296
- revoke(): Promise<void>;
297
- };
298
- type Team = {
299
- id: string;
300
- displayName: string;
301
- profileImageUrl: string | null;
302
- clientMetadata: any;
303
- clientReadOnlyMetadata: any;
304
- inviteUser(options: {
305
- email: string;
306
- callbackUrl?: string;
307
- }): Promise<void>;
308
- listUsers(): Promise<TeamUser[]>;
309
- listInvitations(): Promise<TeamInvitation[]>;
310
- update(update: TeamUpdateOptions): Promise<void>;
311
- delete(): Promise<void>;
312
- };
313
- type TeamUpdateOptions = {
314
- displayName?: string;
315
- profileImageUrl?: string | null;
316
- clientMetadata?: ReadonlyJson;
317
- };
318
- declare function teamUpdateOptionsToCrud(options: TeamUpdateOptions): TeamsCrud["Client"]["Update"];
319
- type TeamCreateOptions = {
320
- displayName: string;
321
- profileImageUrl?: string;
322
- };
323
- declare function teamCreateOptionsToCrud(options: TeamCreateOptions, creatorUserId: string): TeamsCrud["Client"]["Create"];
324
- type ServerTeamMemberProfile = TeamMemberProfile;
325
- type ServerTeamUser = ServerUser & {
326
- teamProfile: ServerTeamMemberProfile;
327
- };
328
- type ServerTeam = {
329
- createdAt: Date;
330
- serverMetadata: any;
331
- listUsers(): Promise<ServerTeamUser[]>;
332
- update(update: ServerTeamUpdateOptions): Promise<void>;
333
- delete(): Promise<void>;
334
- addUser(userId: string): Promise<void>;
335
- inviteUser(options: {
336
- email: string;
337
- callbackUrl?: string;
338
- }): Promise<void>;
339
- removeUser(userId: string): Promise<void>;
340
- } & Team;
341
- type ServerListUsersOptions = {
342
- cursor?: string;
343
- limit?: number;
344
- orderBy?: 'signedUpAt';
345
- desc?: boolean;
346
- query?: string;
347
- };
348
- type ServerTeamCreateOptions = TeamCreateOptions & {
349
- creatorUserId?: string;
350
- };
351
- declare function serverTeamCreateOptionsToCrud(options: ServerTeamCreateOptions): TeamsCrud["Server"]["Create"];
352
- type ServerTeamUpdateOptions = TeamUpdateOptions & {
353
- clientReadOnlyMetadata?: ReadonlyJson;
354
- serverMetadata?: ReadonlyJson;
355
- };
356
- declare function serverTeamUpdateOptionsToCrud(options: ServerTeamUpdateOptions): TeamsCrud["Server"]["Update"];
357
-
358
- type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
359
- secretServerKey?: string;
360
- };
361
- type StackServerAppConstructor = {
362
- new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>;
363
- new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>;
364
- };
365
- type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
366
- createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam>;
367
- /**
368
- * @deprecated use `getUser()` instead
369
- */
370
- getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
371
- createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
372
- getUser(options: GetUserOptions<HasTokenStore> & {
373
- or: 'redirect';
374
- }): Promise<ProjectCurrentServerUser<ProjectId>>;
375
- getUser(options: GetUserOptions<HasTokenStore> & {
376
- or: 'throw';
377
- }): Promise<ProjectCurrentServerUser<ProjectId>>;
378
- getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
379
- listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
380
- nextCursor: string | null;
381
- }>;
382
- } & 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>);
383
- declare const StackServerApp: StackServerAppConstructor;
384
-
385
- type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
386
- superSecretAdminKey?: string;
387
- }) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
388
- projectOwnerSession: InternalSession;
389
- }));
390
- type StackAdminAppConstructor = {
391
- new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
392
- new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
393
- };
394
- type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"apiKeys", [], ApiKey[], true> & AsyncStoreProperty<"teamPermissionDefinitions", [], AdminTeamPermissionDefinition[], true> & {
395
- listEmailTemplates(): Promise<AdminEmailTemplate[]>;
396
- updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void>;
397
- resetEmailTemplate(type: EmailTemplateType): Promise<void>;
398
- createApiKey(options: ApiKeyCreateOptions): Promise<ApiKeyFirstView>;
399
- createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
400
- updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
401
- deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
402
- sendTestEmail(options: {
403
- recipientEmail: string;
404
- emailConfig: EmailConfig;
405
- }): Promise<Result<undefined, {
406
- errorMessage: string;
407
- }>>;
408
- } & StackServerApp<HasTokenStore, ProjectId>);
409
- declare const StackAdminApp: StackAdminAppConstructor;
410
-
411
- type Project = {
412
- readonly id: string;
413
- readonly displayName: string;
414
- readonly config: ProjectConfig;
415
- };
416
- type AdminProject = {
417
- readonly id: string;
418
- readonly displayName: string;
419
- readonly description: string | null;
420
- readonly createdAt: Date;
421
- readonly userCount: number;
422
- readonly isProductionMode: boolean;
423
- readonly config: AdminProjectConfig;
424
- update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
425
- delete(this: AdminProject): Promise<void>;
426
- getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
427
- useProductionModeErrors(this: AdminProject): ProductionModeError[];
428
- } & Project;
429
- type AdminOwnedProject = {
430
- readonly app: StackAdminApp<false>;
431
- } & AdminProject;
432
- type AdminProjectUpdateOptions = {
433
- displayName?: string;
434
- description?: string;
435
- isProductionMode?: boolean;
436
- config?: AdminProjectConfigUpdateOptions;
437
- };
438
- declare function adminProjectUpdateOptionsToCrud(options: AdminProjectUpdateOptions): ProjectsCrud["Admin"]["Update"];
439
- type AdminProjectCreateOptions = Omit<AdminProjectUpdateOptions, 'displayName'> & {
440
- displayName: string;
441
- };
442
- declare function adminProjectCreateOptionsToCrud(options: AdminProjectCreateOptions): InternalProjectsCrud["Server"]["Create"];
443
-
444
- type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
445
- baseUrl?: string | {
446
- browser: string;
447
- server: string;
448
- };
449
- projectId?: ProjectId;
450
- publishableClientKey?: string;
451
- urls?: Partial<HandlerUrls>;
452
- oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
453
- tokenStore: TokenStoreInit<HasTokenStore>;
454
- redirectMethod?: RedirectMethod;
455
- /**
456
- * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
457
- * constructed. This improves the performance of your app, but will create network requests that are unnecessary if
458
- * the app is never used or disposed of immediately. To disable this behavior, set this option to true.
459
- */
460
- noAutomaticPrefetch?: boolean;
461
- };
462
- type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
463
- uniqueIdentifier: string;
464
- };
465
- type StackClientAppConstructor = {
466
- new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>;
467
- new (options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>;
468
- [stackAppInternalsSymbol]: {
469
- fromClientJson<HasTokenStore extends boolean, ProjectId extends string>(json: StackClientAppJson<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>;
470
- };
471
- };
472
- type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
473
- readonly projectId: ProjectId;
474
- readonly urls: Readonly<HandlerUrls>;
475
- signInWithOAuth(provider: string): Promise<void>;
476
- signInWithCredential(options: {
477
- email: string;
478
- password: string;
479
- noRedirect?: boolean;
480
- }): Promise<Result<undefined, KnownErrors["EmailPasswordMismatch"] | KnownErrors["InvalidTotpCode"]>>;
481
- signUpWithCredential(options: {
482
- email: string;
483
- password: string;
484
- noRedirect?: boolean;
485
- verificationCallbackUrl?: string;
486
- }): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
487
- signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
488
- callOAuthCallback(): Promise<boolean>;
489
- sendForgotPasswordEmail(email: string, options?: {
490
- callbackUrl?: string;
491
- }): Promise<Result<undefined, KnownErrors["UserNotFound"]>>;
492
- sendMagicLinkEmail(email: string, options?: {
493
- callbackUrl?: string;
494
- }): Promise<Result<{
495
- nonce: string;
496
- }, KnownErrors["RedirectUrlNotWhitelisted"]>>;
497
- resetPassword(options: {
498
- code: string;
499
- password: string;
500
- }): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
501
- verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
502
- verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
503
- acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
504
- getTeamInvitationDetails(code: string): Promise<Result<{
505
- teamDisplayName: string;
506
- }, KnownErrors["VerificationCodeError"]>>;
507
- verifyEmail(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
508
- signInWithMagicLink(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
509
- redirectToOAuthCallback(): Promise<void>;
510
- getUser(options: GetUserOptions<HasTokenStore> & {
511
- or: 'redirect';
512
- }): Promise<ProjectCurrentUser<ProjectId>>;
513
- getUser(options: GetUserOptions<HasTokenStore> & {
514
- or: 'throw';
515
- }): Promise<ProjectCurrentUser<ProjectId>>;
516
- getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
517
- [stackAppInternalsSymbol]: {
518
- toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
519
- setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
520
- };
521
- } & AsyncStoreProperty<"project", [], Project, false> & {
522
- [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
523
- });
524
- declare const StackClientApp: StackClientAppConstructor;
525
-
526
- export { adminProjectCreateOptionsToCrud as $, type Auth as A, type BaseUser as B, type CurrentUser as C, serverUserUpdateOptionsToCrud as D, type EditableTeamMemberProfile as E, serverUserCreateOptionsToCrud as F, type TeamMemberProfile as G, type TeamMemberProfileUpdateOptions as H, type InternalUserExtra as I, type TeamUpdateOptions as J, teamUpdateOptionsToCrud as K, type TeamCreateOptions as L, teamCreateOptionsToCrud as M, type ServerTeamMemberProfile as N, serverTeamCreateOptionsToCrud as O, type Project as P, type ServerTeamUpdateOptions as Q, serverTeamUpdateOptionsToCrud as R, type StackClientAppConstructorOptions as S, type TeamUser as T, type UserExtra as U, StackServerApp as V, type StackServerAppConstructor as W, StackAdminApp as X, type StackAdminAppConstructor as Y, adminProjectUpdateOptionsToCrud as Z, type AdminProjectCreateOptions as _, StackClientApp as a, type StackClientAppConstructor as a0, type TeamInvitation as b, type Team as c, type ProjectCurrentUser as d, type UserUpdateOptions as e, type AdminOwnedProject as f, type AdminProjectUpdateOptions as g, type StackClientAppJson as h, type StackServerAppConstructorOptions as i, type ServerUser as j, type ServerTeamUser as k, type ProjectCurrentServerUser as l, type ServerTeam as m, type ServerUserCreateOptions as n, type ServerListUsersOptions as o, type ServerTeamCreateOptions as p, type StackAdminAppConstructorOptions as q, type AdminProject as r, type Session as s, type User as t, type CurrentInternalUser as u, userUpdateOptionsToCrud as v, type ServerBaseUser as w, type CurrentServerUser as x, type CurrentInternalServerUser as y, type ServerUserUpdateOptions as z };