@workos-inc/node 3.0.0-alpha.2 → 3.0.0-alpha.3
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/audit-trail/audit-trail.d.ts +2 -2
- package/lib/common/interfaces/at-least-one-property-of.interface.d.ts +7 -0
- package/lib/common/interfaces/event.interface.d.ts +142 -0
- package/lib/common/interfaces/index.d.ts +2 -0
- package/lib/common/interfaces/index.js +2 -0
- package/lib/common/interfaces/list.interface.d.ts +2 -2
- package/lib/common/serializers/event.serializer.js +40 -0
- package/lib/common/serializers/index.d.ts +1 -0
- package/lib/common/serializers/index.js +1 -0
- package/lib/common/serializers/list.serializer.d.ts +2 -2
- package/lib/directory-sync/directory-sync.d.ts +5 -5
- package/lib/directory-sync/directory-sync.spec.js +2 -0
- package/lib/directory-sync/interfaces/directory-group.interface.d.ts +20 -0
- package/lib/directory-sync/interfaces/directory-user.interface.d.ts +2 -0
- package/lib/directory-sync/interfaces/directory.interface.d.ts +34 -2
- package/lib/directory-sync/interfaces/list-groups-options.interface.d.ts +1 -1
- package/lib/directory-sync/serializers/directory-group.serializer.d.ts +3 -1
- package/lib/directory-sync/serializers/directory-group.serializer.js +24 -1
- package/lib/directory-sync/serializers/directory-user.serializer.d.ts +1 -0
- package/lib/directory-sync/serializers/directory-user.serializer.js +21 -1
- package/lib/directory-sync/serializers/directory.serializer.d.ts +3 -1
- package/lib/directory-sync/serializers/directory.serializer.js +25 -1
- package/lib/directory-sync/utils/get-primary-email.spec.js +1 -0
- package/lib/events/events.d.ts +2 -3
- package/lib/events/events.js +1 -2
- package/lib/events/events.spec.js +22 -4
- package/lib/events/interfaces/index.d.ts +0 -1
- package/lib/events/interfaces/index.js +0 -1
- package/lib/events/interfaces/list-events-options.interface.d.ts +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/organizations/organizations.d.ts +2 -2
- package/lib/sso/interfaces/connection.interface.d.ts +0 -8
- package/lib/sso/serializers/connection.serializer.js +0 -1
- package/lib/sso/sso.d.ts +2 -2
- package/lib/sso/sso.spec.js +0 -1
- package/lib/users/fixtures/list-users.json +0 -1
- package/lib/users/fixtures/session.json +2 -0
- package/lib/users/fixtures/user.json +0 -1
- package/lib/users/interfaces/session.interface.d.ts +29 -0
- package/lib/users/interfaces/update-user-options.interface.d.ts +8 -3
- package/lib/users/interfaces/user.interface.d.ts +0 -18
- package/lib/users/serializers/session.serializer.d.ts +3 -1
- package/lib/users/serializers/session.serializer.js +13 -1
- package/lib/users/serializers/user.serializer.js +2 -9
- package/lib/users/users.d.ts +2 -2
- package/lib/users/users.spec.js +20 -2
- package/lib/webhooks/fixtures/webhook.json +67 -1
- package/lib/webhooks/webhooks.d.ts +2 -2
- package/lib/webhooks/webhooks.js +2 -1
- package/lib/webhooks/webhooks.spec.js +8 -6
- package/lib/workos.js +1 -1
- package/package.json +1 -1
- package/lib/events/interfaces/event.interface.d.ts +0 -66
- package/lib/events/serializers/event.serializer.js +0 -10
- package/lib/webhooks/interfaces/index.d.ts +0 -4
- package/lib/webhooks/interfaces/index.js +0 -20
- package/lib/webhooks/interfaces/webhook-directory-group.interface.d.ts +0 -10
- package/lib/webhooks/interfaces/webhook-directory-user.interface.d.ts +0 -5
- package/lib/webhooks/interfaces/webhook-directory-user.interface.js +0 -2
- package/lib/webhooks/interfaces/webhook-directory.interface.d.ts +0 -20
- package/lib/webhooks/interfaces/webhook-directory.interface.js +0 -2
- package/lib/webhooks/interfaces/webhook.interface.d.ts +0 -74
- package/lib/webhooks/interfaces/webhook.interface.js +0 -2
- /package/lib/{events/interfaces/event.interface.js → common/interfaces/at-least-one-property-of.interface.js} +0 -0
- /package/lib/{webhooks/interfaces/webhook-directory-group.interface.js → common/interfaces/event.interface.js} +0 -0
- /package/lib/{events → common}/serializers/event.serializer.d.ts +0 -0
package/lib/index.js
CHANGED
|
@@ -28,7 +28,6 @@ __exportStar(require("./organizations/interfaces"), exports);
|
|
|
28
28
|
__exportStar(require("./passwordless/interfaces"), exports);
|
|
29
29
|
__exportStar(require("./portal/interfaces"), exports);
|
|
30
30
|
__exportStar(require("./sso/interfaces"), exports);
|
|
31
|
-
__exportStar(require("./webhooks/interfaces"), exports);
|
|
32
31
|
__exportStar(require("./users/interfaces"), exports);
|
|
33
32
|
// tslint:disable-next-line:no-default-export
|
|
34
33
|
exports.default = workos_1.WorkOS;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List } from '../common/interfaces';
|
|
2
2
|
import { WorkOS } from '../workos';
|
|
3
3
|
import { CreateOrganizationOptions, CreateOrganizationRequestOptions, ListOrganizationsOptions, Organization, UpdateOrganizationOptions } from './interfaces';
|
|
4
4
|
export declare class Organizations {
|
|
5
5
|
private readonly workos;
|
|
6
6
|
constructor(workos: WorkOS);
|
|
7
|
-
listOrganizations(options?: ListOrganizationsOptions): Promise<
|
|
7
|
+
listOrganizations(options?: ListOrganizationsOptions): Promise<List<Organization>>;
|
|
8
8
|
createOrganization(payload: CreateOrganizationOptions, requestOptions?: CreateOrganizationRequestOptions): Promise<Organization>;
|
|
9
9
|
deleteOrganization(id: string): Promise<void>;
|
|
10
10
|
getOrganization(id: string): Promise<Organization>;
|
|
@@ -14,10 +14,6 @@ export interface Connection {
|
|
|
14
14
|
*/
|
|
15
15
|
connectionType: ConnectionType;
|
|
16
16
|
state: 'draft' | 'active' | 'inactive' | 'validating';
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated The status parameter has been deprecated. Please use state.
|
|
19
|
-
*/
|
|
20
|
-
status: 'linked' | 'unlinked';
|
|
21
17
|
domains: ConnectionDomain[];
|
|
22
18
|
type: ConnectionType;
|
|
23
19
|
createdAt: string;
|
|
@@ -30,10 +26,6 @@ export interface ConnectionResponse {
|
|
|
30
26
|
name: string;
|
|
31
27
|
connection_type: ConnectionType;
|
|
32
28
|
state: 'draft' | 'active' | 'inactive' | 'validating';
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated The status parameter has been deprecated. Please use state.
|
|
35
|
-
*/
|
|
36
|
-
status: 'linked' | 'unlinked';
|
|
37
29
|
domains: ConnectionDomain[];
|
|
38
30
|
created_at: string;
|
|
39
31
|
updated_at: string;
|
|
@@ -9,7 +9,6 @@ const deserializeConnection = (connection) => ({
|
|
|
9
9
|
connectionType: connection.connection_type,
|
|
10
10
|
type: connection.connection_type,
|
|
11
11
|
state: connection.state,
|
|
12
|
-
status: connection.status,
|
|
13
12
|
domains: connection.domains,
|
|
14
13
|
createdAt: connection.created_at,
|
|
15
14
|
updatedAt: connection.updated_at,
|
package/lib/sso/sso.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List } from '../common/interfaces';
|
|
2
2
|
import { WorkOS } from '../workos';
|
|
3
3
|
import { AuthorizationURLOptions, Connection, GetProfileAndTokenOptions, GetProfileOptions, ListConnectionsOptions, Profile, ProfileAndToken } from './interfaces';
|
|
4
4
|
export declare class SSO {
|
|
@@ -9,5 +9,5 @@ export declare class SSO {
|
|
|
9
9
|
getConnection(id: string): Promise<Connection>;
|
|
10
10
|
getProfileAndToken({ code, clientID, }: GetProfileAndTokenOptions): Promise<ProfileAndToken>;
|
|
11
11
|
getProfile({ accessToken }: GetProfileOptions): Promise<Profile>;
|
|
12
|
-
listConnections(options?: ListConnectionsOptions): Promise<
|
|
12
|
+
listConnections(options?: ListConnectionsOptions): Promise<List<Connection>>;
|
|
13
13
|
}
|
package/lib/sso/sso.spec.js
CHANGED
|
@@ -2,11 +2,40 @@ export interface Session {
|
|
|
2
2
|
id: string;
|
|
3
3
|
createdAt: string;
|
|
4
4
|
expiresAt: string;
|
|
5
|
+
authorizedOrganizations: AuthorizedOrganization[];
|
|
6
|
+
unauthorizedOrganizations: UnauthorizedOrganization[];
|
|
5
7
|
token: string;
|
|
6
8
|
}
|
|
9
|
+
interface OrganizationSummary {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
interface AuthorizedOrganization {
|
|
14
|
+
organization: OrganizationSummary;
|
|
15
|
+
}
|
|
16
|
+
type SessionAuthenticationMethod = 'GoogleOauth' | 'MagicAuth' | 'MicrosoftOauth' | 'Password';
|
|
17
|
+
export type UnauthorizedOrganizationReason = {
|
|
18
|
+
type: 'authentication_method_required';
|
|
19
|
+
allowedAuthenticationMethods: SessionAuthenticationMethod[];
|
|
20
|
+
};
|
|
21
|
+
export type UnauthorizedOrganizationReasonResponse = {
|
|
22
|
+
type: 'authentication_method_required';
|
|
23
|
+
allowed_authentication_methods: SessionAuthenticationMethod[];
|
|
24
|
+
};
|
|
25
|
+
export interface UnauthorizedOrganization {
|
|
26
|
+
organization: OrganizationSummary;
|
|
27
|
+
reasons: UnauthorizedOrganizationReason[];
|
|
28
|
+
}
|
|
29
|
+
export interface UnauthorizedOrganizationResponse {
|
|
30
|
+
organization: OrganizationSummary;
|
|
31
|
+
reasons: UnauthorizedOrganizationReasonResponse[];
|
|
32
|
+
}
|
|
7
33
|
export interface SessionResponse {
|
|
8
34
|
id: string;
|
|
9
35
|
created_at: string;
|
|
10
36
|
expires_at: string;
|
|
37
|
+
authorized_organizations: AuthorizedOrganization[];
|
|
38
|
+
unauthorized_organizations: UnauthorizedOrganizationResponse[];
|
|
11
39
|
token: string;
|
|
12
40
|
}
|
|
41
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { AtLeastOnePropertyOf } from '../../common/interfaces';
|
|
2
|
+
interface BaseUpdateUserOptions {
|
|
2
3
|
userId: string;
|
|
4
|
+
}
|
|
5
|
+
interface UpdateUserOptionsProperties {
|
|
3
6
|
firstName: string;
|
|
4
7
|
lastName: string;
|
|
5
8
|
}
|
|
9
|
+
export type UpdateUserOptions = BaseUpdateUserOptions & AtLeastOnePropertyOf<UpdateUserOptionsProperties>;
|
|
6
10
|
export interface SerializedUpdateUserOptions {
|
|
7
|
-
first_name
|
|
8
|
-
last_name
|
|
11
|
+
first_name?: string;
|
|
12
|
+
last_name?: string;
|
|
9
13
|
}
|
|
14
|
+
export {};
|
|
@@ -2,24 +2,20 @@ export type User = ManagedUser | UnmanagedUser;
|
|
|
2
2
|
export type UserResponse = ManagedUserResponse | UnmanagedUserResponse;
|
|
3
3
|
interface ManagedUser extends BaseUser {
|
|
4
4
|
userType: 'managed';
|
|
5
|
-
organizationMemberships: [OrganizationMembership];
|
|
6
5
|
ssoProfileId: string | null;
|
|
7
6
|
}
|
|
8
7
|
interface ManagedUserResponse extends BaseUserResponse {
|
|
9
8
|
user_type: 'managed';
|
|
10
|
-
organization_memberships: [OrganizationMembershipResponse];
|
|
11
9
|
sso_profile_id: string | null;
|
|
12
10
|
}
|
|
13
11
|
interface UnmanagedUser extends BaseUser {
|
|
14
12
|
userType: 'unmanaged';
|
|
15
|
-
organizationMemberships: OrganizationMembership[];
|
|
16
13
|
emailVerifiedAt: string | null;
|
|
17
14
|
googleOauthProfileId: string | null;
|
|
18
15
|
microsoftOauthProfileId: string | null;
|
|
19
16
|
}
|
|
20
17
|
interface UnmanagedUserResponse extends BaseUserResponse {
|
|
21
18
|
user_type: 'unmanaged';
|
|
22
|
-
organization_memberships: OrganizationMembershipResponse[];
|
|
23
19
|
email_verified_at: string | null;
|
|
24
20
|
google_oauth_profile_id: string | null;
|
|
25
21
|
microsoft_oauth_profile_id: string | null;
|
|
@@ -42,18 +38,4 @@ interface BaseUserResponse {
|
|
|
42
38
|
created_at: string;
|
|
43
39
|
updated_at: string;
|
|
44
40
|
}
|
|
45
|
-
export interface OrganizationMembership {
|
|
46
|
-
organization: OrganizationSummary;
|
|
47
|
-
createdAt: string;
|
|
48
|
-
updatedAt: string;
|
|
49
|
-
}
|
|
50
|
-
export interface OrganizationMembershipResponse {
|
|
51
|
-
organization: OrganizationSummary;
|
|
52
|
-
created_at: string;
|
|
53
|
-
updated_at: string;
|
|
54
|
-
}
|
|
55
|
-
interface OrganizationSummary {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
}
|
|
59
41
|
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { Session, SessionResponse } from '../interfaces/session.interface';
|
|
1
|
+
import { Session, SessionResponse, UnauthorizedOrganization, UnauthorizedOrganizationReason, UnauthorizedOrganizationReasonResponse, UnauthorizedOrganizationResponse } from '../interfaces/session.interface';
|
|
2
2
|
export declare const deserializeSession: (session: SessionResponse) => Session;
|
|
3
|
+
export declare const deserializeUnauthorizedOrganization: (unauthorizedOrganization: UnauthorizedOrganizationResponse) => UnauthorizedOrganization;
|
|
4
|
+
export declare const deserializeUnauthorizedOrganizationReason: (unauthorizedOrganizationReason: UnauthorizedOrganizationReasonResponse) => UnauthorizedOrganizationReason;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeSession = void 0;
|
|
3
|
+
exports.deserializeUnauthorizedOrganizationReason = exports.deserializeUnauthorizedOrganization = exports.deserializeSession = void 0;
|
|
4
4
|
const deserializeSession = (session) => ({
|
|
5
5
|
id: session.id,
|
|
6
6
|
createdAt: session.created_at,
|
|
7
7
|
expiresAt: session.expires_at,
|
|
8
|
+
authorizedOrganizations: session.authorized_organizations,
|
|
9
|
+
unauthorizedOrganizations: session.unauthorized_organizations.map(exports.deserializeUnauthorizedOrganization),
|
|
8
10
|
token: session.token,
|
|
9
11
|
});
|
|
10
12
|
exports.deserializeSession = deserializeSession;
|
|
13
|
+
const deserializeUnauthorizedOrganization = (unauthorizedOrganization) => ({
|
|
14
|
+
organization: unauthorizedOrganization.organization,
|
|
15
|
+
reasons: unauthorizedOrganization.reasons.map(exports.deserializeUnauthorizedOrganizationReason),
|
|
16
|
+
});
|
|
17
|
+
exports.deserializeUnauthorizedOrganization = deserializeUnauthorizedOrganization;
|
|
18
|
+
const deserializeUnauthorizedOrganizationReason = (unauthorizedOrganizationReason) => ({
|
|
19
|
+
type: unauthorizedOrganizationReason.type,
|
|
20
|
+
allowedAuthenticationMethods: unauthorizedOrganizationReason.allowed_authentication_methods,
|
|
21
|
+
});
|
|
22
|
+
exports.deserializeUnauthorizedOrganizationReason = deserializeUnauthorizedOrganizationReason;
|
|
@@ -14,18 +14,11 @@ const deserializeUser = (user) => {
|
|
|
14
14
|
};
|
|
15
15
|
switch (user.user_type) {
|
|
16
16
|
case 'managed':
|
|
17
|
-
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type,
|
|
18
|
-
deserializeOrganizationMembership(user.organization_memberships[0]),
|
|
19
|
-
], ssoProfileId: user.sso_profile_id });
|
|
17
|
+
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type, ssoProfileId: user.sso_profile_id });
|
|
20
18
|
case 'unmanaged':
|
|
21
|
-
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type,
|
|
19
|
+
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type, emailVerifiedAt: user.email_verified_at, googleOauthProfileId: user.google_oauth_profile_id, microsoftOauthProfileId: user.microsoft_oauth_profile_id });
|
|
22
20
|
default:
|
|
23
21
|
throw new exceptions_1.UnexpectedUserTypeException(user);
|
|
24
22
|
}
|
|
25
23
|
};
|
|
26
24
|
exports.deserializeUser = deserializeUser;
|
|
27
|
-
const deserializeOrganizationMembership = (organizationMembership) => ({
|
|
28
|
-
organization: organizationMembership.organization,
|
|
29
|
-
createdAt: organizationMembership.created_at,
|
|
30
|
-
updatedAt: organizationMembership.updated_at,
|
|
31
|
-
});
|
package/lib/users/users.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AddUserToOrganizationOptions, AuthenticateUserWithPasswordOptions, AuthenticateUserWithTokenOptions, AuthenticationResponse, CompletePasswordResetOptions, CreateEmailVerificationChallengeOptions, CreateEmailVerificationChallengeResponse, CreatePasswordResetChallengeOptions, CreatePasswordResetChallengeResponse, CreateUserOptions, ListUsersOptions, RemoveUserFromOrganizationOptions, RevokeSessionOptions, UpdateUserOptions, UpdateUserPasswordOptions, User, VerifySessionOptions, VerifySessionResponse } from './interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { List } from '../common/interfaces';
|
|
4
4
|
export declare class Users {
|
|
5
5
|
private readonly workos;
|
|
6
6
|
constructor(workos: WorkOS);
|
|
7
7
|
getUser(userId: string): Promise<User>;
|
|
8
|
-
listUsers(options?: ListUsersOptions): Promise<
|
|
8
|
+
listUsers(options?: ListUsersOptions): Promise<List<User>>;
|
|
9
9
|
createUser(payload: CreateUserOptions): Promise<User>;
|
|
10
10
|
authenticateUserWithPassword(payload: AuthenticateUserWithPasswordOptions): Promise<AuthenticationResponse>;
|
|
11
11
|
authenticateUserWithToken(payload: AuthenticateUserWithTokenOptions): Promise<AuthenticationResponse>;
|
package/lib/users/users.spec.js
CHANGED
|
@@ -34,7 +34,6 @@ describe('UserManagement', () => {
|
|
|
34
34
|
email: 'test01@example.com',
|
|
35
35
|
firstName: 'Test 01',
|
|
36
36
|
lastName: 'User',
|
|
37
|
-
organizationMemberships: [],
|
|
38
37
|
userType: 'unmanaged',
|
|
39
38
|
emailVerifiedAt: '2023-07-17T20:07:20.055Z',
|
|
40
39
|
});
|
|
@@ -93,7 +92,6 @@ describe('UserManagement', () => {
|
|
|
93
92
|
email: 'test01@example.com',
|
|
94
93
|
firstName: 'Test 01',
|
|
95
94
|
lastName: 'User',
|
|
96
|
-
organizationMemberships: [],
|
|
97
95
|
userType: 'unmanaged',
|
|
98
96
|
emailVerifiedAt: '2023-07-17T20:07:20.055Z',
|
|
99
97
|
createdAt: '2023-07-18T02:07:19.911Z',
|
|
@@ -297,10 +295,30 @@ describe('UserManagement', () => {
|
|
|
297
295
|
lastName: 'Williams',
|
|
298
296
|
});
|
|
299
297
|
expect(mock.history.put[0].url).toEqual(`/users/${userId}`);
|
|
298
|
+
expect(JSON.parse(mock.history.put[0].data)).toEqual({
|
|
299
|
+
first_name: 'Dane',
|
|
300
|
+
last_name: 'Williams',
|
|
301
|
+
});
|
|
300
302
|
expect(resp).toMatchObject({
|
|
301
303
|
email: 'test01@example.com',
|
|
302
304
|
});
|
|
303
305
|
}));
|
|
306
|
+
describe('when only one property is provided', () => {
|
|
307
|
+
it('sends a updateUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
308
|
+
mock.onPut(`/users/${userId}`).reply(200, user_json_1.default);
|
|
309
|
+
const resp = yield workos.users.updateUser({
|
|
310
|
+
userId,
|
|
311
|
+
firstName: 'Dane',
|
|
312
|
+
});
|
|
313
|
+
expect(mock.history.put[0].url).toEqual(`/users/${userId}`);
|
|
314
|
+
expect(JSON.parse(mock.history.put[0].data)).toEqual({
|
|
315
|
+
first_name: 'Dane',
|
|
316
|
+
});
|
|
317
|
+
expect(resp).toMatchObject({
|
|
318
|
+
email: 'test01@example.com',
|
|
319
|
+
});
|
|
320
|
+
}));
|
|
321
|
+
});
|
|
304
322
|
});
|
|
305
323
|
describe('updateUserPassword', () => {
|
|
306
324
|
it('sends a updateUserPassword request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1 +1,67 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"id": "wh_123",
|
|
3
|
+
"data": {
|
|
4
|
+
"id": "directory_user_01FAEAJCR3ZBZ30D8BD1924TVG",
|
|
5
|
+
"state": "active",
|
|
6
|
+
"emails": [
|
|
7
|
+
{
|
|
8
|
+
"type": "work",
|
|
9
|
+
"value": "blair@foo-corp.com",
|
|
10
|
+
"primary": true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"idp_id": "00u1e8mutl6wlH3lL4x7",
|
|
14
|
+
"object": "directory_user",
|
|
15
|
+
"username": "blair@foo-corp.com",
|
|
16
|
+
"last_name": "Lunchford",
|
|
17
|
+
"first_name": "Blair",
|
|
18
|
+
"job_title": "Software Engineer",
|
|
19
|
+
"directory_id": "directory_01F9M7F68PZP8QXP8G7X5QRHS7",
|
|
20
|
+
"created_at": "2021-06-25T19:07:33.155Z",
|
|
21
|
+
"updated_at": "2021-06-25T19:07:33.155Z",
|
|
22
|
+
"raw_attributes": {
|
|
23
|
+
"name": {
|
|
24
|
+
"givenName": "Blair",
|
|
25
|
+
"familyName": "Lunchford",
|
|
26
|
+
"middleName": "Elizabeth",
|
|
27
|
+
"honorificPrefix": "Ms."
|
|
28
|
+
},
|
|
29
|
+
"title": "Software Engineer",
|
|
30
|
+
"active": true,
|
|
31
|
+
"emails": [
|
|
32
|
+
{
|
|
33
|
+
"type": "work",
|
|
34
|
+
"value": "blair@foo-corp.com",
|
|
35
|
+
"primary": true
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"groups": [],
|
|
39
|
+
"locale": "en-US",
|
|
40
|
+
"schemas": [
|
|
41
|
+
"urn:ietf:params:scim:schemas:core:2.0:User",
|
|
42
|
+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
|
|
43
|
+
],
|
|
44
|
+
"userName": "blair@foo-corp.com",
|
|
45
|
+
"addresses": [
|
|
46
|
+
{
|
|
47
|
+
"region": "CA",
|
|
48
|
+
"primary": true,
|
|
49
|
+
"locality": "San Francisco",
|
|
50
|
+
"postalCode": "94016"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"externalId": "00u1e8mutl6wlH3lL4x7",
|
|
54
|
+
"displayName": "Blair Lunchford",
|
|
55
|
+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
|
|
56
|
+
"manager": {
|
|
57
|
+
"value": "2",
|
|
58
|
+
"displayName": "Kate Chapman"
|
|
59
|
+
},
|
|
60
|
+
"division": "Engineering",
|
|
61
|
+
"department": "Customer Success"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"event": "dsync.user.created",
|
|
66
|
+
"created_at": "2021-06-25T19:07:33.155Z"
|
|
67
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Event } from '../common/interfaces';
|
|
2
2
|
export declare class Webhooks {
|
|
3
3
|
constructEvent({ payload, sigHeader, secret, tolerance, }: {
|
|
4
4
|
payload: unknown;
|
|
5
5
|
sigHeader: string;
|
|
6
6
|
secret: string;
|
|
7
7
|
tolerance?: number;
|
|
8
|
-
}):
|
|
8
|
+
}): Event;
|
|
9
9
|
verifyHeader({ payload, sigHeader, secret, tolerance, }: {
|
|
10
10
|
payload: any;
|
|
11
11
|
sigHeader: string;
|
package/lib/webhooks/webhooks.js
CHANGED
|
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Webhooks = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const exceptions_1 = require("../common/exceptions");
|
|
9
|
+
const serializers_1 = require("../common/serializers");
|
|
9
10
|
class Webhooks {
|
|
10
11
|
constructEvent({ payload, sigHeader, secret, tolerance = 180000, }) {
|
|
11
12
|
const options = { payload, sigHeader, secret, tolerance };
|
|
12
13
|
this.verifyHeader(options);
|
|
13
14
|
const webhookPayload = payload;
|
|
14
|
-
return webhookPayload;
|
|
15
|
+
return (0, serializers_1.deserializeEvent)(webhookPayload);
|
|
15
16
|
}
|
|
16
17
|
verifyHeader({ payload, sigHeader, secret, tolerance = 180000, }) {
|
|
17
18
|
const [timestamp, signatureHash] = this.getTimestampAndSignatureHash(sigHeader);
|
|
@@ -35,14 +35,16 @@ describe('Webhooks', () => {
|
|
|
35
35
|
primary: true,
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
|
-
|
|
38
|
+
idpId: '00u1e8mutl6wlH3lL4x7',
|
|
39
39
|
object: 'directory_user',
|
|
40
40
|
username: 'blair@foo-corp.com',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
lastName: 'Lunchford',
|
|
42
|
+
firstName: 'Blair',
|
|
43
|
+
jobTitle: 'Software Engineer',
|
|
44
|
+
directoryId: 'directory_01F9M7F68PZP8QXP8G7X5QRHS7',
|
|
45
|
+
createdAt: '2021-06-25T19:07:33.155Z',
|
|
46
|
+
updatedAt: '2021-06-25T19:07:33.155Z',
|
|
47
|
+
rawAttributes: {
|
|
46
48
|
name: {
|
|
47
49
|
givenName: 'Blair',
|
|
48
50
|
familyName: 'Lunchford',
|
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.0.0-alpha.
|
|
30
|
+
const VERSION = '3.0.0-alpha.3';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
class WorkOS {
|
|
33
33
|
constructor(key, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
interface EventBase {
|
|
2
|
-
id: string;
|
|
3
|
-
createdAt: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ConnectionActivatedEvent extends EventBase {
|
|
6
|
-
event: 'connection.activated';
|
|
7
|
-
data: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
export interface ConnectionDeactivatedEvent extends EventBase {
|
|
10
|
-
event: 'connection.deactivated';
|
|
11
|
-
data: Record<string, unknown>;
|
|
12
|
-
}
|
|
13
|
-
export interface ConnectionDeletedEvent extends EventBase {
|
|
14
|
-
event: 'connection.deleted';
|
|
15
|
-
data: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
export interface DsyncActivatedEvent extends EventBase {
|
|
18
|
-
event: 'dsync.activated';
|
|
19
|
-
data: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
export interface DsyncDeactivatedEvent extends EventBase {
|
|
22
|
-
event: 'dsync.deactivated';
|
|
23
|
-
data: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
export interface DsyncDeletedEvent extends EventBase {
|
|
26
|
-
event: 'dsync.deleted';
|
|
27
|
-
data: Record<string, unknown>;
|
|
28
|
-
}
|
|
29
|
-
export interface DsyncGroupCreatedEvent extends EventBase {
|
|
30
|
-
event: 'dsync.group.created';
|
|
31
|
-
data: Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
export interface DsyncGroupDeletedEvent extends EventBase {
|
|
34
|
-
event: 'dsync.group.deleted';
|
|
35
|
-
data: Record<string, unknown>;
|
|
36
|
-
}
|
|
37
|
-
export interface DsyncGroupUpdatedEvent extends EventBase {
|
|
38
|
-
event: 'dsync.group.updated';
|
|
39
|
-
data: Record<string, unknown>;
|
|
40
|
-
}
|
|
41
|
-
export interface DsyncGroupUserAddedEvent extends EventBase {
|
|
42
|
-
event: 'dsync.group.user_added';
|
|
43
|
-
data: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
export interface DsyncGroupUserRemovedEvent extends EventBase {
|
|
46
|
-
event: 'dsync.group.user_removed';
|
|
47
|
-
data: Record<string, unknown>;
|
|
48
|
-
}
|
|
49
|
-
export interface DsyncUserCreatedEvent extends EventBase {
|
|
50
|
-
event: 'dsync.user.created';
|
|
51
|
-
data: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
export interface DsyncUserDeletedEvent extends EventBase {
|
|
54
|
-
event: 'dsync.user.deleted';
|
|
55
|
-
data: Record<string, unknown>;
|
|
56
|
-
}
|
|
57
|
-
export interface DsyncUserUpdatedEvent extends EventBase {
|
|
58
|
-
event: 'dsync.user.updated';
|
|
59
|
-
data: Record<string, unknown>;
|
|
60
|
-
}
|
|
61
|
-
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent;
|
|
62
|
-
export type EventResponse = Omit<Event, 'createdAt'> & {
|
|
63
|
-
created_at: string;
|
|
64
|
-
};
|
|
65
|
-
export type EventNames = 'connection.activated' | 'connection.deactivated' | 'connection.deleted' | 'dsync.activated' | 'dsync.deactivated' | 'dsync.deleted' | 'dsync.group.created' | 'dsync.group.deleted' | 'dsync.group.updated' | 'dsync.group.user_added' | 'dsync.group.user_removed' | 'dsync.user.created' | 'dsync.user.deleted' | 'dsync.user.updated';
|
|
66
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeEvent = void 0;
|
|
4
|
-
const deserializeEvent = (event) => ({
|
|
5
|
-
id: event.id,
|
|
6
|
-
createdAt: event.created_at,
|
|
7
|
-
data: event.data,
|
|
8
|
-
event: event.event,
|
|
9
|
-
});
|
|
10
|
-
exports.deserializeEvent = deserializeEvent;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./webhook.interface"), exports);
|
|
18
|
-
__exportStar(require("./webhook-directory.interface"), exports);
|
|
19
|
-
__exportStar(require("./webhook-directory-group.interface"), exports);
|
|
20
|
-
__exportStar(require("./webhook-directory-user.interface"), exports);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type WebhookDirectoryType = 'okta scim v1.1' | 'okta scim v2.0' | 'azure scim v2.0' | 'bamboohr' | 'breathe hr' | 'cyberark scim v2.0' | 'fourth hr' | 'gsuite directory' | 'generic scim v1.1' | 'generic scim v2.0' | 'gusto' | 'hibob' | 'jump cloud scim v2.0' | 'onelogin scim v2.0' | 'people hr' | 'pingfederate scim v2.0' | 'rippling' | 's3' | 'workday';
|
|
2
|
-
export type WebhookDirectoryState = 'active' | 'validating' | 'invalid_credentials' | 'inactive' | 'deleting';
|
|
3
|
-
interface WebhookDirectoryDomain {
|
|
4
|
-
object: 'organization_domain';
|
|
5
|
-
id: string;
|
|
6
|
-
domain: string;
|
|
7
|
-
}
|
|
8
|
-
export interface WebhookDirectory {
|
|
9
|
-
object: 'directory';
|
|
10
|
-
id: string;
|
|
11
|
-
external_key: string;
|
|
12
|
-
type: WebhookDirectoryType;
|
|
13
|
-
state: WebhookDirectoryState;
|
|
14
|
-
name: string;
|
|
15
|
-
organization_id?: string;
|
|
16
|
-
domains: WebhookDirectoryDomain[];
|
|
17
|
-
created_at: string;
|
|
18
|
-
updated_at: string;
|
|
19
|
-
}
|
|
20
|
-
export {};
|