@workos-inc/node 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/interfaces/event.interface.d.ts +19 -3
- package/lib/common/serializers/event.serializer.js +4 -0
- package/lib/user-management/fixtures/invitation.json +1 -0
- package/lib/user-management/fixtures/list-invitations.json +1 -0
- package/lib/user-management/fixtures/magic_auth.json +10 -0
- package/lib/user-management/interfaces/create-magic-auth-options.interface.d.ts +8 -0
- package/lib/user-management/interfaces/create-magic-auth-options.interface.js +2 -0
- package/lib/user-management/interfaces/index.d.ts +2 -0
- package/lib/user-management/interfaces/index.js +2 -0
- package/lib/user-management/interfaces/invitation.interface.d.ts +26 -0
- package/lib/user-management/interfaces/magic-auth.interface.d.ts +38 -0
- package/lib/user-management/interfaces/magic-auth.interface.js +2 -0
- package/lib/user-management/serializers/create-magic-auth-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/create-magic-auth-options.serializer.js +8 -0
- package/lib/user-management/serializers/index.d.ts +3 -0
- package/lib/user-management/serializers/index.js +3 -0
- package/lib/user-management/serializers/invitation.serializer.d.ts +2 -1
- package/lib/user-management/serializers/invitation.serializer.js +15 -1
- package/lib/user-management/serializers/magic-auth.serializer.d.ts +3 -0
- package/lib/user-management/serializers/magic-auth.serializer.js +24 -0
- package/lib/user-management/user-management.d.ts +6 -1
- package/lib/user-management/user-management.js +15 -0
- package/lib/user-management/user-management.spec.js +39 -0
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DirectoryUser, DirectoryUserResponse, DirectoryGroup, DirectoryGroupResponse, EventDirectory, EventDirectoryResponse } from '../../directory-sync/interfaces';
|
|
2
2
|
import { Organization, OrganizationResponse } from '../../organizations/interfaces';
|
|
3
3
|
import { Connection, ConnectionResponse } from '../../sso/interfaces';
|
|
4
|
-
import { Session, SessionResponse, User, UserResponse } from '../../user-management/interfaces';
|
|
4
|
+
import { InvitationEvent, InvitationEventResponse, MagicAuthEvent, MagicAuthEventResponse, Session, SessionResponse, User, UserResponse } from '../../user-management/interfaces';
|
|
5
5
|
import { OrganizationMembership, OrganizationMembershipResponse } from '../../user-management/interfaces/organization-membership.interface';
|
|
6
6
|
import { RoleEvent, RoleEventResponse } from '../../user-management/interfaces/role.interface';
|
|
7
7
|
export interface EventBase {
|
|
@@ -140,6 +140,22 @@ export interface DsyncUserUpdatedEventResponse extends EventResponseBase {
|
|
|
140
140
|
event: 'dsync.user.updated';
|
|
141
141
|
data: DirectoryUserResponse & Record<'previous_attributes', any>;
|
|
142
142
|
}
|
|
143
|
+
export interface InvitationCreatedEvent extends EventBase {
|
|
144
|
+
event: 'invitation.created';
|
|
145
|
+
data: InvitationEvent;
|
|
146
|
+
}
|
|
147
|
+
export interface InvitationCreatedEventResponse extends EventResponseBase {
|
|
148
|
+
event: 'invitation.created';
|
|
149
|
+
data: InvitationEventResponse;
|
|
150
|
+
}
|
|
151
|
+
export interface MagicAuthCreatedEvent extends EventBase {
|
|
152
|
+
event: 'magic_auth.created';
|
|
153
|
+
data: MagicAuthEvent;
|
|
154
|
+
}
|
|
155
|
+
export interface MagicAuthCreatedEventResponse extends EventResponseBase {
|
|
156
|
+
event: 'magic_auth.created';
|
|
157
|
+
data: MagicAuthEventResponse;
|
|
158
|
+
}
|
|
143
159
|
export interface UserCreatedEvent extends EventBase {
|
|
144
160
|
event: 'user.created';
|
|
145
161
|
data: User;
|
|
@@ -264,7 +280,7 @@ export interface SessionCreatedEventResponse extends EventResponseBase {
|
|
|
264
280
|
event: 'session.created';
|
|
265
281
|
data: SessionResponse;
|
|
266
282
|
}
|
|
267
|
-
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent;
|
|
268
|
-
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse;
|
|
283
|
+
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent;
|
|
284
|
+
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse;
|
|
269
285
|
export type EventName = Event['event'];
|
|
270
286
|
export {};
|
|
@@ -40,6 +40,10 @@ const deserializeEvent = (event) => {
|
|
|
40
40
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeDirectoryUser)(event.data) });
|
|
41
41
|
case 'dsync.user.updated':
|
|
42
42
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeUpdatedEventDirectoryUser)(event.data) });
|
|
43
|
+
case 'invitation.created':
|
|
44
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeInvitationEvent)(event.data) });
|
|
45
|
+
case 'magic_auth.created':
|
|
46
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeMagicAuthEvent)(event.data) });
|
|
43
47
|
case 'user.created':
|
|
44
48
|
case 'user.updated':
|
|
45
49
|
case 'user.deleted':
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"expires_at": "2023-07-18T02:07:19.911Z",
|
|
9
9
|
"organization_id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
10
10
|
"token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
11
|
+
"accept_invitation_url": "https://myauthkit.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
11
12
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
12
13
|
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
13
14
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"expires_at": "2023-07-18T02:07:19.911Z",
|
|
12
12
|
"organization_id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
13
13
|
"token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
14
|
+
"accept_invitation_url": "https://myauthkit.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
14
15
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
15
16
|
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
16
17
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "magic_auth",
|
|
3
|
+
"id": "magic_auth_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
4
|
+
"user_id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
5
|
+
"email": "dane@workos.com",
|
|
6
|
+
"expires_at": "2023-07-18T02:07:19.911Z",
|
|
7
|
+
"code": "123456",
|
|
8
|
+
"created_at": "2023-07-18T02:07:19.911Z",
|
|
9
|
+
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
10
|
+
}
|
|
@@ -9,6 +9,7 @@ export * from './authenticate-with-password-options.interface';
|
|
|
9
9
|
export * from './authenticate-with-refresh-token-options.interface';
|
|
10
10
|
export * from './authenticate-with-totp-options.interface';
|
|
11
11
|
export * from './authentication-response.interface';
|
|
12
|
+
export * from './create-magic-auth-options.interface';
|
|
12
13
|
export * from './create-organization-membership-options.interface';
|
|
13
14
|
export * from './create-user-options.interface';
|
|
14
15
|
export * from './enroll-auth-factor.interface';
|
|
@@ -19,6 +20,7 @@ export * from './list-auth-factors-options.interface';
|
|
|
19
20
|
export * from './list-invitations-options.interface';
|
|
20
21
|
export * from './list-organization-memberships-options.interface';
|
|
21
22
|
export * from './list-users-options.interface';
|
|
23
|
+
export * from './magic-auth.interface';
|
|
22
24
|
export * from './organization-membership.interface';
|
|
23
25
|
export * from './reset-password-options.interface';
|
|
24
26
|
export * from './revoke-session-options.interface';
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./authenticate-with-password-options.interface"), exports)
|
|
|
25
25
|
__exportStar(require("./authenticate-with-refresh-token-options.interface"), exports);
|
|
26
26
|
__exportStar(require("./authenticate-with-totp-options.interface"), exports);
|
|
27
27
|
__exportStar(require("./authentication-response.interface"), exports);
|
|
28
|
+
__exportStar(require("./create-magic-auth-options.interface"), exports);
|
|
28
29
|
__exportStar(require("./create-organization-membership-options.interface"), exports);
|
|
29
30
|
__exportStar(require("./create-user-options.interface"), exports);
|
|
30
31
|
__exportStar(require("./enroll-auth-factor.interface"), exports);
|
|
@@ -35,6 +36,7 @@ __exportStar(require("./list-auth-factors-options.interface"), exports);
|
|
|
35
36
|
__exportStar(require("./list-invitations-options.interface"), exports);
|
|
36
37
|
__exportStar(require("./list-organization-memberships-options.interface"), exports);
|
|
37
38
|
__exportStar(require("./list-users-options.interface"), exports);
|
|
39
|
+
__exportStar(require("./magic-auth.interface"), exports);
|
|
38
40
|
__exportStar(require("./organization-membership.interface"), exports);
|
|
39
41
|
__exportStar(require("./reset-password-options.interface"), exports);
|
|
40
42
|
__exportStar(require("./revoke-session-options.interface"), exports);
|
|
@@ -8,6 +8,19 @@ export interface Invitation {
|
|
|
8
8
|
expiresAt: string;
|
|
9
9
|
organizationId: string | null;
|
|
10
10
|
token: string;
|
|
11
|
+
acceptInvitationUrl: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface InvitationEvent {
|
|
16
|
+
object: 'invitation';
|
|
17
|
+
id: string;
|
|
18
|
+
email: string;
|
|
19
|
+
state: 'pending' | 'accepted' | 'expired' | 'revoked';
|
|
20
|
+
acceptedAt: string | null;
|
|
21
|
+
revokedAt: string | null;
|
|
22
|
+
expiresAt: string;
|
|
23
|
+
organizationId: string | null;
|
|
11
24
|
createdAt: string;
|
|
12
25
|
updatedAt: string;
|
|
13
26
|
}
|
|
@@ -21,6 +34,19 @@ export interface InvitationResponse {
|
|
|
21
34
|
expires_at: string;
|
|
22
35
|
organization_id: string | null;
|
|
23
36
|
token: string;
|
|
37
|
+
accept_invitation_url: string;
|
|
38
|
+
created_at: string;
|
|
39
|
+
updated_at: string;
|
|
40
|
+
}
|
|
41
|
+
export interface InvitationEventResponse {
|
|
42
|
+
object: 'invitation';
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
state: 'pending' | 'accepted' | 'expired' | 'revoked';
|
|
46
|
+
accepted_at: string | null;
|
|
47
|
+
revoked_at: string | null;
|
|
48
|
+
expires_at: string;
|
|
49
|
+
organization_id: string | null;
|
|
24
50
|
created_at: string;
|
|
25
51
|
updated_at: string;
|
|
26
52
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface MagicAuth {
|
|
2
|
+
object: 'magic_auth';
|
|
3
|
+
id: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
email: string;
|
|
6
|
+
expiresAt: string;
|
|
7
|
+
code: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MagicAuthEvent {
|
|
12
|
+
object: 'magic_auth';
|
|
13
|
+
id: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
email: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
export interface MagicAuthResponse {
|
|
21
|
+
object: 'magic_auth';
|
|
22
|
+
id: string;
|
|
23
|
+
user_id: string;
|
|
24
|
+
email: string;
|
|
25
|
+
expires_at: string;
|
|
26
|
+
code: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
updated_at: string;
|
|
29
|
+
}
|
|
30
|
+
export interface MagicAuthEventResponse {
|
|
31
|
+
object: 'magic_auth';
|
|
32
|
+
id: string;
|
|
33
|
+
user_id: string;
|
|
34
|
+
email: string;
|
|
35
|
+
expires_at: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
updated_at: string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeCreateMagicAuthOptions = void 0;
|
|
4
|
+
const serializeCreateMagicAuthOptions = (options) => ({
|
|
5
|
+
email: options.email,
|
|
6
|
+
invitation_token: options.invitationToken,
|
|
7
|
+
});
|
|
8
|
+
exports.serializeCreateMagicAuthOptions = serializeCreateMagicAuthOptions;
|
|
@@ -4,8 +4,11 @@ export * from './authenticate-with-password-options.serializer';
|
|
|
4
4
|
export * from './authenticate-with-refresh-token.options.serializer';
|
|
5
5
|
export * from './authenticate-with-totp-options.serializer';
|
|
6
6
|
export * from './authentication-response.serializer';
|
|
7
|
+
export * from './create-magic-auth-options.serializer';
|
|
7
8
|
export * from './enroll-auth-factor-options.serializer';
|
|
8
9
|
export * from './factor.serializer';
|
|
10
|
+
export * from './invitation.serializer';
|
|
11
|
+
export * from './magic-auth.serializer';
|
|
9
12
|
export * from './reset-password-options.serializer';
|
|
10
13
|
export * from './send-password-reset-email.serializer';
|
|
11
14
|
export * from './create-user-options.serializer';
|
|
@@ -20,8 +20,11 @@ __exportStar(require("./authenticate-with-password-options.serializer"), exports
|
|
|
20
20
|
__exportStar(require("./authenticate-with-refresh-token.options.serializer"), exports);
|
|
21
21
|
__exportStar(require("./authenticate-with-totp-options.serializer"), exports);
|
|
22
22
|
__exportStar(require("./authentication-response.serializer"), exports);
|
|
23
|
+
__exportStar(require("./create-magic-auth-options.serializer"), exports);
|
|
23
24
|
__exportStar(require("./enroll-auth-factor-options.serializer"), exports);
|
|
24
25
|
__exportStar(require("./factor.serializer"), exports);
|
|
26
|
+
__exportStar(require("./invitation.serializer"), exports);
|
|
27
|
+
__exportStar(require("./magic-auth.serializer"), exports);
|
|
25
28
|
__exportStar(require("./reset-password-options.serializer"), exports);
|
|
26
29
|
__exportStar(require("./send-password-reset-email.serializer"), exports);
|
|
27
30
|
__exportStar(require("./create-user-options.serializer"), exports);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Invitation, InvitationResponse } from '../interfaces/invitation.interface';
|
|
1
|
+
import { Invitation, InvitationEvent, InvitationEventResponse, InvitationResponse } from '../interfaces/invitation.interface';
|
|
2
2
|
export declare const deserializeInvitation: (invitation: InvitationResponse) => Invitation;
|
|
3
|
+
export declare const deserializeInvitationEvent: (invitation: InvitationEventResponse) => InvitationEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeInvitation = void 0;
|
|
3
|
+
exports.deserializeInvitationEvent = exports.deserializeInvitation = void 0;
|
|
4
4
|
const deserializeInvitation = (invitation) => ({
|
|
5
5
|
object: invitation.object,
|
|
6
6
|
id: invitation.id,
|
|
@@ -11,7 +11,21 @@ const deserializeInvitation = (invitation) => ({
|
|
|
11
11
|
expiresAt: invitation.expires_at,
|
|
12
12
|
organizationId: invitation.organization_id,
|
|
13
13
|
token: invitation.token,
|
|
14
|
+
acceptInvitationUrl: invitation.accept_invitation_url,
|
|
14
15
|
createdAt: invitation.created_at,
|
|
15
16
|
updatedAt: invitation.updated_at,
|
|
16
17
|
});
|
|
17
18
|
exports.deserializeInvitation = deserializeInvitation;
|
|
19
|
+
const deserializeInvitationEvent = (invitation) => ({
|
|
20
|
+
object: invitation.object,
|
|
21
|
+
id: invitation.id,
|
|
22
|
+
email: invitation.email,
|
|
23
|
+
state: invitation.state,
|
|
24
|
+
acceptedAt: invitation.accepted_at,
|
|
25
|
+
revokedAt: invitation.revoked_at,
|
|
26
|
+
expiresAt: invitation.expires_at,
|
|
27
|
+
organizationId: invitation.organization_id,
|
|
28
|
+
createdAt: invitation.created_at,
|
|
29
|
+
updatedAt: invitation.updated_at,
|
|
30
|
+
});
|
|
31
|
+
exports.deserializeInvitationEvent = deserializeInvitationEvent;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MagicAuth, MagicAuthEvent, MagicAuthEventResponse, MagicAuthResponse } from '../interfaces/magic-auth.interface';
|
|
2
|
+
export declare const deserializeMagicAuth: (magicAuth: MagicAuthResponse) => MagicAuth;
|
|
3
|
+
export declare const deserializeMagicAuthEvent: (magicAuth: MagicAuthEventResponse) => MagicAuthEvent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeMagicAuthEvent = exports.deserializeMagicAuth = void 0;
|
|
4
|
+
const deserializeMagicAuth = (magicAuth) => ({
|
|
5
|
+
object: magicAuth.object,
|
|
6
|
+
id: magicAuth.id,
|
|
7
|
+
userId: magicAuth.user_id,
|
|
8
|
+
email: magicAuth.email,
|
|
9
|
+
expiresAt: magicAuth.expires_at,
|
|
10
|
+
code: magicAuth.code,
|
|
11
|
+
createdAt: magicAuth.created_at,
|
|
12
|
+
updatedAt: magicAuth.updated_at,
|
|
13
|
+
});
|
|
14
|
+
exports.deserializeMagicAuth = deserializeMagicAuth;
|
|
15
|
+
const deserializeMagicAuthEvent = (magicAuth) => ({
|
|
16
|
+
object: magicAuth.object,
|
|
17
|
+
id: magicAuth.id,
|
|
18
|
+
userId: magicAuth.user_id,
|
|
19
|
+
email: magicAuth.email,
|
|
20
|
+
expiresAt: magicAuth.expires_at,
|
|
21
|
+
createdAt: magicAuth.created_at,
|
|
22
|
+
updatedAt: magicAuth.updated_at,
|
|
23
|
+
});
|
|
24
|
+
exports.deserializeMagicAuthEvent = deserializeMagicAuthEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
|
-
import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, RefreshAuthenticationResponse } from './interfaces';
|
|
3
|
+
import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, RefreshAuthenticationResponse, MagicAuth, CreateMagicAuthOptions } from './interfaces';
|
|
4
4
|
import { Challenge } from '../mfa/interfaces';
|
|
5
5
|
import { OrganizationMembership } from './interfaces/organization-membership.interface';
|
|
6
6
|
import { ListOrganizationMembershipsOptions } from './interfaces/list-organization-memberships-options.interface';
|
|
@@ -30,6 +30,11 @@ export declare class UserManagement {
|
|
|
30
30
|
sendVerificationEmail({ userId, }: SendVerificationEmailOptions): Promise<{
|
|
31
31
|
user: User;
|
|
32
32
|
}>;
|
|
33
|
+
getMagicAuth(magicAuthId: string): Promise<MagicAuth>;
|
|
34
|
+
createMagicAuth(options: CreateMagicAuthOptions): Promise<MagicAuth>;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Please use `createMagicAuth` instead. This method will be removed in a future major version.
|
|
37
|
+
*/
|
|
33
38
|
sendMagicAuthCode(options: SendMagicAuthCodeOptions): Promise<void>;
|
|
34
39
|
verifyEmail({ code, userId, }: VerifyEmailOptions): Promise<{
|
|
35
40
|
user: User;
|
|
@@ -106,6 +106,21 @@ class UserManagement {
|
|
|
106
106
|
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
getMagicAuth(magicAuthId) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const { data } = yield this.workos.get(`/user_management/magic_auth/${magicAuthId}`);
|
|
112
|
+
return (0, serializers_1.deserializeMagicAuth)(data);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
createMagicAuth(options) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const { data } = yield this.workos.post('/user_management/magic_auth', (0, serializers_1.serializeCreateMagicAuthOptions)(Object.assign({}, options)));
|
|
118
|
+
return (0, serializers_1.deserializeMagicAuth)(data);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated Please use `createMagicAuth` instead. This method will be removed in a future major version.
|
|
123
|
+
*/
|
|
109
124
|
sendMagicAuthCode(options) {
|
|
110
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
126
|
yield this.workos.post('/user_management/magic_auth/send', (0, serializers_1.serializeSendMagicAuthCodeOptions)(options));
|
|
@@ -22,10 +22,12 @@ const organization_membership_json_1 = __importDefault(require("./fixtures/organ
|
|
|
22
22
|
const list_organization_memberships_json_1 = __importDefault(require("./fixtures/list-organization-memberships.json"));
|
|
23
23
|
const invitation_json_1 = __importDefault(require("./fixtures/invitation.json"));
|
|
24
24
|
const list_invitations_json_1 = __importDefault(require("./fixtures/list-invitations.json"));
|
|
25
|
+
const magic_auth_json_1 = __importDefault(require("./fixtures/magic_auth.json"));
|
|
25
26
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
26
27
|
const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
27
28
|
const organizationMembershipId = 'om_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
28
29
|
const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
30
|
+
const magicAuthId = 'magic_auth_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
29
31
|
describe('UserManagement', () => {
|
|
30
32
|
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
31
33
|
describe('getUser', () => {
|
|
@@ -324,6 +326,43 @@ describe('UserManagement', () => {
|
|
|
324
326
|
}));
|
|
325
327
|
});
|
|
326
328
|
});
|
|
329
|
+
describe('getMagicAuth', () => {
|
|
330
|
+
it('sends a Get Magic Auth request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
331
|
+
(0, test_utils_1.fetchOnce)(magic_auth_json_1.default);
|
|
332
|
+
const magicAuth = yield workos.userManagement.getMagicAuth(magicAuthId);
|
|
333
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/magic_auth/${magicAuthId}`);
|
|
334
|
+
expect(magicAuth).toMatchObject({
|
|
335
|
+
id: 'magic_auth_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
336
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
337
|
+
email: 'dane@workos.com',
|
|
338
|
+
expiresAt: '2023-07-18T02:07:19.911Z',
|
|
339
|
+
code: '123456',
|
|
340
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
341
|
+
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
342
|
+
});
|
|
343
|
+
}));
|
|
344
|
+
});
|
|
345
|
+
describe('createMagicAuth', () => {
|
|
346
|
+
it('sends a Create Magic Auth request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
347
|
+
(0, test_utils_1.fetchOnce)(magic_auth_json_1.default);
|
|
348
|
+
const response = yield workos.userManagement.createMagicAuth({
|
|
349
|
+
email: 'bob.loblaw@example.com',
|
|
350
|
+
});
|
|
351
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/user_management/magic_auth');
|
|
352
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
353
|
+
email: 'bob.loblaw@example.com',
|
|
354
|
+
});
|
|
355
|
+
expect(response).toMatchObject({
|
|
356
|
+
id: 'magic_auth_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
357
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
358
|
+
email: 'dane@workos.com',
|
|
359
|
+
expiresAt: '2023-07-18T02:07:19.911Z',
|
|
360
|
+
code: '123456',
|
|
361
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
362
|
+
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
363
|
+
});
|
|
364
|
+
}));
|
|
365
|
+
});
|
|
327
366
|
describe('sendMagicAuthCode', () => {
|
|
328
367
|
it('sends a Send Magic Auth Code request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
329
368
|
(0, test_utils_1.fetchOnce)();
|
package/lib/workos.js
CHANGED
|
@@ -24,7 +24,7 @@ const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
|
24
24
|
const user_management_1 = require("./user-management/user-management");
|
|
25
25
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
26
26
|
const fetch_client_1 = require("./common/utils/fetch-client");
|
|
27
|
-
const VERSION = '7.
|
|
27
|
+
const VERSION = '7.3.0';
|
|
28
28
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
29
29
|
class WorkOS {
|
|
30
30
|
constructor(key, options = {}) {
|
package/package.json
CHANGED