@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6890694: Mark stytch.member as deprecated in favor of stytch.self
8
+ Adds RBAC functionality
9
+
10
+ ### Patch Changes
11
+
12
+ - 9ee61b3: Allow "Login without a password" to immediately login a user who followed a valid password reset link
13
+ - c3c108b: Remove bundled dependencies from package manifest
14
+ - Updated dependencies [76ad832]
15
+ - Updated dependencies [6890694]
16
+ - @stytch/core@1.5.0
17
+
18
+ ## 3.2.5
19
+
20
+ ### Patch Changes
21
+
22
+ - 70cf053: Adding better handling for Passkey cross device errors.
23
+
3
24
  ## 3.2.4
4
25
 
5
26
  ### Patch Changes
@@ -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
  import { Callbacks as Callbacks$0 } from "@stytch/core/public";
3
3
  import { StyleConfig as StyleConfig$0 } from "@stytch/core/public";
4
4
  import { StytchB2BUIConfig as StytchB2BUIConfig$0 } from "@stytch/core/public";
@@ -122,7 +122,7 @@ interface MemberSession {
122
122
  /**
123
123
  * All the authentication factors that have been associated with the current member session.
124
124
  */
125
- authentication_factors: Array<B2BAuthenticationFactor>;
125
+ authentication_factors: B2BAuthenticationFactor[];
126
126
  /**
127
127
  * A map of the custom claims associated with the session.
128
128
  * Custom claims can only be set from the server, they cannot be set using the clientside SDKs.
@@ -131,6 +131,12 @@ interface MemberSession {
131
131
  * If no claims are set, this field will be null.
132
132
  */
133
133
  custom_claims?: Record<string, unknown>;
134
+ /**
135
+ * A list of the roles associated with the session.
136
+ * Members may inherit certain roles depending on the factors in their session.
137
+ * For example, some roles may only be active if the member logged in from a specific SAML IDP.
138
+ */
139
+ roles: string[];
134
140
  }
