@workos-inc/node 7.72.2 → 7.74.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.
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuditLogs = void 0;
13
+ const crypto_1 = require("crypto");
13
14
  const serializers_1 = require("./serializers");
14
15
  class AuditLogs {
15
16
  constructor(workos) {
@@ -17,10 +18,12 @@ class AuditLogs {
17
18
  }
18
19
  createEvent(organization, event, options = {}) {
19
20
  return __awaiter(this, void 0, void 0, function* () {
21
+ // Auto-generate idempotency key if not provided
22
+ const optionsWithIdempotency = Object.assign(Object.assign({}, options), { idempotencyKey: options.idempotencyKey || `workos-node-${(0, crypto_1.randomUUID)()}` });
20
23
  yield this.workos.post('/audit_logs/events', {
21
24
  event: (0, serializers_1.serializeCreateAuditLogEventOptions)(event),
22
25
  organization_id: organization,
23
- }, options);
26
+ }, optionsWithIdempotency);
24
27
  });
25
28
  }
26
29
  createExport(options) {
@@ -79,6 +79,34 @@ describe('AuditLogs', () => {
79
79
  }, { idempotencyKey: 'the-idempotency-key' });
80
80
  }));
81
81
  });
82
+ describe('without an idempotency key', () => {
83
+ it('auto-generates an idempotency key with workos-node prefix', () => __awaiter(void 0, void 0, void 0, function* () {
84
+ const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'post');
85
+ workosSpy.mockResolvedValueOnce((0, workos_mock_response_1.mockWorkOsResponse)(201, { success: true }));
86
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
87
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
88
+ // Verify that an idempotency key was auto-generated
89
+ expect(workosSpy).toHaveBeenCalledWith('/audit_logs/events', {
90
+ event: (0, serializers_1.serializeCreateAuditLogEventOptions)(event),
91
+ organization_id: 'org_123',
92
+ }, expect.objectContaining({
93
+ idempotencyKey: expect.stringMatching(/^workos-node\S*/),
94
+ }));
95
+ }));
96
+ it('generates different idempotency keys for different requests', () => __awaiter(void 0, void 0, void 0, function* () {
97
+ var _a, _b;
98
+ const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'post');
99
+ workosSpy.mockResolvedValue((0, workos_mock_response_1.mockWorkOsResponse)(201, { success: true }));
100
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
101
+ yield workos.auditLogs.createEvent('org_123', event);
102
+ yield workos.auditLogs.createEvent('org_123', event);
103
+ const firstCallKey = (_a = workosSpy.mock.calls[0][2]) === null || _a === void 0 ? void 0 : _a.idempotencyKey;
104
+ const secondCallKey = (_b = workosSpy.mock.calls[1][2]) === null || _b === void 0 ? void 0 : _b.idempotencyKey;
105
+ expect(firstCallKey).toBeDefined();
106
+ expect(secondCallKey).toBeDefined();
107
+ expect(firstCallKey).not.toBe(secondCallKey);
108
+ }));
109
+ });
82
110
  describe('when the api responds with a 200', () => {
83
111
  it('returns void', () => __awaiter(void 0, void 0, void 0, function* () {
84
112
  const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'post');
@@ -88,7 +116,9 @@ describe('AuditLogs', () => {
88
116
  expect(workosSpy).toHaveBeenCalledWith('/audit_logs/events', {
89
117
  event: (0, serializers_1.serializeCreateAuditLogEventOptions)(event),
90
118
  organization_id: 'org_123',
91
- }, {});
119
+ }, expect.objectContaining({
120
+ idempotencyKey: expect.stringMatching(/^workos-node\S*/),
121
+ }));
92
122
  }));
93
123
  });
94
124
  describe('when the api responds with a 401', () => {
@@ -125,6 +155,84 @@ describe('AuditLogs', () => {
125
155
  yield expect(workos.auditLogs.createEvent('org_123', event)).rejects.toThrow(bad_request_exception_1.BadRequestException);
126
156
  }));
127
157
  });
