@stytch/vanilla-js 3.2.4 → 3.3.0

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.
@@ -1,4 +1,4 @@
1
- import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, StytchClientOptions } from "@stytch/core/public";
1
+ import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BSelfClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, IHeadlessB2BRBACClient, StytchClientOptions } from "@stytch/core/public";
2
2
  type ResponseCommon = {
3
3
  /**
4
4
  * Globally unique UUID that is returned with every API call.
@@ -119,7 +119,7 @@ interface MemberSession {
119
119
  /**
120
120
  * All the authentication factors that have been associated with the current member session.
121
121
  */
122
- authentication_factors: Array<B2BAuthenticationFactor>;
122
+ authentication_factors: B2BAuthenticationFactor[];
123
123
  /**
124
124
  * A map of the custom claims associated with the session.
125
125
  * Custom claims can only be set from the server, they cannot be set using the clientside SDKs.
@@ -128,6 +128,12 @@ interface MemberSession {
128
128
  * If no claims are set, this field will be null.
129
129
  */
130
130
  custom_claims?: Record<string, unknown>;
131
+ /**
132
+ * A list of the roles associated with the session.
133
+ * Members may inherit certain roles depending on the factors in their session.
134
+ * For example, some roles may only be active if the member logged in from a specific SAML IDP.
135
+ */
136
+ roles: string[];
131
137
  }
132
138
  interface SSORegistration {
133
139
  connection_id: string;
@@ -135,6 +141,26 @@ interface SSORegistration {
135
141
  registration_id: string;
136
142
  sso_attributes: Record<string, unknown>;
137
143
  }
144
+ type RoleSource = {
145
+ type: "direct_assignment";
146
+ details: Record<string, never>;
147
+ } | {
148
+ type: "email_assignment";
149
+ details: {
150
+ email_domain: string;
151
+ };
152
+ } | {
153
+ type: "sso_connection";
154
+ details: {
155
+ connection_id: string;
156
+ };
157
+ } | {
158
+ type: "sso_connection_group";
159
+ details: {
160
+ connection_id: string;
161
+ group: string;
162
+ };
163
+ };
138
164
  interface Member {
139
165
  /**
140
166
  * Globally unique UUID that identifies an organization in the Stytch API.
@@ -175,7 +201,11 @@ interface Member {
175
201
  * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
176
202
  */
177
203
  untrusted_metadata: Record<string, unknown>;
178
- sso_registrations: Array<SSORegistration>;
204
+ sso_registrations: SSORegistration[];
205
+ /**
206
+ * Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings.
207
+ * A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures.
208
+ */
179
209
  is_breakglass: boolean;
180
210
  /**
181
211
  * Returned if the member has a registered password
@@ -194,6 +224,13 @@ interface Member {
194
224
  * Whether the member's phone number is verified.
195
225
  */
196
226
  mfa_phone_number_verified: boolean;
227
+ /**
228
+ * A list of the member's roles and their sources
229
+ */
230
+ roles: {
231
+ role_id: string;
232
+ sources: RoleSource[];
233
+ }[];
197
234
  }
198
235
  type B2BAuthenticateResponse = ResponseCommon & {
199
236
  /**
@@ -278,19 +315,77 @@ interface Organization {
278
315
  * This field can only be updated by a direct API integration.
279
316
  */
280
317
  trusted_metadata: Record<string, unknown>;
318
+ /**
319
+ * The default connection used for SSO when there are multiple active connections.
320
+ */
281
321
  sso_default_connection_id: string | null;
322
+ /**
323
+ * The authentication setting that controls the JIT provisioning of Members when authenticating via SSO.
324
+ * The accepted values are:
325
+ * ALL_ALLOWED – new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections.
326
+ * RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication.
327
+ * NOT_ALLOWED – disable JIT provisioning via SSO.
328
+ */
282
329
  sso_jit_provisioning: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
330
+ /**
331
+ * An array of connection_ids that reference SAML Connection objects.
332
+ * Only these connections will be allowed to JIT provision Members via SSO when sso_jit_provisioning is set to RESTRICTED.
333
+ */
283
334
  sso_jit_provisioning_allowed_connections: string[];
284
- sso_active_connections: Array<{
335
+ /**
336
+ * An array of active SSO Connection references.
337
+ */
338
+ sso_active_connections: {
285
339
  connection_id: string;
286
340
  display_name: string;
287
- }>;
341
+ }[];
342
+ /**
343
+ * An array of email domains that allow invites or JIT provisioning for new Members.
344
+ * This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED.
345
+ * Common domains such as gmail.com are not allowed.
346
+ */
288
347
  email_allowed_domains: string[];
348
+ /**
349
+ * The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link.
350
+ * The accepted values are:
351
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link.
352
+ * NOT_ALLOWED – disable JIT provisioning via Email Magic Link.
353
+ */
289
354
  email_jit_provisioning: "RESTRICTED" | "NOT_ALLOWED";
355
+ /**
356
+ * The authentication setting that controls how a new Member can be invited to an organization by email.
357
+ * The accepted values are:
358
+ * ALL_ALLOWED – any new Member can be invited to join via email.
359
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
360
+ * NOT_ALLOWED – disable email invites.
361
+ */
290
362
  email_invites: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
363
+ /**
364
+ * The setting that controls which authentication methods can be used by Members of an Organization.
365
+ * The accepted values are:
366
+ * ALL_ALLOWED – the default setting which allows all authentication methods to be used.
367
+ * RESTRICTED – only methods that comply with allowed_auth_methods can be used for authentication. This setting does not apply to Members with is_breakglass set to true.
368
+ */
291
369
  auth_methods: "ALL_ALLOWED" | "RESTRICTED";
370
+ /**
371
+ * An array of allowed authentication methods.
372
+ * This list is enforced when auth_methods is set to RESTRICTED.
373
+ * The list's accepted values are: sso, magic_link, password, google_oauth, and microsoft_oauth.
374
+ */
292
375
  allowed_auth_methods: string[];
376
+ /**
377
+ * The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
378
+ * REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in.
379
+ * OPTIONAL – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their mfa_enrolled status is set to true
380
+ */
293
381
  mfa_policy: "OPTIONAL" | "REQUIRED_FOR_ALL";
382
+ /**
383
+ * An array of implicit role assignments granted to members in this organization whose emails match the domain.
384
+ */
385
+ rbac_email_implicit_role_assignments?: {
386
+ role_id: string;
387
+ domain: string;
388
+ }[];
294
389
  }
295
390
  interface MfaRequired {
296
391
  member_options: MemberOptions;
@@ -620,13 +715,16 @@ declare class StytchB2BHeadlessClient {
620
715
  // External API Clients
621
716
  magicLinks: IHeadlessB2BMagicLinksClient;
622
717
  session: IHeadlessB2BSessionClient;
718
+ /** @deprecated Please use client.self instead. This will be removed in a future release. */
623
719
  member: IHeadlessB2BMemberClient;
720
+ self: IHeadlessB2BSelfClient;
624
721
  organization: IHeadlessB2BOrganizationClient;
625
722
  oauth: IHeadlessB2BOAuthClient;
626
723
  sso: IHeadlessB2BSSOClient;
627
724
  discovery: IHeadlessB2BDiscoveryClient;
628
725
  passwords: IHeadlessB2BPasswordClient;
629
726
  otps: IHeadlessB2BOTPsClient;
727
+ rbac: IHeadlessB2BRBACClient;
630
728
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
631
729
  }
632
730
  export { StytchB2BHeadlessClient };
@@ -1,4 +1,4 @@
1
- import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, StytchClientOptions } from "@stytch/core/public";
1
+ import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BSelfClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, IHeadlessB2BRBACClient, StytchClientOptions } from "@stytch/core/public";
2
2
  type ResponseCommon = {
3
3
  /**
4
4
  * Globally unique UUID that is returned with every API call.
@@ -119,7 +119,7 @@ interface MemberSession {
119
119
  /**
120
120
  * All the authentication factors that have been associated with the current member session.
121
121
  */
122
- authentication_factors: Array<B2BAuthenticationFactor>;
122
+ authentication_factors: B2BAuthenticationFactor[];
123
123
  /**
124
124
  * A map of the custom claims associated with the session.
125
125
  * Custom claims can only be set from the server, they cannot be set using the clientside SDKs.
@@ -128,6 +128,12 @@ interface MemberSession {
128
128
  * If no claims are set, this field will be null.
129
129
  */
130
130
  custom_claims?: Record<string, unknown>;
131
+ /**
132
+ * A list of the roles associated with the session.
133
+ * Members may inherit certain roles depending on the factors in their session.
134
+ * For example, some roles may only be active if the member logged in from a specific SAML IDP.
135
+ */
136
+ roles: string[];
131
137
  }
132
138
  interface SSORegistration {
133
139
  connection_id: string;
@@ -135,6 +141,26 @@ interface SSORegistration {
135
141
  registration_id: string;
136
142
  sso_attributes: Record<string, unknown>;
137
143
  }
144
+ type RoleSource = {
145
+ type: "direct_assignment";
146
+ details: Record<string, never>;
147
+ } | {
148
+ type: "email_assignment";
149
+ details: {
150
+ email_domain: string;
151
+ };
152
+ } | {
153
+ type: "sso_connection";
154
+ details: {
155
+ connection_id: string;
156
+ };
157
+ } | {
158
+ type: "sso_connection_group";
159
+ details: {
160
+ connection_id: string;
161
+ group: string;
162
+ };
163
+ };
138
164
  interface Member {
139
165
  /**
140
166
  * Globally unique UUID that identifies an organization in the Stytch API.
@@ -175,7 +201,11 @@ interface Member {
175
201
  * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
176
202
  */
177
203
  untrusted_metadata: Record<string, unknown>;
178
- sso_registrations: Array<SSORegistration>;
204
+ sso_registrations: SSORegistration[];
205
+ /**
206
+ * Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings.
207
+ * A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures.
208
+ */
179
209
  is_breakglass: boolean;
180
210
  /**
181
211
  * Returned if the member has a registered password
@@ -194,6 +224,13 @@ interface Member {
194
224
  * Whether the member's phone number is verified.
195
225
  */
196
226
  mfa_phone_number_verified: boolean;
227
+ /**
228
+ * A list of the member's roles and their sources
229
+ */
230
+ roles: {
231
+ role_id: string;
232
+ sources: RoleSource[];
233
+ }[];
197
234
  }
198
235
  type B2BAuthenticateResponse = ResponseCommon & {
199
236
  /**
@@ -278,19 +315,77 @@ interface Organization {
278
315
  * This field can only be updated by a direct API integration.
279
316
  */
280
317
  trusted_metadata: Record<string, unknown>;
318
+ /**
319
+ * The default connection used for SSO when there are multiple active connections.
320
+ */
281
321
  sso_default_connection_id: string | null;
322
+ /**
323
+ * The authentication setting that controls the JIT provisioning of Members when authenticating via SSO.
324
+ * The accepted values are:
325
+ * ALL_ALLOWED – new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections.
326
+ * RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication.
327
+ * NOT_ALLOWED – disable JIT provisioning via SSO.
328
+ */
282
329
  sso_jit_provisioning: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
330
+ /**
331
+ * An array of connection_ids that reference SAML Connection objects.
332
+ * Only these connections will be allowed to JIT provision Members via SSO when sso_jit_provisioning is set to RESTRICTED.
333
+ */
283
334
  sso_jit_provisioning_allowed_connections: string[];
284
- sso_active_connections: Array<{
335
+ /**
336
+ * An array of active SSO Connection references.
337
+ */
338
+ sso_active_connections: {
285
339
  connection_id: string;
286
340
  display_name: string;
287
- }>;
341
+ }[];
342
+ /**
343
+ * An array of email domains that allow invites or JIT provisioning for new Members.
344
+ * This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED.
345
+ * Common domains such as gmail.com are not allowed.
346
+ */
288
347
  email_allowed_domains: string[];
348
+ /**
349
+ * The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link.
350
+ * The accepted values are:
351
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link.
352
+ * NOT_ALLOWED – disable JIT provisioning via Email Magic Link.
353
+ */
289
354
  email_jit_provisioning: "RESTRICTED" | "NOT_ALLOWED";
355
+ /**
356
+ * The authentication setting that controls how a new Member can be invited to an organization by email.
357
+ * The accepted values are:
358
+ * ALL_ALLOWED – any new Member can be invited to join via email.
359
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
360
+ * NOT_ALLOWED – disable email invites.
361
+ */
290
362
  email_invites: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
363
+ /**
364
+ * The setting that controls which authentication methods can be used by Members of an Organization.
365
+ * The accepted values are:
366
+ * ALL_ALLOWED – the default setting which allows all authentication methods to be used.
367
+ * RESTRICTED – only methods that comply with allowed_auth_methods can be used for authentication. This setting does not apply to Members with is_breakglass set to true.
368
+ */
291
369
  auth_methods: "ALL_ALLOWED" | "RESTRICTED";
370
+ /**
371
+ * An array of allowed authentication methods.
372
+ * This list is enforced when auth_methods is set to RESTRICTED.
373
+ * The list's accepted values are: sso, magic_link, password, google_oauth, and microsoft_oauth.
374
+ */
292
375
  allowed_auth_methods: string[];
376
+ /**
377
+ * The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
378
+ * REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in.
379
+ * OPTIONAL – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their mfa_enrolled status is set to true
380
+ */
293
381
  mfa_policy: "OPTIONAL" | "REQUIRED_FOR_ALL";
382
+ /**
383
+ * An array of implicit role assignments granted to members in this organization whose emails match the domain.
384
+ */
385
+ rbac_email_implicit_role_assignments?: {
386
+ role_id: string;
387
+ domain: string;
388
+ }[];
294
389
  }
295
390
  interface MfaRequired {
296
391
  member_options: MemberOptions;
@@ -620,13 +715,16 @@ declare class StytchB2BHeadlessClient {
620
715
  // External API Clients
621
716
  magicLinks: IHeadlessB2BMagicLinksClient;
622
717
  session: IHeadlessB2BSessionClient;
718
+ /** @deprecated Please use client.self instead. This will be removed in a future release. */
623
719
  member: IHeadlessB2BMemberClient;
720
+ self: IHeadlessB2BSelfClient;
624
721
  organization: IHeadlessB2BOrganizationClient;
625
722
  oauth: IHeadlessB2BOAuthClient;
626
723
  sso: IHeadlessB2BSSOClient;
627
724
  discovery: IHeadlessB2BDiscoveryClient;
628
725
  passwords: IHeadlessB2BPasswordClient;
629
726
  otps: IHeadlessB2BOTPsClient;
727
+ rbac: IHeadlessB2BRBACClient;
630
728
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
631
729
  }
632
730
  export { StytchB2BHeadlessClient };