@workos-inc/node 7.76.0 → 7.79.2

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.
Files changed (51) hide show
  1. package/lib/feature-flags/feature-flags.d.ts +13 -0
  2. package/lib/feature-flags/feature-flags.js +56 -0
  3. package/lib/feature-flags/feature-flags.spec.d.ts +1 -0
  4. package/lib/feature-flags/feature-flags.spec.js +173 -0
  5. package/lib/feature-flags/fixtures/disable-feature-flag.json +12 -0
  6. package/lib/feature-flags/fixtures/enable-feature-flag.json +12 -0
  7. package/lib/feature-flags/fixtures/get-feature-flag.json +12 -0
  8. package/lib/feature-flags/fixtures/list-feature-flags.json +45 -0
  9. package/lib/feature-flags/interfaces/add-flag-target-options.interface.d.ts +4 -0
  10. package/lib/feature-flags/interfaces/add-flag-target-options.interface.js +2 -0
  11. package/lib/feature-flags/interfaces/feature-flag.interface.d.ts +8 -2
  12. package/lib/feature-flags/interfaces/index.d.ts +3 -0
  13. package/lib/feature-flags/interfaces/index.js +3 -0
  14. package/lib/feature-flags/interfaces/list-feature-flags-options.interface.d.ts +2 -0
  15. package/lib/feature-flags/interfaces/list-feature-flags-options.interface.js +2 -0
  16. package/lib/feature-flags/interfaces/remove-flag-target-options.interface.d.ts +4 -0
  17. package/lib/feature-flags/interfaces/remove-flag-target-options.interface.js +2 -0
  18. package/lib/feature-flags/serializers/feature-flag.serializer.js +3 -0
  19. package/lib/feature-flags/serializers/index.d.ts +1 -0
  20. package/lib/feature-flags/serializers/index.js +17 -0
  21. package/lib/organizations/fixtures/list-organization-feature-flags.json +10 -1
  22. package/lib/organizations/organizations.js +2 -2
  23. package/lib/organizations/organizations.spec.js +10 -1
  24. package/lib/pipes/fixtures/get-access-token-needs-reauth.json +4 -0
  25. package/lib/pipes/fixtures/get-access-token-no-expiry.json +10 -0
  26. package/lib/pipes/fixtures/get-access-token-not-installed.json +4 -0
  27. package/lib/pipes/fixtures/get-access-token-success.json +10 -0
  28. package/lib/pipes/interfaces/access-token.interface.d.ts +14 -0
  29. package/lib/pipes/interfaces/access-token.interface.js +2 -0
  30. package/lib/pipes/interfaces/get-access-token.interface.d.ts +27 -0
  31. package/lib/pipes/interfaces/get-access-token.interface.js +2 -0
  32. package/lib/pipes/pipes.d.ts +9 -0
  33. package/lib/pipes/pipes.js +37 -0
  34. package/lib/pipes/pipes.spec.d.ts +1 -0
  35. package/lib/pipes/pipes.spec.js +109 -0
  36. package/lib/pipes/serializers/access-token.serializer.d.ts +2 -0
  37. package/lib/pipes/serializers/access-token.serializer.js +15 -0
  38. package/lib/pipes/serializers/get-access-token.serializer.d.ts +3 -0
  39. package/lib/pipes/serializers/get-access-token.serializer.js +24 -0
  40. package/lib/user-management/fixtures/list-user-feature-flags.json +10 -1
  41. package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +3 -2
  42. package/lib/user-management/session.js +2 -0
  43. package/lib/user-management/user-management.js +42 -40
  44. package/lib/user-management/user-management.spec.js +10 -1
  45. package/lib/vault/vault-live-test.spec.js +33 -4
  46. package/lib/vault/vault.d.ts +1 -0
  47. package/lib/vault/vault.js +6 -0
  48. package/lib/vault/vault.spec.js +25 -0
  49. package/lib/workos.d.ts +9 -5
  50. package/lib/workos.js +9 -5
  51. package/package.json +4 -4
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.Pipes = void 0;
24
+ const get_access_token_serializer_1 = require("./serializers/get-access-token.serializer");
25
+ class Pipes {
26
+ constructor(workos) {
27
+ this.workos = workos;
28
+ }
29
+ getAccessToken(_a) {
30
+ var { provider } = _a, options = __rest(_a, ["provider"]);
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { data } = yield this.workos.post(`data-integrations/${provider}/token`, (0, get_access_token_serializer_1.serializeGetAccessTokenOptions)(options));
33
+ return (0, get_access_token_serializer_1.deserializeGetAccessTokenResponse)(data);
34
+ });
35
+ }
36
+ }
37
+ exports.Pipes = Pipes;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
16
+ const test_utils_1 = require("../common/utils/test-utils");
17
+ const workos_1 = require("../workos");
18
+ const get_access_token_success_json_1 = __importDefault(require("./fixtures/get-access-token-success.json"));
19
+ const get_access_token_no_expiry_json_1 = __importDefault(require("./fixtures/get-access-token-no-expiry.json"));
20
+ const get_access_token_not_installed_json_1 = __importDefault(require("./fixtures/get-access-token-not-installed.json"));
21
+ const get_access_token_needs_reauth_json_1 = __importDefault(require("./fixtures/get-access-token-needs-reauth.json"));
22
+ describe('Pipes', () => {
23
+ let workos;
24
+ beforeAll(() => {
25
+ workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU', {
26
+ apiHostname: 'api.workos.test',
27
+ clientId: 'proj_123',
28
+ });
29
+ });
30
+ beforeEach(() => jest_fetch_mock_1.default.resetMocks());
31
+ describe('getAccessToken', () => {
32
+ it('returns access token with expiry date', () => __awaiter(void 0, void 0, void 0, function* () {
33
+ (0, test_utils_1.fetchOnce)(get_access_token_success_json_1.default);
34
+ const response = yield workos.pipes.getAccessToken({
35
+ provider: 'test-provider',
36
+ userId: 'user_123',
37
+ organizationId: 'org_456',
38
+ });
39
+ expect((0, test_utils_1.fetchURL)()).toContain('/data-integrations/test-provider/token');
40
+ expect((0, test_utils_1.fetchBody)()).toEqual({
41
+ user_id: 'user_123',
42
+ organization_id: 'org_456',
43
+ });
44
+ expect(response).toEqual({
45
+ active: true,
46
+ accessToken: {
47
+ object: 'access_token',
48
+ accessToken: 'test_access_token_123',
49
+ expiresAt: new Date('2025-10-18T12:00:00.000Z'),
50
+ scopes: ['read:users', 'write:users'],
51
+ missingScopes: [],
52
+ },
53
+ });
54
+ }));
55
+ it('returns access token without expiry date', () => __awaiter(void 0, void 0, void 0, function* () {
56
+ (0, test_utils_1.fetchOnce)(get_access_token_no_expiry_json_1.default);
57
+ const response = yield workos.pipes.getAccessToken({
58
+ provider: 'test-provider',
59
+ userId: 'user_789',
60
+ });
61
+ expect((0, test_utils_1.fetchURL)()).toContain('/data-integrations/test-provider/token');
62
+ expect((0, test_utils_1.fetchBody)()).toEqual({
63
+ user_id: 'user_789',
64
+ organization_id: undefined,
65
+ });
66
+ expect(response).toEqual({
67
+ active: true,
68
+ accessToken: {
69
+ object: 'access_token',
70
+ accessToken: 'test_access_token_456',
71
+ expiresAt: null,
72
+ scopes: ['read:data'],
73
+ missingScopes: ['write:data'],
74
+ },
75
+ });
76
+ }));
77
+ it('returns not_installed failure when integration is not installed', () => __awaiter(void 0, void 0, void 0, function* () {
78
+ (0, test_utils_1.fetchOnce)(get_access_token_not_installed_json_1.default);
79
+ const response = yield workos.pipes.getAccessToken({
80
+ provider: 'test-provider',
81
+ userId: 'user_123',
82
+ });
83
+ expect((0, test_utils_1.fetchURL)()).toContain('/data-integrations/test-provider/token');
84
+ expect(response).toEqual({
85
+ active: false,
86
+ error: 'not_installed',
87
+ });
88
+ }));
89
+ it('returns needs_reauthorization failure when token needs refresh', () => __awaiter(void 0, void 0, void 0, function* () {
90
+ (0, test_utils_1.fetchOnce)(get_access_token_needs_reauth_json_1.default);
91
+ const response = yield workos.pipes.getAccessToken({
92
+ provider: 'test-provider',
93
+ userId: 'user_123',
94
+ });
95
+ expect((0, test_utils_1.fetchURL)()).toContain('/data-integrations/test-provider/token');
96
+ expect(response).toEqual({
97
+ active: false,
98
+ error: 'needs_reauthorization',
99
+ });
100
+ }));
101
+ it('throws error for server errors', () => __awaiter(void 0, void 0, void 0, function* () {
102
+ (0, test_utils_1.fetchOnce)({ message: 'Internal Server Error' }, { status: 500 });
103
+ yield expect(workos.pipes.getAccessToken({
104
+ provider: 'test-provider',
105
+ userId: 'user_123',
106
+ })).rejects.toThrow();
107
+ }));
108
+ });
109
+ });
@@ -0,0 +1,2 @@
1
+ import { AccessToken, SerializedAccessToken } from '../interfaces/access-token.interface';
2
+ export declare function deserializeAccessToken(serialized: SerializedAccessToken): AccessToken;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeAccessToken = void 0;
4
+ function deserializeAccessToken(serialized) {
5
+ return {
6
+ object: 'access_token',
7
+ accessToken: serialized.access_token,
8
+ expiresAt: serialized.expires_at
9
+ ? new Date(Date.parse(serialized.expires_at))
10
+ : null,
11
+ scopes: serialized.scopes,
12
+ missingScopes: serialized.missing_scopes,
13
+ };
14
+ }
15
+ exports.deserializeAccessToken = deserializeAccessToken;
@@ -0,0 +1,3 @@
1
+ import { GetAccessTokenOptions, GetAccessTokenResponse, SerializedGetAccessTokenOptions, SerializedGetAccessTokenResponse } from '../interfaces/get-access-token.interface';
2
+ export declare function serializeGetAccessTokenOptions(options: GetAccessTokenOptions): SerializedGetAccessTokenOptions;
3
+ export declare function deserializeGetAccessTokenResponse(response: SerializedGetAccessTokenResponse): GetAccessTokenResponse;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeGetAccessTokenResponse = exports.serializeGetAccessTokenOptions = void 0;
4
+ const access_token_serializer_1 = require("./access-token.serializer");
5
+ function serializeGetAccessTokenOptions(options) {
6
+ return {
7
+ user_id: options.userId,
8
+ organization_id: options.organizationId,
9
+ };
10
+ }
11
+ exports.serializeGetAccessTokenOptions = serializeGetAccessTokenOptions;
12
+ function deserializeGetAccessTokenResponse(response) {
13
+ if (response.active) {
14
+ return {
15
+ active: true,
16
+ accessToken: (0, access_token_serializer_1.deserializeAccessToken)(response.access_token),
17
+ };
18
+ }
19
+ return {
20
+ active: false,
21
+ error: response.error,
22
+ };
23
+ }
24
+ exports.deserializeGetAccessTokenResponse = deserializeGetAccessTokenResponse;
@@ -7,6 +7,9 @@
7
7
  "name": "Advanced Dashboard",
