@stackframe/stack-shared 2.5.3 → 2.5.5

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 (71) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/crud.d.ts +10 -3
  3. package/dist/helpers/production-mode.d.ts +6 -0
  4. package/dist/helpers/production-mode.js +43 -0
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.js +4 -4
  7. package/dist/interface/adminInterface.d.ts +28 -67
  8. package/dist/interface/adminInterface.js +63 -21
  9. package/dist/interface/clientInterface.d.ts +21 -133
  10. package/dist/interface/clientInterface.js +92 -118
  11. package/dist/interface/crud/api-keys.d.ts +134 -0
  12. package/dist/interface/crud/api-keys.js +61 -0
  13. package/dist/interface/crud/current-user.d.ts +47 -11
  14. package/dist/interface/crud/current-user.js +7 -3
  15. package/dist/interface/crud/email-templates.d.ts +53 -34
  16. package/dist/interface/crud/email-templates.js +37 -24
  17. package/dist/interface/crud/oauth.d.ts +8 -9
  18. package/dist/interface/crud/oauth.js +5 -5
  19. package/dist/interface/crud/projects.d.ts +458 -0
  20. package/dist/interface/crud/projects.js +112 -0
  21. package/dist/interface/crud/team-memberships.d.ts +22 -0
  22. package/dist/interface/crud/team-memberships.js +22 -0
  23. package/dist/interface/crud/team-permissions.d.ts +129 -0
  24. package/dist/interface/crud/team-permissions.js +83 -0
  25. package/dist/interface/crud/teams.d.ts +148 -0
  26. package/dist/interface/crud/teams.js +80 -0
  27. package/dist/interface/crud/users.d.ts +88 -33
  28. package/dist/interface/crud/users.js +22 -14
  29. package/dist/interface/crud-deprecated/api-keys.d.ts +134 -0
  30. package/dist/interface/crud-deprecated/api-keys.js +61 -0
  31. package/dist/interface/crud-deprecated/current-user.d.ts +127 -0
  32. package/dist/interface/crud-deprecated/current-user.js +49 -0
  33. package/dist/interface/crud-deprecated/email-templates.d.ts +75 -0
  34. package/dist/interface/crud-deprecated/email-templates.js +41 -0
  35. package/dist/interface/crud-deprecated/oauth.d.ts +24 -0
  36. package/dist/interface/crud-deprecated/oauth.js +12 -0
  37. package/dist/interface/crud-deprecated/projects.d.ts +440 -0
  38. package/dist/interface/crud-deprecated/projects.js +109 -0
  39. package/dist/interface/crud-deprecated/team-memberships.d.ts +22 -0
  40. package/dist/interface/crud-deprecated/team-memberships.js +22 -0
  41. package/dist/interface/crud-deprecated/team-permissions.d.ts +129 -0
  42. package/dist/interface/crud-deprecated/team-permissions.js +83 -0
  43. package/dist/interface/crud-deprecated/teams.d.ts +126 -0
  44. package/dist/interface/crud-deprecated/teams.js +78 -0
  45. package/dist/interface/crud-deprecated/users.d.ts +201 -0
  46. package/dist/interface/crud-deprecated/users.js +75 -0
  47. package/dist/interface/serverInterface.d.ts +33 -60
  48. package/dist/interface/serverInterface.js +74 -101
  49. package/dist/known-errors.d.ts +43 -26
  50. package/dist/known-errors.js +132 -85
  51. package/dist/schema-fields.d.ts +53 -4
  52. package/dist/schema-fields.js +156 -25
  53. package/dist/sessions.d.ts +1 -0
  54. package/dist/sessions.js +13 -3
  55. package/dist/utils/compile-time.d.ts +3 -1
  56. package/dist/utils/compile-time.js +3 -1
  57. package/dist/utils/errors.d.ts +8 -1
  58. package/dist/utils/errors.js +17 -4
  59. package/dist/utils/objects.d.ts +4 -1
  60. package/dist/utils/objects.js +16 -8
  61. package/dist/utils/promises.js +6 -1
  62. package/dist/utils/proxies.d.ts +1 -0
  63. package/dist/utils/proxies.js +65 -0
  64. package/dist/utils/react.d.ts +1 -1
  65. package/dist/utils/react.js +2 -2
  66. package/dist/utils/strings.js +3 -3
  67. package/dist/utils/urls.d.ts +1 -0
  68. package/dist/utils/urls.js +8 -0
  69. package/package.json +2 -2
  70. package/dist/utils/yup.d.ts +0 -3
  71. package/dist/utils/yup.js +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - @stackframe/stack-sc@2.5.5
8
+
9
+ ## 2.5.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Backend rework
14
+ - Updated dependencies
15
+ - @stackframe/stack-sc@2.5.4
16
+
3
17
  ## 2.5.3
4
18
 
5
19
  ### Patch Changes
package/dist/crud.d.ts CHANGED
@@ -2,7 +2,9 @@ import * as yup from 'yup';
2
2
  import { NullishCoalesce } from './utils/types';
3
3
  export type AccessType = "client" | "server" | "admin";
4
4
  export type CrudOperation = "create" | "read" | "update" | "delete";
5
+ export type CrudlOperation = "create" | "read" | "update" | "delete" | "list";
5
6
  export type AccessTypeXCrudOperation = `${AccessType}${Capitalize<CrudOperation>}`;
7
+ export type AccessTypeXCrudlOperation = `${AccessType}${Capitalize<CrudlOperation>}`;
6
8
  declare module 'yup' {
7
9
  interface CustomSchemaMetadata {
8
10
  openapiField?: {
@@ -22,7 +24,7 @@ export type EndpointDocumentation = ({
22
24
  } & Partial<ShownEndpointDocumentation>) | ({
23
25
  hidden?: boolean;
24
26
  } & ShownEndpointDocumentation);
25
- type InnerCrudSchema<CreateSchema extends yup.Schema<any> | undefined = yup.Schema<any> | undefined, ReadSchema extends yup.Schema<any> | undefined = yup.Schema<any> | undefined, UpdateSchema extends yup.Schema<any> | undefined = yup.Schema<any> | undefined, DeleteSchema extends yup.Schema<any> | undefined = yup.Schema<any> | undefined> = {
27
+ type InnerCrudSchema<CreateSchema extends yup.AnySchema | undefined = yup.AnySchema | undefined, ReadSchema extends yup.AnySchema | undefined = yup.AnySchema | undefined, UpdateSchema extends yup.AnySchema | undefined = yup.AnySchema | undefined, DeleteSchema extends yup.AnySchema | undefined = yup.AnySchema | undefined> = {
26
28
  createSchema: CreateSchema;
27
29
  createDocs: EndpointDocumentation | undefined;
28
30
  readSchema: ReadSchema;
@@ -43,7 +45,7 @@ export type CrudSchema<ClientSchema extends InnerCrudSchema = InnerCrudSchema, S
43
45
  hasDelete: boolean;
44
46
  };
45
47
  export type CrudSchemaCreationOptions = {
46
- [K in AccessTypeXCrudOperation as `${K}Schema`]?: yup.Schema<any>;
48
+ [K in AccessTypeXCrudOperation as `${K}Schema`]?: yup.AnySchema;
47
49
  };
48
50
  type FillInOptionalsPrepareStep<O extends CrudSchemaCreationOptions> = {
49
51
  [K in keyof Required<CrudSchemaCreationOptions>]: K extends keyof O ? O[K] : undefined;
@@ -73,6 +75,11 @@ type InnerCrudTypeOf<S extends InnerCrudSchema> = (S['createSchema'] extends {}
73
75
  Update: yup.InferType<S['updateSchema']>;
74
76
  } : {}) & (S['deleteSchema'] extends {} ? {
75
77
  Delete: yup.InferType<S['deleteSchema']>;
78
+ } : {}) & (S['readSchema'] extends {} ? {
79
+ List: {
80
+ items: yup.InferType<S['readSchema']>[];
81
+ is_paginated: boolean;
82
+ };
76
83
  } : {});
77
84
  export type CrudTypeOf<S extends CrudSchema> = {
78
85
  Client: InnerCrudTypeOf<S['client']>;
@@ -80,7 +87,7 @@ export type CrudTypeOf<S extends CrudSchema> = {
80
87
  Admin: InnerCrudTypeOf<S['admin']>;
81
88
  };
82
89
  type CrudDocsCreationOptions<SO extends CrudSchemaCreationOptions> = {
83
- [X in AccessTypeXCrudOperation as (X extends `${infer A}Read` ? X | `${A}List` : X)]?: EndpointDocumentation;
90
+ [X in AccessTypeXCrudlOperation]?: EndpointDocumentation;
84
91
  };
85
92
  export declare function createCrud<SO extends CrudSchemaCreationOptions>(options: SO & {
86
93
  docs?: CrudDocsCreationOptions<SO>;
@@ -0,0 +1,6 @@
1
+ import { ProjectsCrud } from "../interface/crud/projects";
2
+ export type ProductionModeError = {
3
+ message: string;
4
+ relativeFixUrl: `/${string}`;
5
+ };
6
+ export declare function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]): ProductionModeError[];
@@ -0,0 +1,43 @@
1
+ import { StackAssertionError } from "../utils/errors";
2
+ import { isLocalhost } from "../utils/urls";
3
+ export function getProductionModeErrors(project) {
4
+ const errors = [];
5
+ const domainsFixUrl = `/projects/${project.id}/domains`;
6
+ if (project.config.allow_localhost) {
7
+ errors.push({
8
+ message: "Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings",
9
+ relativeFixUrl: domainsFixUrl,
10
+ });
11
+ }
12
+ for (const { domain } of project.config.domains) {
13
+ let url;
14
+ try {
15
+ url = new URL(domain);
16
+ }
17
+ catch (e) {
18
+ throw new StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", {
19
+ domain,
20
+ projectId: project
21
+ });
22
+ }
23
+ if (isLocalhost(url)) {
24
+ errors.push({
25
+ message: "Localhost domains are not allowed to be trusted in production mode: " + domain,
26
+ relativeFixUrl: domainsFixUrl,
27
+ });
28
+ }
29
+ else if (url.hostname.match(/^\d+(\.\d+)*$/)) {
30
+ errors.push({
31
+ message: "Direct IPs are not valid for trusted domains in production mode: " + domain,
32
+ relativeFixUrl: domainsFixUrl,
33
+ });
34
+ }
35
+ else if (url.protocol !== "https:") {
36
+ errors.push({
37
+ message: "Trusted domains should be HTTPS: " + domain,
38
+ relativeFixUrl: domainsFixUrl,
39
+ });
40
+ }
41
+ }
42
+ return errors;
43
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { StackClientInterface, UserJson as UserJson, ClientProjectJson, ProjectJson, OAuthProviderConfigJson, getProductionModeErrors, } from "./interface/clientInterface";
2
- export { StackServerInterface, ServerUserJson, } from "./interface/serverInterface";
3
- export { StackAdminInterface, ApiKeySetBaseJson, ApiKeySetFirstViewJson, ApiKeySetJson, } from "./interface/adminInterface";
4
- export { KnownError, KnownErrors, } from "./known-errors";
1
+ export { StackAdminInterface } from "./interface/adminInterface";
2
+ export { StackClientInterface } from "./interface/clientInterface";
3
+ export { StackServerInterface } from "./interface/serverInterface";
4
+ export { KnownError, KnownErrors } from "./known-errors";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { StackClientInterface, getProductionModeErrors, } from "./interface/clientInterface";
2
- export { StackServerInterface, } from "./interface/serverInterface";
3
- export { StackAdminInterface, } from "./interface/adminInterface";
4
- export { KnownError, KnownErrors, } from "./known-errors";
1
+ export { StackAdminInterface } from "./interface/adminInterface";
2
+ export { StackClientInterface } from "./interface/clientInterface";
3
+ export { StackServerInterface } from "./interface/serverInterface";
4
+ export { KnownError, KnownErrors } from "./known-errors";
@@ -1,69 +1,25 @@
1
- import { ServerAuthApplicationOptions, StackServerInterface } from "./serverInterface";
2
- import { EmailConfigJson, ProjectJson, SharedProvider, StandardProvider } from "./clientInterface";
3
1
  import { InternalSession } from "../sessions";
4
- export type AdminAuthApplicationOptions = Readonly<ServerAuthApplicationOptions & ({
2
+ import { ApiKeysCrud } from "./crud/api-keys";
3
+ import { EmailTemplateCrud, EmailTemplateType } from "./crud/email-templates";
4
+ import { ProjectsCrud } from "./crud/projects";
5
+ import { TeamPermissionDefinitionsCrud } from "./crud/team-permissions";
6
+ import { ServerAuthApplicationOptions, StackServerInterface } from "./serverInterface";
7
+ export type AdminAuthApplicationOptions = ServerAuthApplicationOptions & ({
5
8
  superSecretAdminKey: string;
6
9
  } | {
7
10
  projectOwnerSession: InternalSession;
8
- })>;
9
- export type OAuthProviderUpdateOptions = {
10
- id: string;
11
- enabled: boolean;
12
- } & ({
13
- type: SharedProvider;
14
- } | {
15
- type: StandardProvider;
16
- clientId: string;
17
- clientSecret: string;
18
11
  });
19
- export type ProjectUpdateOptions = {
20
- displayName?: string;
21
- description?: string;
22
- isProductionMode?: boolean;
23
- config?: {
24
- domains?: {
25
- domain: string;
26
- handlerPath: string;
27
- }[];
28
- oauthProviders?: OAuthProviderUpdateOptions[];
29
- credentialEnabled?: boolean;
30
- magicLinkEnabled?: boolean;
31
- allowLocalhost?: boolean;
32
- createTeamOnSignUp?: boolean;
33
- emailConfig?: EmailConfigJson;
34
- teamCreatorDefaultPermissionIds?: string[];
35
- teamMemberDefaultPermissionIds?: string[];
36
- };
37
- };
38
- export type ApiKeySetBaseJson = {
39
- id: string;
12
+ export type ApiKeyCreateCrudRequest = {
13
+ has_publishable_client_key: boolean;
14
+ has_secret_server_key: boolean;
15
+ has_super_secret_admin_key: boolean;
16
+ expires_at_millis: number;
40
17
  description: string;
41
- expiresAtMillis: number;
42
- manuallyRevokedAtMillis: number | null;
43
- createdAtMillis: number;
44
18
  };
45
- export type ApiKeySetFirstViewJson = ApiKeySetBaseJson & {
46
- publishableClientKey?: string;
47
- secretServerKey?: string;
48
- superSecretAdminKey?: string;
49
- };
50
- export type ApiKeySetJson = ApiKeySetBaseJson & {
51
- publishableClientKey: null | {
52
- lastFour: string;
53
- };
54
- secretServerKey: null | {
55
- lastFour: string;
56
- };
57
- superSecretAdminKey: null | {
58
- lastFour: string;
59
- };
60
- };
61
- export type ApiKeySetCreateOptions = {
62
- hasPublishableClientKey: boolean;
63
- hasSecretServerKey: boolean;
64
- hasSuperSecretAdminKey: boolean;
65
- expiresAt: Date;
66
- description: string;
19
+ export type ApiKeyCreateCrudResponse = ApiKeysCrud["Admin"]["Read"] & {
20
+ publishable_client_key?: string;
21
+ secret_server_key?: string;
22
+ super_secret_admin_key?: string;
67
23
  };
68
24
  export declare class StackAdminInterface extends StackServerInterface {
69
25
  readonly options: AdminAuthApplicationOptions;
@@ -74,12 +30,17 @@ export declare class StackAdminInterface extends StackServerInterface {
74
30
  refreshToken: import("../sessions").RefreshToken | null;
75
31
  } | null;
76
32
  }>;
77
- getProject(options?: {
78
- showDisabledOAuth?: boolean;
79
- }): Promise<ProjectJson>;
80
- updateProject(update: ProjectUpdateOptions): Promise<ProjectJson>;
81
- createApiKeySet(options: ApiKeySetCreateOptions): Promise<ApiKeySetFirstViewJson>;
82
- listApiKeySets(): Promise<ApiKeySetJson[]>;
83
- revokeApiKeySetById(id: string): Promise<void>;
84
- getApiKeySet(id: string, session: InternalSession): Promise<ApiKeySetJson>;
33
+ getProject(): Promise<ProjectsCrud["Admin"]["Read"]>;
34
+ updateProject(update: ProjectsCrud["Admin"]["Update"]): Promise<ProjectsCrud["Admin"]["Read"]>;
35
+ createApiKey(options: ApiKeyCreateCrudRequest): Promise<ApiKeyCreateCrudResponse>;
36
+ listApiKeys(): Promise<ApiKeysCrud["Admin"]["Read"][]>;
37
+ revokeApiKeyById(id: string): Promise<void>;
38
+ getApiKey(id: string, session: InternalSession): Promise<ApiKeysCrud["Admin"]["Read"]>;
39
+ listEmailTemplates(): Promise<EmailTemplateCrud['Admin']['Read'][]>;
40
+ updateEmailTemplate(type: EmailTemplateType, data: EmailTemplateCrud['Admin']['Update']): Promise<EmailTemplateCrud['Admin']['Read']>;
41
+ resetEmailTemplate(type: EmailTemplateType): Promise<void>;
42
+ listPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]>;
43
+ createPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
44
+ updatePermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
45
+ deletePermissionDefinition(permissionId: string): Promise<void>;
85
46
  }
@@ -13,19 +13,15 @@ export class StackAdminInterface extends StackServerInterface {
13
13
  },
14
14
  }, session, requestType);
15
15
  }
16
- async getProject(options) {
17
- const response = await this.sendAdminRequest("/projects/" + encodeURIComponent(this.projectId), {
18
- method: "POST",
19
- headers: {
20
- "content-type": "application/json",
21
- },
22
- body: JSON.stringify(options ?? {}),
16
+ async getProject() {
17
+ const response = await this.sendAdminRequest("/projects/current", {
18
+ method: "GET",
23
19
  }, null);
24
20
  return await response.json();
25
21
  }
26
22
  async updateProject(update) {
27
- const response = await this.sendAdminRequest("/projects/" + encodeURIComponent(this.projectId), {
28
- method: "PUT",
23
+ const response = await this.sendAdminRequest("/projects/current", {
24
+ method: "PATCH",
29
25
  headers: {
30
26
  "content-type": "application/json",
31
27
  },
@@ -33,8 +29,8 @@ export class StackAdminInterface extends StackServerInterface {
33
29
  }, null);
34
30
  return await response.json();
35
31
  }
36
- async createApiKeySet(options) {
37
- const response = await this.sendServerRequest("/api-keys", {
32
+ async createApiKey(options) {
33
+ const response = await this.sendServerRequest("/internal/api-keys", {
38
34
  method: "POST",
39
35
  headers: {
40
36
  "content-type": "application/json",
@@ -43,24 +39,70 @@ export class StackAdminInterface extends StackServerInterface {
43
39
  }, null);
44
40
  return await response.json();
45
41
  }
46
- async listApiKeySets() {
47
- const response = await this.sendAdminRequest("/api-keys", {}, null);
48
- const json = await response.json();
49
- return json.map((k) => k);
42
+ async listApiKeys() {
43
+ const response = await this.sendAdminRequest("/internal/api-keys", {}, null);
44
+ const result = await response.json();
45
+ return result.items;
50
46
  }
51
- async revokeApiKeySetById(id) {
52
- await this.sendAdminRequest(`/api-keys/${id}`, {
53
- method: "PUT",
47
+ async revokeApiKeyById(id) {
48
+ await this.sendAdminRequest(`/internal/api-keys/${id}`, {
49
+ method: "PATCH",
54
50
  headers: {
55
51
  "content-type": "application/json",
56
52
  },
57
53
  body: JSON.stringify({
58
- revoke: true,
54
+ revoked: true,
59
55
  }),
60
56
  }, null);
61
57
  }
62
- async getApiKeySet(id, session) {
63
- const response = await this.sendAdminRequest(`/api-keys/${id}`, {}, session);
58
+ async getApiKey(id, session) {
59
+ const response = await this.sendAdminRequest(`/internal/api-keys/${id}`, {}, session);
60
+ return await response.json();
61
+ }
62
+ async listEmailTemplates() {
63
+ const response = await this.sendAdminRequest(`/email-templates`, {}, null);
64
+ const result = await response.json();
65
+ return result.items;
66
+ }
67
+ async updateEmailTemplate(type, data) {
68
+ const result = await this.sendAdminRequest(`/email-templates/${type}`, {
69
+ method: "PATCH",
70
+ headers: {
71
+ "content-type": "application/json",
72
+ },
73
+ body: JSON.stringify(data),
74
+ }, null);
75
+ return await result.json();
76
+ }
77
+ async resetEmailTemplate(type) {
78
+ await this.sendAdminRequest(`/email-templates/${type}`, { method: "DELETE" }, null);
79
+ }
80
+ async listPermissionDefinitions() {
81
+ const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);
82
+ const result = await response.json();
83
+ return result.items;
84
+ }
85
+ async createPermissionDefinition(data) {
86
+ const response = await this.sendAdminRequest("/team-permission-definitions", {
87
+ method: "POST",
88
+ headers: {
89
+ "content-type": "application/json",
90
+ },
91
+ body: JSON.stringify(data),
92
+ }, null);
93
+ return await response.json();
94
+ }
95
+ async updatePermissionDefinition(permissionId, data) {
96
+ const response = await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, {
97
+ method: "PATCH",
98
+ headers: {
99
+ "content-type": "application/json",
100
+ },
101
+ body: JSON.stringify(data),
102
+ }, null);
64
103
  return await response.json();
65
104
  }
105
+ async deletePermissionDefinition(permissionId) {
106
+ await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, { method: "DELETE" }, null);
107
+ }
66
108
  }
@@ -1,42 +1,11 @@
1
- import { Result } from "../utils/results";
2
- import { ReadonlyJson } from '../utils/json';
3
1
  import { KnownErrors } from '../known-errors';
4
- import { ProjectUpdateOptions } from './adminInterface';
5
- import { AccessToken, RefreshToken, InternalSession } from '../sessions';
6
- type UserCustomizableJson = {
7
- displayName: string | null;
8
- clientMetadata: ReadonlyJson;
9
- selectedTeamId: string | null;
10
- };
11
- export type UserJson = UserCustomizableJson & {
12
- projectId: string;
13
- id: string;
14
- primaryEmail: string | null;
15
- primaryEmailVerified: boolean;
16
- displayName: string | null;
17
- clientMetadata: ReadonlyJson;
18
- profileImageUrl: string | null;
19
- signedUpAtMillis: number;
20
- /**
21
- * not used anymore, for backwards compatibility
22
- */
23
- authMethod: "credential" | "oauth";
24
- hasPassword: boolean;
25
- authWithEmail: boolean;
26
- oauthProviders: string[];
27
- selectedTeamId: string | null;
28
- selectedTeam: TeamJson | null;
29
- };
30
- export type UserUpdateJson = Partial<UserCustomizableJson>;
31
- export type ClientProjectJson = {
32
- id: string;
33
- credentialEnabled: boolean;
34
- magicLinkEnabled: boolean;
35
- oauthProviders: {
36
- id: string;
37
- enabled: boolean;
38
- }[];
39
- };
2
+ import { AccessToken, InternalSession, RefreshToken } from '../sessions';
3
+ import { ReadonlyJson } from '../utils/json';
4
+ import { Result } from "../utils/results";
5
+ import { CurrentUserCrud } from './crud/current-user';
6
+ import { InternalProjectsCrud, ProjectsCrud } from './crud/projects';
7
+ import { TeamPermissionsCrud } from './crud/team-permissions';
8
+ import { TeamsCrud } from './crud/teams';
40
9
  export type ClientInterfaceOptions = {
41
10
  clientVersion: string;
42
11
  baseUrl: string;
@@ -52,82 +21,6 @@ export type StandardProvider = "github" | "facebook" | "google" | "microsoft" |
52
21
  export declare const standardProviders: readonly ["github", "facebook", "google", "microsoft", "spotify"];
53
22
  export declare function toStandardProvider(provider: SharedProvider | StandardProvider): StandardProvider;
54
23
  export declare function toSharedProvider(provider: SharedProvider | StandardProvider): SharedProvider;
55
- export type ProjectJson = {
56
- id: string;
57
- displayName: string;
58
- description?: string;
59
- createdAtMillis: number;
60
- userCount: number;
61
- isProductionMode: boolean;
62
- evaluatedConfig: {
63
- id: string;
64
- allowLocalhost: boolean;
65
- credentialEnabled: boolean;
66
- magicLinkEnabled: boolean;
67
- oauthProviders: OAuthProviderConfigJson[];
68
- emailConfig?: EmailConfigJson;
69
- domains: DomainConfigJson[];
70
- createTeamOnSignUp: boolean;
71
- teamCreatorDefaultPermissions: PermissionDefinitionJson[];
72
- teamMemberDefaultPermissions: PermissionDefinitionJson[];
73
- };
74
- };
75
- export type OAuthProviderConfigJson = {
76
- id: string;
77
- enabled: boolean;
78
- } & ({
79
- type: SharedProvider;
80
- } | {
81
- type: StandardProvider;
82
- clientId: string;
83
- clientSecret: string;
84
- });
85
- export type EmailConfigJson = ({
86
- type: "standard";
87
- senderName: string;
88
- senderEmail: string;
89
- host: string;
90
- port: number;
91
- username: string;
92
- password: string;
93
- } | {
94
- type: "shared";
95
- });
96
- export type DomainConfigJson = {
97
- domain: string;
98
- handlerPath: string;
99
- };
100
- export type ProductionModeError = {
101
- errorMessage: string;
102
- fixUrlRelative: string;
103
- };
104
- export type OrglikeJson = {
105
- id: string;
106
- displayName: string;
107
- profileImageUrl?: string;
108
- createdAtMillis: number;
109
- };
110
- export type TeamJson = OrglikeJson;
111
- export type OrganizationJson = OrglikeJson;
112
- export type OrglikeCustomizableJson = Pick<OrglikeJson, "displayName" | "profileImageUrl">;
113
- export type TeamCustomizableJson = OrglikeCustomizableJson;
114
- export type TeamMemberJson = {
115
- userId: string;
116
- teamId: string;
117
- displayName: string | null;
118
- };
119
- export type PermissionDefinitionScopeJson = {
120
- type: "global";
121
- } | {
122
- type: "any-team";
123
- } | {
124
- type: "specific-team";
125
- teamId: string;
126
- };
127
- export type PermissionDefinitionJson = {
128
- id: string;
129
- scope: PermissionDefinitionScopeJson;
130
- };
131
24
  export declare class StackClientInterface {
132
25
  readonly options: ClientInterfaceOptions;
133
26
  constructor(options: ClientInterfaceOptions);
@@ -152,9 +45,9 @@ export declare class StackClientInterface {
152
45
  checkFeatureSupport(options: {
153
46
  featureName?: string;
154
47
  } & ReadonlyJson): Promise<never>;
155
- sendForgotPasswordEmail(email: string, redirectUrl: string): Promise<KnownErrors["UserNotFound"] | undefined>;
48
+ sendForgotPasswordEmail(email: string, callbackUrl: string): Promise<KnownErrors["UserNotFound"] | undefined>;
156
49
  sendVerificationEmail(emailVerificationRedirectUrl: string, session: InternalSession): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
157
- sendMagicLinkEmail(email: string, redirectUrl: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
50
+ sendMagicLinkEmail(email: string, callbackUrl: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
158
51
  resetPassword(options: {
159
52
  code: string;
160
53
  } & ({
@@ -165,7 +58,7 @@ export declare class StackClientInterface {
165
58
  updatePassword(options: {
166
59
  oldPassword: string;
167
60
  newPassword: string;
168
- }, session: InternalSession): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
61
+ }, session: InternalSession): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
169
62
  verifyPasswordResetCode(code: string): Promise<KnownErrors["VerificationCodeError"] | undefined>;
170
63
  verifyEmail(code: string): Promise<KnownErrors["VerificationCodeError"] | undefined>;
171
64
  signInWithCredential(email: string, password: string, session: InternalSession): Promise<KnownErrors["EmailPasswordMismatch"] | {
@@ -176,7 +69,7 @@ export declare class StackClientInterface {
176
69
  accessToken: string;
177
70
  refreshToken: string;
178
71
  }>;
179
- signInWithMagicLink(code: string, session: InternalSession): Promise<KnownErrors["VerificationCodeError"] | {
72
+ signInWithMagicLink(code: string): Promise<KnownErrors["VerificationCodeError"] | {
180
73
  newUser: boolean;
181
74
  accessToken: string;
182
75
  refreshToken: string;
@@ -208,23 +101,18 @@ export declare class StackClientInterface {
208
101
  refreshToken: string;
209
102
  }>;
210
103
  signOut(session: InternalSession): Promise<void>;
211
- getClientUserByToken(tokenStore: InternalSession): Promise<Result<UserJson>>;
212
- listClientUserTeamPermissions(options: {
104
+ getClientUserByToken(session: InternalSession): Promise<CurrentUserCrud["Client"]["Read"] | null>;
105
+ listCurrentUserTeamPermissions(options: {
213
106
  teamId: string;
214
- type: 'global' | 'team';
215
- direct: boolean;
216
- }, session: InternalSession): Promise<PermissionDefinitionJson[]>;
217
- listClientUserTeams(session: InternalSession): Promise<TeamJson[]>;
218
- getClientProject(): Promise<Result<ClientProjectJson>>;
219
- setClientUserCustomizableData(update: UserUpdateJson, session: InternalSession): Promise<void>;
220
- listProjects(session: InternalSession): Promise<ProjectJson[]>;
221
- createProject(project: ProjectUpdateOptions & {
222
- displayName: string;
223
- }, session: InternalSession): Promise<ProjectJson>;
107
+ recursive: boolean;
108
+ }, session: InternalSession): Promise<TeamPermissionsCrud['Client']['Read'][]>;
109
+ listCurrentUserTeams(session: InternalSession): Promise<TeamsCrud["Client"]["Read"][]>;
110
+ getClientProject(): Promise<Result<ProjectsCrud['Client']['Read'], KnownErrors["ProjectNotFound"]>>;
111
+ updateClientUser(update: CurrentUserCrud["Client"]["Update"], session: InternalSession): Promise<void>;
112
+ listProjects(session: InternalSession): Promise<InternalProjectsCrud['Client']['Read'][]>;
113
+ createProject(project: InternalProjectsCrud['Client']['Create'], session: InternalSession): Promise<InternalProjectsCrud['Client']['Read']>;
224
114
  getAccessToken(provider: string, scope: string, session: InternalSession): Promise<{
225
115
  accessToken: string;
226
116
  }>;
227
- createTeamForCurrentUser(data: TeamCustomizableJson, session: InternalSession): Promise<TeamJson>;
117
+ createTeamForCurrentUser(data: TeamsCrud['Client']['Create'], session: InternalSession): Promise<TeamsCrud['Client']['Read']>;
228
118
  }
229
- export declare function getProductionModeErrors(project: ProjectJson): ProductionModeError[];
230
- export {};