@workos-inc/node 3.0.0-user-management.2 → 3.0.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/audit-logs/audit-logs.js +5 -4
- package/lib/audit-logs/audit-logs.spec.js +87 -87
- package/lib/audit-logs/interfaces/audit-log-export-options.interface.d.ts +13 -3
- package/lib/audit-logs/interfaces/audit-log-export.interface.d.ts +8 -0
- package/lib/audit-logs/interfaces/create-audit-log-event-options.interface.d.ts +13 -1
- package/lib/audit-logs/serializers/audit-log-export-options.serializer.d.ts +2 -0
- package/lib/audit-logs/serializers/audit-log-export-options.serializer.js +14 -0
- package/lib/audit-logs/serializers/audit-log-export.serializer.d.ts +2 -0
- package/lib/audit-logs/serializers/audit-log-export.serializer.js +12 -0
- package/lib/audit-logs/serializers/create-audit-log-event-options.serializer.d.ts +2 -0
- package/lib/audit-logs/serializers/create-audit-log-event-options.serializer.js +16 -0
- package/lib/audit-logs/serializers/index.d.ts +3 -0
- package/lib/audit-logs/serializers/index.js +19 -0
- package/lib/audit-trail/audit-trail.d.ts +2 -2
- package/lib/audit-trail/audit-trail.spec.js +2 -1
- 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 +5 -0
- package/lib/common/interfaces/index.js +5 -0
- package/lib/common/interfaces/list.interface.d.ts +9 -1
- package/lib/common/interfaces/workos-response-error.interface.d.ts +8 -0
- package/lib/common/serializers/event.serializer.d.ts +2 -0
- package/lib/common/serializers/event.serializer.js +40 -0
- package/lib/common/serializers/index.d.ts +2 -0
- package/lib/common/serializers/index.js +18 -0
- package/lib/common/serializers/list.serializer.d.ts +2 -0
- package/lib/common/serializers/list.serializer.js +9 -0
- package/lib/common/utils/fetch-and-deserialize.d.ts +3 -0
- package/lib/common/utils/fetch-and-deserialize.js +23 -0
- package/lib/common/utils/pagination.d.ts +15 -0
- package/lib/common/utils/pagination.js +90 -0
- package/lib/common/utils/workos-mock-response.d.ts +7 -0
- package/lib/common/utils/workos-mock-response.js +11 -0
- package/lib/directory-sync/directory-sync.d.ts +8 -12
- package/lib/directory-sync/directory-sync.js +9 -15
- package/lib/directory-sync/directory-sync.spec.js +132 -20
- package/lib/directory-sync/interfaces/directory-group.interface.d.ts +40 -0
- package/lib/directory-sync/interfaces/directory-user.interface.d.ts +50 -0
- package/lib/directory-sync/interfaces/directory.interface.d.ts +47 -2
- package/lib/directory-sync/interfaces/index.d.ts +6 -6
- package/lib/directory-sync/interfaces/index.js +20 -0
- package/lib/directory-sync/interfaces/list-directories-options.interface.d.ts +1 -1
- package/lib/directory-sync/interfaces/{list-users-options.interface.d.ts → list-directory-users-options.interface.d.ts} +1 -1
- package/lib/directory-sync/interfaces/list-groups-options.interface.d.ts +1 -1
- package/lib/directory-sync/serializers/directory-group.serializer.d.ts +4 -0
- package/lib/directory-sync/serializers/directory-group.serializer.js +37 -0
- package/lib/directory-sync/serializers/directory-user.serializer.d.ts +4 -0
- package/lib/directory-sync/serializers/directory-user.serializer.js +43 -0
- package/lib/directory-sync/serializers/directory.serializer.d.ts +5 -0
- package/lib/directory-sync/serializers/directory.serializer.js +50 -0
- package/lib/directory-sync/serializers/index.d.ts +3 -0
- package/lib/directory-sync/serializers/index.js +19 -0
- package/lib/directory-sync/utils/get-primary-email.d.ts +2 -2
- package/lib/directory-sync/utils/get-primary-email.spec.js +11 -8
- package/lib/events/events.d.ts +1 -2
- package/lib/events/events.js +2 -1
- package/lib/events/events.spec.js +39 -5
- 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 +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/mfa/interfaces/challenge.interface.d.ts +9 -0
- package/lib/mfa/interfaces/factor.interface.d.ts +13 -4
- package/lib/mfa/interfaces/index.d.ts +9 -0
- package/lib/mfa/interfaces/index.js +25 -0
- package/lib/mfa/interfaces/sms.interface.d.ts +3 -0
- package/lib/mfa/interfaces/totp.interface.d.ts +7 -0
- package/lib/mfa/interfaces/verify-challenge-response.d.ts +5 -1
- package/lib/mfa/mfa.d.ts +2 -8
- package/lib/mfa/mfa.js +5 -4
- package/lib/mfa/mfa.spec.js +134 -115
- package/lib/mfa/serializers/challenge.serializer.d.ts +2 -0
- package/lib/mfa/serializers/challenge.serializer.js +13 -0
- package/lib/mfa/serializers/factor.serializer.d.ts +2 -0
- package/lib/mfa/serializers/factor.serializer.js +7 -0
- package/lib/mfa/serializers/index.d.ts +3 -0
- package/lib/{webhooks/interfaces → mfa/serializers}/index.js +3 -4
- package/lib/mfa/serializers/sms.serializer.d.ts +2 -0
- package/lib/mfa/serializers/sms.serializer.js +7 -0
- package/lib/mfa/serializers/totp.serializer.d.ts +2 -0
- package/lib/mfa/serializers/totp.serializer.js +11 -0
- package/lib/mfa/serializers/verify-response.serializer.d.ts +2 -0
- package/lib/mfa/serializers/verify-response.serializer.js +9 -0
- package/lib/organizations/interfaces/create-organization-options.interface.d.ts +5 -0
- package/lib/organizations/interfaces/organization.interface.d.ts +9 -0
- package/lib/organizations/interfaces/update-organization-options.interface.d.ts +5 -0
- package/lib/organizations/organizations.d.ts +2 -2
- package/lib/organizations/organizations.js +9 -9
- package/lib/organizations/organizations.spec.js +11 -4
- package/lib/organizations/serializers/create-organization-options.serializer.d.ts +2 -0
- package/lib/organizations/serializers/create-organization-options.serializer.js +9 -0
- package/lib/organizations/serializers/index.d.ts +3 -0
- package/lib/organizations/serializers/index.js +19 -0
- package/lib/organizations/serializers/organization.serializer.d.ts +2 -0
- package/lib/organizations/serializers/organization.serializer.js +13 -0
- package/lib/organizations/serializers/update-organization-options.serializer.d.ts +2 -0
- package/lib/organizations/serializers/update-organization-options.serializer.js +9 -0
- package/lib/passwordless/interfaces/create-passwordless-session-options.interface.d.ts +8 -0
- package/lib/passwordless/interfaces/index.d.ts +3 -3
- package/lib/passwordless/interfaces/index.js +17 -0
- package/lib/passwordless/interfaces/passwordless-session.interface.d.ts +7 -0
- package/lib/passwordless/passwordless.d.ts +1 -3
- package/lib/passwordless/passwordless.js +2 -1
- package/lib/passwordless/serializers/index.d.ts +0 -0
- package/lib/passwordless/serializers/index.js +1 -0
- package/lib/passwordless/serializers/passwordless-session.serializer.d.ts +2 -0
- package/lib/passwordless/serializers/passwordless-session.serializer.js +11 -0
- package/lib/portal/interfaces/generate-portal-link-intent.interface.js +1 -1
- package/lib/sso/interfaces/connection-type.enum.d.ts +1 -0
- package/lib/sso/interfaces/connection-type.enum.js +2 -1
- package/lib/sso/interfaces/connection.interface.d.ts +16 -5
- package/lib/sso/interfaces/index.d.ts +2 -0
- package/lib/sso/interfaces/index.js +2 -0
- package/lib/sso/interfaces/list-connections-options.interface.d.ts +5 -0
- package/lib/sso/interfaces/profile-and-token.interface.d.ts +6 -2
- package/lib/sso/interfaces/profile.interface.d.ts +14 -0
- package/lib/sso/serializers/connection.serializer.d.ts +2 -0
- package/lib/sso/serializers/connection.serializer.js +16 -0
- package/lib/sso/serializers/index.d.ts +3 -0
- package/lib/sso/serializers/index.js +19 -0
- package/lib/sso/serializers/profile-and-token.serializer.d.ts +2 -0
- package/lib/sso/serializers/profile-and-token.serializer.js +9 -0
- package/lib/sso/serializers/profile.serializer.d.ts +2 -0
- package/lib/sso/serializers/profile.serializer.js +16 -0
- package/lib/sso/sso.d.ts +3 -9
- package/lib/sso/sso.js +23 -16
- package/lib/sso/sso.spec.js +26 -9
- package/lib/users/exceptions/index.d.ts +4 -0
- package/lib/users/exceptions/index.js +10 -0
- 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/add-user-to-organization-options.interface.d.ts +4 -1
- package/lib/users/interfaces/authenticate-user-with-magic-auth-options.interface.d.ts +21 -0
- package/lib/users/interfaces/authenticate-user-with-password-options.interface.d.ts +14 -1
- package/lib/users/interfaces/authenticate-user-with-token-options.interface.d.ts +10 -1
- package/lib/users/interfaces/authentication-response.interface.d.ts +7 -3
- package/lib/users/interfaces/complete-password-reset-options.interface.d.ts +4 -0
- package/lib/users/interfaces/create-email-verification-challenge-options.interface.d.ts +9 -2
- package/lib/users/interfaces/create-password-reset-challenge-options.interface.d.ts +9 -1
- package/lib/users/interfaces/create-user-options.interface.d.ts +8 -1
- package/lib/users/interfaces/index.d.ts +7 -0
- package/lib/users/interfaces/index.js +7 -0
- package/lib/users/interfaces/magic-auth-challenge.interface.d.ts +3 -0
- package/lib/users/interfaces/remove-user-from-organization-options.interface.d.ts +2 -2
- package/lib/users/interfaces/revoke-all-sessions-for-user-options.interface.d.ts +3 -0
- package/lib/users/interfaces/revoke-all-sessions-for-user-options.interface.js +2 -0
- package/lib/users/interfaces/revoke-session-options.interface.d.ts +7 -0
- package/lib/users/interfaces/send-magic-auth-code-options.interface.d.ts +6 -0
- package/lib/users/interfaces/send-magic-auth-code-options.interface.js +2 -0
- package/lib/users/interfaces/session.interface.d.ts +35 -0
- package/lib/users/interfaces/update-user-options.interface.d.ts +14 -0
- package/lib/users/interfaces/update-user-options.interface.js +2 -0
- package/lib/users/interfaces/update-user-password-options.interface.d.ts +7 -0
- package/lib/users/interfaces/update-user-password-options.interface.js +2 -0
- package/lib/users/interfaces/user.interface.d.ts +28 -18
- package/lib/users/interfaces/verify-session.interface.d.ts +10 -2
- package/lib/users/serializers/authenticate-user-with-magic-auth-options.serializer.d.ts +2 -0
- package/lib/users/serializers/authenticate-user-with-magic-auth-options.serializer.js +14 -0
- package/lib/users/serializers/authenticate-user-with-password-options.serializer.d.ts +2 -0
- package/lib/users/serializers/authenticate-user-with-password-options.serializer.js +14 -0
- package/lib/users/serializers/authenticate-user-with-token-options.serializer.d.ts +2 -0
- package/lib/users/serializers/authenticate-user-with-token-options.serializer.js +11 -0
- package/lib/users/serializers/authentication-response.serializer.d.ts +2 -0
- package/lib/users/serializers/authentication-response.serializer.js +10 -0
- package/lib/users/serializers/complete-password-reset-options.serializer.d.ts +2 -0
- package/lib/users/serializers/complete-password-reset-options.serializer.js +8 -0
- package/lib/users/serializers/create-email-verification-challenge.serializer.d.ts +2 -0
- package/lib/users/serializers/create-email-verification-challenge.serializer.js +9 -0
- package/lib/users/serializers/create-password-reset-challenge.serializer.d.ts +3 -0
- package/lib/users/serializers/create-password-reset-challenge.serializer.js +14 -0
- package/lib/users/serializers/create-user-options.serializer.d.ts +2 -0
- package/lib/users/serializers/create-user-options.serializer.js +11 -0
- package/lib/users/serializers/index.d.ts +15 -0
- package/lib/users/serializers/index.js +31 -0
- package/lib/users/serializers/revoke-session-options.serializer.d.ts +2 -0
- package/lib/users/serializers/revoke-session-options.serializer.js +14 -0
- package/lib/users/serializers/send-magic-auth-code-options.serializer.d.ts +2 -0
- package/lib/users/serializers/send-magic-auth-code-options.serializer.js +7 -0
- package/lib/users/serializers/session.serializer.d.ts +4 -0
- package/lib/users/serializers/session.serializer.js +22 -0
- package/lib/users/serializers/update-user-options.serializer.d.ts +2 -0
- package/lib/users/serializers/update-user-options.serializer.js +8 -0
- package/lib/users/serializers/update-user-password-options.serializer.d.ts +2 -0
- package/lib/users/serializers/update-user-password-options.serializer.js +7 -0
- package/lib/users/serializers/user.serializer.d.ts +2 -0
- package/lib/users/serializers/user.serializer.js +24 -0
- package/lib/users/serializers/verify-session.serializer.d.ts +3 -0
- package/lib/users/serializers/verify-session.serializer.js +15 -0
- package/lib/users/users.d.ts +11 -7
- package/lib/users/users.js +54 -30
- package/lib/users/users.spec.js +133 -49
- 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.d.ts +5 -4
- package/lib/workos.js +4 -1
- package/lib/workos.spec.js +11 -1
- package/package.json +14 -15
- package/lib/directory-sync/interfaces/group.interface.d.ts +0 -10
- package/lib/directory-sync/interfaces/user.interface.d.ts +0 -23
- package/lib/events/interfaces/event.interface.d.ts +0 -63
- package/lib/webhooks/interfaces/index.d.ts +0 -4
- 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.interface.d.ts +0 -20
- package/lib/webhooks/interfaces/webhook.interface.d.ts +0 -73
- /package/lib/{directory-sync/interfaces/group.interface.js → common/interfaces/at-least-one-property-of.interface.js} +0 -0
- /package/lib/{events → common}/interfaces/event.interface.js +0 -0
- /package/lib/{directory-sync/interfaces/list-users-options.interface.js → common/interfaces/workos-response-error.interface.js} +0 -0
- /package/lib/directory-sync/interfaces/{user.interface.js → directory-group.interface.js} +0 -0
- /package/lib/{webhooks/interfaces/webhook-directory-group.interface.js → directory-sync/interfaces/directory-user.interface.js} +0 -0
- /package/lib/{webhooks/interfaces/webhook-directory-user.interface.js → directory-sync/interfaces/list-directory-users-options.interface.js} +0 -0
- /package/lib/{webhooks/interfaces/webhook-directory.interface.js → users/interfaces/authenticate-user-with-magic-auth-options.interface.js} +0 -0
- /package/lib/{webhooks/interfaces/webhook.interface.js → users/interfaces/magic-auth-challenge.interface.js} +0 -0
package/lib/sso/sso.spec.js
CHANGED
|
@@ -15,7 +15,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const axios_1 = __importDefault(require("axios"));
|
|
16
16
|
const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
|
|
17
17
|
const workos_1 = require("../workos");
|
|
18
|
+
const interfaces_1 = require("./interfaces");
|
|
18
19
|
describe('SSO', () => {
|
|
20
|
+
const connectionResponse = {
|
|
21
|
+
object: 'connection',
|
|
22
|
+
id: 'conn_123',
|
|
23
|
+
organization_id: 'org_123',
|
|
24
|
+
name: 'Connection',
|
|
25
|
+
connection_type: interfaces_1.ConnectionType.OktaSAML,
|
|
26
|
+
state: 'active',
|
|
27
|
+
domains: [],
|
|
28
|
+
created_at: '2023-07-17T20:07:20.055Z',
|
|
29
|
+
updated_at: '2023-07-17T20:07:20.055Z',
|
|
30
|
+
};
|
|
19
31
|
describe('SSO', () => {
|
|
20
32
|
describe('getAuthorizationURL', () => {
|
|
21
33
|
describe('with no custom api hostname', () => {
|
|
@@ -113,7 +125,7 @@ describe('SSO', () => {
|
|
|
113
125
|
redirectURI: 'example.com/sso/workos/callback',
|
|
114
126
|
state: 'custom state',
|
|
115
127
|
});
|
|
116
|
-
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&domain_hint=lyft.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom
|
|
128
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&domain_hint=lyft.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
|
|
117
129
|
});
|
|
118
130
|
});
|
|
119
131
|
describe('with loginHint', () => {
|
|
@@ -126,7 +138,7 @@ describe('SSO', () => {
|
|
|
126
138
|
redirectURI: 'example.com/sso/workos/callback',
|
|
127
139
|
state: 'custom state',
|
|
128
140
|
});
|
|
129
|
-
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom
|
|
141
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
|
|
130
142
|
});
|
|
131
143
|
});
|
|
132
144
|
});
|
|
@@ -172,7 +184,7 @@ describe('SSO', () => {
|
|
|
172
184
|
return [404];
|
|
173
185
|
});
|
|
174
186
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
175
|
-
const {
|
|
187
|
+
const { accessToken, profile } = yield workos.sso.getProfileAndToken({
|
|
176
188
|
code: 'authorization_code',
|
|
177
189
|
clientID: 'proj_123',
|
|
178
190
|
});
|
|
@@ -223,7 +235,7 @@ describe('SSO', () => {
|
|
|
223
235
|
return [404];
|
|
224
236
|
});
|
|
225
237
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
226
|
-
const {
|
|
238
|
+
const { accessToken, profile } = yield workos.sso.getProfileAndToken({
|
|
227
239
|
code: 'authorization_code',
|
|
228
240
|
clientID: 'proj_123',
|
|
229
241
|
});
|
|
@@ -266,7 +278,7 @@ describe('SSO', () => {
|
|
|
266
278
|
});
|
|
267
279
|
expect(mock.history.get.length).toBe(1);
|
|
268
280
|
const { headers } = mock.history.get[0];
|
|
269
|
-
expect(headers.Authorization).toBe(`Bearer access_token`);
|
|
281
|
+
expect(headers === null || headers === void 0 ? void 0 : headers.Authorization).toBe(`Bearer access_token`);
|
|
270
282
|
expect(profile.id).toBe('prof_123');
|
|
271
283
|
}));
|
|
272
284
|
});
|
|
@@ -282,19 +294,24 @@ describe('SSO', () => {
|
|
|
282
294
|
describe('getConnection', () => {
|
|
283
295
|
it(`requests a Connection`, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
284
296
|
const mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
285
|
-
mock.onGet('/connections/conn_123').replyOnce(200,
|
|
297
|
+
mock.onGet('/connections/conn_123').replyOnce(200, connectionResponse);
|
|
286
298
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
287
|
-
yield workos.sso.getConnection('conn_123');
|
|
299
|
+
const subject = yield workos.sso.getConnection('conn_123');
|
|
288
300
|
expect(mock.history.get[0].url).toEqual('/connections/conn_123');
|
|
301
|
+
expect(subject.connectionType).toEqual('OktaSAML');
|
|
289
302
|
}));
|
|
290
303
|
});
|
|
291
304
|
describe('listConnections', () => {
|
|
292
305
|
it(`requests a list of Connections`, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
293
306
|
const mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
294
|
-
mock.onGet('/connections').replyOnce(200, {
|
|
307
|
+
mock.onGet('/connections').replyOnce(200, {
|
|
308
|
+
data: [connectionResponse],
|
|
309
|
+
list_metadata: {},
|
|
310
|
+
});
|
|
295
311
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
296
|
-
yield workos.sso.listConnections();
|
|
312
|
+
const subject = yield workos.sso.listConnections();
|
|
297
313
|
expect(mock.history.get[0].url).toEqual('/connections');
|
|
314
|
+
expect(subject.data).toHaveLength(1);
|
|
298
315
|
}));
|
|
299
316
|
});
|
|
300
317
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnexpectedUserTypeException = void 0;
|
|
4
|
+
class UnexpectedUserTypeException extends Error {
|
|
5
|
+
constructor(user) {
|
|
6
|
+
super();
|
|
7
|
+
this.message = `Unsupported user type: ${user.user_type} received from API.`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UnexpectedUserTypeException = UnexpectedUserTypeException;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface AuthenticateUserWithMagicAuthOptions {
|
|
2
|
+
clientId: string;
|
|
3
|
+
code: string;
|
|
4
|
+
magicAuthChallengeId: string;
|
|
5
|
+
ipAddress?: string;
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
expiresIn?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AuthenticateUserWithMagicAuthCredentials {
|
|
10
|
+
clientSecret: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface SerializedAuthenticateUserWithMagicAuthOptions {
|
|
13
|
+
grant_type: 'urn:workos:oauth:grant-type:magic-auth:code';
|
|
14
|
+
client_id: string;
|
|
15
|
+
client_secret: string | undefined;
|
|
16
|
+
code: string;
|
|
17
|
+
magic_auth_challenge_id: string;
|
|
18
|
+
ip_address?: string;
|
|
19
|
+
user_agent?: string;
|
|
20
|
+
expires_in?: number;
|
|
21
|
+
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
export interface AuthenticateUserWithPasswordOptions {
|
|
2
|
+
clientId: string;
|
|
3
|
+
email: string;
|
|
4
|
+
password: string;
|
|
5
|
+
ipAddress?: string;
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
expiresIn?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AuthenticateUserWithPasswordCredentials {
|
|
10
|
+
clientSecret: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface SerializedAuthenticateUserWithPasswordOptions {
|
|
13
|
+
grant_type: 'password';
|
|
14
|
+
client_id: string;
|
|
15
|
+
client_secret: string | undefined;
|
|
2
16
|
email: string;
|
|
3
17
|
password: string;
|
|
4
18
|
ip_address?: string;
|
|
5
19
|
user_agent?: string;
|
|
6
|
-
start_session?: boolean;
|
|
7
20
|
expires_in?: number;
|
|
8
21
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export interface AuthenticateUserWithTokenOptions {
|
|
2
|
+
clientId: string;
|
|
3
|
+
code: string;
|
|
4
|
+
expiresIn?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AuthenticateUserWithTokenCredentials {
|
|
7
|
+
clientSecret: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface SerializedAuthenticateUserWithTokenOptions {
|
|
10
|
+
grant_type: 'authorization_code';
|
|
2
11
|
client_id: string;
|
|
12
|
+
client_secret: string | undefined;
|
|
3
13
|
code: string;
|
|
4
|
-
start_session?: boolean;
|
|
5
14
|
expires_in?: number;
|
|
6
15
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { User } from './user.interface';
|
|
2
|
-
import { Session } from './session.interface';
|
|
1
|
+
import { User, UserResponse } from './user.interface';
|
|
2
|
+
import { Session, SessionResponse } from './session.interface';
|
|
3
3
|
export interface AuthenticationResponse {
|
|
4
|
-
session
|
|
4
|
+
session: Session;
|
|
5
5
|
user: User;
|
|
6
6
|
}
|
|
7
|
+
export interface AuthenticationResponseResponse {
|
|
8
|
+
session: SessionResponse;
|
|
9
|
+
user: UserResponse;
|
|
10
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { User } from './user.interface';
|
|
1
|
+
import { User, UserResponse } from './user.interface';
|
|
2
2
|
export interface CreateEmailVerificationChallengeOptions {
|
|
3
|
-
|
|
3
|
+
userId: string;
|
|
4
|
+
verificationUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SerializedCreateEmailVerificationChallengeOptions {
|
|
4
7
|
verification_url: string;
|
|
5
8
|
}
|
|
6
9
|
export interface CreateEmailVerificationChallengeResponse {
|
|
7
10
|
token: string;
|
|
8
11
|
user: User;
|
|
9
12
|
}
|
|
13
|
+
export interface CreateEmailVerificationChallengeResponseResponse {
|
|
14
|
+
token: string;
|
|
15
|
+
user: UserResponse;
|
|
16
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { User } from './user.interface';
|
|
1
|
+
import { User, UserResponse } from './user.interface';
|
|
2
2
|
export interface CreatePasswordResetChallengeOptions {
|
|
3
|
+
email: string;
|
|
4
|
+
passwordResetUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SerializedCreatePasswordResetChallengeOptions {
|
|
3
7
|
email: string;
|
|
4
8
|
password_reset_url: string;
|
|
5
9
|
}
|
|
@@ -7,3 +11,7 @@ export interface CreatePasswordResetChallengeResponse {
|
|
|
7
11
|
token: string;
|
|
8
12
|
user: User;
|
|
9
13
|
}
|
|
14
|
+
export interface CreatePasswordResetChallengeResponseResponse {
|
|
15
|
+
token: string;
|
|
16
|
+
user: UserResponse;
|
|
17
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export interface CreateUserOptions {
|
|
2
2
|
email: string;
|
|
3
|
-
password
|
|
3
|
+
password?: string;
|
|
4
|
+
firstName?: string;
|
|
5
|
+
lastName?: string;
|
|
6
|
+
emailVerified?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SerializedCreateUserOptions {
|
|
9
|
+
email: string;
|
|
10
|
+
password?: string;
|
|
4
11
|
first_name?: string;
|
|
5
12
|
last_name?: string;
|
|
6
13
|
email_verified?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './add-user-to-organization-options.interface';
|
|
2
|
+
export * from './authenticate-user-with-magic-auth-options.interface';
|
|
2
3
|
export * from './authenticate-user-with-password-options.interface';
|
|
3
4
|
export * from './authenticate-user-with-token-options.interface';
|
|
4
5
|
export * from './authentication-response.interface';
|
|
@@ -7,7 +8,13 @@ export * from './create-email-verification-challenge-options.interface';
|
|
|
7
8
|
export * from './create-password-reset-challenge-options.interface';
|
|
8
9
|
export * from './create-user-options.interface';
|
|
9
10
|
export * from './list-users-options.interface';
|
|
11
|
+
export * from './magic-auth-challenge.interface';
|
|
10
12
|
export * from './remove-user-from-organization-options.interface';
|
|
13
|
+
export * from './revoke-all-sessions-for-user-options.interface';
|
|
11
14
|
export * from './revoke-session-options.interface';
|
|
15
|
+
export * from './send-magic-auth-code-options.interface';
|
|
16
|
+
export * from './session.interface';
|
|
17
|
+
export * from './update-user-options.interface';
|
|
18
|
+
export * from './update-user-password-options.interface';
|
|
12
19
|
export * from './user.interface';
|
|
13
20
|
export * from './verify-session.interface';
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./add-user-to-organization-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./authenticate-user-with-magic-auth-options.interface"), exports);
|
|
18
19
|
__exportStar(require("./authenticate-user-with-password-options.interface"), exports);
|
|
19
20
|
__exportStar(require("./authenticate-user-with-token-options.interface"), exports);
|
|
20
21
|
__exportStar(require("./authentication-response.interface"), exports);
|
|
@@ -23,7 +24,13 @@ __exportStar(require("./create-email-verification-challenge-options.interface"),
|
|
|
23
24
|
__exportStar(require("./create-password-reset-challenge-options.interface"), exports);
|
|
24
25
|
__exportStar(require("./create-user-options.interface"), exports);
|
|
25
26
|
__exportStar(require("./list-users-options.interface"), exports);
|
|
27
|
+
__exportStar(require("./magic-auth-challenge.interface"), exports);
|
|
26
28
|
__exportStar(require("./remove-user-from-organization-options.interface"), exports);
|
|
29
|
+
__exportStar(require("./revoke-all-sessions-for-user-options.interface"), exports);
|
|
27
30
|
__exportStar(require("./revoke-session-options.interface"), exports);
|
|
31
|
+
__exportStar(require("./send-magic-auth-code-options.interface"), exports);
|
|
32
|
+
__exportStar(require("./session.interface"), exports);
|
|
33
|
+
__exportStar(require("./update-user-options.interface"), exports);
|
|
34
|
+
__exportStar(require("./update-user-password-options.interface"), exports);
|
|
28
35
|
__exportStar(require("./user.interface"), exports);
|
|
29
36
|
__exportStar(require("./verify-session.interface"), exports);
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export type RevokeSessionOptions = SessionId | SessionToken;
|
|
2
|
+
export type SerializedRevokeSessionOptions = SerializedSessionId | SerializedSessionToken;
|
|
2
3
|
interface SessionId {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
interface SerializedSessionId {
|
|
3
7
|
session_id: string;
|
|
4
8
|
}
|
|
5
9
|
interface SessionToken {
|
|
10
|
+
sessionToken: string;
|
|
11
|
+
}
|
|
12
|
+
interface SerializedSessionToken {
|
|
6
13
|
session_token: string;
|
|
7
14
|
}
|
|
8
15
|
export {};
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
export interface Session {
|
|
2
|
+
id: string;
|
|
3
|
+
createdAt: string;
|
|
4
|
+
expiresAt: string;
|
|
5
|
+
authorizedOrganizations: AuthorizedOrganization[];
|
|
6
|
+
unauthorizedOrganizations: UnauthorizedOrganization[];
|
|
7
|
+
token: string;
|
|
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
|
+
}
|
|
33
|
+
export interface SessionResponse {
|
|
2
34
|
id: string;
|
|
3
35
|
created_at: string;
|
|
4
36
|
expires_at: string;
|
|
37
|
+
authorized_organizations: AuthorizedOrganization[];
|
|
38
|
+
unauthorized_organizations: UnauthorizedOrganizationResponse[];
|
|
5
39
|
token: string;
|
|
6
40
|
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AtLeastOnePropertyOf } from '../../common/interfaces';
|
|
2
|
+
interface BaseUpdateUserOptions {
|
|
3
|
+
userId: string;
|
|
4
|
+
}
|
|
5
|
+
interface UpdateUserOptionsProperties {
|
|
6
|
+
firstName: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
}
|
|
9
|
+
export type UpdateUserOptions = BaseUpdateUserOptions & AtLeastOnePropertyOf<UpdateUserOptionsProperties>;
|
|
10
|
+
export interface SerializedUpdateUserOptions {
|
|
11
|
+
first_name?: string;
|
|
12
|
+
last_name?: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
export type User = ManagedUser |
|
|
1
|
+
export type User = ManagedUser | UnmanagedUser;
|
|
2
|
+
export type UserResponse = ManagedUserResponse | UnmanagedUserResponse;
|
|
2
3
|
interface ManagedUser extends BaseUser {
|
|
4
|
+
userType: 'managed';
|
|
5
|
+
ssoProfileId: string | null;
|
|
6
|
+
}
|
|
7
|
+
interface ManagedUserResponse extends BaseUserResponse {
|
|
3
8
|
user_type: 'managed';
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
sso_profile_id: string | null;
|
|
10
|
+
}
|
|
11
|
+
interface UnmanagedUser extends BaseUser {
|
|
12
|
+
userType: 'unmanaged';
|
|
13
|
+
emailVerifiedAt: string | null;
|
|
14
|
+
googleOauthProfileId: string | null;
|
|
15
|
+
microsoftOauthProfileId: string | null;
|
|
6
16
|
}
|
|
7
|
-
interface
|
|
17
|
+
interface UnmanagedUserResponse extends BaseUserResponse {
|
|
8
18
|
user_type: 'unmanaged';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
email_verified_at: string | null;
|
|
20
|
+
google_oauth_profile_id: string | null;
|
|
21
|
+
microsoft_oauth_profile_id: string | null;
|
|
12
22
|
}
|
|
13
|
-
interface BaseUser {
|
|
23
|
+
export interface BaseUser {
|
|
14
24
|
object: 'user';
|
|
15
25
|
id: string;
|
|
16
26
|
email: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
firstName: string | null;
|
|
28
|
+
lastName: string | null;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
21
31
|
}
|
|
22
|
-
interface
|
|
23
|
-
|
|
32
|
+
interface BaseUserResponse {
|
|
33
|
+
object: 'user';
|
|
34
|
+
id: string;
|
|
35
|
+
email: string;
|
|
36
|
+
first_name: string | null;
|
|
37
|
+
last_name: string | null;
|
|
24
38
|
created_at: string;
|
|
25
39
|
updated_at: string;
|
|
26
40
|
}
|
|
27
|
-
interface OrganizationSummary {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
}
|
|
31
41
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { User } from './user.interface';
|
|
2
|
-
import { Session } from './session.interface';
|
|
1
|
+
import { User, UserResponse } from './user.interface';
|
|
2
|
+
import { Session, SessionResponse } from './session.interface';
|
|
3
3
|
export interface VerifySessionOptions {
|
|
4
|
+
token: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SerializedVerifySessionOptions {
|
|
4
8
|
token: string;
|
|
5
9
|
client_id: string;
|
|
6
10
|
}
|
|
@@ -8,3 +12,7 @@ export interface VerifySessionResponse {
|
|
|
8
12
|
session: Session;
|
|
9
13
|
user: User;
|
|
10
14
|
}
|
|
15
|
+
export interface VerifySessionResponseResponse {
|
|
16
|
+
session: SessionResponse;
|
|
17
|
+
user: UserResponse;
|
|
18
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AuthenticateUserWithMagicAuthCredentials, AuthenticateUserWithMagicAuthOptions, SerializedAuthenticateUserWithMagicAuthOptions } from '../interfaces';
|
|
2
|
+
export declare const serializeAuthenticateUserWithMagicAuthOptions: (options: AuthenticateUserWithMagicAuthOptions & AuthenticateUserWithMagicAuthCredentials) => SerializedAuthenticateUserWithMagicAuthOptions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeAuthenticateUserWithMagicAuthOptions = void 0;
|
|
4
|
+
const serializeAuthenticateUserWithMagicAuthOptions = (options) => ({
|
|
5
|
+
grant_type: 'urn:workos:oauth:grant-type:magic-auth:code',
|
|
6
|
+
client_id: options.clientId,
|
|
7
|
+
client_secret: options.clientSecret,
|
|
8
|
+
code: options.code,
|
|
9
|
+
magic_auth_challenge_id: options.magicAuthChallengeId,
|
|
10
|
+
ip_address: options.ipAddress,
|
|
11
|
+
user_agent: options.userAgent,
|
|
12
|
+
expires_in: options.expiresIn,
|
|
13
|
+
});
|
|
14
|
+
exports.serializeAuthenticateUserWithMagicAuthOptions = serializeAuthenticateUserWithMagicAuthOptions;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AuthenticateUserWithPasswordCredentials, AuthenticateUserWithPasswordOptions, SerializedAuthenticateUserWithPasswordOptions } from '../interfaces';
|
|
2
|
+
export declare const serializeAuthenticateUserWithPasswordOptions: (options: AuthenticateUserWithPasswordOptions & AuthenticateUserWithPasswordCredentials) => SerializedAuthenticateUserWithPasswordOptions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeAuthenticateUserWithPasswordOptions = void 0;
|
|
4
|
+
const serializeAuthenticateUserWithPasswordOptions = (options) => ({
|
|
5
|
+
grant_type: 'password',
|
|
6
|
+
client_id: options.clientId,
|
|
7
|
+
client_secret: options.clientSecret,
|
|
8
|
+
email: options.email,
|
|
9
|
+
password: options.password,
|
|
10
|
+
ip_address: options.ipAddress,
|
|
11
|
+
user_agent: options.userAgent,
|
|
12
|
+
expires_in: options.expiresIn,
|
|
13
|
+
});
|
|
14
|
+
exports.serializeAuthenticateUserWithPasswordOptions = serializeAuthenticateUserWithPasswordOptions;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AuthenticateUserWithTokenCredentials, AuthenticateUserWithTokenOptions, SerializedAuthenticateUserWithTokenOptions } from '../interfaces';
|
|
2
|
+
export declare const serializeAuthenticateUserWithTokenOptions: (options: AuthenticateUserWithTokenOptions & AuthenticateUserWithTokenCredentials) => SerializedAuthenticateUserWithTokenOptions;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeAuthenticateUserWithTokenOptions = void 0;
|
|
4
|
+
const serializeAuthenticateUserWithTokenOptions = (options) => ({
|
|
5
|
+
grant_type: 'authorization_code',
|
|
6
|
+
client_id: options.clientId,
|
|
7
|
+
client_secret: options.clientSecret,
|
|
8
|
+
code: options.code,
|
|
9
|
+
expires_in: options.expiresIn,
|
|
10
|
+
});
|
|
11
|
+
exports.serializeAuthenticateUserWithTokenOptions = serializeAuthenticateUserWithTokenOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeAuthenticationResponse = void 0;
|
|
4
|
+
const session_serializer_1 = require("./session.serializer");
|
|
5
|
+
const user_serializer_1 = require("./user.serializer");
|
|
6
|
+
const deserializeAuthenticationResponse = (authenticationResponse) => ({
|
|
7
|
+
session: (0, session_serializer_1.deserializeSession)(authenticationResponse.session),
|
|
8
|
+
user: (0, user_serializer_1.deserializeUser)(authenticationResponse.user),
|
|
9
|
+
});
|
|
10
|
+
exports.deserializeAuthenticationResponse = deserializeAuthenticationResponse;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeCompletePasswordResetOptions = void 0;
|
|
4
|
+
const serializeCompletePasswordResetOptions = (options) => ({
|
|
5
|
+
token: options.token,
|
|
6
|
+
new_password: options.newPassword,
|
|
7
|
+
});
|
|
8
|
+
exports.serializeCompletePasswordResetOptions = serializeCompletePasswordResetOptions;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CreateEmailVerificationChallengeResponse, CreateEmailVerificationChallengeResponseResponse } from '../interfaces';
|
|
2
|
+
export declare const deserializeCreateEmailVerificationChallengeResponse: (createEmailVerificationChallengeResponse: CreateEmailVerificationChallengeResponseResponse) => CreateEmailVerificationChallengeResponse;
|