@stackframe/stack-shared 2.6.28 → 2.6.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.6.30
4
+
5
+ ### Patch Changes
6
+
7
+ - Bugfixes
8
+ - @stackframe/stack-sc@2.6.30
9
+
10
+ ## 2.6.29
11
+
12
+ ### Patch Changes
13
+
14
+ - Bugfixes
15
+ - @stackframe/stack-sc@2.6.29
16
+
3
17
  ## 2.6.28
4
18
 
5
19
  ### Patch Changes
@@ -7,6 +7,7 @@ import { ContactChannelsCrud } from './crud/contact-channels';
7
7
  import { CurrentUserCrud } from './crud/current-user';
8
8
  import { ConnectedAccountAccessTokenCrud } from './crud/oauth';
9
9
  import { InternalProjectsCrud, ProjectsCrud } from './crud/projects';
10
+ import { TeamInvitationCrud } from './crud/team-invitation';
10
11
  import { TeamMemberProfilesCrud } from './crud/team-member-profiles';
11
12
  import { TeamPermissionsCrud } from './crud/team-permissions';
12
13
  import { TeamsCrud } from './crud/teams';
@@ -152,6 +153,10 @@ export declare class StackClientInterface {
152
153
  }>;
153
154
  signOut(session: InternalSession): Promise<void>;
154
155
  getClientUserByToken(session: InternalSession): Promise<CurrentUserCrud["Client"]["Read"] | null>;
156
+ listTeamInvitations(options: {
157
+ teamId: string;
158
+ }, session: InternalSession): Promise<TeamInvitationCrud['Client']['Read'][]>;
159
+ revokeTeamInvitation(invitationId: string, teamId: string, session: InternalSession): Promise<void>;
155
160
  listTeamMemberProfiles(options: {
156
161
  teamId?: string;
157
162
  userId?: string;
@@ -695,6 +695,14 @@ export class StackClientInterface {
695
695
  throw new StackAssertionError("User endpoint returned null; this should never happen");
696
696
  return user;
697
697
  }
698
+ async listTeamInvitations(options, session) {
699
+ const response = await this.sendClientRequest("/team-invitations?" + new URLSearchParams({ team_id: options.teamId }), {}, session);
700
+ const result = await response.json();
701
+ return result.items;
702
+ }
703
+ async revokeTeamInvitation(invitationId, teamId, session) {
704
+ await this.sendClientRequest(`/team-invitations/${invitationId}?team_id=${teamId}`, { method: "DELETE" }, session);
705
+ }
698
706
  async listTeamMemberProfiles(options, session) {
699
707
  const response = await this.sendClientRequest("/team-member-profiles?" + new URLSearchParams(filterUndefined({
700
708
  team_id: options.teamId,
@@ -1,6 +1,6 @@
1
1
  import { createCrud } from "../../crud";
2
2
  import * as schemaFields from "../../schema-fields";
3
- import { yupArray, yupObject, yupDefinedWhen, yupString } from "../../schema-fields";
3
+ import { yupArray, yupDefinedWhen, yupObject, yupString } from "../../schema-fields";
4
4
  const teamPermissionSchema = yupObject({
5
5
  id: yupString().defined(),
6
6
  }).defined();
@@ -11,8 +11,8 @@ const oauthProviderSchema = yupObject({
11
11
  client_id: yupDefinedWhen(schemaFields.oauthClientIdSchema, 'type', 'standard'),
12
12
  client_secret: yupDefinedWhen(schemaFields.oauthClientSecretSchema, 'type', 'standard'),
13
13
  // extra params
14
- facebook_config_id: yupString().optional().meta({ openapiField: { description: 'This parameter is the configuration id for Facebook business login (for things like ads and marketing).' } }),
15
- microsoft_tenant_id: yupString().optional().meta({ openapiField: { description: 'This parameter is the Microsoft tenant id for Microsoft directory' } }),
14
+ facebook_config_id: schemaFields.oauthFacebookConfigIdSchema.optional(),
15
+ microsoft_tenant_id: schemaFields.oauthMicrosoftTenantIdSchema.optional(),
16
16
  });
17
17
  const enabledOAuthProviderSchema = yupObject({
18
18
  id: schemaFields.oauthIdSchema.defined(),
@@ -0,0 +1,34 @@
1
+ import { CrudTypeOf } from "../../crud";
2
+ export declare const teamInvitationDetailsClientReadSchema: import("yup").ObjectSchema<{
3
+ id: string;
4
+ team_id: string;
5
+ expires_at_millis: number;
6
+ recipient_email: string;
7
+ }, import("yup").AnyObject, {
8
+ id: undefined;
9
+ team_id: undefined;
10
+ expires_at_millis: undefined;
11
+ recipient_email: undefined;
12
+ }, "">;
13
+ export declare const teamInvitationCrud: import("../../crud").CrudSchemaFromOptions<{
14
+ clientReadSchema: import("yup").ObjectSchema<{
15
+ id: string;
16
+ team_id: string;
17
+ expires_at_millis: number;
18
+ recipient_email: string;
19
+ }, import("yup").AnyObject, {
20
+ id: undefined;
21
+ team_id: undefined;
22
+ expires_at_millis: undefined;
23
+ recipient_email: undefined;
24
+ }, "">;
25
+ clientDeleteSchema: import("yup").MixedSchema<any, import("yup").AnyObject, undefined, "">;
26
+ docs: {
27
+ clientRead: {
28
+ summary: string;
29
+ description: string;
30
+ tags: string[];
31
+ };
32
+ };
33
+ }>;
34
+ export type TeamInvitationCrud = CrudTypeOf<typeof teamInvitationCrud>;
@@ -0,0 +1,20 @@
1
+ import { createCrud } from "../../crud";
2
+ import * as schemaFields from "../../schema-fields";
3
+ import { yupObject } from "../../schema-fields";
4
+ export const teamInvitationDetailsClientReadSchema = yupObject({
5
+ id: schemaFields.yupString().uuid().defined(),
6
+ team_id: schemaFields.teamIdSchema.defined(),
7
+ expires_at_millis: schemaFields.yupNumber().defined(),
8
+ recipient_email: schemaFields.emailSchema.defined(),
9
+ }).defined();
10
+ export const teamInvitationCrud = createCrud({
11
+ clientReadSchema: teamInvitationDetailsClientReadSchema,
12
+ clientDeleteSchema: schemaFields.yupMixed(),
13
+ docs: {
14
+ clientRead: {
15
+ summary: "Get the team details with invitation code",
16
+ description: "",
17
+ tags: ["Teams"],
18
+ },
19
+ },
20
+ });
@@ -5,6 +5,7 @@ import { ClientInterfaceOptions, StackClientInterface } from "./clientInterface"
5
5
  import { ContactChannelsCrud } from "./crud/contact-channels";
6
6
  import { CurrentUserCrud } from "./crud/current-user";
7
7
  import { ConnectedAccountAccessTokenCrud } from "./crud/oauth";
8
+ import { TeamInvitationCrud } from "./crud/team-invitation";
8
9
  import { TeamMemberProfilesCrud } from "./crud/team-member-profiles";
9
10
  import { TeamMembershipsCrud } from "./crud/team-memberships";
10
11
  import { TeamPermissionsCrud } from "./crud/team-permissions";
@@ -33,6 +34,10 @@ export declare class StackServerInterface extends StackClientInterface {
33
34
  createServerUser(data: UsersCrud['Server']['Create']): Promise<UsersCrud['Server']['Read']>;
34
35
  getServerUserByToken(session: InternalSession): Promise<CurrentUserCrud['Server']['Read'] | null>;
35
36
  getServerUserById(userId: string): Promise<Result<UsersCrud['Server']['Read']>>;
37
+ listServerTeamInvitations(options: {
38
+ teamId: string;
39
+ }): Promise<TeamInvitationCrud['Server']['Read'][]>;
40
+ revokeServerTeamInvitation(invitationId: string, teamId: string): Promise<void>;
36
41
  listServerTeamMemberProfiles(options: {
37
42
  teamId: string;
38
43
  }): Promise<TeamMemberProfilesCrud['Server']['Read'][]>;
@@ -63,6 +63,14 @@ export class StackServerInterface extends StackClientInterface {
63
63
  return Result.error(new Error("Failed to get user"));
64
64
  return Result.ok(user);
65
65
  }
66
+ async listServerTeamInvitations(options) {
67
+ const response = await this.sendServerRequest("/team-invitations?team_id=" + options.teamId, {}, null);
68
+ const result = await response.json();
69
+ return result.items;
70
+ }
71
+ async revokeServerTeamInvitation(invitationId, teamId) {
72
+ await this.sendServerRequest(`/team-invitations/${invitationId}?team_id=${teamId}`, { method: "DELETE" }, null);
73
+ }
66
74
  async listServerTeamMemberProfiles(options) {
67
75
  const response = await this.sendServerRequest("/team-member-profiles?team_id=" + options.teamId, {}, null);
68
76
  const result = await response.json();
@@ -62,6 +62,8 @@ export declare const oauthEnabledSchema: yup.BooleanSchema<boolean | undefined,
62
62
  export declare const oauthTypeSchema: yup.StringSchema<"shared" | "standard" | undefined, yup.AnyObject, undefined, "">;
63
63
  export declare const oauthClientIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
64
64
  export declare const oauthClientSecretSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
65
+ export declare const oauthFacebookConfigIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
66
+ export declare const oauthMicrosoftTenantIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
65
67
  export declare const emailTypeSchema: yup.StringSchema<"shared" | "standard" | undefined, yup.AnyObject, undefined, "">;
66
68
  export declare const emailSenderNameSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
67
69
  export declare const emailHostSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -236,6 +236,8 @@ export const oauthEnabledSchema = yupBoolean().meta({ openapiField: { descriptio
236
236
  export const oauthTypeSchema = yupString().oneOf(['shared', 'standard']).meta({ openapiField: { description: 'OAuth provider type, one of shared, standard. "shared" uses Stack shared OAuth keys and it is only meant for development. "standard" uses your own OAuth keys and will show your logo and company name when signing in with the provider.', exampleValue: 'standard' } });
237
237
  export const oauthClientIdSchema = yupString().meta({ openapiField: { description: 'OAuth client ID. Needs to be specified when using type="standard"', exampleValue: 'google-oauth-client-id' } });
238
238
  export const oauthClientSecretSchema = yupString().meta({ openapiField: { description: 'OAuth client secret. Needs to be specified when using type="standard"', exampleValue: 'google-oauth-client-secret' } });
239
+ export const oauthFacebookConfigIdSchema = yupString().meta({ openapiField: { description: 'The configuration id for Facebook business login (for things like ads and marketing). This is only required if you are using the standard OAuth with Facebook and you are using Facebook business login.' } });
240
+ export const oauthMicrosoftTenantIdSchema = yupString().meta({ openapiField: { description: 'The Microsoft tenant id for Microsoft directory. This is only required if you are using the standard OAuth with Microsoft and you have an Azure AD tenant.' } });
239
241
  // Project email config
240
242
  export const emailTypeSchema = yupString().oneOf(['shared', 'standard']).meta({ openapiField: { description: 'Email provider type, one of shared, standard. "shared" uses Stack shared email provider and it is only meant for development. "standard" uses your own email server and will have your email address as the sender.', exampleValue: 'standard' } });
241
243
  export const emailSenderNameSchema = yupString().meta({ openapiField: { description: 'Email sender name. Needs to be specified when using type="standard"', exampleValue: 'Stack' } });
@@ -3,4 +3,5 @@ export declare function isBrowserLike(): boolean;
3
3
  * Returns the environment variable with the given name, returning the default (if given) or throwing an error (otherwise) if it's undefined or the empty string.
4
4
  */
5
5
  export declare function getEnvVariable(name: string, defaultValue?: string | undefined): string;
6
+ export declare function getNextRuntime(): string;
6
7
  export declare function getNodeEnvironment(): string;
package/dist/utils/env.js CHANGED
@@ -14,8 +14,19 @@ export function getEnvVariable(name, defaultValue) {
14
14
  Use process.env.XYZ directly instead.
15
15
  `);
16
16
  }
17
+ if (name === "NEXT_RUNTIME") {
18
+ throw new Error(deindent `
19
+ Can't use getEnvVariable to access the NEXT_RUNTIME environment variable because it's compiled into the client bundle.
20
+
21
+ Use getNextRuntime() instead.
22
+ `);
23
+ }
17
24
  return ((process.env[name] || defaultValue) ?? throwErr(`Missing environment variable: ${name}`)) || (defaultValue ?? throwErr(`Empty environment variable: ${name}`));
18
25
  }
26
+ export function getNextRuntime() {
27
+ // This variable is compiled into the client bundle, so we can't use getEnvVariable here.
28
+ return process.env.NEXT_RUNTIME || throwErr("Missing environment variable: NEXT_RUNTIME");
29
+ }
19
30
  export function getNodeEnvironment() {
20
31
  return getEnvVariable("NODE_ENV", "");
21
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.6.28",
3
+ "version": "2.6.30",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -50,7 +50,7 @@
50
50
  "oauth4webapi": "^2.10.3",
51
51
  "semver": "^7.6.3",
52
52
  "uuid": "^9.0.1",
53
- "@stackframe/stack-sc": "2.6.28"
53
+ "@stackframe/stack-sc": "2.6.30"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@simplewebauthn/types": "^11.0.0",