@workos-inc/node 7.47.0 → 7.49.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.
@@ -5,6 +5,7 @@ import { AuthenticationEvent, AuthenticationEventResponse, EmailVerificationEven
5
5
  import { OrganizationMembership, OrganizationMembershipResponse } from '../../user-management/interfaces/organization-membership.interface';
6
6
  import { RoleEvent, RoleEventResponse } from '../../roles/interfaces/role.interface';
7
7
  import { OrganizationDomain, OrganizationDomainResponse } from '../../organization-domains/interfaces';
8
+ import { AuthenticationRadarRiskDetectedEventData, AuthenticationRadarRiskDetectedEventResponseData } from '../../user-management/interfaces/authentication-radar-risk-detected-event.interface';
8
9
  export interface EventBase {
9
10
  id: string;
10
11
  createdAt: string;
@@ -77,6 +78,14 @@ export interface AuthenticationPasswordSucceededEventResponse extends EventRespo
77
78
  event: 'authentication.password_succeeded';
78
79
  data: AuthenticationEventResponse;
79
80
  }
81
+ export interface AuthenticationRadarRiskDetectedEvent extends EventBase {
82
+ event: 'authentication.radar_risk_detected';
83
+ data: AuthenticationRadarRiskDetectedEventData;
84
+ }
85
+ export interface AuthenticationRadarRiskDetectedEventResponse extends EventResponseBase {
86
+ event: 'authentication.radar_risk_detected';
87
+ data: AuthenticationRadarRiskDetectedEventResponseData;
88
+ }
80
89
  export interface AuthenticationSSOFailedEvent extends EventBase {
81
90
  event: 'authentication.sso_failed';
82
91
  data: AuthenticationEvent;
@@ -409,7 +418,7 @@ export interface OrganizationDomainVerificationFailedEventResponse extends Event
409
418
  event: 'organization_domain.verification_failed';
410
419
  data: OrganizationDomainResponse;
411
420
  }
412
- export type Event = AuthenticationEmailVerificationSucceededEvent | AuthenticationMfaSucceededEvent | AuthenticationOAuthFailedEvent | AuthenticationOAuthSucceededEvent | AuthenticationSSOFailedEvent | AuthenticationSSOSucceededEvent | AuthenticationPasswordFailedEvent | AuthenticationPasswordSucceededEvent | AuthenticationMagicAuthFailedEvent | AuthenticationMagicAuthSucceededEvent | ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent;
413
- export type EventResponse = AuthenticationEmailVerificationSucceededEventResponse | AuthenticationMagicAuthFailedEventResponse | AuthenticationMagicAuthSucceededEventResponse | AuthenticationMfaSucceededEventResponse | AuthenticationOAuthFailedEventResponse | AuthenticationOAuthSucceededEventResponse | AuthenticationPasswordFailedEventResponse | AuthenticationPasswordSucceededEventResponse | AuthenticationSSOFailedEventResponse | AuthenticationSSOSucceededEventResponse | ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse;
421
+ export type Event = AuthenticationEmailVerificationSucceededEvent | AuthenticationMfaSucceededEvent | AuthenticationOAuthFailedEvent | AuthenticationOAuthSucceededEvent | AuthenticationSSOFailedEvent | AuthenticationSSOSucceededEvent | AuthenticationPasswordFailedEvent | AuthenticationPasswordSucceededEvent | AuthenticationMagicAuthFailedEvent | AuthenticationMagicAuthSucceededEvent | AuthenticationRadarRiskDetectedEvent | ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent;
422
+ export type EventResponse = AuthenticationEmailVerificationSucceededEventResponse | AuthenticationMagicAuthFailedEventResponse | AuthenticationMagicAuthSucceededEventResponse | AuthenticationMfaSucceededEventResponse | AuthenticationOAuthFailedEventResponse | AuthenticationOAuthSucceededEventResponse | AuthenticationPasswordFailedEventResponse | AuthenticationPasswordSucceededEventResponse | AuthenticationSSOFailedEventResponse | AuthenticationSSOSucceededEventResponse | AuthenticationRadarRiskDetectedEventResponse | ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse;
414
423
  export type EventName = Event['event'];
415
424
  export {};
@@ -0,0 +1 @@
1
+ export type UnknownRecord = Record<string, unknown>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,6 +9,7 @@ const organization_domain_serializer_1 = require("../../organization-domains/ser
9
9
  const organization_membership_serializer_1 = require("../../user-management/serializers/organization-membership.serializer");
10
10
  const role_serializer_1 = require("../../user-management/serializers/role.serializer");
11
11
  const session_serializer_1 = require("../../user-management/serializers/session.serializer");
12
+ const authentication_radar_risk_event_serializer_1 = require("../../user-management/serializers/authentication-radar-risk-event-serializer");
12
13
  const deserializeEvent = (event) => {
13
14
  const eventBase = {
14
15
  id: event.id,
@@ -26,6 +27,8 @@ const deserializeEvent = (event) => {
26
27
  case 'authentication.sso_failed':
27
28
  case 'authentication.sso_succeeded':
28
29
  return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeAuthenticationEvent)(event.data) });
30
+ case 'authentication.radar_risk_detected':
31
+ return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, authentication_radar_risk_event_serializer_1.deserializeAuthenticationRadarRiskDetectedEvent)(event.data) });
29
32
  case 'connection.activated':
