@workos-inc/node 4.0.1 → 4.0.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.
- package/lib/mfa/interfaces/factor.interface.d.ts +19 -3
- package/lib/mfa/interfaces/totp.interface.d.ts +6 -7
- package/lib/mfa/mfa.d.ts +2 -2
- package/lib/mfa/mfa.js +1 -1
- package/lib/mfa/mfa.spec.js +0 -6
- package/lib/mfa/serializers/factor.serializer.d.ts +2 -1
- package/lib/mfa/serializers/factor.serializer.js +4 -2
- package/lib/mfa/serializers/totp.serializer.d.ts +2 -1
- package/lib/mfa/serializers/totp.serializer.js +15 -16
- package/lib/sso/interfaces/authorization-url-options.interface.d.ts +1 -1
- package/lib/sso/sso.d.ts +1 -1
- package/lib/sso/sso.js +2 -2
- package/lib/sso/sso.spec.js +9 -9
- package/lib/user-management/fixtures/list-factors.json +0 -3
- package/lib/user-management/interfaces/authorization-url-options.interface.d.ts +1 -1
- package/lib/user-management/interfaces/factor.interface.d.ts +37 -0
- package/lib/user-management/interfaces/factor.interface.js +2 -0
- package/lib/user-management/serializers/factor.serializer.d.ts +3 -0
- package/lib/user-management/serializers/factor.serializer.js +24 -0
- package/lib/user-management/serializers/index.d.ts +1 -0
- package/lib/user-management/serializers/index.js +1 -0
- package/lib/user-management/user-management.d.ts +4 -3
- package/lib/user-management/user-management.js +5 -4
- package/lib/user-management/user-management.spec.js +9 -12
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sms, SmsResponse } from './sms.interface';
|
|
2
|
-
import { Totp, TotpResponse } from './totp.interface';
|
|
2
|
+
import { Totp, TotpResponse, TotpWithSecrets, TotpWithSecretsResponse } from './totp.interface';
|
|
3
3
|
type FactorType = 'sms' | 'totp' | 'generic_otp';
|
|
4
4
|
export interface Factor {
|
|
5
5
|
object: 'authentication_factor';
|
|
@@ -9,7 +9,15 @@ export interface Factor {
|
|
|
9
9
|
type: FactorType;
|
|
10
10
|
sms?: Sms;
|
|
11
11
|
totp?: Totp;
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
export interface FactorWithSecrets {
|
|
14
|
+
object: 'authentication_factor';
|
|
15
|
+
id: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
type: FactorType;
|
|
19
|
+
sms?: Sms;
|
|
20
|
+
totp?: TotpWithSecrets;
|
|
13
21
|
}
|
|
14
22
|
export interface FactorResponse {
|
|
15
23
|
object: 'authentication_factor';
|
|
@@ -19,6 +27,14 @@ export interface FactorResponse {
|
|
|
19
27
|
type: FactorType;
|
|
20
28
|
sms?: SmsResponse;
|
|
21
29
|
totp?: TotpResponse;
|
|
22
|
-
|
|
30
|
+
}
|
|
31
|
+
export interface FactorWithSecretsResponse {
|
|
32
|
+
object: 'authentication_factor';
|
|
33
|
+
id: string;
|
|
34
|
+
created_at: string;
|
|
35
|
+
updated_at: string;
|
|
36
|
+
type: FactorType;
|
|
37
|
+
sms?: SmsResponse;
|
|
38
|
+
totp?: TotpWithSecretsResponse;
|
|
23
39
|
}
|
|
24
40
|
export {};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface Totp {
|
|
2
2
|
issuer: string;
|
|
3
3
|
user: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TotpWithSecrets extends Totp {
|
|
4
6
|
qrCode: string;
|
|
5
7
|
secret: string;
|
|
6
8
|
uri: string;
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
export type Totp = TotpObject | TotpObjectWithOnlyIssuerAndUser;
|
|
10
|
-
interface TotpResponseObject {
|
|
10
|
+
export interface TotpResponse {
|
|
11
11
|
issuer: string;
|
|
12
12
|
user: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TotpWithSecretsResponse extends TotpResponse {
|
|
13
15
|
qr_code: string;
|
|
14
16
|
secret: string;
|
|
15
17
|
uri: string;
|
|
16
18
|
}
|
|
17
|
-
type TotpResponseObjectWithOnlyIssuerAndUser = Pick<TotpResponseObject, 'issuer' | 'user'>;
|
|
18
|
-
export type TotpResponse = TotpResponseObject | TotpResponseObjectWithOnlyIssuerAndUser;
|
|
19
|
-
export {};
|
package/lib/mfa/mfa.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
|
-
import { ChallengeFactorOptions, Challenge, EnrollFactorOptions, Factor, VerifyChallengeOptions, VerifyFactorOptions, VerifyResponse } from './interfaces';
|
|
2
|
+
import { ChallengeFactorOptions, Challenge, EnrollFactorOptions, Factor, VerifyChallengeOptions, VerifyFactorOptions, VerifyResponse, FactorWithSecrets } from './interfaces';
|
|
3
3
|
export declare class Mfa {
|
|
4
4
|
private readonly workos;
|
|
5
5
|
constructor(workos: WorkOS);
|
|
6
6
|
deleteFactor(id: string): Promise<void>;
|
|
7
7
|
getFactor(id: string): Promise<Factor>;
|
|
8
|
-
enrollFactor(options: EnrollFactorOptions): Promise<
|
|
8
|
+
enrollFactor(options: EnrollFactorOptions): Promise<FactorWithSecrets>;
|
|
9
9
|
challengeFactor(options: ChallengeFactorOptions): Promise<Challenge>;
|
|
10
10
|
/**
|
|
11
11
|
* @deprecated Please use `verifyChallenge` instead.
|
package/lib/mfa/mfa.js
CHANGED
package/lib/mfa/mfa.spec.js
CHANGED
|
@@ -28,9 +28,6 @@ describe('MFA', () => {
|
|
|
28
28
|
type: 'totp',
|
|
29
29
|
totp: {
|
|
30
30
|
issuer: 'WorkOS',
|
|
31
|
-
qrCode: 'qr-code-test',
|
|
32
|
-
secret: 'secret-test',
|
|
33
|
-
uri: 'uri-test',
|
|
34
31
|
user: 'some_user',
|
|
35
32
|
},
|
|
36
33
|
};
|
|
@@ -42,9 +39,6 @@ describe('MFA', () => {
|
|
|
42
39
|
type: 'totp',
|
|
43
40
|
totp: {
|
|
44
41
|
issuer: 'WorkOS',
|
|
45
|
-
qr_code: 'qr-code-test',
|
|
46
|
-
secret: 'secret-test',
|
|
47
|
-
uri: 'uri-test',
|
|
48
42
|
user: 'some_user',
|
|
49
43
|
},
|
|
50
44
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Factor, FactorResponse } from '../interfaces';
|
|
1
|
+
import { Factor, FactorResponse, FactorWithSecrets, FactorWithSecretsResponse } from '../interfaces';
|
|
2
2
|
export declare const deserializeFactor: (factor: FactorResponse) => Factor;
|
|
3
|
+
export declare const deserializeFactorWithSecrets: (factor: FactorWithSecretsResponse) => FactorWithSecrets;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeFactor = void 0;
|
|
3
|
+
exports.deserializeFactorWithSecrets = exports.deserializeFactor = void 0;
|
|
4
4
|
const sms_serializer_1 = require("./sms.serializer");
|
|
5
5
|
const totp_serializer_1 = require("./totp.serializer");
|
|
6
|
-
const deserializeFactor = (factor) => (Object.assign(Object.assign(
|
|
6
|
+
const deserializeFactor = (factor) => (Object.assign(Object.assign({ object: factor.object, id: factor.id, createdAt: factor.created_at, updatedAt: factor.updated_at, type: factor.type }, (factor.sms ? { sms: (0, sms_serializer_1.deserializeSms)(factor.sms) } : {})), (factor.totp ? { totp: (0, totp_serializer_1.deserializeTotp)(factor.totp) } : {})));
|
|
7
7
|
exports.deserializeFactor = deserializeFactor;
|
|
8
|
+
const deserializeFactorWithSecrets = (factor) => (Object.assign(Object.assign({ object: factor.object, id: factor.id, createdAt: factor.created_at, updatedAt: factor.updated_at, type: factor.type }, (factor.sms ? { sms: (0, sms_serializer_1.deserializeSms)(factor.sms) } : {})), (factor.totp ? { totp: (0, totp_serializer_1.deserializeTotpWithSecrets)(factor.totp) } : {})));
|
|
9
|
+
exports.deserializeFactorWithSecrets = deserializeFactorWithSecrets;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Totp, TotpResponse } from '../interfaces';
|
|
1
|
+
import { Totp, TotpResponse, TotpWithSecretsResponse, TotpWithSecrets } from '../interfaces';
|
|
2
2
|
export declare const deserializeTotp: (totp: TotpResponse) => Totp;
|
|
3
|
+
export declare const deserializeTotpWithSecrets: (totp: TotpWithSecretsResponse) => TotpWithSecrets;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeTotp = void 0;
|
|
3
|
+
exports.deserializeTotpWithSecrets = exports.deserializeTotp = void 0;
|
|
4
4
|
const deserializeTotp = (totp) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
qrCode: totp.qr_code,
|
|
10
|
-
secret: totp.secret,
|
|
11
|
-
uri: totp.uri,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return {
|
|
16
|
-
issuer: totp.issuer,
|
|
17
|
-
user: totp.user,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
5
|
+
return {
|
|
6
|
+
issuer: totp.issuer,
|
|
7
|
+
user: totp.user,
|
|
8
|
+
};
|
|
20
9
|
};
|
|
21
10
|
exports.deserializeTotp = deserializeTotp;
|
|
11
|
+
const deserializeTotpWithSecrets = (totp) => {
|
|
12
|
+
return {
|
|
13
|
+
issuer: totp.issuer,
|
|
14
|
+
user: totp.user,
|
|
15
|
+
qrCode: totp.qr_code,
|
|
16
|
+
secret: totp.secret,
|
|
17
|
+
uri: totp.uri,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.deserializeTotpWithSecrets = deserializeTotpWithSecrets;
|
package/lib/sso/sso.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class SSO {
|
|
|
6
6
|
constructor(workos: WorkOS);
|
|
7
7
|
listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection>>;
|
|
8
8
|
deleteConnection(id: string): Promise<void>;
|
|
9
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider,
|
|
9
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }: AuthorizationURLOptions): string;
|
|
10
10
|
getConnection(id: string): Promise<Connection>;
|
|
11
11
|
getProfileAndToken({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken>;
|
|
12
12
|
getProfile({ accessToken }: GetProfileOptions): Promise<Profile>;
|
package/lib/sso/sso.js
CHANGED
|
@@ -38,7 +38,7 @@ class SSO {
|
|
|
38
38
|
yield this.workos.delete(`/connections/${id}`);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider,
|
|
41
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }) {
|
|
42
42
|
if (!domain && !provider && !connection && !organization) {
|
|
43
43
|
throw new Error(`Incomplete arguments. Need to specify either a 'connection', 'organization', 'domain', or 'provider'.`);
|
|
44
44
|
}
|
|
@@ -53,7 +53,7 @@ class SSO {
|
|
|
53
53
|
login_hint: loginHint,
|
|
54
54
|
provider,
|
|
55
55
|
client_id: clientId,
|
|
56
|
-
redirect_uri:
|
|
56
|
+
redirect_uri: redirectUri,
|
|
57
57
|
response_type: 'code',
|
|
58
58
|
state,
|
|
59
59
|
});
|
package/lib/sso/sso.spec.js
CHANGED
|
@@ -36,7 +36,7 @@ describe('SSO', () => {
|
|
|
36
36
|
const url = workos.sso.getAuthorizationUrl({
|
|
37
37
|
domain: 'lyft.com',
|
|
38
38
|
clientId: 'proj_123',
|
|
39
|
-
|
|
39
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
40
40
|
});
|
|
41
41
|
expect(url).toMatchSnapshot();
|
|
42
42
|
});
|
|
@@ -46,7 +46,7 @@ describe('SSO', () => {
|
|
|
46
46
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
47
47
|
const urlFn = () => workos.sso.getAuthorizationUrl({
|
|
48
48
|
clientId: 'proj_123',
|
|
49
|
-
|
|
49
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
50
50
|
});
|
|
51
51
|
expect(urlFn).toThrowErrorMatchingSnapshot();
|
|
52
52
|
});
|
|
@@ -59,7 +59,7 @@ describe('SSO', () => {
|
|
|
59
59
|
const url = workos.sso.getAuthorizationUrl({
|
|
60
60
|
provider: 'Google',
|
|
61
61
|
clientId: 'proj_123',
|
|
62
|
-
|
|
62
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
63
63
|
});
|
|
64
64
|
expect(url).toMatchSnapshot();
|
|
65
65
|
});
|
|
@@ -72,7 +72,7 @@ describe('SSO', () => {
|
|
|
72
72
|
const url = workos.sso.getAuthorizationUrl({
|
|
73
73
|
connection: 'connection_123',
|
|
74
74
|
clientId: 'proj_123',
|
|
75
|
-
|
|
75
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
76
76
|
});
|
|
77
77
|
expect(url).toMatchSnapshot();
|
|
78
78
|
});
|
|
@@ -85,7 +85,7 @@ describe('SSO', () => {
|
|
|
85
85
|
const url = workos.sso.getAuthorizationUrl({
|
|
86
86
|
organization: 'organization_123',
|
|
87
87
|
clientId: 'proj_123',
|
|
88
|
-
|
|
88
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
89
89
|
});
|
|
90
90
|
expect(url).toMatchSnapshot();
|
|
91
91
|
});
|
|
@@ -98,7 +98,7 @@ describe('SSO', () => {
|
|
|
98
98
|
const url = workos.sso.getAuthorizationUrl({
|
|
99
99
|
domain: 'lyft.com',
|
|
100
100
|
clientId: 'proj_123',
|
|
101
|
-
|
|
101
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
102
102
|
});
|
|
103
103
|
expect(url).toMatchSnapshot();
|
|
104
104
|
});
|
|
@@ -109,7 +109,7 @@ describe('SSO', () => {
|
|
|
109
109
|
const url = workos.sso.getAuthorizationUrl({
|
|
110
110
|
domain: 'lyft.com',
|
|
111
111
|
clientId: 'proj_123',
|
|
112
|
-
|
|
112
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
113
113
|
state: 'custom state',
|
|
114
114
|
});
|
|
115
115
|
expect(url).toMatchSnapshot();
|
|
@@ -122,7 +122,7 @@ describe('SSO', () => {
|
|
|
122
122
|
domainHint: 'lyft.com',
|
|
123
123
|
connection: 'connection_123',
|
|
124
124
|
clientId: 'proj_123',
|
|
125
|
-
|
|
125
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
126
126
|
state: 'custom state',
|
|
127
127
|
});
|
|
128
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"`);
|
|
@@ -135,7 +135,7 @@ describe('SSO', () => {
|
|
|
135
135
|
loginHint: 'foo@workos.com',
|
|
136
136
|
connection: 'connection_123',
|
|
137
137
|
clientId: 'proj_123',
|
|
138
|
-
|
|
138
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
139
139
|
state: 'custom state',
|
|
140
140
|
});
|
|
141
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"`);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Totp, TotpResponse, TotpWithSecrets, TotpWithSecretsResponse } from '../../mfa/interfaces/totp.interface';
|
|
2
|
+
export interface Factor {
|
|
3
|
+
object: 'authentication_factor';
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
type: 'totp';
|
|
8
|
+
totp: Totp;
|
|
9
|
+
userId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FactorWithSecrets {
|
|
12
|
+
object: 'authentication_factor';
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
type: 'totp';
|
|
17
|
+
totp: TotpWithSecrets;
|
|
18
|
+
userId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FactorResponse {
|
|
21
|
+
object: 'authentication_factor';
|
|
22
|
+
id: string;
|
|
23
|
+
created_at: string;
|
|
24
|
+
updated_at: string;
|
|
25
|
+
type: 'totp';
|
|
26
|
+
totp: TotpResponse;
|
|
27
|
+
user_id: string;
|
|
28
|
+
}
|
|
29
|
+
export interface FactorWithSecretsResponse {
|
|
30
|
+
object: 'authentication_factor';
|
|
31
|
+
id: string;
|
|
32
|
+
created_at: string;
|
|
33
|
+
updated_at: string;
|
|
34
|
+
type: 'totp';
|
|
35
|
+
totp: TotpWithSecretsResponse;
|
|
36
|
+
user_id: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Factor, FactorResponse, FactorWithSecrets, FactorWithSecretsResponse } from '../interfaces/factor.interface';
|
|
2
|
+
export declare const deserializeFactor: (factor: FactorResponse) => Factor;
|
|
3
|
+
export declare const deserializeFactorWithSecrets: (factor: FactorWithSecretsResponse) => FactorWithSecrets;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeFactorWithSecrets = exports.deserializeFactor = void 0;
|
|
4
|
+
const totp_serializer_1 = require("../../mfa/serializers/totp.serializer");
|
|
5
|
+
const deserializeFactor = (factor) => ({
|
|
6
|
+
object: factor.object,
|
|
7
|
+
id: factor.id,
|
|
8
|
+
createdAt: factor.created_at,
|
|
9
|
+
updatedAt: factor.updated_at,
|
|
10
|
+
type: factor.type,
|
|
11
|
+
totp: (0, totp_serializer_1.deserializeTotp)(factor.totp),
|
|
12
|
+
userId: factor.user_id,
|
|
13
|
+
});
|
|
14
|
+
exports.deserializeFactor = deserializeFactor;
|
|
15
|
+
const deserializeFactorWithSecrets = (factor) => ({
|
|
16
|
+
object: factor.object,
|
|
17
|
+
id: factor.id,
|
|
18
|
+
createdAt: factor.created_at,
|
|
19
|
+
updatedAt: factor.updated_at,
|
|
20
|
+
type: factor.type,
|
|
21
|
+
totp: (0, totp_serializer_1.deserializeTotpWithSecrets)(factor.totp),
|
|
22
|
+
userId: factor.user_id,
|
|
23
|
+
});
|
|
24
|
+
exports.deserializeFactorWithSecrets = deserializeFactorWithSecrets;
|
|
@@ -4,6 +4,7 @@ export * from './authenticate-with-password-options.serializer';
|
|
|
4
4
|
export * from './authenticate-with-totp-options.serializer';
|
|
5
5
|
export * from './authentication-response.serializer';
|
|
6
6
|
export * from './enroll-auth-factor-options.serializer';
|
|
7
|
+
export * from './factor.serializer';
|
|
7
8
|
export * from './reset-password-options.serializer';
|
|
8
9
|
export * from './send-password-reset-email.serializer';
|
|
9
10
|
export * from './create-user-options.serializer';
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./authenticate-with-password-options.serializer"), exports
|
|
|
20
20
|
__exportStar(require("./authenticate-with-totp-options.serializer"), exports);
|
|
21
21
|
__exportStar(require("./authentication-response.serializer"), exports);
|
|
22
22
|
__exportStar(require("./enroll-auth-factor-options.serializer"), exports);
|
|
23
|
+
__exportStar(require("./factor.serializer"), exports);
|
|
23
24
|
__exportStar(require("./reset-password-options.serializer"), exports);
|
|
24
25
|
__exportStar(require("./send-password-reset-email.serializer"), exports);
|
|
25
26
|
__exportStar(require("./create-user-options.serializer"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
3
|
import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions } from './interfaces';
|
|
4
|
-
import { Challenge
|
|
4
|
+
import { Challenge } from '../mfa/interfaces';
|
|
5
5
|
import { OrganizationMembership } from './interfaces/organization-membership.interface';
|
|
6
6
|
import { ListOrganizationMembershipsOptions } from './interfaces/list-organization-memberships-options.interface';
|
|
7
7
|
import { CreateOrganizationMembershipOptions } from './interfaces/create-organization-membership-options.interface';
|
|
@@ -11,6 +11,7 @@ import { SendInvitationOptions } from './interfaces/send-invitation-options.inte
|
|
|
11
11
|
import { AuthorizationURLOptions } from './interfaces/authorization-url-options.interface';
|
|
12
12
|
import { AuthenticateWithEmailVerificationOptions } from './interfaces/authenticate-with-email-verification-options.interface';
|
|
13
13
|
import { AuthenticateWithOrganizationSelectionOptions } from './interfaces/authenticate-with-organization-selection.interface';
|
|
14
|
+
import { Factor, FactorWithSecrets } from './interfaces/factor.interface';
|
|
14
15
|
export declare class UserManagement {
|
|
15
16
|
private readonly workos;
|
|
16
17
|
constructor(workos: WorkOS);
|
|
@@ -36,7 +37,7 @@ export declare class UserManagement {
|
|
|
36
37
|
}>;
|
|
37
38
|
updateUser(payload: UpdateUserOptions): Promise<User>;
|
|
38
39
|
enrollAuthFactor(payload: EnrollAuthFactorOptions): Promise<{
|
|
39
|
-
authenticationFactor:
|
|
40
|
+
authenticationFactor: FactorWithSecrets;
|
|
40
41
|
authenticationChallenge: Challenge;
|
|
41
42
|
}>;
|
|
42
43
|
listAuthFactors(options: ListAuthFactorsOptions): Promise<AutoPaginatable<Factor>>;
|
|
@@ -49,5 +50,5 @@ export declare class UserManagement {
|
|
|
49
50
|
listInvitations(options: ListInvitationsOptions): Promise<AutoPaginatable<Invitation>>;
|
|
50
51
|
sendInvitation(payload: SendInvitationOptions): Promise<Invitation>;
|
|
51
52
|
revokeInvitation(invitationId: string): Promise<Invitation>;
|
|
52
|
-
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider,
|
|
53
|
+
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, }: AuthorizationURLOptions): string;
|
|
53
54
|
}
|
|
@@ -23,6 +23,7 @@ const send_invitation_options_serializer_1 = require("./serializers/send-invitat
|
|
|
23
23
|
const list_users_options_serializer_1 = require("./serializers/list-users-options.serializer");
|
|
24
24
|
const authenticate_with_email_verification_serializer_1 = require("./serializers/authenticate-with-email-verification.serializer");
|
|
25
25
|
const authenticate_with_organization_selection_options_serializer_1 = require("./serializers/authenticate-with-organization-selection-options.serializer");
|
|
26
|
+
const factor_serializer_1 = require("./serializers/factor.serializer");
|
|
26
27
|
const toQueryString = (options) => {
|
|
27
28
|
const searchParams = new URLSearchParams();
|
|
28
29
|
const keys = Object.keys(options).sort();
|
|
@@ -131,14 +132,14 @@ class UserManagement {
|
|
|
131
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
133
|
const { data } = yield this.workos.post(`/user_management/users/${payload.userId}/auth_factors`, (0, serializers_1.serializeEnrollAuthFactorOptions)(payload));
|
|
133
134
|
return {
|
|
134
|
-
authenticationFactor: (0,
|
|
135
|
+
authenticationFactor: (0, serializers_1.deserializeFactorWithSecrets)(data.authentication_factor),
|
|
135
136
|
authenticationChallenge: (0, serializers_2.deserializeChallenge)(data.authentication_challenge),
|
|
136
137
|
};
|
|
137
138
|
});
|
|
138
139
|
}
|
|
139
140
|
listAuthFactors(options) {
|
|
140
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${options.userId}/auth_factors`,
|
|
142
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${options.userId}/auth_factors`, factor_serializer_1.deserializeFactor, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${options.userId}/auth_factors`, factor_serializer_1.deserializeFactor, params), options);
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
145
|
deleteUser(userId) {
|
|
@@ -193,7 +194,7 @@ class UserManagement {
|
|
|
193
194
|
return (0, invitation_serializer_1.deserializeInvitation)(data);
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
|
-
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider,
|
|
197
|
+
getAuthorizationUrl({ connectionId, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, }) {
|
|
197
198
|
if (!provider && !connectionId && !organizationId) {
|
|
198
199
|
throw new Error(`Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.`);
|
|
199
200
|
}
|
|
@@ -204,7 +205,7 @@ class UserManagement {
|
|
|
204
205
|
login_hint: loginHint,
|
|
205
206
|
provider,
|
|
206
207
|
client_id: clientId,
|
|
207
|
-
redirect_uri:
|
|
208
|
+
redirect_uri: redirectUri,
|
|
208
209
|
response_type: 'code',
|
|
209
210
|
state,
|
|
210
211
|
});
|
|
@@ -429,9 +429,6 @@ describe('UserManagement', () => {
|
|
|
429
429
|
type: 'totp',
|
|
430
430
|
totp: {
|
|
431
431
|
issuer: 'WorkOS',
|
|
432
|
-
qrCode: 'qr-code-test',
|
|
433
|
-
secret: 'secret-test',
|
|
434
|
-
uri: 'uri-test',
|
|
435
432
|
user: 'some_user',
|
|
436
433
|
},
|
|
437
434
|
},
|
|
@@ -645,7 +642,7 @@ describe('UserManagement', () => {
|
|
|
645
642
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
646
643
|
provider: 'Google',
|
|
647
644
|
clientId: 'proj_123',
|
|
648
|
-
|
|
645
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
649
646
|
});
|
|
650
647
|
expect(url).toMatchSnapshot();
|
|
651
648
|
});
|
|
@@ -655,7 +652,7 @@ describe('UserManagement', () => {
|
|
|
655
652
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
656
653
|
const urlFn = () => workos.userManagement.getAuthorizationUrl({
|
|
657
654
|
clientId: 'proj_123',
|
|
658
|
-
|
|
655
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
659
656
|
});
|
|
660
657
|
expect(urlFn).toThrowErrorMatchingSnapshot();
|
|
661
658
|
});
|
|
@@ -666,7 +663,7 @@ describe('UserManagement', () => {
|
|
|
666
663
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
667
664
|
provider: 'Google',
|
|
668
665
|
clientId: 'proj_123',
|
|
669
|
-
|
|
666
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
670
667
|
});
|
|
671
668
|
expect(url).toMatchSnapshot();
|
|
672
669
|
});
|
|
@@ -677,7 +674,7 @@ describe('UserManagement', () => {
|
|
|
677
674
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
678
675
|
connectionId: 'connection_123',
|
|
679
676
|
clientId: 'proj_123',
|
|
680
|
-
|
|
677
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
681
678
|
});
|
|
682
679
|
expect(url).toMatchSnapshot();
|
|
683
680
|
});
|
|
@@ -688,7 +685,7 @@ describe('UserManagement', () => {
|
|
|
688
685
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
689
686
|
organizationId: 'organization_123',
|
|
690
687
|
clientId: 'proj_123',
|
|
691
|
-
|
|
688
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
692
689
|
});
|
|
693
690
|
expect(url).toMatchSnapshot();
|
|
694
691
|
});
|
|
@@ -701,7 +698,7 @@ describe('UserManagement', () => {
|
|
|
701
698
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
702
699
|
organizationId: 'organization_123',
|
|
703
700
|
clientId: 'proj_123',
|
|
704
|
-
|
|
701
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
705
702
|
});
|
|
706
703
|
expect(url).toMatchSnapshot();
|
|
707
704
|
});
|
|
@@ -712,7 +709,7 @@ describe('UserManagement', () => {
|
|
|
712
709
|
const url = workos.userManagement.getAuthorizationUrl({
|
|
713
710
|
organizationId: 'organization_123',
|
|
714
711
|
clientId: 'proj_123',
|
|
715
|
-
|
|
712
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
716
713
|
state: 'custom state',
|
|
717
714
|
});
|
|
718
715
|
expect(url).toMatchSnapshot();
|
|
@@ -725,7 +722,7 @@ describe('UserManagement', () => {
|
|
|
725
722
|
domainHint: 'example.com',
|
|
726
723
|
connectionId: 'connection_123',
|
|
727
724
|
clientId: 'proj_123',
|
|
728
|
-
|
|
725
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
729
726
|
state: 'custom state',
|
|
730
727
|
});
|
|
731
728
|
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/user_management/authorize?client_id=proj_123&connection_id=connection_123&domain_hint=example.com&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
|
|
@@ -738,7 +735,7 @@ describe('UserManagement', () => {
|
|
|
738
735
|
loginHint: 'foo@workos.com',
|
|
739
736
|
connectionId: 'connection_123',
|
|
740
737
|
clientId: 'proj_123',
|
|
741
|
-
|
|
738
|
+
redirectUri: 'example.com/auth/workos/callback',
|
|
742
739
|
state: 'custom state',
|
|
743
740
|
});
|
|
744
741
|
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/user_management/authorize?client_id=proj_123&connection_id=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
|
package/lib/workos.js
CHANGED
|
@@ -27,7 +27,7 @@ const mfa_1 = require("./mfa/mfa");
|
|
|
27
27
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
28
28
|
const user_management_1 = require("./user-management/user-management");
|
|
29
29
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
30
|
-
const VERSION = '4.0.
|
|
30
|
+
const VERSION = '4.0.2';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
class WorkOS {
|
|
33
33
|
constructor(key, options = {}) {
|
package/package.json
CHANGED