@workos-inc/node 2.12.0 → 2.13.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.
@@ -1,4 +1,5 @@
1
1
  export declare enum GeneratePortalLinkIntent {
2
- SSO = "sso",
3
- DSync = "dsync"
2
+ AuditLogs = "audit_logs",
3
+ DSync = "dsync",
4
+ SSO = "sso"
4
5
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GeneratePortalLinkIntent = void 0;
4
4
  var GeneratePortalLinkIntent;
5
5
  (function (GeneratePortalLinkIntent) {
6
- GeneratePortalLinkIntent["SSO"] = "sso";
6
+ GeneratePortalLinkIntent["AuditLogs"] = "audit_logs";
7
7
  GeneratePortalLinkIntent["DSync"] = "dsync";
8
+ GeneratePortalLinkIntent["SSO"] = "sso";
8
9
  })(GeneratePortalLinkIntent = exports.GeneratePortalLinkIntent || (exports.GeneratePortalLinkIntent = {}));
@@ -58,6 +58,23 @@ describe('Portal', () => {
58
58
  expect(link).toEqual('https://id.workos.com/portal/launch?secret=secret');
59
59
  }));
60
60
  });
61
+ describe('with the `audit_logs` intent', () => {
62
+ it('returns an Admin Portal link', () => __awaiter(void 0, void 0, void 0, function* () {
63
+ mock
64
+ .onPost('/portal/generate_link', {
65
+ intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.AuditLogs,
66
+ organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3',
67
+ return_url: 'https://www.example.com',
68
+ })
69
+ .reply(201, generate_link_json_1.default);
70
+ const { link } = yield workos.portal.generateLink({
71
+ intent: generate_portal_link_intent_interface_1.GeneratePortalLinkIntent.AuditLogs,
72
+ organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3',
73
+ returnUrl: 'https://www.example.com',
74
+ });
75
+ expect(link).toEqual('https://id.workos.com/portal/launch?secret=secret');
76
+ }));
77
+ });
61
78
  });
62
79
  describe('with an invalid organization', () => {
63
80
  it('throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -1 +1 @@
1
- { "id": "wh_123", "data": { "id": "directory_user_01FAEAJCR3ZBZ30D8BD1924TVG", "state": "active", "emails": [{ "type": "work", "value": "blair@foo-corp.com", "primary": true }], "idp_id": "00u1e8mutl6wlH3lL4x7", "object": "directory_user", "username": "blair@foo-corp.com", "last_name": "Lunceford", "first_name": "Blair", "directory_id": "directory_01F9M7F68PZP8QXP8G7X5QRHS7", "raw_attributes": { "name": { "givenName": "Blair", "familyName": "Lunceford", "middleName": "Elizabeth", "honorificPrefix": "Ms." }, "title": "Developer Success Engineer", "active": true, "emails": [{ "type": "work", "value": "blair@foo-corp.com", "primary": true }], "groups": [], "locale": "en-US", "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"], "userName": "blair@foo-corp.com", "addresses": [{ "region": "CO", "primary": true, "locality": "Steamboat Springs", "postalCode": "80487" }], "externalId": "00u1e8mutl6wlH3lL4x7", "displayName": "Blair Lunceford", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "2", "displayName": "Kathleen Chung" }, "division": "Engineering", "department": "Customer Success" } } }, "event": "dsync.user.created" }
1
+ { "id": "wh_123", "data": { "id": "directory_user_01FAEAJCR3ZBZ30D8BD1924TVG", "state": "active", "emails": [{ "type": "work", "value": "blair@foo-corp.com", "primary": true }], "idp_id": "00u1e8mutl6wlH3lL4x7", "object": "directory_user", "username": "blair@foo-corp.com", "last_name": "Lunchford", "first_name": "Blair", "directory_id": "directory_01F9M7F68PZP8QXP8G7X5QRHS7", "raw_attributes": { "name": { "givenName": "Blair", "familyName": "Lunchford", "middleName": "Elizabeth", "honorificPrefix": "Ms." }, "title": "Developer Success Engineer", "active": true, "emails": [{ "type": "work", "value": "blair@foo-corp.com", "primary": true }], "groups": [], "locale": "en-US", "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"], "userName": "blair@foo-corp.com", "addresses": [{ "region": "CA", "primary": true, "locality": "San Francisco", "postalCode": "94016" }], "externalId": "00u1e8mutl6wlH3lL4x7", "displayName": "Blair Lunchford", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "2", "displayName": "Kate Chapman" }, "division": "Engineering", "department": "Customer Success" } } }, "event": "dsync.user.created" }
@@ -6,8 +6,13 @@ export declare class Webhooks {
6
6
  secret: string;
7
7
  tolerance?: number;
8
8
  }): Webhook;