158
+ describe('retry behavior', () => {
159
+ beforeEach(() => {
160
+ jest_fetch_mock_1.default.resetMocks();
161
+ jest.clearAllMocks();
162
+ });
163
+ it('retries on 500 status code and eventually succeeds', () => __awaiter(void 0, void 0, void 0, function* () {
164
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ success: true }), { status: 201 }]);
165
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
166
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
167
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
168
+ }));
169
+ it('retries on 502 status code and eventually succeeds', () => __awaiter(void 0, void 0, void 0, function* () {
170
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Bad Gateway' }), { status: 502 }], [JSON.stringify({ error: 'Bad Gateway' }), { status: 502 }], [JSON.stringify({ success: true }), { status: 201 }]);
171
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
172
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
173
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
174
+ }));
175
+ it('retries on 504 status code and eventually succeeds', () => __awaiter(void 0, void 0, void 0, function* () {
176
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Gateway Timeout' }), { status: 504 }], [JSON.stringify({ error: 'Gateway Timeout' }), { status: 504 }], [JSON.stringify({ success: true }), { status: 201 }]);
177
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
178
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
179
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
180
+ }));
181
+ it('retries on 408 status code and eventually succeeds', () => __awaiter(void 0, void 0, void 0, function* () {
182
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Request Timeout' }), { status: 408 }], [JSON.stringify({ error: 'Request Timeout' }), { status: 408 }], [JSON.stringify({ success: true }), { status: 201 }]);
183
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
184
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
185
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
186
+ }));
187
+ it('succeeds on the last retry attempt (4th attempt)', () => __awaiter(void 0, void 0, void 0, function* () {
188
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ success: true }), { status: 201 }]);
189
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
190
+ yield expect(workos.auditLogs.createEvent('org_123', event)).resolves.toBeUndefined();
191
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(4);
192
+ }), 10000);
193
+ it('retries a maximum of 3 times (4 total attempts)', () => __awaiter(void 0, void 0, void 0, function* () {
194
+ jest_fetch_mock_1.default.mockResponse(JSON.stringify({ error: 'Internal Server Error' }), {
195
+ status: 500,
196
+ });
197
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
198
+ yield expect(workos.auditLogs.createEvent('org_123', event)).rejects.toThrow();
199
+ // 1 initial attempt + 3 retries = 4 total attempts
200
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(4);
201
+ }), 10000);
202
+ it('uses the same idempotency key across all retry attempts', () => __awaiter(void 0, void 0, void 0, function* () {
203
+ var _a;
204
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ success: true }), { status: 201 }]);
205
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
206
+ yield workos.auditLogs.createEvent('org_123', event, {
207
+ idempotencyKey: 'test-idempotency-key',
208
+ });
209
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
210
+ // Verify all requests have the same idempotency key in headers
211
+ const calls = jest_fetch_mock_1.default.mock.calls;
212
+ for (const call of calls) {
213
+ const headers = (_a = call[1]) === null || _a === void 0 ? void 0 : _a.headers;
214
+ expect(headers['Idempotency-Key']).toBe('test-idempotency-key');
215
+ }
216
+ }), 10000);
217
+ it('maintains auto-generated idempotency key across retry attempts', () => __awaiter(void 0, void 0, void 0, function* () {
218
+ jest_fetch_mock_1.default.mockResponses([JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ error: 'Internal Server Error' }), { status: 500 }], [JSON.stringify({ success: true }), { status: 201 }]);
219
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
220
+ yield workos.auditLogs.createEvent('org_123', event);
221
+ expect(jest_fetch_mock_1.default).toHaveBeenCalledTimes(3);
222
+ // Verify all requests have the same auto-generated idempotency key
223
+ const calls = jest_fetch_mock_1.default.mock.calls;
224
+ const idempotencyKeys = calls.map((call) => { var _a; return ((_a = call[1]) === null || _a === void 0 ? void 0 : _a.headers)['Idempotency-Key']; });
225
+ // All keys should be defined
226
+ idempotencyKeys.forEach((key) => {
227
+ expect(key).toBeDefined();
228
+ expect(key).toMatch(/\S/);
229
+ expect(key.startsWith('workos-node-')).toBe(true);
230
+ });
231
+ // All keys should be the same
232
+ expect(idempotencyKeys[0]).toBe(idempotencyKeys[1]);
233
+ expect(idempotencyKeys[1]).toBe(idempotencyKeys[2]);
234
+ }), 10000);
235
+ });
128
236
  });
