@workos-inc/node 7.38.0 → 7.40.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/actions/actions.spec.js +1 -0
- package/lib/user-management/fixtures/list-users.json +3 -1
- package/lib/user-management/fixtures/user.json +2 -1
- package/lib/user-management/interfaces/create-user-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/update-user-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/user.interface.d.ts +4 -0
- package/lib/user-management/serializers/create-user-options.serializer.js +1 -0
- package/lib/user-management/serializers/update-user-options.serializer.js +1 -0
- package/lib/user-management/serializers/user.serializer.js +16 -11
- package/lib/user-management/user-management.d.ts +1 -0
- package/lib/user-management/user-management.js +6 -0
- package/lib/user-management/user-management.spec.js +20 -0
- package/lib/workos.js +1 -1
- package/package.json +3 -2
|
@@ -103,6 +103,7 @@ describe('Actions', () => {
|
|
|
103
103
|
profilePictureUrl: 'https://example.com/jane.jpg',
|
|
104
104
|
createdAt: '2024-10-22T17:12:50.746Z',
|
|
105
105
|
updatedAt: '2024-10-22T17:12:50.746Z',
|
|
106
|
+
externalId: null,
|
|
106
107
|
},
|
|
107
108
|
ipAddress: '50.141.123.10',
|
|
108
109
|
userAgent: 'Mozilla/5.0',
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"last_name": "User",
|
|
10
10
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
11
11
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
12
|
-
"
|
|
12
|
+
"email_verified": true,
|
|
13
|
+
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
14
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
13
15
|
}
|
|
14
16
|
],
|
|
15
17
|
"list_metadata": {
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
8
8
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
9
9
|
"email_verified": true,
|
|
10
|
-
"profile_picture_url": "https://example.com/profile_picture.jpg"
|
|
10
|
+
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
11
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
11
12
|
}
|
|
@@ -7,6 +7,7 @@ export interface CreateUserOptions {
|
|
|
7
7
|
firstName?: string;
|
|
8
8
|
lastName?: string;
|
|
9
9
|
emailVerified?: boolean;
|
|
10
|
+
externalId?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface SerializedCreateUserOptions {
|
|
12
13
|
email: string;
|
|
@@ -16,4 +17,5 @@ export interface SerializedCreateUserOptions {
|
|
|
16
17
|
first_name?: string;
|
|
17
18
|
last_name?: string;
|
|
18
19
|
email_verified?: boolean;
|
|
20
|
+
external_id?: string;
|
|
19
21
|
}
|
|
@@ -7,6 +7,7 @@ export interface UpdateUserOptions {
|
|
|
7
7
|
password?: string;
|
|
8
8
|
passwordHash?: string;
|
|
9
9
|
passwordHashType?: PasswordHashType;
|
|
10
|
+
externalId?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface SerializedUpdateUserOptions {
|
|
12
13
|
first_name?: string;
|
|
@@ -15,4 +16,5 @@ export interface SerializedUpdateUserOptions {
|
|
|
15
16
|
password?: string;
|
|
16
17
|
password_hash?: string;
|
|
17
18
|
password_hash_type?: PasswordHashType;
|
|
19
|
+
external_id?: string;
|
|
18
20
|
}
|
|
@@ -6,8 +6,10 @@ export interface User {
|
|
|
6
6
|
profilePictureUrl: string | null;
|
|
7
7
|
firstName: string | null;
|
|
8
8
|
lastName: string | null;
|
|
9
|
+
lastSignInAt: string | null;
|
|
9
10
|
createdAt: string;
|
|
10
11
|
updatedAt: string;
|
|
12
|
+
externalId: string | null;
|
|
11
13
|
}
|
|
12
14
|
export interface UserResponse {
|
|
13
15
|
object: 'user';
|
|
@@ -17,6 +19,8 @@ export interface UserResponse {
|
|
|
17
19
|
profile_picture_url: string | null;
|
|
18
20
|
first_name: string | null;
|
|
19
21
|
last_name: string | null;
|
|
22
|
+
last_sign_in_at: string | null;
|
|
20
23
|
created_at: string;
|
|
21
24
|
updated_at: string;
|
|
25
|
+
external_id?: string;
|
|
22
26
|
}
|
|
@@ -9,5 +9,6 @@ const serializeCreateUserOptions = (options) => ({
|
|
|
9
9
|
first_name: options.firstName,
|
|
10
10
|
last_name: options.lastName,
|
|
11
11
|
email_verified: options.emailVerified,
|
|
12
|
+
external_id: options.externalId,
|
|
12
13
|
});
|
|
13
14
|
exports.serializeCreateUserOptions = serializeCreateUserOptions;
|
|
@@ -8,5 +8,6 @@ const serializeUpdateUserOptions = (options) => ({
|
|
|
8
8
|
password: options.password,
|
|
9
9
|
password_hash: options.passwordHash,
|
|
10
10
|
password_hash_type: options.passwordHashType,
|
|
11
|
+
external_id: options.externalId,
|
|
11
12
|
});
|
|
12
13
|
exports.serializeUpdateUserOptions = serializeUpdateUserOptions;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeUser = void 0;
|
|
4
|
-
const deserializeUser = (user) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
const deserializeUser = (user) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return ({
|
|
7
|
+
object: user.object,
|
|
8
|
+
id: user.id,
|
|
9
|
+
email: user.email,
|
|
10
|
+
emailVerified: user.email_verified,
|
|
11
|
+
firstName: user.first_name,
|
|
12
|
+
profilePictureUrl: user.profile_picture_url,
|
|
13
|
+
lastName: user.last_name,
|
|
14
|
+
lastSignInAt: user.last_sign_in_at,
|
|
15
|
+
createdAt: user.created_at,
|
|
16
|
+
updatedAt: user.updated_at,
|
|
17
|
+
externalId: (_a = user.external_id) !== null && _a !== void 0 ? _a : null,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
15
20
|
exports.deserializeUser = deserializeUser;
|
|
@@ -39,6 +39,7 @@ export declare class UserManagement {
|
|
|
39
39
|
cookiePassword: string;
|
|
40
40
|
}): Session;
|
|
41
41
|
getUser(userId: string): Promise<User>;
|
|
42
|
+
getUserByExternalId(externalId: string): Promise<User>;
|
|
42
43
|
listUsers(options?: ListUsersOptions): Promise<AutoPaginatable<User>>;
|
|
43
44
|
createUser(payload: CreateUserOptions): Promise<User>;
|
|
44
45
|
authenticateWithMagicAuth(payload: AuthenticateWithMagicAuthOptions): Promise<AuthenticationResponse>;
|
|
@@ -84,6 +84,12 @@ class UserManagement {
|
|
|
84
84
|
return (0, serializers_2.deserializeUser)(data);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
getUserByExternalId(externalId) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const { data } = yield this.workos.get(`/user_management/users/external_id/${externalId}`);
|
|
90
|
+
return (0, serializers_2.deserializeUser)(data);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
87
93
|
listUsers(options) {
|
|
88
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
95
|
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/user_management/users', serializers_2.deserializeUser, options ? (0, list_users_options_serializer_1.serializeListUsersOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/user_management/users', serializers_2.deserializeUser, params), options ? (0, list_users_options_serializer_1.serializeListUsersOptions)(options) : undefined);
|
|
@@ -81,6 +81,26 @@ describe('UserManagement', () => {
|
|
|
81
81
|
firstName: 'Test 01',
|
|
82
82
|
lastName: 'User',
|
|
83
83
|
emailVerified: true,
|
|
84
|
+
lastSignInAt: '2023-07-18T02:07:19.911Z',
|
|
85
|
+
});
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
describe('getUserByExternalId', () => {
|
|
89
|
+
it('sends a Get User request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const externalId = 'user_external_id';
|
|
91
|
+
(0, test_utils_1.fetchOnce)(Object.assign(Object.assign({}, user_json_1.default), { external_id: externalId }));
|
|
92
|
+
const user = yield workos.userManagement.getUserByExternalId(externalId);
|
|
93
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/external_id/${externalId}`);
|
|
94
|
+
expect(user).toMatchObject({
|
|
95
|
+
object: 'user',
|
|
96
|
+
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
97
|
+
email: 'test01@example.com',
|
|
98
|
+
profilePictureUrl: 'https://example.com/profile_picture.jpg',
|
|
99
|
+
firstName: 'Test 01',
|
|
100
|
+
lastName: 'User',
|
|
101
|
+
emailVerified: true,
|
|
102
|
+
lastSignInAt: '2023-07-18T02:07:19.911Z',
|
|
103
|
+
externalId,
|
|
84
104
|
});
|
|
85
105
|
}));
|
|
86
106
|
});
|
package/lib/workos.js
CHANGED
|
@@ -29,7 +29,7 @@ const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider
|
|
|
29
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
30
30
|
const widgets_1 = require("./widgets/widgets");
|
|
31
31
|
const actions_1 = require("./actions/actions");
|
|
32
|
-
const VERSION = '7.
|
|
32
|
+
const VERSION = '7.40.0';
|
|
33
33
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
34
34
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
35
35
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|