9
- private verifyHeader;
10
- private getTimestampAndSignatureHash;
11
- private computeSignature;
12
- private secureCompare;
9
+ verifyHeader({ payload, sigHeader, secret, tolerance, }: {
10
+ payload: any;
11
+ sigHeader: string;
12
+ secret: string;
13
+ tolerance?: number;
14
+ }): boolean;
15
+ getTimestampAndSignatureHash(sigHeader: string): string[];
16
+ computeSignature(timestamp: any, payload: any, secret: string): string;
17
+ secureCompare(stringA: string, stringB: string): boolean;
13
18
  }
@@ -38,13 +38,13 @@ describe('Webhooks', () => {
38
38
  idp_id: '00u1e8mutl6wlH3lL4x7',
39
39
  object: 'directory_user',
40
40
  username: 'blair@foo-corp.com',
41
- last_name: 'Lunceford',
41
+ last_name: 'Lunchford',
42
42
  first_name: 'Blair',
43
43
  directory_id: 'directory_01F9M7F68PZP8QXP8G7X5QRHS7',
44
44
  raw_attributes: {
45
45
  name: {
46
46
  givenName: 'Blair',
47
- familyName: 'Lunceford',
47
+ familyName: 'Lunchford',
48
48
  middleName: 'Elizabeth',
49
49
  honorificPrefix: 'Ms.',
50
50
  },
@@ -66,18 +66,18 @@ describe('Webhooks', () => {
66
66
  userName: 'blair@foo-corp.com',
67
67
  addresses: [
68
68
  {
69
- region: 'CO',
69
+ region: 'CA',
70
70
  primary: true,
71
- locality: 'Steamboat Springs',
72
- postalCode: '80487',
71
+ locality: 'San Francisco',
72
+ postalCode: '94016',
73
73
  },
74
74
  ],
75
75
  externalId: '00u1e8mutl6wlH3lL4x7',
76
- displayName: 'Blair Lunceford',
76
+ displayName: 'Blair Lunchford',
77
77
  'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User': {
78
78
  manager: {
79
79
  value: '2',
80
- displayName: 'Kathleen Chung',
80
+ displayName: 'Kate Chapman',
81
81
  },
82
82
  division: 'Engineering',
83
83
  department: 'Customer Success',
@@ -151,4 +151,27 @@ describe('Webhooks', () => {
151
151
  });
152
152
  });
153
153
  });
154
+ describe('verifyHeader', () => {
155
+ it('returns true when the signature is valid', () => {
156
+ const sigHeader = `t=${timestamp}, v1=${signatureHash}`;
157
+ const options = { payload, sigHeader, secret };
158
+ expect(() => workos.webhooks.verifyHeader(options)).toBeTruthy();
159
+ });
160
+ });
161
+ describe('getTimestampAndSignatureHash', () => {
162
+ it('returns the timestamp and signature when the signature is valid', () => {
163
+ const sigHeader = `t=${timestamp}, v1=${signatureHash}`;
164
+ const timestampAndSignature = workos.webhooks.getTimestampAndSignatureHash(sigHeader);
165
+ expect(timestampAndSignature).toEqual([
166
+ timestamp.toString(),
167
+ signatureHash,
168
+ ]);
169
+ });
170
+ });
171
+ describe('computeSignature', () => {
172
+ it('returns the computed signature', () => {
173
+ const signature = workos.webhooks.computeSignature(timestamp, payload, secret);
174
+ expect(signature).toEqual(signatureHash);
175
+ });
176
+ });
154
177
  });
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.12.0';
28
+ const VERSION = '2.13.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.12.0",
2
+ "version": "2.13.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/jest": "27.5.2",
43
- "@types/node": "14.18.24",
43
+ "@types/node": "14.18.29",
44
44
  "@types/pluralize": "0.0.29",
45
45
  "axios-mock-adapter": "1.21.2",
46
46
  "jest": "27.5.1",
@@ -48,6 +48,6 @@
48
48
  "supertest": "6.2.3",
49
49
  "ts-jest": "27.1.5",
50
50
  "tslint": "6.1.3",
51
- "typescript": "4.7.4"
51
+ "typescript": "4.8.3"
52
52
  }
53
53
  }