@workos-inc/node 7.10.0 → 7.11.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/common/crypto/{NodeCryptoProvider.d.ts → node-crypto-provider.d.ts} +1 -1
- package/lib/common/crypto/{NodeCryptoProvider.js → node-crypto-provider.js} +3 -3
- package/lib/common/crypto/{SubtleCryptoProvider.d.ts → subtle-crypto-provider.d.ts} +1 -1
- package/lib/common/crypto/{SubtleCryptoProvider.js → subtle-crypto-provider.js} +2 -2
- package/lib/common/net/node-client.d.ts +1 -1
- package/lib/common/net/node-client.js +2 -2
- package/lib/index.d.ts +10 -2
- package/lib/index.js +31 -3
- package/lib/index.worker.d.ts +23 -0
- package/lib/index.worker.js +46 -0
- package/lib/organizations/interfaces/create-organization-options.interface.d.ts +8 -2
- package/lib/organizations/interfaces/update-organization-options.interface.d.ts +8 -2
- package/lib/user-management/user-management.js +13 -1
- package/lib/webhooks/webhooks.d.ts +2 -1
- package/lib/webhooks/webhooks.js +2 -8
- package/lib/webhooks/webhooks.spec.js +7 -6
- package/lib/workos.d.ts +4 -1
- package/lib/workos.js +14 -6
- package/lib/workos.spec.js +38 -26
- package/package.json +11 -3
- package/lib/common/crypto/index.d.ts +0 -3
- package/lib/common/crypto/index.js +0 -19
- package/lib/common/net/index.d.ts +0 -5
- package/lib/common/net/index.js +0 -31
- /package/lib/common/crypto/{CryptoProvider.d.ts → crypto-provider.d.ts} +0 -0
- /package/lib/common/crypto/{CryptoProvider.js → crypto-provider.js} +0 -0
|
@@ -33,12 +33,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.NodeCryptoProvider = void 0;
|
|
36
|
-
const crypto = __importStar(require("crypto"));
|
|
37
|
-
const
|
|
36
|
+
const crypto = __importStar(require("node:crypto"));
|
|
37
|
+
const crypto_provider_1 = require("./crypto-provider");
|
|
38
38
|
/**
|
|
39
39
|
* `CryptoProvider which uses the Node `crypto` package for its computations.
|
|
40
40
|
*/
|
|
41
|
-
class NodeCryptoProvider extends
|
|
41
|
+
class NodeCryptoProvider extends crypto_provider_1.CryptoProvider {
|
|
42
42
|
/** @override */
|
|
43
43
|
computeHMACSignature(payload, secret) {
|
|
44
44
|
return crypto
|
|
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SubtleCryptoProvider = void 0;
|
|
13
|
-
const
|
|
13
|
+
const crypto_provider_1 = require("./crypto-provider");
|
|
14
14
|
/**
|
|
15
15
|
* `CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API.
|
|
16
16
|
*
|
|
17
17
|
* This only supports asynchronous operations.
|
|
18
18
|
*/
|
|
19
|
-
class SubtleCryptoProvider extends
|
|
19
|
+
class SubtleCryptoProvider extends crypto_provider_1.CryptoProvider {
|
|
20
20
|
constructor(subtleCrypto) {
|
|
21
21
|
super();
|
|
22
22
|
// If no subtle crypto is interface, default to the global namespace. This
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { HttpClient, HttpClientResponse } from './http-client';
|
|
3
3
|
import { HttpClientInterface, HttpClientResponseInterface, RequestOptions } from '../interfaces/http-client.interface';
|
|
4
|
-
import * as http_ from 'http';
|
|
4
|
+
import * as http_ from 'node:http';
|
|
5
5
|
export declare class NodeHttpClient extends HttpClient implements HttpClientInterface {
|
|
6
6
|
readonly baseURL: string;
|
|
7
7
|
readonly options?: RequestInit | undefined;
|
|
@@ -34,8 +34,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.NodeHttpClientResponse = exports.NodeHttpClient = void 0;
|
|
36
36
|
const http_client_1 = require("./http-client");
|
|
37
|
-
const http_ = __importStar(require("http"));
|
|
38
|
-
const https_ = __importStar(require("https"));
|
|
37
|
+
const http_ = __importStar(require("node:http"));
|
|
38
|
+
const https_ = __importStar(require("node:https"));
|
|
39
39
|
// `import * as http_ from 'http'` creates a "Module Namespace Exotic Object"
|
|
40
40
|
// which is immune to monkey-patching, whereas http_.default (in an ES Module context)
|
|
41
41
|
// will resolve to the same thing as require('http'), which is
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { HttpClient } from './common/net/http-client';
|
|
2
|
+
import { Webhooks } from './webhooks/webhooks';
|
|
1
3
|
import { WorkOS } from './workos';
|
|
4
|
+
import { WorkOSOptions } from './common/interfaces';
|
|
2
5
|
export * from './audit-logs/interfaces';
|
|
3
6
|
export * from './common/exceptions';
|
|
4
7
|
export * from './common/interfaces';
|
|
@@ -11,5 +14,10 @@ export * from './passwordless/interfaces';
|
|
|
11
14
|
export * from './portal/interfaces';
|
|
12
15
|
export * from './sso/interfaces';
|
|
13
16
|
export * from './user-management/interfaces';
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
declare class WorkOSNode extends WorkOS {
|
|
18
|
+
/** @override */
|
|
19
|
+
createHttpClient(options: WorkOSOptions, userAgent: string): HttpClient;
|
|
20
|
+
/** @override */
|
|
21
|
+
createWebhookClient(): Webhooks;
|
|
22
|
+
}
|
|
23
|
+
export { WorkOSNode as WorkOS };
|
package/lib/index.js
CHANGED
|
@@ -15,8 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.WorkOS = void 0;
|
|
18
|
+
const node_crypto_provider_1 = require("./common/crypto/node-crypto-provider");
|
|
19
|
+
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
20
|
+
const fetch_client_1 = require("./common/net/fetch-client");
|
|
21
|
+
const node_client_1 = require("./common/net/node-client");
|
|
22
|
+
const webhooks_1 = require("./webhooks/webhooks");
|
|
18
23
|
const workos_1 = require("./workos");
|
|
19
|
-
Object.defineProperty(exports, "WorkOS", { enumerable: true, get: function () { return workos_1.WorkOS; } });
|
|
20
24
|
__exportStar(require("./audit-logs/interfaces"), exports);
|
|
21
25
|
__exportStar(require("./common/exceptions"), exports);
|
|
22
26
|
__exportStar(require("./common/interfaces"), exports);
|
|
@@ -29,5 +33,29 @@ __exportStar(require("./passwordless/interfaces"), exports);
|
|
|
29
33
|
__exportStar(require("./portal/interfaces"), exports);
|
|
30
34
|
__exportStar(require("./sso/interfaces"), exports);
|
|
31
35
|
__exportStar(require("./user-management/interfaces"), exports);
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
class WorkOSNode extends workos_1.WorkOS {
|
|
37
|
+
/** @override */
|
|
38
|
+
createHttpClient(options, userAgent) {
|
|
39
|
+
var _a;
|
|
40
|
+
const opts = Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) });
|
|
41
|
+
if (typeof fetch !== 'undefined' ||
|
|
42
|
+
typeof options.fetchFn !== 'undefined') {
|
|
43
|
+
return new fetch_client_1.FetchHttpClient(this.baseURL, opts, options.fetchFn);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return new node_client_1.NodeHttpClient(this.baseURL, opts);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** @override */
|
|
50
|
+
createWebhookClient() {
|
|
51
|
+
let cryptoProvider;
|
|
52
|
+
if (typeof crypto !== 'undefined' && typeof crypto.subtle !== 'undefined') {
|
|
53
|
+
cryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
cryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
|
|
57
|
+
}
|
|
58
|
+
return new webhooks_1.Webhooks(cryptoProvider);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.WorkOS = WorkOSNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HttpClient } from './common/net/http-client';
|
|
2
|
+
import { WorkOSOptions } from './index.worker';
|
|
3
|
+
import { Webhooks } from './webhooks/webhooks';
|
|
4
|
+
import { WorkOS } from './workos';
|
|
5
|
+
export * from './audit-logs/interfaces';
|
|
6
|
+
export * from './common/exceptions';
|
|
7
|
+
export * from './common/interfaces';
|
|
8
|
+
export * from './common/utils/pagination';
|
|
9
|
+
export * from './directory-sync/interfaces';
|
|
10
|
+
export * from './directory-sync/utils/get-primary-email';
|
|
11
|
+
export * from './events/interfaces';
|
|
12
|
+
export * from './organizations/interfaces';
|
|
13
|
+
export * from './passwordless/interfaces';
|
|
14
|
+
export * from './portal/interfaces';
|
|
15
|
+
export * from './sso/interfaces';
|
|
16
|
+
export * from './user-management/interfaces';
|
|
17
|
+
declare class WorkOSWorker extends WorkOS {
|
|
18
|
+
/** @override */
|
|
19
|
+
createHttpClient(options: WorkOSOptions, userAgent: string): HttpClient;
|
|
20
|
+
/** @override */
|
|
21
|
+
createWebhookClient(): Webhooks;
|
|
22
|
+
}
|
|
23
|
+
export { WorkOSWorker as WorkOS };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.WorkOS = void 0;
|
|
18
|
+
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
19
|
+
const fetch_client_1 = require("./common/net/fetch-client");
|
|
20
|
+
const webhooks_1 = require("./webhooks/webhooks");
|
|
21
|
+
const workos_1 = require("./workos");
|
|
22
|
+
__exportStar(require("./audit-logs/interfaces"), exports);
|
|
23
|
+
__exportStar(require("./common/exceptions"), exports);
|
|
24
|
+
__exportStar(require("./common/interfaces"), exports);
|
|
25
|
+
__exportStar(require("./common/utils/pagination"), exports);
|
|
26
|
+
__exportStar(require("./directory-sync/interfaces"), exports);
|
|
27
|
+
__exportStar(require("./directory-sync/utils/get-primary-email"), exports);
|
|
28
|
+
__exportStar(require("./events/interfaces"), exports);
|
|
29
|
+
__exportStar(require("./organizations/interfaces"), exports);
|
|
30
|
+
__exportStar(require("./passwordless/interfaces"), exports);
|
|
31
|
+
__exportStar(require("./portal/interfaces"), exports);
|
|
32
|
+
__exportStar(require("./sso/interfaces"), exports);
|
|
33
|
+
__exportStar(require("./user-management/interfaces"), exports);
|
|
34
|
+
class WorkOSWorker extends workos_1.WorkOS {
|
|
35
|
+
/** @override */
|
|
36
|
+
createHttpClient(options, userAgent) {
|
|
37
|
+
var _a;
|
|
38
|
+
return new fetch_client_1.FetchHttpClient(this.baseURL, Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) }));
|
|
39
|
+
}
|
|
40
|
+
/** @override */
|
|
41
|
+
createWebhookClient() {
|
|
42
|
+
const cryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
43
|
+
return new webhooks_1.Webhooks(cryptoProvider);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.WorkOS = WorkOSWorker;
|
|
@@ -2,8 +2,11 @@ import { PostOptions } from '../../common/interfaces';
|
|
|
2
2
|
import { DomainData } from './domain-data.interface';
|
|
3
3
|
export interface CreateOrganizationOptions {
|
|
4
4
|
name: string;
|
|
5
|
-
allowProfilesOutsideOrganization?: boolean;
|
|
6
5
|
domainData?: DomainData[];
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
8
|
+
*/
|
|
9
|
+
allowProfilesOutsideOrganization?: boolean;
|
|
7
10
|
/**
|
|
8
11
|
* @deprecated Use `domain_data` instead.
|
|
9
12
|
*/
|
|
@@ -11,8 +14,11 @@ export interface CreateOrganizationOptions {
|
|
|
11
14
|
}
|
|
12
15
|
export interface SerializedCreateOrganizationOptions {
|
|
13
16
|
name: string;
|
|
14
|
-
allow_profiles_outside_organization?: boolean;
|
|
15
17
|
domain_data?: DomainData[];
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
20
|
+
*/
|
|
21
|
+
allow_profiles_outside_organization?: boolean;
|
|
16
22
|
/**
|
|
17
23
|
* @deprecated Use `domain_data` instead.
|
|
18
24
|
*/
|
|
@@ -2,8 +2,11 @@ import { DomainData } from './domain-data.interface';
|
|
|
2
2
|
export interface UpdateOrganizationOptions {
|
|
3
3
|
organization: string;
|
|
4
4
|
name: string;
|
|
5
|
-
allowProfilesOutsideOrganization?: boolean;
|
|
6
5
|
domainData?: DomainData[];
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
8
|
+
*/
|
|
9
|
+
allowProfilesOutsideOrganization?: boolean;
|
|
7
10
|
/**
|
|
8
11
|
* @deprecated Use `domain_data` instead.
|
|
9
12
|
*/
|
|
@@ -11,8 +14,11 @@ export interface UpdateOrganizationOptions {
|
|
|
11
14
|
}
|
|
12
15
|
export interface SerializedUpdateOrganizationOptions {
|
|
13
16
|
name: string;
|
|
14
|
-
allow_profiles_outside_organization?: boolean;
|
|
15
17
|
domain_data?: DomainData[];
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated If you need to allow sign-ins from any email domain, contact support@workos.com.
|
|
20
|
+
*/
|
|
21
|
+
allow_profiles_outside_organization?: boolean;
|
|
16
22
|
/**
|
|
17
23
|
* @deprecated Use `domain_data` instead.
|
|
18
24
|
*/
|
|
@@ -8,6 +8,17 @@ 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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.UserManagement = void 0;
|
|
13
24
|
const pagination_1 = require("../common/utils/pagination");
|
|
@@ -183,7 +194,8 @@ class UserManagement {
|
|
|
183
194
|
}
|
|
184
195
|
listAuthFactors(options) {
|
|
185
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
|
|
197
|
+
const { userId } = options, restOfOptions = __rest(options, ["userId"]);
|
|
198
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/auth_factors`, factor_serializer_1.deserializeFactor, restOfOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/auth_factors`, factor_serializer_1.deserializeFactor, params), restOfOptions);
|
|
187
199
|
});
|
|
188
200
|
}
|
|
189
201
|
deleteUser(userId) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Event } from '../common/interfaces';
|
|
2
|
+
import { CryptoProvider } from '../common/crypto/crypto-provider';
|
|
2
3
|
export declare class Webhooks {
|
|
3
4
|
private cryptoProvider;
|
|
4
|
-
constructor(
|
|
5
|
+
constructor(cryptoProvider: CryptoProvider);
|
|
5
6
|
constructEvent({ payload, sigHeader, secret, tolerance, }: {
|
|
6
7
|
payload: unknown;
|
|
7
8
|
sigHeader: string;
|
package/lib/webhooks/webhooks.js
CHANGED
|
@@ -12,15 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Webhooks = void 0;
|
|
13
13
|
const exceptions_1 = require("../common/exceptions");
|
|
14
14
|
const serializers_1 = require("../common/serializers");
|
|
15
|
-
const crypto_1 = require("../common/crypto");
|
|
16
15
|
class Webhooks {
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
19
|
-
this.cryptoProvider = new crypto_1.SubtleCryptoProvider(subtleCrypto);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.cryptoProvider = new crypto_1.NodeCryptoProvider();
|
|
23
|
-
}
|
|
16
|
+
constructor(cryptoProvider) {
|
|
17
|
+
this.cryptoProvider = cryptoProvider;
|
|
24
18
|
}
|
|
25
19
|
constructEvent({ payload, sigHeader, secret, tolerance = 180000, }) {
|
|
26
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -17,7 +17,8 @@ const workos_1 = require("../workos");
|
|
|
17
17
|
const webhook_json_1 = __importDefault(require("./fixtures/webhook.json"));
|
|
18
18
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
19
19
|
const exceptions_1 = require("../common/exceptions");
|
|
20
|
-
const
|
|
20
|
+
const node_crypto_provider_1 = require("../common/crypto/node-crypto-provider");
|
|
21
|
+
const subtle_crypto_provider_1 = require("../common/crypto/subtle-crypto-provider");
|
|
21
22
|
describe('Webhooks', () => {
|
|
22
23
|
let payload;
|
|
23
24
|
let secret;
|
|
@@ -191,14 +192,14 @@ describe('Webhooks', () => {
|
|
|
191
192
|
describe('when in an environment that supports SubtleCrypto', () => {
|
|
192
193
|
it('automatically uses the subtle crypto library', () => {
|
|
193
194
|
// tslint:disable-next-line
|
|
194
|
-
expect(workos.webhooks['cryptoProvider']).toBeInstanceOf(
|
|
195
|
+
expect(workos.webhooks['cryptoProvider']).toBeInstanceOf(subtle_crypto_provider_1.SubtleCryptoProvider);
|
|
195
196
|
});
|
|
196
197
|
});
|
|
197
198
|
describe('CryptoProvider', () => {
|
|
198
199
|
describe('when computing HMAC signature', () => {
|
|
199
200
|
it('returns the same for the Node crypto and Web Crypto versions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
-
const nodeCryptoProvider = new
|
|
201
|
-
const subtleCryptoProvider = new
|
|
201
|
+
const nodeCryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
|
|
202
|
+
const subtleCryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
202
203
|
const stringifiedPayload = JSON.stringify(payload);
|
|
203
204
|
const payloadHMAC = `${timestamp}.${stringifiedPayload}`;
|
|
204
205
|
const nodeCompare = yield nodeCryptoProvider.computeHMACSignatureAsync(payloadHMAC, secret);
|
|
@@ -208,8 +209,8 @@ describe('Webhooks', () => {
|
|
|
208
209
|
});
|
|
209
210
|
describe('when securely comparing', () => {
|
|
210
211
|
it('returns the same for the Node crypto and Web Crypto versions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
|
-
const nodeCryptoProvider = new
|
|
212
|
-
const subtleCryptoProvider = new
|
|
212
|
+
const nodeCryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
|
|
213
|
+
const subtleCryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
213
214
|
const signature = yield workos.webhooks.computeSignature(timestamp, payload, secret);
|
|
214
215
|
expect(nodeCryptoProvider.secureCompare(signature, signatureHash)).toEqual(subtleCryptoProvider.secureCompare(signature, signatureHash));
|
|
215
216
|
expect(nodeCryptoProvider.secureCompare(signature, 'foo')).toEqual(subtleCryptoProvider.secureCompare(signature, 'foo'));
|
package/lib/workos.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ import { Webhooks } from './webhooks/webhooks';
|
|
|
10
10
|
import { Mfa } from './mfa/mfa';
|
|
11
11
|
import { AuditLogs } from './audit-logs/audit-logs';
|
|
12
12
|
import { UserManagement } from './user-management/user-management';
|
|
13
|
+
import { HttpClient } from './common/net/http-client';
|
|
13
14
|
export declare class WorkOS {
|
|
14
15
|
readonly key?: string | undefined;
|
|
15
16
|
readonly options: WorkOSOptions;
|
|
16
17
|
readonly baseURL: string;
|
|
17
|
-
|
|
18
|
+
readonly client: HttpClient;
|
|
18
19
|
readonly auditLogs: AuditLogs;
|
|
19
20
|
readonly directorySync: DirectorySync;
|
|
20
21
|
readonly organizations: Organizations;
|
|
@@ -27,6 +28,8 @@ export declare class WorkOS {
|
|
|
27
28
|
readonly events: Events;
|
|
28
29
|
readonly userManagement: UserManagement;
|
|
29
30
|
constructor(key?: string | undefined, options?: WorkOSOptions);
|
|
31
|
+
createWebhookClient(): Webhooks;
|
|
32
|
+
createHttpClient(options: WorkOSOptions, userAgent: string): HttpClient;
|
|
30
33
|
get version(): string;
|
|
31
34
|
post<Result = any, Entity = any>(path: string, entity: Entity, options?: PostOptions): Promise<{
|
|
32
35
|
data: Result;
|
package/lib/workos.js
CHANGED
|
@@ -23,12 +23,13 @@ const mfa_1 = require("./mfa/mfa");
|
|
|
23
23
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
24
24
|
const user_management_1 = require("./user-management/user-management");
|
|
25
25
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
26
|
-
const
|
|
27
|
-
const
|
|
26
|
+
const http_client_1 = require("./common/net/http-client");
|
|
27
|
+
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
28
|
+
const fetch_client_1 = require("./common/net/fetch-client");
|
|
29
|
+
const VERSION = '7.11.1';
|
|
28
30
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
29
31
|
class WorkOS {
|
|
30
32
|
constructor(key, options = {}) {
|
|
31
|
-
var _a;
|
|
32
33
|
this.key = key;
|
|
33
34
|
this.options = options;
|
|
34
35
|
this.auditLogs = new audit_logs_1.AuditLogs(this);
|
|
@@ -38,7 +39,6 @@ class WorkOS {
|
|
|
38
39
|
this.passwordless = new passwordless_1.Passwordless(this);
|
|
39
40
|
this.portal = new portal_1.Portal(this);
|
|
40
41
|
this.sso = new sso_1.SSO(this);
|
|
41
|
-
this.webhooks = new webhooks_1.Webhooks();
|
|
42
42
|
this.mfa = new mfa_1.Mfa(this);
|
|
43
43
|
this.events = new events_1.Events(this);
|
|
44
44
|
this.userManagement = new user_management_1.UserManagement(this);
|
|
@@ -64,7 +64,15 @@ class WorkOS {
|
|
|
64
64
|
const { name, version } = options.appInfo;
|
|
65
65
|
userAgent += ` ${name}: ${version}`;
|
|
66
66
|
}
|
|
67
|
-
this.
|
|
67
|
+
this.webhooks = this.createWebhookClient();
|
|
68
|
+
this.client = this.createHttpClient(options, userAgent);
|
|
69
|
+
}
|
|
70
|
+
createWebhookClient() {
|
|
71
|
+
return new webhooks_1.Webhooks(new subtle_crypto_provider_1.SubtleCryptoProvider());
|
|
72
|
+
}
|
|
73
|
+
createHttpClient(options, userAgent) {
|
|
74
|
+
var _a;
|
|
75
|
+
return new fetch_client_1.FetchHttpClient(this.baseURL, Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) }));
|
|
68
76
|
}
|
|
69
77
|
get version() {
|
|
70
78
|
return VERSION;
|
|
@@ -148,7 +156,7 @@ class WorkOS {
|
|
|
148
156
|
}
|
|
149
157
|
handleHttpError({ path, error }) {
|
|
150
158
|
var _a;
|
|
151
|
-
if (!(error instanceof
|
|
159
|
+
if (!(error instanceof http_client_1.HttpClientError)) {
|
|
152
160
|
throw new Error(`Unexpected error: ${error}`);
|
|
153
161
|
}
|
|
154
162
|
const { response } = error;
|
package/lib/workos.spec.js
CHANGED
|
@@ -16,9 +16,12 @@ const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
|
16
16
|
const test_utils_1 = require("./common/utils/test-utils");
|
|
17
17
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
18
18
|
const exceptions_1 = require("./common/exceptions");
|
|
19
|
-
const
|
|
19
|
+
const index_1 = require("./index");
|
|
20
|
+
const index_worker_1 = require("./index.worker");
|
|
20
21
|
const rate_limit_exceeded_exception_1 = require("./common/exceptions/rate-limit-exceeded.exception");
|
|
21
|
-
const
|
|
22
|
+
const fetch_client_1 = require("./common/net/fetch-client");
|
|
23
|
+
const node_client_1 = require("./common/net/node-client");
|
|
24
|
+
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
22
25
|
describe('WorkOS', () => {
|
|
23
26
|
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
24
27
|
describe('constructor', () => {
|
|
@@ -33,35 +36,35 @@ describe('WorkOS', () => {
|
|
|
33
36
|
});
|
|
34
37
|
describe('when no API key is provided', () => {
|
|
35
38
|
it('throws a NoApiKeyFoundException error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
expect(() => new
|
|
39
|
+
expect(() => new index_1.WorkOS()).toThrowError(exceptions_1.NoApiKeyProvidedException);
|
|
37
40
|
}));
|
|
38
41
|
});
|
|
39
42
|
describe('when API key is provided with environment variable', () => {
|
|
40
43
|
it('initializes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
44
|
process.env.WORKOS_API_KEY = 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU';
|
|
42
|
-
expect(() => new
|
|
45
|
+
expect(() => new index_1.WorkOS()).not.toThrow();
|
|
43
46
|
}));
|
|
44
47
|
});
|
|
45
48
|
describe('when API key is provided with constructor', () => {
|
|
46
49
|
it('initializes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
expect(() => new
|
|
50
|
+
expect(() => new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU')).not.toThrow();
|
|
48
51
|
}));
|
|
49
52
|
});
|
|
50
53
|
describe('with https option', () => {
|
|
51
54
|
it('sets baseURL', () => {
|
|
52
|
-
const workos = new
|
|
55
|
+
const workos = new index_1.WorkOS('foo', { https: false });
|
|
53
56
|
expect(workos.baseURL).toEqual('http://api.workos.com');
|
|
54
57
|
});
|
|
55
58
|
});
|
|
56
59
|
describe('with apiHostname option', () => {
|
|
57
60
|
it('sets baseURL', () => {
|
|
58
|
-
const workos = new
|
|
61
|
+
const workos = new index_1.WorkOS('foo', { apiHostname: 'localhost' });
|
|
59
62
|
expect(workos.baseURL).toEqual('https://localhost');
|
|
60
63
|
});
|
|
61
64
|
});
|
|
62
65
|
describe('with port option', () => {
|
|
63
66
|
it('sets baseURL', () => {
|
|
64
|
-
const workos = new
|
|
67
|
+
const workos = new index_1.WorkOS('foo', {
|
|
65
68
|
apiHostname: 'localhost',
|
|
66
69
|
port: 4000,
|
|
67
70
|
});
|
|
@@ -71,7 +74,7 @@ describe('WorkOS', () => {
|
|
|
71
74
|
describe('when the `config` option is provided', () => {
|
|
72
75
|
it('applies the configuration to the fetch client', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
76
|
(0, test_utils_1.fetchOnce)('{}', { headers: { 'X-Request-ID': 'a-request-id' } });
|
|
74
|
-
const workos = new
|
|
77
|
+
const workos = new index_1.WorkOS('sk_test', {
|
|
75
78
|
config: {
|
|
76
79
|
headers: {
|
|
77
80
|
'X-My-Custom-Header': 'Hey there!',
|
|
@@ -88,7 +91,7 @@ describe('WorkOS', () => {
|
|
|
88
91
|
it('applies the configuration to the fetch client user-agent', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
92
|
(0, test_utils_1.fetchOnce)('{}');
|
|
90
93
|
const packageJson = JSON.parse(yield promises_1.default.readFile('package.json', 'utf8'));
|
|
91
|
-
const workos = new
|
|
94
|
+
const workos = new index_1.WorkOS('sk_test', {
|
|
92
95
|
appInfo: {
|
|
93
96
|
name: 'fooApp',
|
|
94
97
|
version: '1.0.0',
|
|
@@ -104,7 +107,7 @@ describe('WorkOS', () => {
|
|
|
104
107
|
it('adds the HTTP client name to the user-agent', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
108
|
(0, test_utils_1.fetchOnce)('{}');
|
|
106
109
|
const packageJson = JSON.parse(yield promises_1.default.readFile('package.json', 'utf8'));
|
|
107
|
-
const workos = new
|
|
110
|
+
const workos = new index_1.WorkOS('sk_test');
|
|
108
111
|
yield workos.post('/somewhere', {});
|
|
109
112
|
expect((0, test_utils_1.fetchHeaders)()).toMatchObject({
|
|
110
113
|
'User-Agent': `workos-node/${packageJson.version}/fetch`,
|
|
@@ -115,7 +118,7 @@ describe('WorkOS', () => {
|
|
|
115
118
|
it('adds the HTTP client name to the user-agent', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
119
|
(0, test_utils_1.fetchOnce)('{}');
|
|
117
120
|
const packageJson = JSON.parse(yield promises_1.default.readFile('package.json', 'utf8'));
|
|
118
|
-
const workos = new
|
|
121
|
+
const workos = new index_1.WorkOS('sk_test');
|
|
119
122
|
yield workos.post('/somewhere', {});
|
|
120
123
|
expect((0, test_utils_1.fetchHeaders)()).toMatchObject({
|
|
121
124
|
'User-Agent': `workos-node/${packageJson.version}/fetch`,
|
|
@@ -124,16 +127,16 @@ describe('WorkOS', () => {
|
|
|
124
127
|
});
|
|
125
128
|
describe('when using an environment that supports fetch', () => {
|
|
126
129
|
it('automatically uses the fetch HTTP client', () => {
|
|
127
|
-
const workos = new
|
|
130
|
+
const workos = new index_1.WorkOS('sk_test');
|
|
128
131
|
// Bracket notation gets past private visibility
|
|
129
132
|
// tslint:disable-next-line
|
|
130
|
-
expect(workos['client']).toBeInstanceOf(
|
|
133
|
+
expect(workos['client']).toBeInstanceOf(fetch_client_1.FetchHttpClient);
|
|
131
134
|
});
|
|
132
135
|
});
|
|
133
136
|
});
|
|
134
137
|
describe('version', () => {
|
|
135
138
|
it('matches the version in `package.json`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
-
const workos = new
|
|
139
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
137
140
|
// Read `package.json` using file I/O instead of `require` so we don't run
|
|
138
141
|
// into issues with the `require` cache.
|
|
139
142
|
const packageJson = JSON.parse(yield promises_1.default.readFile('package.json', 'utf8'));
|
|
@@ -145,7 +148,7 @@ describe('WorkOS', () => {
|
|
|
145
148
|
it('throws a NotFoundException', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
149
|
const message = 'Not Found';
|
|
147
150
|
(0, test_utils_1.fetchOnce)({ message }, { status: 404, headers: { 'X-Request-ID': 'a-request-id' } });
|
|
148
|
-
const workos = new
|
|
151
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
149
152
|
yield expect(workos.post('/path', {})).rejects.toStrictEqual(new exceptions_1.NotFoundException({
|
|
150
153
|
message,
|
|
151
154
|
path: '/path',
|
|
@@ -156,7 +159,7 @@ describe('WorkOS', () => {
|
|
|
156
159
|
const message = 'The thing you are looking for is not here.';
|
|
157
160
|
const code = 'thing-not-found';
|
|
158
161
|
(0, test_utils_1.fetchOnce)({ code, message }, { status: 404, headers: { 'X-Request-ID': 'a-request-id' } });
|
|
159
|
-
const workos = new
|
|
162
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
160
163
|
yield expect(workos.post('/path', {})).rejects.toMatchObject({
|
|
161
164
|
code,
|
|
162
165
|
message,
|
|
@@ -167,7 +170,7 @@ describe('WorkOS', () => {
|
|
|
167
170
|
const code = 'thing-not-found';
|
|
168
171
|
const path = '/path/to/thing/that-aint-there';
|
|
169
172
|
(0, test_utils_1.fetchOnce)({ code }, { status: 404, headers: { 'X-Request-ID': 'a-request-id' } });
|
|
170
|
-
const workos = new
|
|
173
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
171
174
|
yield expect(workos.post(path, {})).rejects.toMatchObject({
|
|
172
175
|
code,
|
|
173
176
|
message: `The requested path '${path}' could not be found.`,
|
|
@@ -181,7 +184,7 @@ describe('WorkOS', () => {
|
|
|
181
184
|
status: 500,
|
|
182
185
|
headers: { 'X-Request-ID': 'a-request-id' },
|
|
183
186
|
});
|
|
184
|
-
const workos = new
|
|
187
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
185
188
|
yield expect(workos.post('/path', {})).rejects.toStrictEqual(new exceptions_1.GenericServerException(500, undefined, {}, 'a-request-id'));
|
|
186
189
|
}));
|
|
187
190
|
});
|
|
@@ -191,7 +194,7 @@ describe('WorkOS', () => {
|
|
|
191
194
|
status: 400,
|
|
192
195
|
headers: { 'X-Request-ID': 'a-request-id' },
|
|
193
196
|
});
|
|
194
|
-
const workos = new
|
|
197
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
195
198
|
yield expect(workos.post('/path', {})).rejects.toStrictEqual(new exceptions_1.OauthException(400, 'a-request-id', 'error', 'error description', { error: 'error', error_description: 'error description' }));
|
|
196
199
|
}));
|
|
197
200
|
});
|
|
@@ -203,14 +206,14 @@ describe('WorkOS', () => {
|
|
|
203
206
|
status: 429,
|
|
204
207
|
headers: { 'X-Request-ID': 'a-request-id', 'Retry-After': '10' },
|
|
205
208
|
});
|
|
206
|
-
const workos = new
|
|
209
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
207
210
|
yield expect(workos.get('/path')).rejects.toStrictEqual(new rate_limit_exceeded_exception_1.RateLimitExceededException('Too many requests', 'a-request-id', 10));
|
|
208
211
|
}));
|
|
209
212
|
});
|
|
210
213
|
describe('when the entity is null', () => {
|
|
211
214
|
it('sends an empty string body', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
215
|
(0, test_utils_1.fetchOnce)();
|
|
213
|
-
const workos = new
|
|
216
|
+
const workos = new index_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
214
217
|
yield workos.post('/somewhere', null);
|
|
215
218
|
expect((0, test_utils_1.fetchBody)({ raw: true })).toBe('');
|
|
216
219
|
}));
|
|
@@ -226,16 +229,25 @@ describe('WorkOS', () => {
|
|
|
226
229
|
globalThis.fetch = fetchFn;
|
|
227
230
|
});
|
|
228
231
|
it('automatically uses the node HTTP client', () => {
|
|
229
|
-
const workos = new
|
|
232
|
+
const workos = new index_1.WorkOS('sk_test_key');
|
|
230
233
|
// tslint:disable-next-line
|
|
231
|
-
expect(workos['client']).toBeInstanceOf(
|
|
234
|
+
expect(workos['client']).toBeInstanceOf(node_client_1.NodeHttpClient);
|
|
232
235
|
});
|
|
233
236
|
it('uses a fetch function if provided', () => {
|
|
234
|
-
const workos = new
|
|
237
|
+
const workos = new index_1.WorkOS('sk_test_key', {
|
|
235
238
|
fetchFn,
|
|
236
239
|
});
|
|
237
240
|
// tslint:disable-next-line
|
|
238
|
-
expect(workos['client']).toBeInstanceOf(
|
|
241
|
+
expect(workos['client']).toBeInstanceOf(fetch_client_1.FetchHttpClient);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
describe('when in a worker environment', () => {
|
|
245
|
+
it('uses the worker client', () => {
|
|
246
|
+
const workos = new index_worker_1.WorkOS('sk_test_key');
|
|
247
|
+
// tslint:disable-next-line
|
|
248
|
+
expect(workos['client']).toBeInstanceOf(fetch_client_1.FetchHttpClient);
|
|
249
|
+
// tslint:disable-next-line
|
|
250
|
+
expect(workos.webhooks['cryptoProvider']).toBeInstanceOf(subtle_crypto_provider_1.SubtleCryptoProvider);
|
|
239
251
|
});
|
|
240
252
|
});
|
|
241
253
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "7.
|
|
2
|
+
"version": "7.11.1",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=16"
|
|
17
17
|
},
|
|
18
|
-
"main": "lib/index.js",
|
|
19
|
-
"typings": "lib/index.d.ts",
|
|
20
18
|
"files": [
|
|
21
19
|
"lib/"
|
|
22
20
|
],
|
|
@@ -28,6 +26,7 @@
|
|
|
28
26
|
"url": "https://github.com/workos-inc/workos-node/issues"
|
|
29
27
|
},
|
|
30
28
|
"scripts": {
|
|
29
|
+
"clean": "rm -rf lib",
|
|
31
30
|
"build": "tsc -p .",
|
|
32
31
|
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
33
32
|
"test": "jest",
|
|
@@ -51,5 +50,14 @@
|
|
|
51
50
|
"ts-jest": "29.1.3",
|
|
52
51
|
"tslint": "6.1.3",
|
|
53
52
|
"typescript": "5.1.6"
|
|
53
|
+
},
|
|
54
|
+
"exports": {
|
|
55
|
+
"types": "./lib/index.d.ts",
|
|
56
|
+
"worker": {
|
|
57
|
+
"import": "./lib/index.worker.js"
|
|
58
|
+
},
|
|
59
|
+
"default": {
|
|
60
|
+
"import": "./lib/index.js"
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./NodeCryptoProvider"), exports);
|
|
18
|
-
__exportStar(require("./SubtleCryptoProvider"), exports);
|
|
19
|
-
__exportStar(require("./CryptoProvider"), exports);
|
package/lib/common/net/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createHttpClient = void 0;
|
|
18
|
-
const fetch_client_1 = require("./fetch-client");
|
|
19
|
-
const node_client_1 = require("./node-client");
|
|
20
|
-
function createHttpClient(baseURL, options, fetchFn) {
|
|
21
|
-
if (typeof fetch !== 'undefined' || typeof fetchFn !== 'undefined') {
|
|
22
|
-
return new fetch_client_1.FetchHttpClient(baseURL, options, fetchFn);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return new node_client_1.NodeHttpClient(baseURL, options);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.createHttpClient = createHttpClient;
|
|
29
|
-
__exportStar(require("./fetch-client"), exports);
|
|
30
|
-
__exportStar(require("./node-client"), exports);
|
|
31
|
-
__exportStar(require("./http-client"), exports);
|
|
File without changes
|
|
File without changes
|