@workos-inc/node 3.1.0 → 3.2.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.
Files changed (34) hide show
  1. package/lib/common/interfaces/index.d.ts +0 -1
  2. package/lib/common/interfaces/index.js +0 -1
  3. package/lib/directory-sync/directory-sync.js +1 -1
  4. package/lib/directory-sync/directory-sync.spec.js +2 -0
  5. package/lib/directory-sync/interfaces/list-directories-options.interface.d.ts +5 -0
  6. package/lib/directory-sync/serializers/index.d.ts +1 -0
  7. package/lib/directory-sync/serializers/index.js +1 -0
  8. package/lib/directory-sync/serializers/list-directories-options.serializer.d.ts +2 -0
  9. package/lib/directory-sync/serializers/list-directories-options.serializer.js +13 -0
  10. package/lib/sso/serializers/index.d.ts +1 -0
  11. package/lib/sso/serializers/index.js +1 -0
  12. package/lib/sso/serializers/list-connections-options.serializer.d.ts +2 -0
  13. package/lib/sso/serializers/list-connections-options.serializer.js +13 -0
  14. package/lib/sso/sso.js +1 -1
  15. package/lib/sso/sso.spec.js +3 -1
  16. package/lib/users/interfaces/authenticate-user-with-token-options.interface.d.ts +3 -3
  17. package/lib/users/interfaces/enroll-user-in-mfa-factor.interface.d.ts +11 -0
  18. package/lib/users/interfaces/index.d.ts +1 -0
  19. package/lib/users/interfaces/index.js +1 -0
  20. package/lib/users/interfaces/update-user-options.interface.d.ts +3 -8
  21. package/lib/users/serializers/authenticate-user-with-code-options.serializer.d.ts +2 -0
  22. package/lib/users/serializers/{authenticate-user-with-token-options.serializer.js → authenticate-user-with-code-options.serializer.js} +3 -3
  23. package/lib/users/serializers/enroll-user-in-mfa-factor-options.serializer.d.ts +2 -0
  24. package/lib/users/serializers/enroll-user-in-mfa-factor-options.serializer.js +9 -0
  25. package/lib/users/serializers/index.d.ts +2 -2
  26. package/lib/users/serializers/index.js +2 -2
  27. package/lib/users/users.d.ts +7 -2
  28. package/lib/users/users.js +13 -2
  29. package/lib/users/users.spec.js +63 -2
  30. package/lib/workos.js +1 -1
  31. package/package.json +2 -2
  32. package/lib/common/interfaces/at-least-one-property-of.interface.d.ts +0 -7
  33. package/lib/users/serializers/authenticate-user-with-token-options.serializer.d.ts +0 -2
  34. /package/lib/{common/interfaces/at-least-one-property-of.interface.js → users/interfaces/enroll-user-in-mfa-factor.interface.js} +0 -0
@@ -1,4 +1,3 @@
1
- export * from './at-least-one-property-of.interface';
2
1
  export * from './event.interface';
3
2
  export * from './get-options.interface';
4
3
  export * from './list.interface';
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./at-least-one-property-of.interface"), exports);
18
17
  __exportStar(require("./event.interface"), exports);
19
18
  __exportStar(require("./get-options.interface"), exports);
20
19
  __exportStar(require("./list.interface"), exports);
@@ -19,7 +19,7 @@ class DirectorySync {
19
19
  }
20
20
  listDirectories(options) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, params), options);
22
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, options ? (0, serializers_1.serializeListDirectoriesOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, params), options);
23
23
  });
24
24
  }
25
25
  getDirectory(id) {
@@ -130,10 +130,12 @@ describe('DirectorySync', () => {
130
130
  mock
131
131
  .onGet('/directories', {
132
132
  domain: 'google.com',
133
+ organization_id: 'org_1234',
133
134
  })
134
135
  .replyOnce(200, directoryListResponse);
135
136
  const subject = yield workos.directorySync.listDirectories({
136
137
  domain: 'google.com',
138
+ organizationId: 'org_1234',
137
139
  });
138
140
  expect(subject).toMatchObject({
139
141
  object: 'list',
@@ -4,3 +4,8 @@ export interface ListDirectoriesOptions extends PaginationOptions {
4
4
  organizationId?: string;
5
5
  search?: string;
6
6
  }
7
+ export interface SerializedListDirectoriesOptions extends PaginationOptions {
8
+ domain?: string;
9
+ organization_id?: string;
10
+ search?: string;
11
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './directory-group.serializer';
2
2
  export * from './directory-user.serializer';
3
3
  export * from './directory.serializer';
4
+ export * from './list-directories-options.serializer';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./directory-group.serializer"), exports);
18
18
  __exportStar(require("./directory-user.serializer"), exports);
19
19
  __exportStar(require("./directory.serializer"), exports);
20
+ __exportStar(require("./list-directories-options.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { ListDirectoriesOptions, SerializedListDirectoriesOptions } from '../interfaces';
2
+ export declare const serializeListDirectoriesOptions: (options: ListDirectoriesOptions) => SerializedListDirectoriesOptions;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeListDirectoriesOptions = void 0;
4
+ const serializeListDirectoriesOptions = (options) => ({
5
+ domain: options.domain,
6
+ organization_id: options.organizationId,
7
+ search: options.search,
8
+ limit: options.limit,
9
+ before: options.before,
10
+ after: options.after,
11
+ order: options.order,
12
+ });
13
+ exports.serializeListDirectoriesOptions = serializeListDirectoriesOptions;
@@ -1,3 +1,4 @@
1
1
  export * from './connection.serializer';
2
+ export * from './list-connections-options.serializer';
2
3
  export * from './profile-and-token.serializer';
3
4
  export * from './profile.serializer';
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./connection.serializer"), exports);
18
+ __exportStar(require("./list-connections-options.serializer"), exports);
18
19
  __exportStar(require("./profile-and-token.serializer"), exports);
19
20
  __exportStar(require("./profile.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { ListConnectionsOptions, SerializedListConnectionsOptions } from '../interfaces';
2
+ export declare const serializeListConnectionsOptions: (options: ListConnectionsOptions) => SerializedListConnectionsOptions;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeListConnectionsOptions = void 0;
4
+ const serializeListConnectionsOptions = (options) => ({
5
+ connection_type: options.connectionType,
6
+ domain: options.domain,
7
+ organization_id: options.organizationId,
8
+ limit: options.limit,
9
+ before: options.before,
10
+ after: options.after,
11
+ order: options.order,
12
+ });
13
+ exports.serializeListConnectionsOptions = serializeListConnectionsOptions;
package/lib/sso/sso.js CHANGED
@@ -30,7 +30,7 @@ class SSO {
30
30
  }
31
31
  listConnections(options) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, params), options);
33
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, options ? (0, serializers_1.serializeListConnectionsOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, params), options);
34
34
  });
35
35
  }
36
36
  deleteConnection(id) {
@@ -309,7 +309,9 @@ describe('SSO', () => {
309
309
  list_metadata: {},
310
310
  });
311
311
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
312
- const subject = yield workos.sso.listConnections();
312
+ const subject = yield workos.sso.listConnections({
313
+ organizationId: 'org_1234',
314
+ });
313
315
  expect(mock.history.get[0].url).toEqual('/connections');
314
316
  expect(subject.data).toHaveLength(1);
315
317
  }));
@@ -1,12 +1,12 @@
1
- export interface AuthenticateUserWithTokenOptions {
1
+ export interface AuthenticateUserWithCodeOptions {
2
2
  clientId: string;
3
3
  code: string;
4
4
  expiresIn?: number;
5
5
  }
6
- export interface AuthenticateUserWithTokenCredentials {
6
+ export interface AuthenticateUserWithCodeCredentials {
7
7
  clientSecret: string | undefined;
8
8
  }
9
- export interface SerializedAuthenticateUserWithTokenOptions {
9
+ export interface SerializedAuthenticateUserWithCodeOptions {
10
10
  grant_type: 'authorization_code';
11
11
  client_id: string;
12
12
  client_secret: string | undefined;
@@ -0,0 +1,11 @@
1
+ export interface EnrollUserInMfaFactorOptions {
2
+ userId: string;
3
+ type: 'totp';
4
+ totpIssuer: string;
5
+ totpUser: string;
6
+ }
7
+ export interface SerializedEnrollUserInMfaFactorOptions {
8
+ type: 'totp';
9
+ totp_issuer: string;
10
+ totp_user: string;
11
+ }
@@ -7,6 +7,7 @@ export * from './complete-password-reset-options.interface';
7
7
  export * from './create-email-verification-challenge-options.interface';
8
8
  export * from './create-password-reset-challenge-options.interface';
9
9
  export * from './create-user-options.interface';
10
+ export * from './enroll-user-in-mfa-factor.interface';
10
11
  export * from './list-users-options.interface';
11
12
  export * from './magic-auth-challenge.interface';
12
13
  export * from './remove-user-from-organization-options.interface';
@@ -23,6 +23,7 @@ __exportStar(require("./complete-password-reset-options.interface"), exports);
23
23
  __exportStar(require("./create-email-verification-challenge-options.interface"), exports);
24
24
  __exportStar(require("./create-password-reset-challenge-options.interface"), exports);
25
25
  __exportStar(require("./create-user-options.interface"), exports);
26
+ __exportStar(require("./enroll-user-in-mfa-factor.interface"), exports);
26
27
  __exportStar(require("./list-users-options.interface"), exports);
27
28
  __exportStar(require("./magic-auth-challenge.interface"), exports);
28
29
  __exportStar(require("./remove-user-from-organization-options.interface"), exports);
@@ -1,14 +1,9 @@
1
- import { AtLeastOnePropertyOf } from '../../common/interfaces';
2
- interface BaseUpdateUserOptions {
1
+ export interface UpdateUserOptions {
3
2
  userId: string;
3
+ firstName?: string;
4
+ lastName?: string;
4
5
  }
5
- interface UpdateUserOptionsProperties {
6
- firstName: string;
7
- lastName: string;
8
- }
9
- export type UpdateUserOptions = BaseUpdateUserOptions & AtLeastOnePropertyOf<UpdateUserOptionsProperties>;
10
6
  export interface SerializedUpdateUserOptions {
11
7
  first_name?: string;
12
8
  last_name?: string;
13
9
  }
14
- export {};
@@ -0,0 +1,2 @@
1
+ import { AuthenticateUserWithCodeCredentials, AuthenticateUserWithCodeOptions, SerializedAuthenticateUserWithCodeOptions } from '../interfaces';
2
+ export declare const serializeAuthenticateUserWithCodeOptions: (options: AuthenticateUserWithCodeOptions & AuthenticateUserWithCodeCredentials) => SerializedAuthenticateUserWithCodeOptions;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeAuthenticateUserWithTokenOptions = void 0;
4
- const serializeAuthenticateUserWithTokenOptions = (options) => ({
3
+ exports.serializeAuthenticateUserWithCodeOptions = void 0;
4
+ const serializeAuthenticateUserWithCodeOptions = (options) => ({
5
5
  grant_type: 'authorization_code',
6
6
  client_id: options.clientId,
7
7
  client_secret: options.clientSecret,
8
8
  code: options.code,
9
9
  expires_in: options.expiresIn,
10
10
  });
11
- exports.serializeAuthenticateUserWithTokenOptions = serializeAuthenticateUserWithTokenOptions;
11
+ exports.serializeAuthenticateUserWithCodeOptions = serializeAuthenticateUserWithCodeOptions;
@@ -0,0 +1,2 @@
1
+ import { EnrollUserInMfaFactorOptions, SerializedEnrollUserInMfaFactorOptions } from '../interfaces';
2
+ export declare const serializeEnrollUserInMfaFactorOptions: (options: EnrollUserInMfaFactorOptions) => SerializedEnrollUserInMfaFactorOptions;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeEnrollUserInMfaFactorOptions = void 0;
4
+ const serializeEnrollUserInMfaFactorOptions = (options) => ({
5
+ type: options.type,
6
+ totp_issuer: options.totpIssuer,
7
+ totp_user: options.totpUser,
8
+ });
9
+ exports.serializeEnrollUserInMfaFactorOptions = serializeEnrollUserInMfaFactorOptions;
@@ -1,6 +1,6 @@
1
+ export * from './authenticate-user-with-code-options.serializer';
1
2
  export * from './authenticate-user-with-magic-auth-options.serializer';
2
3
  export * from './authenticate-user-with-password-options.serializer';
3
- export * from './authenticate-user-with-token-options.serializer';
4
4
  export * from './authentication-response.serializer';
5
5
  export * from './complete-password-reset-options.serializer';
6
6
  export * from './create-email-verification-challenge.serializer';
@@ -9,7 +9,7 @@ export * from './create-user-options.serializer';
9
9
  export * from './revoke-session-options.serializer';
10
10
  export * from './send-magic-auth-code-options.serializer';
11
11
  export * from './session.serializer';
12
- export * from './update-user-password-options.serializer';
13
12
  export * from './update-user-options.serializer';
13
+ export * from './update-user-password-options.serializer';
14
14
  export * from './user.serializer';
15
15
  export * from './verify-session.serializer';
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./authenticate-user-with-code-options.serializer"), exports);
17
18
  __exportStar(require("./authenticate-user-with-magic-auth-options.serializer"), exports);
18
19
  __exportStar(require("./authenticate-user-with-password-options.serializer"), exports);
19
- __exportStar(require("./authenticate-user-with-token-options.serializer"), exports);
20
20
  __exportStar(require("./authentication-response.serializer"), exports);
21
21
  __exportStar(require("./complete-password-reset-options.serializer"), exports);
22
22
  __exportStar(require("./create-email-verification-challenge.serializer"), exports);
@@ -25,7 +25,7 @@ __exportStar(require("./create-user-options.serializer"), exports);
25
25
  __exportStar(require("./revoke-session-options.serializer"), exports);
26
26
  __exportStar(require("./send-magic-auth-code-options.serializer"), exports);
27
27
  __exportStar(require("./session.serializer"), exports);
28
- __exportStar(require("./update-user-password-options.serializer"), exports);
29
28
  __exportStar(require("./update-user-options.serializer"), exports);
29
+ __exportStar(require("./update-user-password-options.serializer"), exports);
30
30
  __exportStar(require("./user.serializer"), exports);
31
31
  __exportStar(require("./verify-session.serializer"), exports);
@@ -1,6 +1,7 @@
1
1
  import { WorkOS } from '../workos';
2
2
  import { AutoPaginatable } from '../common/utils/pagination';
3
- import { AddUserToOrganizationOptions, AuthenticateUserWithMagicAuthOptions, AuthenticateUserWithPasswordOptions, AuthenticateUserWithTokenOptions, AuthenticationResponse, CompletePasswordResetOptions, CreateEmailVerificationChallengeOptions, CreateEmailVerificationChallengeResponse, CreatePasswordResetChallengeOptions, CreatePasswordResetChallengeResponse, CreateUserOptions, ListUsersOptions, MagicAuthChallenge, RemoveUserFromOrganizationOptions, RevokeAllSessionsForUserOptions, RevokeSessionOptions, SendMagicAuthCodeOptions, UpdateUserOptions, UpdateUserPasswordOptions, User, VerifySessionOptions, VerifySessionResponse } from './interfaces';
3
+ import { AddUserToOrganizationOptions, AuthenticateUserWithMagicAuthOptions, AuthenticateUserWithPasswordOptions, AuthenticateUserWithCodeOptions, AuthenticationResponse, CompletePasswordResetOptions, CreateEmailVerificationChallengeOptions, CreateEmailVerificationChallengeResponse, CreatePasswordResetChallengeOptions, CreatePasswordResetChallengeResponse, CreateUserOptions, ListUsersOptions, MagicAuthChallenge, RemoveUserFromOrganizationOptions, RevokeAllSessionsForUserOptions, RevokeSessionOptions, SendMagicAuthCodeOptions, UpdateUserOptions, UpdateUserPasswordOptions, User, VerifySessionOptions, VerifySessionResponse, EnrollUserInMfaFactorOptions } from './interfaces';
4
+ import { Challenge, Factor } from '../mfa/interfaces';
4
5
  export declare class Users {
5
6
  private readonly workos;
6
7
  constructor(workos: WorkOS);
@@ -9,7 +10,7 @@ export declare class Users {
9
10
  createUser(payload: CreateUserOptions): Promise<User>;
10
11
  authenticateUserWithMagicAuth(payload: AuthenticateUserWithMagicAuthOptions): Promise<AuthenticationResponse>;
11
12
  authenticateUserWithPassword(payload: AuthenticateUserWithPasswordOptions): Promise<AuthenticationResponse>;
12
- authenticateUserWithToken(payload: AuthenticateUserWithTokenOptions): Promise<AuthenticationResponse>;
13
+ authenticateUserWithCode(payload: AuthenticateUserWithCodeOptions): Promise<AuthenticationResponse>;
13
14
  verifySession(payload: VerifySessionOptions): Promise<VerifySessionResponse>;
14
15
  revokeSession(payload: RevokeSessionOptions): Promise<boolean>;
15
16
  revokeAllSessionsForUser({ userId, }: RevokeAllSessionsForUserOptions): Promise<boolean>;
@@ -22,4 +23,8 @@ export declare class Users {
22
23
  removeUserFromOrganization({ userId, organizationId, }: RemoveUserFromOrganizationOptions): Promise<User>;
23
24
  updateUser(payload: UpdateUserOptions): Promise<User>;
24
25
  updateUserPassword(payload: UpdateUserPasswordOptions): Promise<User>;
26
+ enrollUserInMfaFactor(payload: EnrollUserInMfaFactorOptions): Promise<{
27
+ authenticationFactor: Factor;
28
+ authenticationChallenge: Challenge;
29
+ }>;
25
30
  }
@@ -13,6 +13,8 @@ exports.Users = void 0;
13
13
  const pagination_1 = require("../common/utils/pagination");
14
14
  const serializers_1 = require("./serializers");
15
15
  const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
16
+ const serializers_2 = require("../mfa/serializers");
17
+ const enroll_user_in_mfa_factor_options_serializer_1 = require("./serializers/enroll-user-in-mfa-factor-options.serializer");
16
18
  class Users {
17
19
  constructor(workos) {
18
20
  this.workos = workos;
@@ -46,9 +48,9 @@ class Users {
46
48
  return (0, serializers_1.deserializeAuthenticationResponse)(data);
47
49
  });
48
50
  }
49
- authenticateUserWithToken(payload) {
51
+ authenticateUserWithCode(payload) {
50
52
  return __awaiter(this, void 0, void 0, function* () {
51
- const { data } = yield this.workos.post('/users/sessions/token', (0, serializers_1.serializeAuthenticateUserWithTokenOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
53
+ const { data } = yield this.workos.post('/users/sessions/token', (0, serializers_1.serializeAuthenticateUserWithCodeOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
52
54
  return (0, serializers_1.deserializeAuthenticationResponse)(data);
53
55
  });
54
56
  }
@@ -130,5 +132,14 @@ class Users {
130
132
  return (0, serializers_1.deserializeUser)(data);
131
133
  });
132
134
  }
135
+ enrollUserInMfaFactor(payload) {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ const { data } = yield this.workos.post(`/users/${payload.userId}/auth/factors`, (0, enroll_user_in_mfa_factor_options_serializer_1.serializeEnrollUserInMfaFactorOptions)(payload));
138
+ return {
139
+ authenticationFactor: (0, serializers_2.deserializeFactor)(data.authentication_factor),
140
+ authenticationChallenge: (0, serializers_2.deserializeChallenge)(data.authentication_challenge),
141
+ };
142
+ });
143
+ }
133
144
  }
134
145
  exports.Users = Users;
@@ -146,12 +146,12 @@ describe('UserManagement', () => {
146
146
  });
147
147
  }));
148
148
  });
149
- describe('authenticateUserWithToken', () => {
149
+ describe('authenticateUserWithCode', () => {
150
150
  it('sends a token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
151
151
  mock
152
152
  .onPost('/users/sessions/token')
153
153
  .reply(200, { user: user_json_1.default, session: session_json_1.default });
154
- const resp = yield workos.users.authenticateUserWithToken({
154
+ const resp = yield workos.users.authenticateUserWithCode({
155
155
  clientId: 'proj_whatever',
156
156
  code: 'or this',
157
157
  expiresIn: 15,
@@ -375,4 +375,65 @@ describe('UserManagement', () => {
375
375
  });
376
376
  }));
377
377
  });
378
+ describe('enrollUserInMfaFactor', () => {
379
+ it('sends an enrollUserInMfaFactor request', () => __awaiter(void 0, void 0, void 0, function* () {
380
+ mock.onPost(`/users/${userId}/auth/factors`).reply(200, {
381
+ authentication_factor: {
382
+ object: 'authentication_factor',
383
+ id: 'auth_factor_1234',
384
+ created_at: '2022-03-15T20:39:19.892Z',
385
+ updated_at: '2022-03-15T20:39:19.892Z',
386
+ type: 'totp',
387
+ totp: {
388
+ issuer: 'WorkOS',
389
+ qr_code: 'qr-code-test',
390
+ secret: 'secret-test',
391
+ uri: 'uri-test',
392
+ user: 'some_user',
393
+ },
394
+ },
395
+ authentication_challenge: {
396
+ object: 'authentication_challenge',
397
+ id: 'auth_challenge_1234',
398
+ created_at: '2022-03-15T20:39:19.892Z',
399
+ updated_at: '2022-03-15T20:39:19.892Z',
400
+ expires_at: '2022-03-15T21:39:19.892Z',
401
+ code: '12345',
402
+ authentication_factor_id: 'auth_factor_1234',
403
+ },
404
+ });
405
+ const resp = yield workos.users.enrollUserInMfaFactor({
406
+ userId,
407
+ type: 'totp',
408
+ totpIssuer: 'WorkOS',
409
+ totpUser: 'some_user',
410
+ });
411
+ expect(mock.history.post[0].url).toEqual(`/users/${userId}/auth/factors`);
412
+ expect(resp).toMatchObject({
413
+ authenticationFactor: {
414
+ object: 'authentication_factor',
415
+ id: 'auth_factor_1234',
416
+ createdAt: '2022-03-15T20:39:19.892Z',
417
+ updatedAt: '2022-03-15T20:39:19.892Z',
418
+ type: 'totp',
419
+ totp: {
420
+ issuer: 'WorkOS',
421
+ qrCode: 'qr-code-test',
422
+ secret: 'secret-test',
423
+ uri: 'uri-test',
424
+ user: 'some_user',
425
+ },
426
+ },
427
+ authenticationChallenge: {
428
+ object: 'authentication_challenge',
429
+ id: 'auth_challenge_1234',
430
+ createdAt: '2022-03-15T20:39:19.892Z',
431
+ updatedAt: '2022-03-15T20:39:19.892Z',
432
+ expiresAt: '2022-03-15T21:39:19.892Z',
433
+ code: '12345',
434
+ authenticationFactorId: 'auth_factor_1234',
435
+ },
436
+ });
437
+ }));
438
+ });
378
439
  });
package/lib/workos.js CHANGED
@@ -27,7 +27,7 @@ const mfa_1 = require("./mfa/mfa");
27
27
  const audit_logs_1 = require("./audit-logs/audit-logs");
28
28
  const users_1 = require("./users/users");
29
29
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
30
- const VERSION = '3.1.0';
30
+ const VERSION = '3.2.0';
31
31
  const DEFAULT_HOSTNAME = 'api.workos.com';
32
32
  class WorkOS {
33
33
  constructor(key, options = {}) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.1.0",
2
+ "version": "3.2.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -49,4 +49,4 @@
49
49
  "tslint": "6.1.3",
50
50
  "typescript": "5.1.6"
51
51
  }
52
- }
52
+ }
@@ -1,7 +0,0 @@
1
- export type AtLeastOnePropertyOf<T> = {
2
- [K in keyof T]: {
3
- [L in K]: T[L];
4
- } & {
5
- [L in Exclude<keyof T, K>]?: T[L];
6
- };
7
- }[keyof T];
@@ -1,2 +0,0 @@
1
- import { AuthenticateUserWithTokenCredentials, AuthenticateUserWithTokenOptions, SerializedAuthenticateUserWithTokenOptions } from '../interfaces';
2
- export declare const serializeAuthenticateUserWithTokenOptions: (options: AuthenticateUserWithTokenOptions & AuthenticateUserWithTokenCredentials) => SerializedAuthenticateUserWithTokenOptions;