@workos-inc/node 7.22.1 → 7.23.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/portal/interfaces/generate-portal-link-intent.interface.d.ts +2 -1
- package/lib/portal/interfaces/generate-portal-link-intent.interface.js +1 -0
- package/lib/portal/portal.spec.js +34 -0
- package/lib/user-management/user-management.js +2 -0
- package/lib/user-management/user-management.spec.js +36 -15
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -8,4 +8,5 @@ var GeneratePortalLinkIntent;
|
|
|
8
8
|
GeneratePortalLinkIntent["DSync"] = "dsync";
|
|
9
9
|
GeneratePortalLinkIntent["LogStreams"] = "log_streams";
|
|
10
10
|
GeneratePortalLinkIntent["SSO"] = "sso";
|
|
11
|
+
GeneratePortalLinkIntent["CertificateRenewal"] = "certificate_renewal";
|
|
11
12
|
})(GeneratePortalLinkIntent || (exports.GeneratePortalLinkIntent = GeneratePortalLinkIntent = {}));
|
|
@@ -103,6 +103,40 @@ describe('Portal', () => {
|
|
|
103
103
|
expect(link).toEqual('https://id.workos.com/portal/launch?secret=secret');
|
|
104
104
|
}));
|
|
105
105
|
});
|
|
106
|
+
describe('with the `certificate_renewal` intent', () => {
|
|
107
|
+
it('returns an Admin Portal link', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
(0, test_utils_1.fetchOnce)(generate_link_json_1.default, { status: 201 });
|
|
109
|
+
const { link } = yield workos.portal.generateLink({
|
|
110
|
+
intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.CertificateRenewal,
|
|
111
|
+
organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3',
|
|
112
|
+
returnUrl: 'https://www.example.com',
|
|
113
|
+
});
|
|
114
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
115
|
+
intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.CertificateRenewal,
|
|
116
|
+
organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3',
|
|
117
|
+
return_url: 'https://www.example.com',
|
|
118
|
+
});
|
|
119
|
+
expect(link).toEqual('https://id.workos.com/portal/launch?secret=secret');
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('with an invalid organization', () => {
|
|
124
|
+
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
(0, test_utils_1.fetchOnce)(generate_link_invalid_json_1.default, {
|
|
126
|
+
status: 400,
|
|
127
|
+
headers: { 'X-Request-ID': 'a-request-id' },
|
|
128
|
+
});
|
|
129
|
+
yield expect(workos.portal.generateLink({
|
|
130
|
+
intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.SSO,
|
|
131
|
+
organization: 'bogus-id',
|
|
132
|
+
returnUrl: 'https://www.example.com',
|
|
133
|
+
})).rejects.toThrowError('Could not find an organization with the id, bogus-id.');
|
|
134
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
135
|
+
intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.SSO,
|
|
136
|
+
organization: 'bogus-id',
|
|
137
|
+
return_url: 'https://www.example.com',
|
|
138
|
+
});
|
|
139
|
+
}));
|
|
106
140
|
});
|
|
107
141
|
describe('with an invalid organization', () => {
|
|
108
142
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -271,7 +271,9 @@ class UserManagement {
|
|
|
271
271
|
if (!cookiePassword) {
|
|
272
272
|
throw new Error('Cookie password is required');
|
|
273
273
|
}
|
|
274
|
+
const { org_id: organizationIdFromAccessToken } = (0, jose_1.decodeJwt)(authenticationResponse.accessToken);
|
|
274
275
|
const sessionData = {
|
|
276
|
+
organizationId: organizationIdFromAccessToken,
|
|
275
277
|
user: authenticationResponse.user,
|
|
276
278
|
accessToken: authenticationResponse.accessToken,
|
|
277
279
|
refreshToken: authenticationResponse.refreshToken,
|
|
@@ -160,7 +160,10 @@ describe('UserManagement', () => {
|
|
|
160
160
|
}));
|
|
161
161
|
describe('when sealSession = true', () => {
|
|
162
162
|
beforeEach(() => {
|
|
163
|
-
(0, test_utils_1.fetchOnce)({
|
|
163
|
+
(0, test_utils_1.fetchOnce)({
|
|
164
|
+
user: user_json_1.default,
|
|
165
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
166
|
+
});
|
|
164
167
|
});
|
|
165
168
|
describe('when the cookie password is undefined', () => {
|
|
166
169
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -183,7 +186,7 @@ describe('UserManagement', () => {
|
|
|
183
186
|
});
|
|
184
187
|
expect(response).toEqual({
|
|
185
188
|
sealedSession: expect.any(String),
|
|
186
|
-
accessToken:
|
|
189
|
+
accessToken: expect.any(String),
|
|
187
190
|
authenticationMethod: undefined,
|
|
188
191
|
impersonator: undefined,
|
|
189
192
|
organizationId: undefined,
|
|
@@ -213,7 +216,10 @@ describe('UserManagement', () => {
|
|
|
213
216
|
}));
|
|
214
217
|
describe('when sealSession = true', () => {
|
|
215
218
|
beforeEach(() => {
|
|
216
|
-
(0, test_utils_1.fetchOnce)({
|
|
219
|
+
(0, test_utils_1.fetchOnce)({
|
|
220
|
+
user: user_json_1.default,
|
|
221
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
222
|
+
});
|
|
217
223
|
});
|
|
218
224
|
describe('when the cookie password is undefined', () => {
|
|
219
225
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -236,7 +242,7 @@ describe('UserManagement', () => {
|
|
|
236
242
|
});
|
|
237
243
|
expect(response).toEqual({
|
|
238
244
|
sealedSession: expect.any(String),
|
|
239
|
-
accessToken:
|
|
245
|
+
accessToken: expect.any(String),
|
|
240
246
|
authenticationMethod: undefined,
|
|
241
247
|
impersonator: undefined,
|
|
242
248
|
organizationId: undefined,
|
|
@@ -332,7 +338,10 @@ describe('UserManagement', () => {
|
|
|
332
338
|
});
|
|
333
339
|
describe('when sealSession = true', () => {
|
|
334
340
|
beforeEach(() => {
|
|
335
|
-
(0, test_utils_1.fetchOnce)({
|
|
341
|
+
(0, test_utils_1.fetchOnce)({
|
|
342
|
+
user: user_json_1.default,
|
|
343
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
344
|
+
});
|
|
336
345
|
});
|
|
337
346
|
describe('when the cookie password is undefined', () => {
|
|
338
347
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -353,7 +362,7 @@ describe('UserManagement', () => {
|
|
|
353
362
|
});
|
|
354
363
|
expect(response).toEqual({
|
|
355
364
|
sealedSession: expect.any(String),
|
|
356
|
-
accessToken:
|
|
365
|
+
accessToken: expect.any(String),
|
|
357
366
|
authenticationMethod: undefined,
|
|
358
367
|
impersonator: undefined,
|
|
359
368
|
organizationId: undefined,
|
|
@@ -391,7 +400,10 @@ describe('UserManagement', () => {
|
|
|
391
400
|
}));
|
|
392
401
|
describe('when sealSession = true', () => {
|
|
393
402
|
beforeEach(() => {
|
|
394
|
-
(0, test_utils_1.fetchOnce)({
|
|
403
|
+
(0, test_utils_1.fetchOnce)({
|
|
404
|
+
user: user_json_1.default,
|
|
405
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
406
|
+
});
|
|
395
407
|
});
|
|
396
408
|
describe('when the cookie password is undefined', () => {
|
|
397
409
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -412,7 +424,7 @@ describe('UserManagement', () => {
|
|
|
412
424
|
});
|
|
413
425
|
expect(response).toEqual({
|
|
414
426
|
sealedSession: expect.any(String),
|
|
415
|
-
accessToken:
|
|
427
|
+
accessToken: expect.any(String),
|
|
416
428
|
authenticationMethod: undefined,
|
|
417
429
|
impersonator: undefined,
|
|
418
430
|
organizationId: undefined,
|
|
@@ -451,7 +463,10 @@ describe('UserManagement', () => {
|
|
|
451
463
|
}));
|
|
452
464
|
describe('when sealSession = true', () => {
|
|
453
465
|
beforeEach(() => {
|
|
454
|
-
(0, test_utils_1.fetchOnce)({
|
|
466
|
+
(0, test_utils_1.fetchOnce)({
|
|
467
|
+
user: user_json_1.default,
|
|
468
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
469
|
+
});
|
|
455
470
|
});
|
|
456
471
|
describe('when the cookie password is undefined', () => {
|
|
457
472
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -476,7 +491,7 @@ describe('UserManagement', () => {
|
|
|
476
491
|
});
|
|
477
492
|
expect(response).toEqual({
|
|
478
493
|
sealedSession: expect.any(String),
|
|
479
|
-
accessToken:
|
|
494
|
+
accessToken: expect.any(String),
|
|
480
495
|
authenticationMethod: undefined,
|
|
481
496
|
impersonator: undefined,
|
|
482
497
|
organizationId: undefined,
|
|
@@ -513,7 +528,10 @@ describe('UserManagement', () => {
|
|
|
513
528
|
}));
|
|
514
529
|
describe('when sealSession = true', () => {
|
|
515
530
|
beforeEach(() => {
|
|
516
|
-
(0, test_utils_1.fetchOnce)({
|
|
531
|
+
(0, test_utils_1.fetchOnce)({
|
|
532
|
+
user: user_json_1.default,
|
|
533
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
534
|
+
});
|
|
517
535
|
});
|
|
518
536
|
describe('when the cookie password is undefined', () => {
|
|
519
537
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -536,7 +554,7 @@ describe('UserManagement', () => {
|
|
|
536
554
|
});
|
|
537
555
|
expect(response).toEqual({
|
|
538
556
|
sealedSession: expect.any(String),
|
|
539
|
-
accessToken:
|
|
557
|
+
accessToken: expect.any(String),
|
|
540
558
|
authenticationMethod: undefined,
|
|
541
559
|
impersonator: undefined,
|
|
542
560
|
organizationId: undefined,
|
|
@@ -573,7 +591,10 @@ describe('UserManagement', () => {
|
|
|
573
591
|
}));
|
|
574
592
|
describe('when sealSession = true', () => {
|
|
575
593
|
beforeEach(() => {
|
|
576
|
-
(0, test_utils_1.fetchOnce)({
|
|
594
|
+
(0, test_utils_1.fetchOnce)({
|
|
595
|
+
user: user_json_1.default,
|
|
596
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
597
|
+
});
|
|
577
598
|
});
|
|
578
599
|
describe('when the cookie password is undefined', () => {
|
|
579
600
|
it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -596,7 +617,7 @@ describe('UserManagement', () => {
|
|
|
596
617
|
});
|
|
597
618
|
expect(response).toEqual({
|
|
598
619
|
sealedSession: expect.any(String),
|
|
599
|
-
accessToken:
|
|
620
|
+
accessToken: expect.any(String),
|
|
600
621
|
authenticationMethod: undefined,
|
|
601
622
|
impersonator: undefined,
|
|
602
623
|
organizationId: undefined,
|
|
@@ -765,7 +786,7 @@ describe('UserManagement', () => {
|
|
|
765
786
|
it('returns the sealed refreshed session cookie when provided a valid existing session cookie', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
766
787
|
(0, test_utils_1.fetchOnce)({
|
|
767
788
|
user: user_json_1.default,
|
|
768
|
-
access_token: '
|
|
789
|
+
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzdWIiOiAiMTIzNDU2Nzg5MCIsCiAgIm5hbWUiOiAiSm9obiBEb2UiLAogICJpYXQiOiAxNTE2MjM5MDIyLAogICJzaWQiOiAic2Vzc2lvbl8xMjMiLAogICJvcmdfaWQiOiAib3JnXzEyMyIsCiAgInJvbGUiOiAibWVtYmVyIiwKICAicGVybWlzc2lvbnMiOiBbInBvc3RzOmNyZWF0ZSIsICJwb3N0czpkZWxldGUiXQp9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
|
769
790
|
refresh_token: 'refresh_token',
|
|
770
791
|
});
|
|
771
792
|
const cookiePassword = 'alongcookiesecretmadefortestingsessions';
|
package/lib/workos.js
CHANGED
|
@@ -27,7 +27,7 @@ const bad_request_exception_1 = require("./common/exceptions/bad-request.excepti
|
|
|
27
27
|
const http_client_1 = require("./common/net/http-client");
|
|
28
28
|
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
29
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
30
|
-
const VERSION = '7.
|
|
30
|
+
const VERSION = '7.23.0';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
33
33
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED