@workos-inc/node 7.71.0 → 7.72.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.
@@ -0,0 +1,7 @@
1
+ import { WorkOS } from '../workos';
2
+ import { ValidateApiKeyOptions, ValidateApiKeyResponse } from './interfaces/validate-api-key.interface';
3
+ export declare class ApiKeys {
4
+ private readonly workos;
5
+ constructor(workos: WorkOS);
6
+ validateApiKey(payload: ValidateApiKeyOptions): Promise<ValidateApiKeyResponse>;
7
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApiKeys = void 0;
13
+ const validate_api_key_serializer_1 = require("./serializers/validate-api-key.serializer");
14
+ class ApiKeys {
15
+ constructor(workos) {
16
+ this.workos = workos;
17
+ }
18
+ validateApiKey(payload) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const { data } = yield this.workos.post('/api_keys/validations', payload);
21
+ return (0, validate_api_key_serializer_1.deserializeValidateApiKeyResponse)(data);
22
+ });
23
+ }
24
+ }
25
+ exports.ApiKeys = ApiKeys;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
16
+ const test_utils_1 = require("../common/utils/test-utils");
17
+ const workos_1 = require("../workos");
18
+ const validate_api_key_json_1 = __importDefault(require("./fixtures/validate-api-key.json"));
19
+ describe('ApiKeys', () => {
20
+ let workos;
21
+ beforeAll(() => {
22
+ workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU', {
23
+ apiHostname: 'api.workos.test',
24
+ clientId: 'proj_123',
25
+ });
26
+ });
27
+ beforeEach(() => jest_fetch_mock_1.default.resetMocks());
28
+ describe('validateApiKey', () => {
29
+ it('sends a validate API key request', () => __awaiter(void 0, void 0, void 0, function* () {
30
+ (0, test_utils_1.fetchOnce)(validate_api_key_json_1.default);
31
+ const response = yield workos.apiKeys.validateApiKey({
32
+ value: 'sk_123',
33
+ });
34
+ expect((0, test_utils_1.fetchURL)()).toContain('/api_keys/validations');
35
+ expect(response).toEqual({
36
+ apiKey: {
37
+ object: 'api_key',
38
+ id: 'api_key_01H5JQDV7R7ATEYZDEG0W5PRYS',
39
+ owner: {
40
+ type: 'organization',
41
+ id: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
42
+ },
43
+ name: 'Test Api Key',
44
+ obfuscatedValue: 'sk_…PRYS',
45
+ lastUsedAt: null,
46
+ permissions: ['read', 'write'],
47
+ createdAt: '2023-07-18T02:07:19.911Z',
48
+ updatedAt: '2023-07-18T02:07:19.911Z',
49
+ },
50
+ });
51
+ }));
52
+ it('returns null if key is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
53
+ (0, test_utils_1.fetchOnce)({ api_key: null });
54
+ const response = yield workos.apiKeys.validateApiKey({
55
+ value: 'invalid',
56
+ });
57
+ expect((0, test_utils_1.fetchURL)()).toContain('/api_keys/validations');
58
+ expect(response).toEqual({ apiKey: null });
59
+ }));
60
+ });
61
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "api_key": {
3
+ "object": "api_key",
4
+ "id": "api_key_01H5JQDV7R7ATEYZDEG0W5PRYS",
5
+ "owner": {
6
+ "type": "organization",
7
+ "id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS"
8
+ },
9
+ "name": "Test Api Key",
10
+ "obfuscated_value": "sk_…PRYS",
11
+ "last_used_at": null,
12
+ "permissions": ["read", "write"],
13
+ "created_at": "2023-07-18T02:07:19.911Z",
14
+ "updated_at": "2023-07-18T02:07:19.911Z"
15
+ }
16
+ }
@@ -0,0 +1,28 @@
1
+ export interface ApiKey {
2
+ object: 'api_key';
3
+ id: string;
4
+ owner: {
5
+ type: 'organization';
6
+ id: string;
7
+ };
8
+ name: string;
9
+ obfuscatedValue: string;
10
+ lastUsedAt: string | null;
11
+ permissions: string[];
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }
15
+ export interface SerializedApiKey {
16
+ object: 'api_key';
17
+ id: string;
18
+ owner: {
19
+ type: 'organization';
20
+ id: string;
21
+ };
22
+ name: string;
23
+ obfuscated_value: string;
24
+ last_used_at: string | null;
25
+ permissions: string[];
26
+ created_at: string;
27
+ updated_at: string;
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { ApiKey, SerializedApiKey } from './api-key.interface';
2
+ export interface ValidateApiKeyOptions {
3
+ value: string;
4
+ }
5
+ export interface ValidateApiKeyResponse {
6
+ apiKey: ApiKey | null;
7
+ }
8
+ export interface SerializedValidateApiKeyResponse {
9
+ api_key: SerializedApiKey | null;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { ApiKey, SerializedApiKey } from '../interfaces/api-key.interface';
2
+ export declare function deserializeApiKey(apiKey: SerializedApiKey): ApiKey;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeApiKey = void 0;
4
+ function deserializeApiKey(apiKey) {
5
+ return {
6
+ object: apiKey.object,
7
+ id: apiKey.id,
8
+ owner: apiKey.owner,
9
+ name: apiKey.name,
10
+ obfuscatedValue: apiKey.obfuscated_value,
11
+ lastUsedAt: apiKey.last_used_at,
12
+ permissions: apiKey.permissions,
13
+ createdAt: apiKey.created_at,
14
+ updatedAt: apiKey.updated_at,
15
+ };
16
+ }
17
+ exports.deserializeApiKey = deserializeApiKey;
@@ -0,0 +1,2 @@
1
+ import { SerializedValidateApiKeyResponse, ValidateApiKeyResponse } from '../interfaces/validate-api-key.interface';
2
+ export declare function deserializeValidateApiKeyResponse(response: SerializedValidateApiKeyResponse): ValidateApiKeyResponse;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeValidateApiKeyResponse = void 0;
4
+ const api_key_serializer_1 = require("./api-key.serializer");
5
+ function deserializeValidateApiKeyResponse(response) {
6
+ return {
7
+ apiKey: response.api_key ? (0, api_key_serializer_1.deserializeApiKey)(response.api_key) : null,
8
+ };
9
+ }
10
+ exports.deserializeValidateApiKeyResponse = deserializeValidateApiKeyResponse;
package/lib/workos.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GetOptions, PostOptions, PutOptions, WorkOSOptions } from './common/interfaces';
2
+ import { ApiKeys } from './api-keys/api-keys';
2
3
  import { DirectorySync } from './directory-sync/directory-sync';
3
4
  import { Events } from './events/events';
4
5
  import { Organizations } from './organizations/organizations';
@@ -24,6 +25,7 @@ export declare class WorkOS {
24
25
  readonly client: HttpClient;
25
26
  readonly clientId?: string;
26
27
  readonly actions: Actions;
28
+ readonly apiKeys: ApiKeys;
27
29
  readonly auditLogs: AuditLogs;
28
30
  readonly directorySync: DirectorySync;
29
31
  readonly organizations: Organizations;
package/lib/workos.js CHANGED
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.WorkOS = void 0;
13
13
  const exceptions_1 = require("./common/exceptions");
14
+ const api_keys_1 = require("./api-keys/api-keys");
14
15
  const directory_sync_1 = require("./directory-sync/directory-sync");
15
16
  const events_1 = require("./events/events");
16
17
  const organizations_1 = require("./organizations/organizations");
@@ -32,7 +33,7 @@ const actions_1 = require("./actions/actions");
32
33
  const vault_1 = require("./vault/vault");
33
34
  const conflict_exception_1 = require("./common/exceptions/conflict.exception");
34
35
  const parse_error_1 = require("./common/exceptions/parse-error");
35
- const VERSION = '7.71.0';
36
+ const VERSION = '7.72.0';
36
37
  const DEFAULT_HOSTNAME = 'api.workos.com';
37
38
  const HEADER_AUTHORIZATION = 'Authorization';
38
39
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
@@ -41,6 +42,7 @@ class WorkOS {
41
42
  constructor(key, options = {}) {
42
43
  this.key = key;
43
44
  this.options = options;
45
+ this.apiKeys = new api_keys_1.ApiKeys(this);
44
46
  this.auditLogs = new audit_logs_1.AuditLogs(this);
45
47
  this.directorySync = new directory_sync_1.DirectorySync(this);
46
48
  this.organizations = new organizations_1.Organizations(this);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.71.0",
2
+ "version": "7.72.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -65,6 +65,10 @@
65
65
  "import": "./lib/index.worker.js",
66
66
  "default": "./lib/index.worker.js"
67
67
  },
68
+ "convex": {
69
+ "import": "./lib/index.worker.js",
70
+ "default": "./lib/index.worker.js"
71
+ },
68
72
  "default": {
69
73
  "import": "./lib/index.js",
70
74
  "default": "./lib/index.js"