129
237
  describe('createExport', () => {
130
238
  describe('when the api responds with a 201', () => {
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.UnprocessableEntityException = void 0;
7
- const pluralize_1 = __importDefault(require("pluralize"));
8
4
  class UnprocessableEntityException extends Error {
9
5
  constructor({ code, errors, message, requestID, }) {
10
6
  super();
@@ -19,7 +15,7 @@ class UnprocessableEntityException extends Error {
19
15
  this.code = code;
20
16
  }
21
17
  if (errors) {
22
- const requirement = (0, pluralize_1.default)('requirement', errors.length);
18
+ const requirement = errors.length === 1 ? 'requirement' : 'requirements';
23
19
  this.message = `The following ${requirement} must be met:\n`;
24
20
  for (const { code } of errors) {
25
21
  this.message = this.message.concat(`\t${code}\n`);
@@ -62,6 +62,22 @@ export interface AuthenticationOAuthSucceededEventResponse extends EventResponse
62
62
  event: 'authentication.oauth_succeeded';
63
63
  data: AuthenticationEventResponse;
64
64
  }
65
+ export interface AuthenticationPasskeyFailedEvent extends EventBase {
66
+ event: 'authentication.passkey_failed';
67
+ data: AuthenticationEvent;
68
+ }
69
+ export interface AuthenticationPasskeyFailedEventResponse extends EventResponseBase {
70
+ event: 'authentication.passkey_failed';
71
+ data: AuthenticationEventResponse;
72
+ }
73
+ export interface AuthenticationPasskeySucceededEvent extends EventBase {
74
+ event: 'authentication.passkey_succeeded';
75
+ data: AuthenticationEvent;
76
+ }
77
+ export interface AuthenticationPasskeySucceededEventResponse extends EventResponseBase {
78
+ event: 'authentication.passkey_succeeded';
79
+ data: AuthenticationEventResponse;
80
+ }
65
81
  export interface AuthenticationPasswordFailedEvent extends EventBase {
66
82
  event: 'authentication.password_failed';
67
83
  data: AuthenticationEvent;
@@ -466,7 +482,7 @@ export interface OrganizationDomainDeletedEventResponse extends EventResponseBas
466
482
  event: 'organization_domain.deleted';
467
483
  data: OrganizationDomainResponse;
468
484
  }
469
- 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 | InvitationAcceptedEvent | InvitationCreatedEvent | InvitationRevokedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | SessionRevokedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent | OrganizationDomainCreatedEvent | OrganizationDomainUpdatedEvent | OrganizationDomainDeletedEvent;
470
- 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 | InvitationAcceptedEventResponse | InvitationCreatedEventResponse | InvitationRevokedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | SessionRevokedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse | OrganizationDomainCreatedEventResponse | OrganizationDomainUpdatedEventResponse | OrganizationDomainDeletedEventResponse;
485
+ export type Event = AuthenticationEmailVerificationSucceededEvent | AuthenticationMfaSucceededEvent | AuthenticationOAuthFailedEvent | AuthenticationOAuthSucceededEvent | AuthenticationSSOFailedEvent | AuthenticationSSOSucceededEvent | AuthenticationPasskeyFailedEvent | AuthenticationPasskeySucceededEvent | AuthenticationPasswordFailedEvent | AuthenticationPasswordSucceededEvent | AuthenticationMagicAuthFailedEvent | AuthenticationMagicAuthSucceededEvent | AuthenticationRadarRiskDetectedEvent | ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationAcceptedEvent | InvitationCreatedEvent | InvitationRevokedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | SessionRevokedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent | OrganizationDomainCreatedEvent | OrganizationDomainUpdatedEvent | OrganizationDomainDeletedEvent;
486
+ export type EventResponse = AuthenticationEmailVerificationSucceededEventResponse | AuthenticationMagicAuthFailedEventResponse | AuthenticationMagicAuthSucceededEventResponse | AuthenticationMfaSucceededEventResponse | AuthenticationOAuthFailedEventResponse | AuthenticationOAuthSucceededEventResponse | AuthenticationPasskeyFailedEventResponse | AuthenticationPasskeySucceededEventResponse | AuthenticationPasswordFailedEventResponse | AuthenticationPasswordSucceededEventResponse | AuthenticationSSOFailedEventResponse | AuthenticationSSOSucceededEventResponse | AuthenticationRadarRiskDetectedEventResponse | ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationAcceptedEventResponse | InvitationCreatedEventResponse | InvitationRevokedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | SessionRevokedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse | OrganizationDomainCreatedEventResponse | OrganizationDomainUpdatedEventResponse | OrganizationDomainDeletedEventResponse;
471
487
  export type EventName = Event['event'];
472
488
  export {};
@@ -53,7 +53,9 @@ class HttpClient {
53
53
  return JSON.stringify(entity);
54
54
  }
55
55
  static isPathRetryable(path) {
56
- return path.startsWith('/fga/') || path.startsWith('/vault/');
56
+ return (path.startsWith('/fga/') ||
57
+ path.startsWith('/vault/') ||
58
+ path.startsWith('/audit_logs/events'));
57
59
  }
58
60
  getSleepTimeInMilliseconds(retryAttempt) {
59
61
  const sleepTime = this.MINIMUM_SLEEP_TIME_IN_MILLISECONDS *
@@ -22,6 +22,8 @@ const deserializeEvent = (event) => {
22
22
  case 'authentication.mfa_succeeded':
23
23
  case 'authentication.oauth_failed':
24
24
  case 'authentication.oauth_succeeded':
25
+ case 'authentication.passkey_failed':
26
+ case 'authentication.passkey_succeeded':
25
27
  case 'authentication.password_failed':
26
28
  case 'authentication.password_succeeded':
27
29
  case 'authentication.sso_failed':
@@ -1 +1 @@
1
- export type PasswordHashType = 'bcrypt' | 'firebase-scrypt' | 'ssha' | 'scrypt';
1
+ export type PasswordHashType = 'bcrypt' | 'firebase-scrypt' | 'ssha' | 'scrypt' | 'argon2';
@@ -109,6 +109,7 @@ export declare class UserManagement {
109
109
  sendInvitation(payload: SendInvitationOptions): Promise<Invitation>;
110
110
  acceptInvitation(invitationId: string): Promise<Invitation>;
111
111
  revokeInvitation(invitationId: string): Promise<Invitation>;
112
+ resendInvitation(invitationId: string): Promise<Invitation>;
112
113
  revokeSession(payload: RevokeSessionOptions): Promise<void>;
113
114
  getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, context, clientId, domainHint, loginHint, organizationId, provider, providerQueryParams, providerScopes, prompt, redirectUri, state, screenHint, }: UserManagementAuthorizationURLOptions): string;
114
115
  getLogoutUrl({ sessionId, returnTo, }: {
@@ -540,6 +540,12 @@ class UserManagement {
540
540
  return (0, invitation_serializer_1.deserializeInvitation)(data);
541
541
  });
542
542
  }
543
+ resendInvitation(invitationId) {
544
+ return __awaiter(this, void 0, void 0, function* () {
545
+ const { data } = yield this.workos.post(`/user_management/invitations/${invitationId}/resend`, null);
546
+ return (0, invitation_serializer_1.deserializeInvitation)(data);
547
+ });
548
+ }
543
549
  revokeSession(payload) {
544
550
  return __awaiter(this, void 0, void 0, function* () {
545
551
  yield this.workos.post('/user_management/sessions/revoke', (0, revoke_session_options_interface_1.serializeRevokeSessionOptions)(payload));
@@ -1752,6 +1752,50 @@ describe('UserManagement', () => {
1752
1752
  });
1753
1753
  }));
1754
1754
  });
1755
+ describe('resendInvitation', () => {
1756
+ it('send a Resend Invitation request', () => __awaiter(void 0, void 0, void 0, function* () {
1757
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
1758
+ (0, test_utils_1.fetchOnce)(invitation_json_1.default);
1759
+ const response = yield workos.userManagement.resendInvitation(invitationId);
1760
+ expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/invitations/${invitationId}/resend`);
1761
+ expect(response).toMatchObject({
1762
+ object: 'invitation',
1763
+ email: 'dane@workos.com',
1764
+ });
1765
+ }));
1766
+ it('throws an error when invitation is not found (404)', () => __awaiter(void 0, void 0, void 0, function* () {
1767
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
1768
+ (0, test_utils_1.fetchOnce)({
1769
+ message: 'Invitation not found',
1770
+ code: 'not_found',
1771
+ }, { status: 404 });
1772
+ yield expect(workos.userManagement.resendInvitation(invitationId)).rejects.toThrow();
1773
+ }));
1774
+ it('throws an error when invitation is expired (400)', () => __awaiter(void 0, void 0, void 0, function* () {
1775
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
1776
+ (0, test_utils_1.fetchOnce)({
1777
+ message: 'Invite has expired.',
1778
+ code: 'invite_expired',
1779
+ }, { status: 400 });
1780
+ yield expect(workos.userManagement.resendInvitation(invitationId)).rejects.toThrow();
1781
+ }));
1782
+ it('throws an error when invitation is revoked (400)', () => __awaiter(void 0, void 0, void 0, function* () {
1783
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
1784
+ (0, test_utils_1.fetchOnce)({
1785
+ message: 'Invite has been revoked.',
1786
+ code: 'invite_revoked',
1787
+ }, { status: 400 });
1788
+ yield expect(workos.userManagement.resendInvitation(invitationId)).rejects.toThrow();
1789
+ }));
1790
+ it('throws an error when invitation is accepted (400)', () => __awaiter(void 0, void 0, void 0, function* () {
1791
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
1792
+ (0, test_utils_1.fetchOnce)({
1793
+ message: 'Invite has already been accepted.',
1794
+ code: 'invite_accepted',
1795
+ }, { status: 400 });
1796
+ yield expect(workos.userManagement.resendInvitation(invitationId)).rejects.toThrow();
1797
+ }));
1798
+ });
1755
1799
  describe('revokeSession', () => {
1756
1800
  it('sends a Revoke Session request', () => __awaiter(void 0, void 0, void 0, function* () {
1757
1801
  const sessionId = 'session_12345';
package/lib/workos.js CHANGED
@@ -33,7 +33,7 @@ const actions_1 = require("./actions/actions");
33
33
  const vault_1 = require("./vault/vault");
34
34
  const conflict_exception_1 = require("./common/exceptions/conflict.exception");
35
35
  const parse_error_1 = require("./common/exceptions/parse-error");
36
- const VERSION = '7.72.2';
36
+ const VERSION = '7.74.0';
37
37
  const DEFAULT_HOSTNAME = 'api.workos.com';
38
38
  const HEADER_AUTHORIZATION = 'Authorization';
39
39
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.72.2",
2
+ "version": "7.74.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -37,14 +37,12 @@
37
37
  "iron-session": "~6.3.1",
38
38
  "jose": "~5.6.3",
39
39
  "leb": "^1.0.0",
40
- "pluralize": "8.0.0",
41
40
  "qs": "6.14.0"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@peculiar/webcrypto": "^1.4.5",
45
44
  "@types/jest": "29.5.3",
46
45
  "@types/node": "14.18.54",
47
- "@types/pluralize": "0.0.30",
48
46
  "jest": "29.6.2",
49
47
  "jest-environment-miniflare": "^2.14.2",
50
48
  "jest-fetch-mock": "^3.0.3",