8
8
  "slug": "advanced-dashboard",
9
9
  "description": "Enable advanced dashboard features",
10
+ "tags": ["ui"],
11
+ "enabled": true,
12
+ "default_value": false,
10
13
  "created_at": "2024-01-01T00:00:00.000Z",
11
14
  "updated_at": "2024-01-01T00:00:00.000Z"
12
15
  },
@@ -15,7 +18,10 @@
15
18
  "id": "flag_01EHQMYV6MBK39QC5PZXHY59C6",
16
19
  "name": "Beta Features",
17
20
  "slug": "beta-features",
18
- "description": null,
21
+ "description": "",
22
+ "tags": [],
23
+ "enabled": false,
24
+ "default_value": false,
19
25
  "created_at": "2024-01-01T00:00:00.000Z",
20
26
  "updated_at": "2024-01-01T00:00:00.000Z"
21
27
  },
@@ -25,6 +31,9 @@
25
31
  "name": "Premium Support",
26
32
  "slug": "premium-support",
27
33
  "description": "Access to premium support features",
34
+ "tags": ["dev-support"],
35
+ "enabled": false,
36
+ "default_value": true,
28
37
  "created_at": "2024-01-01T00:00:00.000Z",
29
38
  "updated_at": "2024-01-01T00:00:00.000Z"
30
39
  }
@@ -14,7 +14,7 @@ export interface AccessToken {
14
14
  entitlements?: string[];
15
15
  feature_flags?: string[];
16
16
  }
17
- export type SessionCookieData = Pick<AuthenticationResponse, 'accessToken' | 'impersonator' | 'organizationId' | 'refreshToken' | 'user'>;
17
+ export type SessionCookieData = Pick<AuthenticationResponse, 'accessToken' | 'authenticationMethod' | 'impersonator' | 'organizationId' | 'refreshToken' | 'user'>;
18
18
  export declare enum AuthenticateWithSessionCookieFailureReason {
19
19
  INVALID_JWT = "invalid_jwt",
20
20
  INVALID_SESSION_COOKIE = "invalid_session_cookie",
@@ -26,6 +26,8 @@ export type AuthenticateWithSessionCookieFailedResponse = {
26
26
  };
27
27
  export type AuthenticateWithSessionCookieSuccessResponse = {
28
28
  authenticated: true;
29
+ accessToken: string;
30
+ authenticationMethod: AuthenticationResponse['authenticationMethod'];
29
31
  sessionId: string;
30
32
  organizationId?: string;
31
33
  role?: string;
@@ -35,5 +37,4 @@ export type AuthenticateWithSessionCookieSuccessResponse = {
35
37
  featureFlags?: string[];
36
38
  user: User;
37
39
  impersonator?: Impersonator;
38
- accessToken: string;
39
40
  };
@@ -72,6 +72,7 @@ class CookieSession {
72
72
  entitlements,
73
73
  featureFlags,
74
74
  user: session.user,
75
+ authenticationMethod: session.authenticationMethod,
75
76
  impersonator: session.impersonator,
76
77
  accessToken: session.accessToken,
77
78
  };
@@ -122,6 +123,7 @@ class CookieSession {
122
123
  authenticated: true,
123
124
  sealedSession: authenticationResponse.sealedSession,
124
125
  session: authenticationResponse,
126
+ authenticationMethod: authenticationResponse.authenticationMethod,
125
127
  sessionId,
126
128
  organizationId,
127
129
  role,
@@ -30,11 +30,11 @@ const oauth_exception_1 = require("../common/exceptions/oauth.exception");
30
30
  const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
31
31
  const pagination_1 = require("../common/utils/pagination");
32
32
  const serializers_1 = require("../mfa/serializers");
33
- const feature_flag_serializer_1 = require("../feature-flags/serializers/feature-flag.serializer");
33
+ const serializers_2 = require("../feature-flags/serializers");
34
34
  const authenticate_with_session_cookie_interface_1 = require("./interfaces/authenticate-with-session-cookie.interface");
35
35
  const refresh_and_seal_session_data_interface_1 = require("./interfaces/refresh-and-seal-session-data.interface");
36
36
  const revoke_session_options_interface_1 = require("./interfaces/revoke-session-options.interface");
37
- const serializers_2 = require("./serializers");
37
+ const serializers_3 = require("./serializers");
38
38
  const authenticate_with_email_verification_serializer_1 = require("./serializers/authenticate-with-email-verification.serializer");
39
39
  const authenticate_with_organization_selection_options_serializer_1 = require("./serializers/authenticate-with-organization-selection-options.serializer");
40
40
  const create_organization_membership_options_serializer_1 = require("./serializers/create-organization-membership-options.serializer");
@@ -89,32 +89,32 @@ class UserManagement {
89
89
  getUser(userId) {
90
90
  return __awaiter(this, void 0, void 0, function* () {
91
91
  const { data } = yield this.workos.get(`/user_management/users/${userId}`);
92
- return (0, serializers_2.deserializeUser)(data);
92
+ return (0, serializers_3.deserializeUser)(data);
93
93
  });
94
94
  }
95
95
  getUserByExternalId(externalId) {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
97
  const { data } = yield this.workos.get(`/user_management/users/external_id/${externalId}`);
98
- return (0, serializers_2.deserializeUser)(data);
98
+ return (0, serializers_3.deserializeUser)(data);
99
99
  });
100
100
  }
101
101
  listUsers(options) {
102
102
  return __awaiter(this, void 0, void 0, function* () {
103
- 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);
103
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/user_management/users', serializers_3.deserializeUser, options ? (0, list_users_options_serializer_1.serializeListUsersOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/user_management/users', serializers_3.deserializeUser, params), options ? (0, list_users_options_serializer_1.serializeListUsersOptions)(options) : undefined);
104
104
  });
105
105
  }
106
106
  createUser(payload) {
107
107
  return __awaiter(this, void 0, void 0, function* () {
108
- const { data } = yield this.workos.post('/user_management/users', (0, serializers_2.serializeCreateUserOptions)(payload));
109
- return (0, serializers_2.deserializeUser)(data);
108
+ const { data } = yield this.workos.post('/user_management/users', (0, serializers_3.serializeCreateUserOptions)(payload));
109
+ return (0, serializers_3.deserializeUser)(data);
110
110
  });
111
111
  }
112
112
  authenticateWithMagicAuth(payload) {
113
113
  return __awaiter(this, void 0, void 0, function* () {
114
114
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
115
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithMagicAuthOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
115
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithMagicAuthOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
116
116
  return this.prepareAuthenticationResponse({
117
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
117
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
118
118
  session,
119
119
  });
120
120
  });
@@ -122,9 +122,9 @@ class UserManagement {
122
122
  authenticateWithPassword(payload) {
123
123
  return __awaiter(this, void 0, void 0, function* () {
124
124
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
125
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithPasswordOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
125
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithPasswordOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
126
126
  return this.prepareAuthenticationResponse({
127
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
127
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
128
128
  session,
129
129
  });
130
130
  });
@@ -132,9 +132,9 @@ class UserManagement {
132
132
  authenticateWithCode(payload) {
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
135
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithCodeOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
135
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithCodeOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
136
136
  return this.prepareAuthenticationResponse({
137
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
137
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
138
138
  session,
139
139
  });
140
140
  });
@@ -142,9 +142,9 @@ class UserManagement {
142
142
  authenticateWithCodeAndVerifier(payload) {
143
143
  return __awaiter(this, void 0, void 0, function* () {
144
144
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
145
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithCodeAndVerifierOptions)(remainingPayload));
145
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithCodeAndVerifierOptions)(remainingPayload));
146
146
  return this.prepareAuthenticationResponse({
147
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
147
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
148
148
  session,
149
149
  });
150
150
  });
@@ -152,9 +152,9 @@ class UserManagement {
152
152
  authenticateWithRefreshToken(payload) {
153
153
  return __awaiter(this, void 0, void 0, function* () {
154
154
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
155
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithRefreshTokenOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
155
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithRefreshTokenOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
156
156
  return this.prepareAuthenticationResponse({
157
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
157
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
158
158
  session,
159
159
  });
160
160
  });
@@ -162,9 +162,9 @@ class UserManagement {
162
162
  authenticateWithTotp(payload) {
163
163
  return __awaiter(this, void 0, void 0, function* () {
164
164
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
165
- const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_2.serializeAuthenticateWithTotpOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
165
+ const { data } = yield this.workos.post('/user_management/authenticate', (0, serializers_3.serializeAuthenticateWithTotpOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
166
166
  return this.prepareAuthenticationResponse({
167
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
167
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
168
168
  session,
169
169
  });
170
170
  });
@@ -174,7 +174,7 @@ class UserManagement {
174
174
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
175
175
  const { data } = yield this.workos.post('/user_management/authenticate', (0, authenticate_with_email_verification_serializer_1.serializeAuthenticateWithEmailVerificationOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
176
176
  return this.prepareAuthenticationResponse({
177
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
177
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
178
178
  session,
179
179
  });
180
180
  });
@@ -184,7 +184,7 @@ class UserManagement {
184
184
  const { session } = payload, remainingPayload = __rest(payload, ["session"]);
185
185
  const { data } = yield this.workos.post('/user_management/authenticate', (0, authenticate_with_organization_selection_options_serializer_1.serializeAuthenticateWithOrganizationSelectionOptions)(Object.assign(Object.assign({}, remainingPayload), { clientSecret: this.workos.key })));
186
186
  return this.prepareAuthenticationResponse({
187
- authenticationResponse: (0, serializers_2.deserializeAuthenticationResponse)(data),
187
+ authenticationResponse: (0, serializers_3.deserializeAuthenticationResponse)(data),
188
188
  session,
189
189
  });
190
190
  });
@@ -230,6 +230,7 @@ class UserManagement {
230
230
  entitlements,
231
231
  featureFlags,
232
232
  accessToken: session.accessToken,
233
+ authenticationMethod: session.authenticationMethod,
233
234
  };
234
235
  });
235
236
  }
@@ -328,6 +329,7 @@ class UserManagement {
328
329
  user: authenticationResponse.user,
329
330
  accessToken: authenticationResponse.accessToken,
330
331
  refreshToken: authenticationResponse.refreshToken,
332
+ authenticationMethod: authenticationResponse.authenticationMethod,
331
333
  impersonator: authenticationResponse.impersonator,
332
334
  };
333
335
  return this.ironSessionProvider.sealData(sessionData, {
@@ -351,25 +353,25 @@ class UserManagement {
351
353
  getEmailVerification(emailVerificationId) {
352
354
  return __awaiter(this, void 0, void 0, function* () {
353
355
  const { data } = yield this.workos.get(`/user_management/email_verification/${emailVerificationId}`);
354
- return (0, serializers_2.deserializeEmailVerification)(data);
356
+ return (0, serializers_3.deserializeEmailVerification)(data);
355
357
  });
356
358
  }
357
359
  sendVerificationEmail({ userId, }) {
358
360
  return __awaiter(this, void 0, void 0, function* () {
359
361
  const { data } = yield this.workos.post(`/user_management/users/${userId}/email_verification/send`, {});
360
- return { user: (0, serializers_2.deserializeUser)(data.user) };
362
+ return { user: (0, serializers_3.deserializeUser)(data.user) };
361
363
  });
362
364
  }
363
365
  getMagicAuth(magicAuthId) {
364
366
  return __awaiter(this, void 0, void 0, function* () {
365
367
  const { data } = yield this.workos.get(`/user_management/magic_auth/${magicAuthId}`);
366
- return (0, serializers_2.deserializeMagicAuth)(data);
368
+ return (0, serializers_3.deserializeMagicAuth)(data);
367
369
  });
368
370
  }
369
371
  createMagicAuth(options) {
370
372
  return __awaiter(this, void 0, void 0, function* () {
371
- const { data } = yield this.workos.post('/user_management/magic_auth', (0, serializers_2.serializeCreateMagicAuthOptions)(Object.assign({}, options)));
372
- return (0, serializers_2.deserializeMagicAuth)(data);
373
+ const { data } = yield this.workos.post('/user_management/magic_auth', (0, serializers_3.serializeCreateMagicAuthOptions)(Object.assign({}, options)));
374
+ return (0, serializers_3.deserializeMagicAuth)(data);
373
375
  });
374
376
  }
375
377
  /**
@@ -378,7 +380,7 @@ class UserManagement {
378
380
  */
379
381
  sendMagicAuthCode(options) {
380
382
  return __awaiter(this, void 0, void 0, function* () {
381
- yield this.workos.post('/user_management/magic_auth/send', (0, serializers_2.serializeSendMagicAuthCodeOptions)(options));
383
+ yield this.workos.post('/user_management/magic_auth/send', (0, serializers_3.serializeSendMagicAuthCodeOptions)(options));
382
384
  });
383
385
  }
384
386
  verifyEmail({ code, userId, }) {
@@ -386,19 +388,19 @@ class UserManagement {
386
388
  const { data } = yield this.workos.post(`/user_management/users/${userId}/email_verification/confirm`, {
387
389
  code,
388
390
  });
389
- return { user: (0, serializers_2.deserializeUser)(data.user) };
391
+ return { user: (0, serializers_3.deserializeUser)(data.user) };
390
392
  });
391
393
  }
392
394
  getPasswordReset(passwordResetId) {
393
395
  return __awaiter(this, void 0, void 0, function* () {
394
396
  const { data } = yield this.workos.get(`/user_management/password_reset/${passwordResetId}`);
395
- return (0, serializers_2.deserializePasswordReset)(data);
397
+ return (0, serializers_3.deserializePasswordReset)(data);
396
398
  });
397
399
  }
398
400
  createPasswordReset(options) {
399
401
  return __awaiter(this, void 0, void 0, function* () {
400
- const { data } = yield this.workos.post('/user_management/password_reset', (0, serializers_2.serializeCreatePasswordResetOptions)(Object.assign({}, options)));
401
- return (0, serializers_2.deserializePasswordReset)(data);
402
+ const { data } = yield this.workos.post('/user_management/password_reset', (0, serializers_3.serializeCreatePasswordResetOptions)(Object.assign({}, options)));
403
+ return (0, serializers_3.deserializePasswordReset)(data);
402
404
  });
403
405
  }
404
406
  /**
@@ -406,26 +408,26 @@ class UserManagement {
406
408
  */
407
409
  sendPasswordResetEmail(payload) {
408
410
  return __awaiter(this, void 0, void 0, function* () {
409
- yield this.workos.post('/user_management/password_reset/send', (0, serializers_2.serializeSendPasswordResetEmailOptions)(payload));
411
+ yield this.workos.post('/user_management/password_reset/send', (0, serializers_3.serializeSendPasswordResetEmailOptions)(payload));
410
412
  });
411
413
  }
412
414
  resetPassword(payload) {
413
415
  return __awaiter(this, void 0, void 0, function* () {
414
- const { data } = yield this.workos.post('/user_management/password_reset/confirm', (0, serializers_2.serializeResetPasswordOptions)(payload));
415
- return { user: (0, serializers_2.deserializeUser)(data.user) };
416
+ const { data } = yield this.workos.post('/user_management/password_reset/confirm', (0, serializers_3.serializeResetPasswordOptions)(payload));
417
+ return { user: (0, serializers_3.deserializeUser)(data.user) };
416
418
  });
417
419
  }
418
420
  updateUser(payload) {
419
421
  return __awaiter(this, void 0, void 0, function* () {
420
- const { data } = yield this.workos.put(`/user_management/users/${payload.userId}`, (0, serializers_2.serializeUpdateUserOptions)(payload));
421
- return (0, serializers_2.deserializeUser)(data);
422
+ const { data } = yield this.workos.put(`/user_management/users/${payload.userId}`, (0, serializers_3.serializeUpdateUserOptions)(payload));
423
+ return (0, serializers_3.deserializeUser)(data);
422
424
  });
423
425
  }
424
426
  enrollAuthFactor(payload) {
425
427
  return __awaiter(this, void 0, void 0, function* () {
426
- const { data } = yield this.workos.post(`/user_management/users/${payload.userId}/auth_factors`, (0, serializers_2.serializeEnrollAuthFactorOptions)(payload));
428
+ const { data } = yield this.workos.post(`/user_management/users/${payload.userId}/auth_factors`, (0, serializers_3.serializeEnrollAuthFactorOptions)(payload));
427
429
  return {
428
- authenticationFactor: (0, serializers_2.deserializeFactorWithSecrets)(data.authentication_factor),
430
+ authenticationFactor: (0, serializers_3.deserializeFactorWithSecrets)(data.authentication_factor),
429
431
  authenticationChallenge: (0, serializers_1.deserializeChallenge)(data.authentication_challenge),
430
432
  };
431
433
  });
@@ -439,12 +441,12 @@ class UserManagement {
439
441
  listUserFeatureFlags(options) {
440
442
  return __awaiter(this, void 0, void 0, function* () {
441
443
  const { userId } = options, paginationOptions = __rest(options, ["userId"]);
442
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, paginationOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, params), paginationOptions);
444
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, serializers_2.deserializeFeatureFlag, paginationOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, serializers_2.deserializeFeatureFlag, params), paginationOptions);
443
445
  });
444
446
  }
445
447
  listSessions(userId, options) {
446
448
  return __awaiter(this, void 0, void 0, function* () {
447
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_2.deserializeSession, options ? (0, serializers_2.serializeListSessionsOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_2.deserializeSession, params), options ? (0, serializers_2.serializeListSessionsOptions)(options) : undefined);
449
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_3.deserializeSession, options ? (0, serializers_3.serializeListSessionsOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_3.deserializeSession, params), options ? (0, serializers_3.serializeListSessionsOptions)(options) : undefined);
448
450
  });
449
451
  }
450
452
  deleteUser(userId) {
@@ -1364,6 +1364,9 @@ describe('UserManagement', () => {
1364
1364
  name: 'Advanced Dashboard',
1365
1365
  slug: 'advanced-dashboard',
1366
1366
  description: 'Enable advanced dashboard features',
1367
+ tags: ['ui'],
1368
+ enabled: true,
1369
+ defaultValue: false,
1367
1370
  createdAt: '2024-01-01T00:00:00.000Z',
1368
1371
  updatedAt: '2024-01-01T00:00:00.000Z',
1369
1372
  },
@@ -1372,7 +1375,10 @@ describe('UserManagement', () => {
1372
1375
  id: 'flag_01EHQMYV6MBK39QC5PZXHY59C6',
1373
1376
  name: 'Beta Features',
1374
1377
  slug: 'beta-features',
1375
- description: null,
1378
+ description: '',
1379
+ tags: [],
1380
+ enabled: false,
1381
+ defaultValue: false,
1376
1382
  createdAt: '2024-01-01T00:00:00.000Z',
1377
1383
  updatedAt: '2024-01-01T00:00:00.000Z',
1378
1384
  },
@@ -1382,6 +1388,9 @@ describe('UserManagement', () => {
1382
1388
  name: 'Premium Support',
1383
1389
  slug: 'premium-support',
1384
1390
  description: 'Access to premium support features',
1391
+ tags: ['dev-support'],
1392
+ enabled: false,
1393
+ defaultValue: true,
1385
1394
  createdAt: '2024-01-01T00:00:00.000Z',
1386
1395
  updatedAt: '2024-01-01T00:00:00.000Z',
1387
1396
  },
@@ -69,6 +69,35 @@ describe.skip('Vault Live Test', () => {
69
69
  metadata: expectedMetadata,
70
70
  });
71
71
  }));
72
+ it('Reads objects by name', () => __awaiter(void 0, void 0, void 0, function* () {
73
+ const objectName = `${objectPrefix}-nazca`;
74
+ const newObject = yield workos.vault.createObject({
75
+ name: objectName,
76
+ value: 'Suri 10-15 micron',
77
+ context: { fiber: 'Alpalca' },
78
+ });
79
+ const expectedMetadata = {
80
+ id: expect.any(String),
81
+ context: {
82
+ fiber: 'Alpalca',
83
+ },
84
+ environmentId: expect.any(String),
85
+ keyId: expect.any(String),
86
+ updatedAt: expect.any(Date),
87
+ updatedBy: {
88
+ id: expect.any(String),
89
+ name: expect.any(String),
90
+ },
91
+ versionId: expect.any(String),
92
+ };
93
+ const objectValue = yield workos.vault.readObjectByName(objectName);
94
+ expect(objectValue).toStrictEqual({
95
+ id: newObject.id,
96
+ name: objectName,
97
+ value: 'Suri 10-15 micron',
98
+ metadata: expectedMetadata,
99
+ });
100
+ }));
72
101
  it('Fails to create objects with the same name', () => __awaiter(void 0, void 0, void 0, function* () {
73
102
  const objectName = `${objectPrefix}-lima`;
74
103
  yield workos.vault.createObject({
@@ -153,7 +182,7 @@ describe.skip('Vault Live Test', () => {
153
182
  const newObject = yield workos.vault.createObject({
154
183
  name: objectName,
155
184
  value: 'Qiviut 11-13 micron',
156
- context: { fiber: 'Musk Ox' },
185
+ context: { fiber: 'MuskOx' },
157
186
  });
158
187
  const objectDescription = yield workos.vault.describeObject({
159
188
  id: newObject.id,
@@ -161,7 +190,7 @@ describe.skip('Vault Live Test', () => {
161
190
  const expectedMetadata = {
162
191
  id: expect.any(String),
163
192
  context: {
164
- fiber: 'Musk Ox',
193
+ fiber: 'MuskOx',
165
194
  },
166
195
  environmentId: expect.any(String),
167
196
  keyId: expect.any(String),
@@ -188,7 +217,7 @@ describe.skip('Vault Live Test', () => {
188
217
  yield workos.vault.createObject({
189
218
  name: objectName,
190
219
  value: 'Qiviut 11-13 micron',
191
- context: { fiber: 'Musk Ox' },
220
+ context: { fiber: 'MuskOx' },
192
221
  });
193
222
  objectNames.push(objectName);
194
223
  }
@@ -254,7 +283,7 @@ describe.skip('Vault Live Test', () => {
254
283
  const keyContext = { everything: 'everywhere' };
255
284
  const aad = 'seq1';
256
285
  const encrypted = yield workos.vault.encrypt(data, keyContext, aad);
257
- yield expect(() => workos.vault.decrypt(encrypted)).rejects.toThrow('unable to authenticate data');
286
+ yield expect(() => workos.vault.decrypt(encrypted)).rejects.toThrow('The operation failed for an operation-specific reason');
258
287
  }));
259
288
  });
260
289
  });