@workos-inc/node 3.1.1 → 3.2.1
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/lib/common/interfaces/event.interface.d.ts +11 -11
- package/lib/common/serializers/event.serializer.js +2 -2
- package/lib/directory-sync/interfaces/directory-group.interface.d.ts +0 -20
- package/lib/directory-sync/serializers/directory-group.serializer.d.ts +2 -3
- package/lib/directory-sync/serializers/directory-group.serializer.js +1 -12
- package/lib/users/interfaces/authenticate-user-with-token-options.interface.d.ts +3 -3
- package/lib/users/interfaces/enroll-user-in-mfa-factor.interface.d.ts +11 -0
- package/lib/users/interfaces/enroll-user-in-mfa-factor.interface.js +2 -0
- package/lib/users/interfaces/index.d.ts +1 -0
- package/lib/users/interfaces/index.js +1 -0
- package/lib/users/serializers/authenticate-user-with-code-options.serializer.d.ts +2 -0
- package/lib/users/serializers/{authenticate-user-with-token-options.serializer.js → authenticate-user-with-code-options.serializer.js} +3 -3
- package/lib/users/serializers/enroll-user-in-mfa-factor-options.serializer.d.ts +2 -0
- package/lib/users/serializers/enroll-user-in-mfa-factor-options.serializer.js +9 -0
- package/lib/users/serializers/index.d.ts +2 -2
- package/lib/users/serializers/index.js +2 -2
- package/lib/users/users.d.ts +7 -2
- package/lib/users/users.js +13 -2
- package/lib/users/users.spec.js +63 -2
- package/lib/workos.js +1 -1
- package/package.json +1 -1
- package/lib/users/serializers/authenticate-user-with-token-options.serializer.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DirectoryUser, DirectoryUserResponse,
|
|
1
|
+
import { DirectoryUser, DirectoryUserResponse, DirectoryGroup, DirectoryGroupResponse, EventDirectory, EventDirectoryResponse } from '../../directory-sync/interfaces';
|
|
2
2
|
import { Connection, ConnectionResponse } from '../../sso/interfaces';
|
|
3
3
|
export interface EventBase {
|
|
4
4
|
id: string;
|
|
@@ -58,34 +58,34 @@ export interface DsyncDeletedEventResponse extends EventResponseBase {
|
|
|
58
58
|
}
|
|
59
59
|
export interface DsyncGroupCreatedEvent extends EventBase {
|
|
60
60
|
event: 'dsync.group.created';
|
|
61
|
-
data:
|
|
61
|
+
data: DirectoryGroup;
|
|
62
62
|
}
|
|
63
63
|
export interface DsyncGroupCreatedEventResponse extends EventResponseBase {
|
|
64
64
|
event: 'dsync.group.created';
|
|
65
|
-
data:
|
|
65
|
+
data: DirectoryGroupResponse;
|
|
66
66
|
}
|
|
67
67
|
export interface DsyncGroupDeletedEvent extends EventBase {
|
|
68
68
|
event: 'dsync.group.deleted';
|
|
69
|
-
data:
|
|
69
|
+
data: DirectoryGroup;
|
|
70
70
|
}
|
|
71
71
|
export interface DsyncGroupDeletedEventResponse extends EventResponseBase {
|
|
72
72
|
event: 'dsync.group.deleted';
|
|
73
|
-
data:
|
|
73
|
+
data: DirectoryGroupResponse;
|
|
74
74
|
}
|
|
75
75
|
export interface DsyncGroupUpdatedEvent extends EventBase {
|
|
76
76
|
event: 'dsync.group.updated';
|
|
77
|
-
data:
|
|
77
|
+
data: DirectoryGroup & Record<'previousAttributes', any>;
|
|
78
78
|
}
|
|
79
79
|
export interface DsyncGroupUpdatedEventResponse extends EventResponseBase {
|
|
80
80
|
event: 'dsync.group.updated';
|
|
81
|
-
data:
|
|
81
|
+
data: DirectoryGroupResponse & Record<'previous_attributes', any>;
|
|
82
82
|
}
|
|
83
83
|
export interface DsyncGroupUserAddedEvent extends EventBase {
|
|
84
84
|
event: 'dsync.group.user_added';
|
|
85
85
|
data: {
|
|
86
86
|
directoryId: string;
|
|
87
87
|
user: DirectoryUser;
|
|
88
|
-
group:
|
|
88
|
+
group: DirectoryGroup;
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
export interface DsyncGroupUserAddedEventResponse extends EventResponseBase {
|
|
@@ -93,7 +93,7 @@ export interface DsyncGroupUserAddedEventResponse extends EventResponseBase {
|
|
|
93
93
|
data: {
|
|
94
94
|
directory_id: string;
|
|
95
95
|
user: DirectoryUserResponse;
|
|
96
|
-
group:
|
|
96
|
+
group: DirectoryGroupResponse;
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
export interface DsyncGroupUserRemovedEvent extends EventBase {
|
|
@@ -101,7 +101,7 @@ export interface DsyncGroupUserRemovedEvent extends EventBase {
|
|
|
101
101
|
data: {
|
|
102
102
|
directoryId: string;
|
|
103
103
|
user: DirectoryUser;
|
|
104
|
-
group:
|
|
104
|
+
group: DirectoryGroup;
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
export interface DsyncGroupUserRemovedEventResponse extends EventResponseBase {
|
|
@@ -109,7 +109,7 @@ export interface DsyncGroupUserRemovedEventResponse extends EventResponseBase {
|
|
|
109
109
|
data: {
|
|
110
110
|
directory_id: string;
|
|
111
111
|
user: DirectoryUserResponse;
|
|
112
|
-
group:
|
|
112
|
+
group: DirectoryGroupResponse;
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
export interface DsyncUserCreatedEvent extends EventBase {
|
|
@@ -20,7 +20,7 @@ const deserializeEvent = (event) => {
|
|
|
20
20
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeDeletedEventDirectory)(event.data) });
|
|
21
21
|
case 'dsync.group.created':
|
|
22
22
|
case 'dsync.group.deleted':
|
|
23
|
-
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.
|
|
23
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeDirectoryGroup)(event.data) });
|
|
24
24
|
case 'dsync.group.updated':
|
|
25
25
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeUpdatedEventDirectoryGroup)(event.data) });
|
|
26
26
|
case 'dsync.group.user_added':
|
|
@@ -28,7 +28,7 @@ const deserializeEvent = (event) => {
|
|
|
28
28
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: {
|
|
29
29
|
directoryId: event.data.directory_id,
|
|
30
30
|
user: (0, serializers_1.deserializeDirectoryUser)(event.data.user),
|
|
31
|
-
group: event.data.group,
|
|
31
|
+
group: (0, serializers_1.deserializeDirectoryGroup)(event.data.group),
|
|
32
32
|
} });
|
|
33
33
|
case 'dsync.user.created':
|
|
34
34
|
case 'dsync.user.deleted':
|
|
@@ -18,23 +18,3 @@ export interface DirectoryGroupResponse {
|
|
|
18
18
|
updated_at: string;
|
|
19
19
|
raw_attributes: any;
|
|
20
20
|
}
|
|
21
|
-
export interface EventDirectoryGroup<TRawAttributes = any> {
|
|
22
|
-
id: string;
|
|
23
|
-
idpId: string;
|
|
24
|
-
directoryId: string;
|
|
25
|
-
organizationId: string | null;
|
|
26
|
-
name: string;
|
|
27
|
-
createdAt: string;
|
|
28
|
-
updatedAt: string;
|
|
29
|
-
rawAttributes: TRawAttributes;
|
|
30
|
-
}
|
|
31
|
-
export interface EventDirectoryGroupResponse<TRawAttributes = any> {
|
|
32
|
-
id: string;
|
|
33
|
-
idp_id: string;
|
|
34
|
-
directory_id: string;
|
|
35
|
-
organization_id: string | null;
|
|
36
|
-
name: string;
|
|
37
|
-
created_at: string;
|
|
38
|
-
updated_at: string;
|
|
39
|
-
raw_attributes: TRawAttributes;
|
|
40
|
-
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DirectoryGroup, DirectoryGroupResponse
|
|
1
|
+
import { DirectoryGroup, DirectoryGroupResponse } from '../interfaces';
|
|
2
2
|
export declare const deserializeDirectoryGroup: (directoryGroup: DirectoryGroupResponse) => DirectoryGroup;
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const deserializeUpdatedEventDirectoryGroup: (directoryGroup: EventDirectoryGroupResponse & Record<'previous_attributes', any>) => EventDirectoryGroup & Record<'previousAttributes', any>;
|
|
3
|
+
export declare const deserializeUpdatedEventDirectoryGroup: (directoryGroup: DirectoryGroupResponse & Record<'previous_attributes', any>) => DirectoryGroup & Record<'previousAttributes', any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeUpdatedEventDirectoryGroup = exports.
|
|
3
|
+
exports.deserializeUpdatedEventDirectoryGroup = exports.deserializeDirectoryGroup = void 0;
|
|
4
4
|
const deserializeDirectoryGroup = (directoryGroup) => ({
|
|
5
5
|
id: directoryGroup.id,
|
|
6
6
|
idpId: directoryGroup.idp_id,
|
|
@@ -12,17 +12,6 @@ const deserializeDirectoryGroup = (directoryGroup) => ({
|
|
|
12
12
|
rawAttributes: directoryGroup.raw_attributes,
|
|
13
13
|
});
|
|
14
14
|
exports.deserializeDirectoryGroup = deserializeDirectoryGroup;
|
|
15
|
-
const deserializeEventDirectoryGroup = (directoryGroup) => ({
|
|
16
|
-
id: directoryGroup.id,
|
|
17
|
-
idpId: directoryGroup.idp_id,
|
|
18
|
-
directoryId: directoryGroup.directory_id,
|
|
19
|
-
organizationId: directoryGroup.organization_id,
|
|
20
|
-
name: directoryGroup.name,
|
|
21
|
-
createdAt: directoryGroup.created_at,
|
|
22
|
-
updatedAt: directoryGroup.updated_at,
|
|
23
|
-
rawAttributes: directoryGroup.raw_attributes,
|
|
24
|
-
});
|
|
25
|
-
exports.deserializeEventDirectoryGroup = deserializeEventDirectoryGroup;
|
|
26
15
|
const deserializeUpdatedEventDirectoryGroup = (directoryGroup) => ({
|
|
27
16
|
id: directoryGroup.id,
|
|
28
17
|
idpId: directoryGroup.idp_id,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface AuthenticateUserWithCodeOptions {
|
|
2
2
|
clientId: string;
|
|
3
3
|
code: string;
|
|
4
4
|
expiresIn?: number;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface AuthenticateUserWithCodeCredentials {
|
|
7
7
|
clientSecret: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface SerializedAuthenticateUserWithCodeOptions {
|
|
10
10
|
grant_type: 'authorization_code';
|
|
11
11
|
client_id: string;
|
|
12
12
|
client_secret: string | undefined;
|
|
@@ -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);
|
|
@@ -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.
|
|
4
|
-
const
|
|
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.
|
|
11
|
+
exports.serializeAuthenticateUserWithCodeOptions = serializeAuthenticateUserWithCodeOptions;
|
|
@@ -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);
|
package/lib/users/users.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
|
-
import { AddUserToOrganizationOptions, AuthenticateUserWithMagicAuthOptions, AuthenticateUserWithPasswordOptions,
|
|
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
|
-
|
|
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
|
}
|
package/lib/users/users.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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;
|
package/lib/users/users.spec.js
CHANGED
|
@@ -146,12 +146,12 @@ describe('UserManagement', () => {
|
|
|
146
146
|
});
|
|
147
147
|
}));
|
|
148
148
|
});
|
|
149
|
-
describe('
|
|
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.
|
|
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.
|
|
30
|
+
const VERSION = '3.2.1';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
class WorkOS {
|
|
33
33
|
constructor(key, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { AuthenticateUserWithTokenCredentials, AuthenticateUserWithTokenOptions, SerializedAuthenticateUserWithTokenOptions } from '../interfaces';
|
|
2
|
-
export declare const serializeAuthenticateUserWithTokenOptions: (options: AuthenticateUserWithTokenOptions & AuthenticateUserWithTokenCredentials) => SerializedAuthenticateUserWithTokenOptions;
|