30
33
  case 'connection.deactivated':
31
34
  case 'connection.deleted':
@@ -1,9 +1,10 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { Profile, ProfileResponse } from './profile.interface';
2
- export interface ProfileAndToken {
3
+ export interface ProfileAndToken<CustomAttributesType extends UnknownRecord> {
3
4
  accessToken: string;
4
- profile: Profile;
5
+ profile: Profile<CustomAttributesType>;
5
6
  }
6
- export interface ProfileAndTokenResponse {
7
+ export interface ProfileAndTokenResponse<CustomAttributesType extends UnknownRecord> {
7
8
  access_token: string;
8
- profile: ProfileResponse;
9
+ profile: ProfileResponse<CustomAttributesType>;
9
10
  }
@@ -1,6 +1,7 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { RoleResponse } from '../../roles/interfaces';
2
3
  import { ConnectionType } from './connection-type.enum';
3
- export interface Profile {
4
+ export interface Profile<CustomAttributesType extends UnknownRecord> {
4
5
  id: string;
5
6
  idpId: string;
6
7
  organizationId?: string;
@@ -11,11 +12,12 @@ export interface Profile {
11
12
  lastName?: string;
12
13
  role?: RoleResponse;
13
14
  groups?: string[];
15
+ customAttributes?: CustomAttributesType;
14
16
  rawAttributes?: {
15
17
  [key: string]: any;
16
18
  };
17
19
  }
18
- export interface ProfileResponse {
20
+ export interface ProfileResponse<CustomAttributesType extends UnknownRecord> {
19
21
  id: string;
20
22
  idp_id: string;
21
23
  organization_id?: string;
@@ -26,6 +28,7 @@ export interface ProfileResponse {
26
28
  last_name?: string;
27
29
  role?: RoleResponse;
28
30
  groups?: string[];
31
+ custom_attributes?: CustomAttributesType;
29
32
  raw_attributes?: {
30
33
  [key: string]: any;
31
34
  };
@@ -1,2 +1,3 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { ProfileAndToken, ProfileAndTokenResponse } from '../interfaces';
2
- export declare const deserializeProfileAndToken: (profileAndToken: ProfileAndTokenResponse) => ProfileAndToken;
3
+ export declare const deserializeProfileAndToken: <CustomAttributesType extends UnknownRecord>(profileAndToken: ProfileAndTokenResponse<CustomAttributesType>) => ProfileAndToken<CustomAttributesType>;
@@ -1,2 +1,3 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { Profile, ProfileResponse } from '../interfaces';
2
- export declare const deserializeProfile: (profile: ProfileResponse) => Profile;
3
+ export declare const deserializeProfile: <CustomAttributesType extends UnknownRecord>(profile: ProfileResponse<CustomAttributesType>) => Profile<CustomAttributesType>;
@@ -12,6 +12,7 @@ const deserializeProfile = (profile) => ({
12
12
  lastName: profile.last_name,
13
13
  role: profile.role,
14
14
  groups: profile.groups,
15
+ customAttributes: profile.custom_attributes,
15
16
  rawAttributes: profile.raw_attributes,
16
17
  });
17
18
  exports.deserializeProfile = deserializeProfile;
package/lib/sso/sso.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AutoPaginatable } from '../common/utils/pagination';
2
2
  import { WorkOS } from '../workos';
3
3
  import { AuthorizationURLOptions, Connection, GetProfileAndTokenOptions, GetProfileOptions, ListConnectionsOptions, Profile, ProfileAndToken } from './interfaces';
4
+ import { UnknownRecord } from '../common/interfaces/unknown-record.interface';
4
5
  export declare class SSO {
5
6
  private readonly workos;
6
7
  constructor(workos: WorkOS);
@@ -8,6 +9,6 @@ export declare class SSO {
8
9
  deleteConnection(id: string): Promise<void>;
9
10
  getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }: AuthorizationURLOptions): string;
10
11
  getConnection(id: string): Promise<Connection>;
11
- getProfileAndToken({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken>;
12
- getProfile({ accessToken }: GetProfileOptions): Promise<Profile>;
12
+ getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
13
+ getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
13
14
  }
package/lib/sso/sso.js CHANGED
@@ -77,7 +77,7 @@ class SSO {
77
77
  return (0, serializers_1.deserializeProfileAndToken)(data);
78
78
  });
79
79
  }
80
- getProfile({ accessToken }) {
80
+ getProfile({ accessToken, }) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  const { data } = yield this.workos.get('/sso/profile', {
83
83
  accessToken,
@@ -185,6 +185,10 @@ describe('SSO', () => {
185
185
  first_name: 'foo',
186
186
  last_name: 'bar',
187
187
  groups: ['Admins', 'Developers'],
188
+ license: 'professional',
189
+ },
190
+ custom_attributes: {
191
+ license: 'professional',
188
192
  },
189
193
  },
190
194
  });
@@ -221,6 +225,7 @@ describe('SSO', () => {
221
225
  first_name: 'foo',
222
226
  last_name: 'bar',
223
227
  },
228
+ custom_attributes: {},
224
229
  },
225
230
  });
226
231
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
@@ -257,6 +262,7 @@ describe('SSO', () => {
257
262
  last_name: 'bar',
258
263
  groups: ['Admins', 'Developers'],
259
264
  },
265
+ custom_attributes: {},
260
266
  });
261
267
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
262
268
  const profile = yield workos.sso.getProfile({
@@ -0,0 +1,20 @@
1
+ export type AuthenticationRadarRiskDetectedEventData = {
2
+ authMethod: string;
3
+ action: 'signup' | 'login';
4
+ control: string | null;
5
+ blocklistType: string | null;
6
+ ipAddress: string | null;
7
+ userAgent: string | null;
8
+ userId: string;
9
+ email: string;
10
+ };
11
+ export interface AuthenticationRadarRiskDetectedEventResponseData {
12
+ auth_method: string;
13
+ action: 'signup' | 'login';
14
+ control: string | null;
15
+ blocklist_type: string | null;
16
+ ip_address: string | null;
17
+ user_agent: string | null;
18
+ user_id: string;
19
+ email: string;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,6 +3,10 @@ export interface AuthorizationURLOptions {
3
3
  codeChallenge?: string;
4
4
  codeChallengeMethod?: 'S256';
5
5
  connectionId?: string;
6
+ /**
7
+ * @deprecated We previously required initiate login endpoints to return the `context`
8
+ * query parameter when getting the authorization URL. This is no longer necessary.
9
+ */
6
10
  context?: string;
7
11
  organizationId?: string;
8
12
  domainHint?: string;
@@ -9,6 +9,7 @@ export * from './authenticate-with-session-cookie.interface';
9
9
  export * from './authenticate-with-totp-options.interface';
10
10
  export * from './authentication-event.interface';
11
11
  export * from './authentication-response.interface';
12
+ export * from './authentication-radar-risk-detected-event.interface';
12
13
  export * from './create-magic-auth-options.interface';
13
14
  export * from './create-organization-membership-options.interface';
14
15
  export * from './create-password-reset-options.interface';
@@ -25,6 +25,7 @@ __exportStar(require("./authenticate-with-session-cookie.interface"), exports);
25
25
  __exportStar(require("./authenticate-with-totp-options.interface"), exports);
26
26
  __exportStar(require("./authentication-event.interface"), exports);
27
27
  __exportStar(require("./authentication-response.interface"), exports);
28
+ __exportStar(require("./authentication-radar-risk-detected-event.interface"), exports);
28
29
  __exportStar(require("./create-magic-auth-options.interface"), exports);
29
30
  __exportStar(require("./create-organization-membership-options.interface"), exports);
30
31
  __exportStar(require("./create-password-reset-options.interface"), exports);
@@ -0,0 +1,2 @@
1
+ import type { AuthenticationRadarRiskDetectedEventData, AuthenticationRadarRiskDetectedEventResponseData } from '../interfaces';
2
+ export declare const deserializeAuthenticationRadarRiskDetectedEvent: (authenticationRadarRiskDetectedEvent: AuthenticationRadarRiskDetectedEventResponseData) => AuthenticationRadarRiskDetectedEventData;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeAuthenticationRadarRiskDetectedEvent = void 0;
4
+ const deserializeAuthenticationRadarRiskDetectedEvent = (authenticationRadarRiskDetectedEvent) => ({
5
+ authMethod: authenticationRadarRiskDetectedEvent.auth_method,
6
+ action: authenticationRadarRiskDetectedEvent.action,
7
+ control: authenticationRadarRiskDetectedEvent.control,
8
+ blocklistType: authenticationRadarRiskDetectedEvent.blocklist_type,
9
+ ipAddress: authenticationRadarRiskDetectedEvent.ip_address,
10
+ userAgent: authenticationRadarRiskDetectedEvent.user_agent,
11
+ userId: authenticationRadarRiskDetectedEvent.user_id,
12
+ email: authenticationRadarRiskDetectedEvent.email,
13
+ });
14
+ exports.deserializeAuthenticationRadarRiskDetectedEvent = deserializeAuthenticationRadarRiskDetectedEvent;
@@ -526,6 +526,10 @@ class UserManagement {
526
526
  if (provider !== 'authkit' && screenHint) {
527
527
  throw new TypeError(`'screenHint' is only supported for 'authkit' provider`);
528
528
  }
529
+ if (context) {
530
+ this.workos.emitWarning(`\`context\` is deprecated. We previously required initiate login endpoints to return the
531
+ \`context\` query parameter when getting the authorization URL. This is no longer necessary.`);
532
+ }
529
533
  const query = toQueryString({
530
534
  connection_id: connectionId,
531
535
  code_challenge: codeChallenge,
package/lib/workos.js CHANGED
@@ -31,7 +31,7 @@ const widgets_1 = require("./widgets/widgets");
31
31
  const actions_1 = require("./actions/actions");
32
32
  const vault_1 = require("./vault/vault");
33
33
  const conflict_exception_1 = require("./common/exceptions/conflict.exception");
34
- const VERSION = '7.47.0';
34
+ const VERSION = '7.49.0';
35
35
  const DEFAULT_HOSTNAME = 'api.workos.com';
36
36
  const HEADER_AUTHORIZATION = 'Authorization';
37
37
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.47.0",
2
+ "version": "7.49.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",