135
141
  interface SSORegistration {
136
142
  connection_id: string;
@@ -138,6 +144,26 @@ interface SSORegistration {
138
144
  registration_id: string;
139
145
  sso_attributes: Record<string, unknown>;
140
146
  }
147
+ type RoleSource = {
148
+ type: "direct_assignment";
149
+ details: Record<string, never>;
150
+ } | {
151
+ type: "email_assignment";
152
+ details: {
153
+ email_domain: string;
154
+ };
155
+ } | {
156
+ type: "sso_connection";
157
+ details: {
158
+ connection_id: string;
159
+ };
160
+ } | {
161
+ type: "sso_connection_group";
162
+ details: {
163
+ connection_id: string;
164
+ group: string;
165
+ };
166
+ };
141
167
  interface Member {
142
168
  /**
143
169
  * Globally unique UUID that identifies an organization in the Stytch API.
@@ -178,7 +204,11 @@ interface Member {
178
204
  * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
179
205
  */
180
206
  untrusted_metadata: Record<string, unknown>;
181
- sso_registrations: Array<SSORegistration>;
207
+ sso_registrations: SSORegistration[];
208
+ /**
209
+ * Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings.
210
+ * A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures.
211
+ */
182
212
  is_breakglass: boolean;
183
213
  /**
184
214
  * Returned if the member has a registered password
@@ -197,6 +227,13 @@ interface Member {
197
227
  * Whether the member's phone number is verified.
198
228
  */
199
229
  mfa_phone_number_verified: boolean;
230
+ /**
231
+ * A list of the member's roles and their sources
232
+ */
233
+ roles: {
234
+ role_id: string;
235
+ sources: RoleSource[];
236
+ }[];
200
237
  }
201
238
  type B2BAuthenticateResponse = ResponseCommon & {
202
239
  /**
@@ -281,19 +318,77 @@ interface Organization {
281
318
  * This field can only be updated by a direct API integration.
282
319
  */
283
320
  trusted_metadata: Record<string, unknown>;
321
+ /**
322
+ * The default connection used for SSO when there are multiple active connections.
323
+ */
284
324
  sso_default_connection_id: string | null;
325
+ /**
326
+ * The authentication setting that controls the JIT provisioning of Members when authenticating via SSO.
327
+ * The accepted values are:
328
+ * ALL_ALLOWED – new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections.
329
+ * RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication.
330
+ * NOT_ALLOWED – disable JIT provisioning via SSO.
331
+ */
285
332
  sso_jit_provisioning: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
333
+ /**
334
+ * An array of connection_ids that reference SAML Connection objects.
335
+ * Only these connections will be allowed to JIT provision Members via SSO when sso_jit_provisioning is set to RESTRICTED.
336
+ */
286
337
  sso_jit_provisioning_allowed_connections: string[];
287
- sso_active_connections: Array<{
338
+ /**
339
+ * An array of active SSO Connection references.
340
+ */
341
+ sso_active_connections: {
288
342
  connection_id: string;
289
343
  display_name: string;
290
- }>;
344
+ }[];
345
+ /**
346
+ * An array of email domains that allow invites or JIT provisioning for new Members.
347
+ * This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED.
348
+ * Common domains such as gmail.com are not allowed.
349
+ */
291
350
  email_allowed_domains: string[];
351
+ /**
352
+ * The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link.
353
+ * The accepted values are:
354
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link.
355
+ * NOT_ALLOWED – disable JIT provisioning via Email Magic Link.
356
+ */
292
357
  email_jit_provisioning: "RESTRICTED" | "NOT_ALLOWED";
358
+ /**
359
+ * The authentication setting that controls how a new Member can be invited to an organization by email.
360
+ * The accepted values are:
361
+ * ALL_ALLOWED – any new Member can be invited to join via email.
362
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
363
+ * NOT_ALLOWED – disable email invites.
364
+ */
293
365
  email_invites: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
366
+ /**
367
+ * The setting that controls which authentication methods can be used by Members of an Organization.
368
+ * The accepted values are:
369
+ * ALL_ALLOWED – the default setting which allows all authentication methods to be used.
370
+ * 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.
371
+ */
294
372
  auth_methods: "ALL_ALLOWED" | "RESTRICTED";
373
+ /**
374
+ * An array of allowed authentication methods.
375
+ * This list is enforced when auth_methods is set to RESTRICTED.
376
+ * The list's accepted values are: sso, magic_link, password, google_oauth, and microsoft_oauth.
377
+ */
295
378
  allowed_auth_methods: string[];
379
+ /**
380
+ * The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
381
+ * REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in.
382
+ * 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
383
+ */
296
384
  mfa_policy: "OPTIONAL" | "REQUIRED_FOR_ALL";
385
+ /**
386
+ * An array of implicit role assignments granted to members in this organization whose emails match the domain.
387
+ */
388
+ rbac_email_implicit_role_assignments?: {
389
+ role_id: string;
390
+ domain: string;
391
+ }[];
297
392
  }
298
393
  interface MfaRequired {
299
394
  member_options: MemberOptions;
@@ -623,13 +718,16 @@ declare class StytchB2BHeadlessClient {
623
718
  // External API Clients
624
719
  magicLinks: IHeadlessB2BMagicLinksClient;
625
720
  session: IHeadlessB2BSessionClient;
721
+ /** @deprecated Please use client.self instead. This will be removed in a future release. */
626
722
  member: IHeadlessB2BMemberClient;
723
+ self: IHeadlessB2BSelfClient;
627
724
  organization: IHeadlessB2BOrganizationClient;
628
725
  oauth: IHeadlessB2BOAuthClient;
629
726
  sso: IHeadlessB2BSSOClient;
630
727
  discovery: IHeadlessB2BDiscoveryClient;
631
728
  passwords: IHeadlessB2BPasswordClient;
632
729
  otps: IHeadlessB2BOTPsClient;
730
+ rbac: IHeadlessB2BRBACClient;
633
731
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
634
732
  }
635
733
  /**
@@ -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
  import { Callbacks as Callbacks$0 } from "@stytch/core/public";
3
3
  import { StyleConfig as StyleConfig$0 } from "@stytch/core/public";
4
4
  import { StytchB2BUIConfig as StytchB2BUIConfig$0 } from "@stytch/core/public";
@@ -122,7 +122,7 @@ interface MemberSession {
122
122
  /**
123
123
  * All the authentication factors that have been associated with the current member session.
124
124
  */
125
- authentication_factors: Array<B2BAuthenticationFactor>;
125
+ authentication_factors: B2BAuthenticationFactor[];
126
126
  /**
127
127
  * A map of the custom claims associated with the session.
128
128
  * Custom claims can only be set from the server, they cannot be set using the clientside SDKs.
@@ -131,6 +131,12 @@ interface MemberSession {
131
131
  * If no claims are set, this field will be null.
132
132
  */
133
133
  custom_claims?: Record<string, unknown>;
134
+ /**
135
+ * A list of the roles associated with the session.
136
+ * Members may inherit certain roles depending on the factors in their session.
137
+ * For example, some roles may only be active if the member logged in from a specific SAML IDP.
138
+ */
139
+ roles: string[];
134
140
  }
135
141
  interface SSORegistration {
136
142
  connection_id: string;
@@ -138,6 +144,26 @@ interface SSORegistration {
138
144
  registration_id: string;
139
145
  sso_attributes: Record<string, unknown>;
140
146
  }
147
+ type RoleSource = {
148
+ type: "direct_assignment";
149
+ details: Record<string, never>;
150
+ } | {
151
+ type: "email_assignment";
152
+ details: {
153
+ email_domain: string;
154
+ };
155
+ } | {
156
+ type: "sso_connection";
157
+ details: {
158
+ connection_id: string;
159
+ };
160
+ } | {
161
+ type: "sso_connection_group";
162
+ details: {
163
+ connection_id: string;
164
+ group: string;
165
+ };
166
+ };
141
167
  interface Member {
142
168
  /**
143
169
  * Globally unique UUID that identifies an organization in the Stytch API.
@@ -178,7 +204,11 @@ interface Member {
178
204
  * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
179
205
  */
180
206
  untrusted_metadata: Record<string, unknown>;
181
- sso_registrations: Array<SSORegistration>;
207
+ sso_registrations: SSORegistration[];
208
+ /**
209
+ * Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings.
210
+ * A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures.
211
+ */
182
212
  is_breakglass: boolean;
183
213
  /**
184
214
  * Returned if the member has a registered password
@@ -197,6 +227,13 @@ interface Member {
197
227
  * Whether the member's phone number is verified.
198
228
  */
199
229
  mfa_phone_number_verified: boolean;
230
+ /**
231
+ * A list of the member's roles and their sources
232
+ */
233
+ roles: {
234
+ role_id: string;
235
+ sources: RoleSource[];
236
+ }[];
200
237
  }
201
238
  type B2BAuthenticateResponse = ResponseCommon & {
202
239
  /**
@@ -281,19 +318,77 @@ interface Organization {
281
318
  * This field can only be updated by a direct API integration.
282
319
  */
283
320
  trusted_metadata: Record<string, unknown>;
321
+ /**
322
+ * The default connection used for SSO when there are multiple active connections.
323
+ */
284
324
  sso_default_connection_id: string | null;
325
+ /**
326
+ * The authentication setting that controls the JIT provisioning of Members when authenticating via SSO.
327
+ * The accepted values are:
328
+ * ALL_ALLOWED – new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections.
329
+ * RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication.
330
+ * NOT_ALLOWED – disable JIT provisioning via SSO.
331
+ */
285
332
  sso_jit_provisioning: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
333
+ /**
334
+ * An array of connection_ids that reference SAML Connection objects.
335
+ * Only these connections will be allowed to JIT provision Members via SSO when sso_jit_provisioning is set to RESTRICTED.
336
+ */
286
337
  sso_jit_provisioning_allowed_connections: string[];
287
- sso_active_connections: Array<{
338
+ /**
339
+ * An array of active SSO Connection references.
340
+ */
341
+ sso_active_connections: {
288
342
  connection_id: string;
289
343
  display_name: string;
290
- }>;
344
+ }[];
345
+ /**
346
+ * An array of email domains that allow invites or JIT provisioning for new Members.
347
+ * This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED.
348
+ * Common domains such as gmail.com are not allowed.
349
+ */
291
350
  email_allowed_domains: string[];
351
+ /**
352
+ * The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link.
353
+ * The accepted values are:
354
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link.
355
+ * NOT_ALLOWED – disable JIT provisioning via Email Magic Link.
356
+ */
292
357
  email_jit_provisioning: "RESTRICTED" | "NOT_ALLOWED";
358
+ /**
359
+ * The authentication setting that controls how a new Member can be invited to an organization by email.
360
+ * The accepted values are:
361
+ * ALL_ALLOWED – any new Member can be invited to join via email.
362
+ * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
363
+ * NOT_ALLOWED – disable email invites.
364
+ */
293
365
  email_invites: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
366
+ /**
367
+ * The setting that controls which authentication methods can be used by Members of an Organization.
368
+ * The accepted values are:
369
+ * ALL_ALLOWED – the default setting which allows all authentication methods to be used.
370
+ * 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.
371
+ */
294
372
  auth_methods: "ALL_ALLOWED" | "RESTRICTED";
373
+ /**
374
+ * An array of allowed authentication methods.
375
+ * This list is enforced when auth_methods is set to RESTRICTED.
376
+ * The list's accepted values are: sso, magic_link, password, google_oauth, and microsoft_oauth.
377
+ */
295
378
  allowed_auth_methods: string[];
379
+ /**
380
+ * The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
381
+ * REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in.
382
+ * 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
383
+ */
296
384
  mfa_policy: "OPTIONAL" | "REQUIRED_FOR_ALL";
385
+ /**
386
+ * An array of implicit role assignments granted to members in this organization whose emails match the domain.
387
+ */
388
+ rbac_email_implicit_role_assignments?: {
389
+ role_id: string;
390
+ domain: string;
391
+ }[];
297
392
  }
298
393
  interface MfaRequired {
299
394
  member_options: MemberOptions;
@@ -623,13 +718,16 @@ declare class StytchB2BHeadlessClient {
623
718
  // External API Clients
624
719
  magicLinks: IHeadlessB2BMagicLinksClient;
625
720
  session: IHeadlessB2BSessionClient;
721
+ /** @deprecated Please use client.self instead. This will be removed in a future release. */
626
722
  member: IHeadlessB2BMemberClient;
723
+ self: IHeadlessB2BSelfClient;
627
724
  organization: IHeadlessB2BOrganizationClient;
628
725
  oauth: IHeadlessB2BOAuthClient;
629
726
  sso: IHeadlessB2BSSOClient;
630
727
  discovery: IHeadlessB2BDiscoveryClient;
631
728
  passwords: IHeadlessB2BPasswordClient;
632
729
  otps: IHeadlessB2BOTPsClient;
730
+ rbac: IHeadlessB2BRBACClient;
633
731
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
634
732
  }
635
733
  /**