@workos-inc/node 7.69.0 → 7.69.1
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/sso/sso.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class SSO {
|
|
|
7
7
|
constructor(workos: WorkOS);
|
|
8
8
|
listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection>>;
|
|
9
9
|
deleteConnection(id: string): Promise<void>;
|
|
10
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerScopes, redirectUri, state, }: SSOAuthorizationURLOptions): string;
|
|
10
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerQueryParams, providerScopes, redirectUri, state, }: SSOAuthorizationURLOptions): string;
|
|
11
11
|
getConnection(id: string): Promise<Connection>;
|
|
12
12
|
getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
|
|
13
13
|
getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
|
package/lib/sso/sso.js
CHANGED
|
@@ -8,21 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.SSO = void 0;
|
|
16
|
+
const qs_1 = __importDefault(require("qs"));
|
|
13
17
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
14
18
|
const pagination_1 = require("../common/utils/pagination");
|
|
15
19
|
const serializers_1 = require("./serializers");
|
|
16
20
|
const toQueryString = (options) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return searchParams.toString();
|
|
21
|
+
return qs_1.default.stringify(options, {
|
|
22
|
+
arrayFormat: 'repeat',
|
|
23
|
+
// sorts the keys alphabetically to maintain backwards compatibility
|
|
24
|
+
sort: (a, b) => a.localeCompare(b),
|
|
25
|
+
// encodes space as + instead of %20 to maintain backwards compatibility
|
|
26
|
+
format: 'RFC1738',
|
|
27
|
+
});
|
|
26
28
|
};
|
|
27
29
|
class SSO {
|
|
28
30
|
constructor(workos) {
|
|
@@ -38,7 +40,7 @@ class SSO {
|
|
|
38
40
|
yield this.workos.delete(`/connections/${id}`);
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
|
-
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerScopes, redirectUri, state, }) {
|
|
43
|
+
getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, providerQueryParams, providerScopes, redirectUri, state, }) {
|
|
42
44
|
if (!domain && !provider && !connection && !organization) {
|
|
43
45
|
throw new Error(`Incomplete arguments. Need to specify either a 'connection', 'organization', 'domain', or 'provider'.`);
|
|
44
46
|
}
|
|
@@ -52,7 +54,8 @@ class SSO {
|
|
|
52
54
|
domain_hint: domainHint,
|
|
53
55
|
login_hint: loginHint,
|
|
54
56
|
provider,
|
|
55
|
-
|
|
57
|
+
provider_query_params: providerQueryParams,
|
|
58
|
+
provider_scopes: providerScopes,
|
|
56
59
|
client_id: clientId,
|
|
57
60
|
redirect_uri: redirectUri,
|
|
58
61
|
response_type: 'code',
|
package/lib/sso/sso.spec.js
CHANGED
|
@@ -170,7 +170,7 @@ describe('SSO', () => {
|
|
|
170
170
|
clientId: 'proj_123',
|
|
171
171
|
redirectUri: 'example.com/sso/workos/callback',
|
|
172
172
|
});
|
|
173
|
-
expect(url).
|
|
173
|
+
expect(url).toMatchSnapshot();
|
|
174
174
|
});
|
|
175
175
|
it('handles empty provider scopes array', () => {
|
|
176
176
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
@@ -183,6 +183,32 @@ describe('SSO', () => {
|
|
|
183
183
|
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
184
184
|
});
|
|
185
185
|
});
|
|
186
|
+
describe('with providerQueryParams', () => {
|
|
187
|
+
it('generates an authorize url with the provided provider query params', () => {
|
|
188
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
189
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
190
|
+
provider: 'Google',
|
|
191
|
+
providerQueryParams: {
|
|
192
|
+
custom_param: 'custom_value',
|
|
193
|
+
another_param: 123,
|
|
194
|
+
bool_param: true,
|
|
195
|
+
},
|
|
196
|
+
clientId: 'proj_123',
|
|
197
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
198
|
+
});
|
|
199
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&provider_query_params%5Banother_param%5D=123&provider_query_params%5Bbool_param%5D=true&provider_query_params%5Bcustom_param%5D=custom_value&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
200
|
+
});
|
|
201
|
+
it('handles empty provider query params', () => {
|
|
202
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
203
|
+
const url = workos.sso.getAuthorizationUrl({
|
|
204
|
+
provider: 'Google',
|
|
205
|
+
providerQueryParams: {},
|
|
206
|
+
clientId: 'proj_123',
|
|
207
|
+
redirectUri: 'example.com/sso/workos/callback',
|
|
208
|
+
});
|
|
209
|
+
expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&provider=Google&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
186
212
|
});
|
|
187
213
|
describe('getProfileAndToken', () => {
|
|
188
214
|
describe('with all information provided', () => {
|
package/lib/workos.js
CHANGED
|
@@ -32,7 +32,7 @@ const actions_1 = require("./actions/actions");
|
|
|
32
32
|
const vault_1 = require("./vault/vault");
|
|
33
33
|
const conflict_exception_1 = require("./common/exceptions/conflict.exception");
|
|
34
34
|
const parse_error_1 = require("./common/exceptions/parse-error");
|
|
35
|
-
const VERSION = '7.69.
|
|
35
|
+
const VERSION = '7.69.1';
|
|
36
36
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
37
37
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
38
38
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED