@workos-inc/node 7.42.0 → 7.43.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 +2 -0
- package/lib/organizations/fixtures/get-organization.json +2 -1
- package/lib/organizations/interfaces/create-organization-options.interface.d.ts +2 -0
- package/lib/organizations/interfaces/organization.interface.d.ts +2 -0
- package/lib/organizations/interfaces/update-organization-options.interface.d.ts +2 -0
- package/lib/organizations/organizations.spec.js +20 -0
- package/lib/organizations/serializers/create-organization-options.serializer.js +1 -0
- package/lib/organizations/serializers/organization.serializer.js +2 -2
- package/lib/organizations/serializers/organization.serializer.spec.d.ts +1 -0
- package/lib/organizations/serializers/organization.serializer.spec.js +33 -0
- package/lib/organizations/serializers/update-organization-options.serializer.js +1 -0
- 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 +2 -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 +2 -1
- package/lib/user-management/serializers/user.serializer.spec.d.ts +1 -0
- package/lib/user-management/serializers/user.serializer.spec.js +32 -0
- package/lib/user-management/user-management.spec.js +20 -0
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -104,6 +104,7 @@ describe('Actions', () => {
|
|
|
104
104
|
createdAt: '2024-10-22T17:12:50.746Z',
|
|
105
105
|
updatedAt: '2024-10-22T17:12:50.746Z',
|
|
106
106
|
externalId: null,
|
|
107
|
+
metadata: {},
|
|
107
108
|
},
|
|
108
109
|
ipAddress: '50.141.123.10',
|
|
109
110
|
userAgent: 'Mozilla/5.0',
|
|
@@ -119,6 +120,7 @@ describe('Actions', () => {
|
|
|
119
120
|
createdAt: '2024-10-22T17:12:50.746Z',
|
|
120
121
|
updatedAt: '2024-10-22T17:12:50.746Z',
|
|
121
122
|
externalId: null,
|
|
123
|
+
metadata: {},
|
|
122
124
|
},
|
|
123
125
|
organizationMembership: {
|
|
124
126
|
object: 'organization_membership',
|
|
@@ -4,6 +4,7 @@ export interface CreateOrganizationOptions {
|
|
|
4
4
|
name: string;
|
|
5
5
|
domainData?: DomainData[];
|
|
6
6
|
externalId?: string | null;
|
|
7
|
+
metadata?: Record<string, string>;
|
|
7
8
|
/**
|
|
8
9
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
9
10
|
*/
|
|
@@ -17,6 +18,7 @@ export interface SerializedCreateOrganizationOptions {
|
|
|
17
18
|
name: string;
|
|
18
19
|
domain_data?: DomainData[];
|
|
19
20
|
external_id?: string | null;
|
|
21
|
+
metadata?: Record<string, string>;
|
|
20
22
|
/**
|
|
21
23
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
22
24
|
*/
|
|
@@ -9,6 +9,7 @@ export interface Organization {
|
|
|
9
9
|
createdAt: string;
|
|
10
10
|
updatedAt: string;
|
|
11
11
|
externalId: string | null;
|
|
12
|
+
metadata: Record<string, string>;
|
|
12
13
|
}
|
|
13
14
|
export interface OrganizationResponse {
|
|
14
15
|
object: 'organization';
|
|
@@ -20,4 +21,5 @@ export interface OrganizationResponse {
|
|
|
20
21
|
created_at: string;
|
|
21
22
|
updated_at: string;
|
|
22
23
|
external_id?: string | null;
|
|
24
|
+
metadata?: Record<string, string>;
|
|
23
25
|
}
|
|
@@ -5,6 +5,7 @@ export interface UpdateOrganizationOptions {
|
|
|
5
5
|
domainData?: DomainData[];
|
|
6
6
|
stripeCustomerId?: string | null;
|
|
7
7
|
externalId?: string | null;
|
|
8
|
+
metadata?: Record<string, string>;
|
|
8
9
|
/**
|
|
9
10
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
10
11
|
*/
|
|
@@ -19,6 +20,7 @@ export interface SerializedUpdateOrganizationOptions {
|
|
|
19
20
|
domain_data?: DomainData[];
|
|
20
21
|
stripe_customer_id?: string | null;
|
|
21
22
|
external_id?: string | null;
|
|
23
|
+
metadata?: Record<string, string>;
|
|
22
24
|
/**
|
|
23
25
|
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
24
26
|
*/
|
|
@@ -155,6 +155,16 @@ describe('Organizations', () => {
|
|
|
155
155
|
expect(subject.domains).toHaveLength(1);
|
|
156
156
|
}));
|
|
157
157
|
});
|
|
158
|
+
it('adds metadata to the request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
+
(0, test_utils_1.fetchOnce)(create_organization_json_1.default, { status: 201 });
|
|
160
|
+
yield workos.organizations.createOrganization({
|
|
161
|
+
name: 'My organization',
|
|
162
|
+
metadata: { key: 'value' },
|
|
163
|
+
});
|
|
164
|
+
expect((0, test_utils_1.fetchBody)()).toMatchObject({
|
|
165
|
+
metadata: { key: 'value' },
|
|
166
|
+
});
|
|
167
|
+
}));
|
|
158
168
|
});
|
|
159
169
|
describe('with an invalid payload', () => {
|
|
160
170
|
it('returns an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -251,6 +261,16 @@ describe('Organizations', () => {
|
|
|
251
261
|
expect(subject.domains).toHaveLength(1);
|
|
252
262
|
}));
|
|
253
263
|
});
|
|
264
|
+
it('adds metadata to the request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
+
(0, test_utils_1.fetchOnce)(update_organization_json_1.default, { status: 201 });
|
|
266
|
+
yield workos.organizations.updateOrganization({
|
|
267
|
+
organization: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
268
|
+
metadata: { key: 'value' },
|
|
269
|
+
});
|
|
270
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
271
|
+
metadata: { key: 'value' },
|
|
272
|
+
});
|
|
273
|
+
}));
|
|
254
274
|
});
|
|
255
275
|
describe('when given `stripeCustomerId`', () => {
|
|
256
276
|
it('updates the organization’s Stripe customer ID', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -7,5 +7,6 @@ const serializeCreateOrganizationOptions = (options) => ({
|
|
|
7
7
|
domain_data: options.domainData,
|
|
8
8
|
domains: options.domains,
|
|
9
9
|
external_id: options.externalId,
|
|
10
|
+
metadata: options.metadata,
|
|
10
11
|
});
|
|
11
12
|
exports.serializeCreateOrganizationOptions = serializeCreateOrganizationOptions;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deserializeOrganization = void 0;
|
|
4
4
|
const organization_domain_serializer_1 = require("../../organization-domains/serializers/organization-domain.serializer");
|
|
5
5
|
const deserializeOrganization = (organization) => {
|
|
6
|
-
var _a;
|
|
6
|
+
var _a, _b;
|
|
7
7
|
return (Object.assign(Object.assign({ object: organization.object, id: organization.id, name: organization.name, allowProfilesOutsideOrganization: organization.allow_profiles_outside_organization, domains: organization.domains.map(organization_domain_serializer_1.deserializeOrganizationDomain) }, (typeof organization.stripe_customer_id === 'undefined'
|
|
8
8
|
? undefined
|
|
9
|
-
: { stripeCustomerId: organization.stripe_customer_id })), { createdAt: organization.created_at, updatedAt: organization.updated_at, externalId: (_a = organization.external_id) !== null && _a !== void 0 ? _a : null }));
|
|
9
|
+
: { stripeCustomerId: organization.stripe_customer_id })), { createdAt: organization.created_at, updatedAt: organization.updated_at, externalId: (_a = organization.external_id) !== null && _a !== void 0 ? _a : null, metadata: (_b = organization.metadata) !== null && _b !== void 0 ? _b : {} }));
|
|
10
10
|
};
|
|
11
11
|
exports.deserializeOrganization = deserializeOrganization;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const organization_serializer_1 = require("./organization.serializer");
|
|
18
|
+
const get_organization_json_1 = __importDefault(require("../fixtures/get-organization.json"));
|
|
19
|
+
const organizationResponse = Object.assign(Object.assign({}, get_organization_json_1.default), { object: 'organization', created_at: new Date().toISOString(), updated_at: new Date().toISOString(), domains: [] });
|
|
20
|
+
describe('deserializeOrganization', () => {
|
|
21
|
+
it('includes metadata if present', () => {
|
|
22
|
+
const metadata = { key: 'value' };
|
|
23
|
+
expect((0, organization_serializer_1.deserializeOrganization)(Object.assign(Object.assign({}, organizationResponse), { metadata }))).toMatchObject({
|
|
24
|
+
metadata,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
it('coerces missing metadata to empty object', () => {
|
|
28
|
+
const { metadata } = organizationResponse, organizationResponseWithoutMetadata = __rest(organizationResponse, ["metadata"]);
|
|
29
|
+
expect((0, organization_serializer_1.deserializeOrganization)(organizationResponseWithoutMetadata)).toMatchObject({
|
|
30
|
+
metadata: {},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -8,5 +8,6 @@ const serializeUpdateOrganizationOptions = (options) => ({
|
|
|
8
8
|
domains: options.domains,
|
|
9
9
|
stripe_customer_id: options.stripeCustomerId,
|
|
10
10
|
external_id: options.externalId,
|
|
11
|
+
metadata: options.metadata,
|
|
11
12
|
});
|
|
12
13
|
exports.serializeUpdateOrganizationOptions = serializeUpdateOrganizationOptions;
|
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
9
9
|
"email_verified": true,
|
|
10
10
|
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
11
|
-
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
11
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z",
|
|
12
|
+
"metadata": { "key": "value" }
|
|
12
13
|
}
|
|
@@ -8,6 +8,7 @@ export interface CreateUserOptions {
|
|
|
8
8
|
lastName?: string;
|
|
9
9
|
emailVerified?: boolean;
|
|
10
10
|
externalId?: string;
|
|
11
|
+
metadata?: Record<string, string>;
|
|
11
12
|
}
|
|
12
13
|
export interface SerializedCreateUserOptions {
|
|
13
14
|
email: string;
|
|
@@ -18,4 +19,5 @@ export interface SerializedCreateUserOptions {
|
|
|
18
19
|
last_name?: string;
|
|
19
20
|
email_verified?: boolean;
|
|
20
21
|
external_id?: string;
|
|
22
|
+
metadata?: Record<string, string>;
|
|
21
23
|
}
|
|
@@ -8,6 +8,7 @@ export interface UpdateUserOptions {
|
|
|
8
8
|
passwordHash?: string;
|
|
9
9
|
passwordHashType?: PasswordHashType;
|
|
10
10
|
externalId?: string;
|
|
11
|
+
metadata?: Record<string, string>;
|
|
11
12
|
}
|
|
12
13
|
export interface SerializedUpdateUserOptions {
|
|
13
14
|
first_name?: string;
|
|
@@ -17,4 +18,5 @@ export interface SerializedUpdateUserOptions {
|
|
|
17
18
|
password_hash?: string;
|
|
18
19
|
password_hash_type?: PasswordHashType;
|
|
19
20
|
external_id?: string;
|
|
21
|
+
metadata?: Record<string, string>;
|
|
20
22
|
}
|
|
@@ -10,6 +10,7 @@ export interface User {
|
|
|
10
10
|
createdAt: string;
|
|
11
11
|
updatedAt: string;
|
|
12
12
|
externalId: string | null;
|
|
13
|
+
metadata: Record<string, string>;
|
|
13
14
|
}
|
|
14
15
|
export interface UserResponse {
|
|
15
16
|
object: 'user';
|
|
@@ -23,4 +24,5 @@ export interface UserResponse {
|
|
|
23
24
|
created_at: string;
|
|
24
25
|
updated_at: string;
|
|
25
26
|
external_id?: string;
|
|
27
|
+
metadata?: Record<string, string>;
|
|
26
28
|
}
|
|
@@ -10,5 +10,6 @@ const serializeCreateUserOptions = (options) => ({
|
|
|
10
10
|
last_name: options.lastName,
|
|
11
11
|
email_verified: options.emailVerified,
|
|
12
12
|
external_id: options.externalId,
|
|
13
|
+
metadata: options.metadata,
|
|
13
14
|
});
|
|
14
15
|
exports.serializeCreateUserOptions = serializeCreateUserOptions;
|
|
@@ -9,5 +9,6 @@ const serializeUpdateUserOptions = (options) => ({
|
|
|
9
9
|
password_hash: options.passwordHash,
|
|
10
10
|
password_hash_type: options.passwordHashType,
|
|
11
11
|
external_id: options.externalId,
|
|
12
|
+
metadata: options.metadata,
|
|
12
13
|
});
|
|
13
14
|
exports.serializeUpdateUserOptions = serializeUpdateUserOptions;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeUser = void 0;
|
|
4
4
|
const deserializeUser = (user) => {
|
|
5
|
-
var _a;
|
|
5
|
+
var _a, _b;
|
|
6
6
|
return ({
|
|
7
7
|
object: user.object,
|
|
8
8
|
id: user.id,
|
|
@@ -15,6 +15,7 @@ const deserializeUser = (user) => {
|
|
|
15
15
|
createdAt: user.created_at,
|
|
16
16
|
updatedAt: user.updated_at,
|
|
17
17
|
externalId: (_a = user.external_id) !== null && _a !== void 0 ? _a : null,
|
|
18
|
+
metadata: (_b = user.metadata) !== null && _b !== void 0 ? _b : {},
|
|
18
19
|
});
|
|
19
20
|
};
|
|
20
21
|
exports.deserializeUser = deserializeUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const user_serializer_1 = require("./user.serializer");
|
|
18
|
+
const user_json_1 = __importDefault(require("../fixtures/user.json"));
|
|
19
|
+
describe('deserializeUser', () => {
|
|
20
|
+
it('includes metadata if present', () => {
|
|
21
|
+
const metadata = { key: 'value' };
|
|
22
|
+
expect((0, user_serializer_1.deserializeUser)(Object.assign(Object.assign({}, user_json_1.default), { object: 'user', metadata }))).toMatchObject({
|
|
23
|
+
metadata,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('coerces missing metadata to empty object', () => {
|
|
27
|
+
const { metadata } = user_json_1.default, userResponseWithoutMetadata = __rest(user_json_1.default, ["metadata"]);
|
|
28
|
+
expect((0, user_serializer_1.deserializeUser)(Object.assign(Object.assign({}, userResponseWithoutMetadata), { object: 'user' }))).toMatchObject({
|
|
29
|
+
metadata: {},
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -162,6 +162,16 @@ describe('UserManagement', () => {
|
|
|
162
162
|
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
163
163
|
});
|
|
164
164
|
}));
|
|
165
|
+
it('adds metadata to the request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
+
(0, test_utils_1.fetchOnce)(user_json_1.default);
|
|
167
|
+
yield workos.userManagement.createUser({
|
|
168
|
+
email: 'test01@example.com',
|
|
169
|
+
metadata: { key: 'value' },
|
|
170
|
+
});
|
|
171
|
+
expect((0, test_utils_1.fetchBody)()).toMatchObject({
|
|
172
|
+
metadata: { key: 'value' },
|
|
173
|
+
});
|
|
174
|
+
}));
|
|
165
175
|
});
|
|
166
176
|
describe('authenticateUserWithMagicAuth', () => {
|
|
167
177
|
it('sends a magic auth authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1092,6 +1102,16 @@ describe('UserManagement', () => {
|
|
|
1092
1102
|
});
|
|
1093
1103
|
}));
|
|
1094
1104
|
});
|
|
1105
|
+
it('adds metadata to the request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1106
|
+
(0, test_utils_1.fetchOnce)(user_json_1.default);
|
|
1107
|
+
yield workos.userManagement.updateUser({
|
|
1108
|
+
userId,
|
|
1109
|
+
metadata: { key: 'value' },
|
|
1110
|
+
});
|
|
1111
|
+
expect((0, test_utils_1.fetchBody)()).toMatchObject({
|
|
1112
|
+
metadata: { key: 'value' },
|
|
1113
|
+
});
|
|
1114
|
+
}));
|
|
1095
1115
|
});
|
|
1096
1116
|
describe('enrollAuthFactor', () => {
|
|
1097
1117
|
it('sends an enrollAuthFactor request', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/lib/workos.js
CHANGED
|
@@ -31,7 +31,7 @@ const widgets_1 = require("./widgets/widgets");
|
|
|
31
31
|
const actions_1 = require("./actions/actions");
|
|
32
32
|
const vault_1 = require("./vault/vault");
|
|
33
33
|
const conflict_exception_1 = require("./common/exceptions/conflict.exception");
|
|
34
|
-
const VERSION = '7.
|
|
34
|
+
const VERSION = '7.43.0';
|
|
35
35
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
36
36
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
37
37
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED