@workos-inc/node 2.16.0 → 2.17.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.
@@ -8,6 +8,7 @@ export interface Profile {
8
8
  email: string;
9
9
  first_name?: string;
10
10
  last_name?: string;
11
+ groups?: string[];
11
12
  raw_attributes?: {
12
13
  [key: string]: any;
13
14
  };
@@ -132,6 +132,59 @@ describe('SSO', () => {
132
132
  });
133
133
  describe('getProfileAndToken', () => {
134
134
  describe('with all information provided', () => {
135
+ it('sends a request to the WorkOS api for a profile', () => __awaiter(void 0, void 0, void 0, function* () {
136
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
137
+ const expectedBody = new URLSearchParams({
138
+ client_id: 'proj_123',
139
+ client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
140
+ code: 'authorization_code',
141
+ grant_type: 'authorization_code',
142
+ });
143
+ expectedBody.sort();
144
+ mock.onPost('/sso/token').replyOnce((config) => {
145
+ const actualBody = new URLSearchParams(config.data);
146
+ actualBody.sort();
147
+ if (actualBody.toString() === expectedBody.toString()) {
148
+ return [
149
+ 200,
150
+ {
151
+ access_token: '01DMEK0J53CVMC32CK5SE0KZ8Q',
152
+ profile: {
153
+ id: 'prof_123',
154
+ idp_id: '123',
155
+ organization_id: 'org_123',
156
+ connection_id: 'conn_123',
157
+ connection_type: 'OktaSAML',
158
+ email: 'foo@test.com',
159
+ first_name: 'foo',
160
+ last_name: 'bar',
161
+ groups: ['Admins', 'Developers'],
162
+ raw_attributes: {
163
+ email: 'foo@test.com',
164
+ first_name: 'foo',
165
+ last_name: 'bar',
166
+ groups: ['Admins', 'Developers'],
167
+ },
168
+ },
169
+ },
170
+ ];
171
+ }
172
+ return [404];
173
+ });
174
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
175
+ const { access_token: accessToken, profile } = yield workos.sso.getProfileAndToken({
176
+ code: 'authorization_code',
177
+ clientID: 'proj_123',
178
+ });
179
+ expect(mock.history.post.length).toBe(1);
180
+ const { data, headers } = mock.history.post[0];
181
+ expect(data).toMatchSnapshot();
182
+ expect(headers).toMatchSnapshot();
183
+ expect(accessToken).toBe('01DMEK0J53CVMC32CK5SE0KZ8Q');
184
+ expect(profile).toMatchSnapshot();
185
+ }));
186
+ });
187
+ describe('without a groups attribute', () => {
135
188
  it('sends a request to the WorkOS api for a profile', () => __awaiter(void 0, void 0, void 0, function* () {
136
189
  const mock = new axios_mock_adapter_1.default(axios_1.default);
137
190
  const expectedBody = new URLSearchParams({
@@ -199,10 +252,12 @@ describe('SSO', () => {
199
252
  email: 'foo@test.com',
200
253
  first_name: 'foo',
201
254
  last_name: 'bar',
255
+ groups: ['Admins', 'Developers'],
202
256
  raw_attributes: {
203
257
  email: 'foo@test.com',
204
258
  first_name: 'foo',
205
259
  last_name: 'bar',
260
+ groups: ['Admins', 'Developers'],
206
261
  },
207
262
  });
208
263
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
package/lib/workos.js CHANGED
@@ -25,7 +25,7 @@ const webhooks_1 = require("./webhooks/webhooks");
25
25
  const mfa_1 = require("./mfa/mfa");
26
26
  const audit_logs_1 = require("./audit-logs/audit-logs");
27
27
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
28
- const VERSION = '2.16.0';
28
+ const VERSION = '2.17.0';
29
29
  const DEFAULT_HOSTNAME = 'api.workos.com';
30
30
  class WorkOS {
31
31
  constructor(key, options = {}) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.16.0",
2
+ "version": "2.17.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -9,7 +9,7 @@
9
9
  "workos"
10
10
  ],
11
11
  "volta": {
12
- "node": "14.21.1",
12
+ "node": "14.21.2",
13
13
  "yarn": "1.22.19"
14
14
  },
15
15
  "main": "lib/index.js",
@@ -40,14 +40,14 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/jest": "27.5.2",
43
- "@types/node": "14.18.34",
43
+ "@types/node": "14.18.36",
44
44
  "@types/pluralize": "0.0.29",
45
45
  "axios-mock-adapter": "1.21.2",
46
46
  "jest": "27.5.1",
47
- "prettier": "2.8.1",
47
+ "prettier": "2.8.3",
48
48
  "supertest": "6.2.3",
49
49
  "ts-jest": "27.1.5",
50
50
  "tslint": "6.1.3",
51
- "typescript": "4.9.4"
51
+ "typescript": "4.9.5"
52
52
  }
53
53
  }