@fern-api/venus-api-sdk 2.0.0 → 2.1.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.
- package/README.md +1 -1
- package/dist/cjs/BaseClient.d.ts +8 -2
- package/dist/cjs/BaseClient.js +14 -2
- package/dist/cjs/Client.d.ts +2 -2
- package/dist/cjs/Client.js +1 -1
- package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/apiKeys/client/Client.js +11 -6
- package/dist/cjs/api/resources/auth/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/auth/client/Client.js +5 -3
- package/dist/cjs/api/resources/organization/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/organization/client/Client.js +25 -13
- package/dist/cjs/api/resources/registry/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/registry/client/Client.js +5 -3
- package/dist/cjs/api/resources/user/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/user/client/Client.js +7 -4
- package/dist/cjs/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/cjs/auth/BearerAuthProvider.js +76 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +7 -0
- package/dist/cjs/core/auth/AuthProvider.js +2 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
- package/dist/cjs/core/auth/BasicAuth.js +27 -0
- package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
- package/dist/cjs/core/auth/BearerToken.js +16 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +5 -0
- package/dist/cjs/core/auth/index.js +9 -0
- package/dist/cjs/core/base64.d.ts +2 -0
- package/dist/cjs/core/base64.js +26 -0
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +8 -2
- package/dist/esm/BaseClient.mjs +13 -2
- package/dist/esm/Client.d.mts +2 -2
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/apiKeys/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/apiKeys/client/Client.mjs +12 -7
- package/dist/esm/api/resources/auth/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/auth/client/Client.mjs +6 -4
- package/dist/esm/api/resources/organization/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/organization/client/Client.mjs +26 -14
- package/dist/esm/api/resources/registry/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/registry/client/Client.mjs +6 -4
- package/dist/esm/api/resources/user/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/user/client/Client.mjs +8 -5
- package/dist/esm/auth/BearerAuthProvider.d.mts +20 -0
- package/dist/esm/auth/BearerAuthProvider.mjs +39 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +7 -0
- package/dist/esm/core/auth/AuthProvider.mjs +1 -0
- package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
- package/dist/esm/core/auth/AuthRequest.mjs +1 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
- package/dist/esm/core/auth/BasicAuth.mjs +24 -0
- package/dist/esm/core/auth/BearerToken.d.mts +7 -0
- package/dist/esm/core/auth/BearerToken.mjs +13 -0
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +5 -0
- package/dist/esm/core/auth/index.mjs +3 -0
- package/dist/esm/core/base64.d.mts +2 -0
- package/dist/esm/core/base64.mjs +22 -0
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Instantiate and use the client with the following:
|
|
|
40
40
|
```typescript
|
|
41
41
|
import { FernApiClient } from "@fern-api/venus-api-sdk";
|
|
42
42
|
|
|
43
|
-
const client = new FernApiClient({ environment: "YOUR_BASE_URL" });
|
|
43
|
+
const client = new FernApiClient({ environment: "YOUR_BASE_URL", token: "YOUR_TOKEN" });
|
|
44
44
|
await client.apiKeys.create({
|
|
45
45
|
organizationId: "organizationId"
|
|
46
46
|
});
|
package/dist/cjs/BaseClient.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { BearerAuthProvider } from "./auth/BearerAuthProvider.js";
|
|
1
2
|
import * as core from "./core/index.js";
|
|
2
|
-
export
|
|
3
|
+
export type BaseClientOptions = {
|
|
3
4
|
environment: core.Supplier<string>;
|
|
4
5
|
/** Specify a custom URL to connect the client to. */
|
|
5
6
|
baseUrl?: core.Supplier<string>;
|
|
@@ -13,7 +14,7 @@ export interface BaseClientOptions {
|
|
|
13
14
|
fetch?: typeof fetch;
|
|
14
15
|
/** Configure logging for the client. */
|
|
15
16
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
16
|
-
}
|
|
17
|
+
} & BearerAuthProvider.AuthOptions;
|
|
17
18
|
export interface BaseRequestOptions {
|
|
18
19
|
/** The maximum time to wait for a response in seconds. */
|
|
19
20
|
timeoutInSeconds?: number;
|
|
@@ -28,5 +29,10 @@ export interface BaseRequestOptions {
|
|
|
28
29
|
}
|
|
29
30
|
export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
|
|
30
31
|
logging: core.logging.Logger;
|
|
32
|
+
authProvider?: core.AuthProvider;
|
|
33
|
+
};
|
|
34
|
+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
35
|
+
authProvider: core.AuthProvider;
|
|
31
36
|
};
|
|
32
37
|
export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
38
|
+
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -35,16 +35,28 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.normalizeClientOptions = normalizeClientOptions;
|
|
38
|
+
exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
|
|
39
|
+
const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
|
|
38
40
|
const headers_js_1 = require("./core/headers.js");
|
|
39
41
|
const core = __importStar(require("./core/index.js"));
|
|
40
42
|
function normalizeClientOptions(options) {
|
|
41
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
42
44
|
"X-Fern-Language": "JavaScript",
|
|
43
45
|
"X-Fern-SDK-Name": "@fern-api/venus-api-sdk",
|
|
44
|
-
"X-Fern-SDK-Version": "2.
|
|
45
|
-
"User-Agent": "@fern-api/venus-api-sdk/2.
|
|
46
|
+
"X-Fern-SDK-Version": "2.1.0",
|
|
47
|
+
"User-Agent": "@fern-api/venus-api-sdk/2.1.0",
|
|
46
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
47
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
48
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
49
51
|
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
|
|
50
52
|
}
|
|
53
|
+
function normalizeClientOptionsWithAuth(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
const normalized = normalizeClientOptions(options);
|
|
56
|
+
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
57
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider_js_1.BearerAuthProvider(normalizedWithNoOpAuthProvider));
|
|
58
|
+
return normalized;
|
|
59
|
+
}
|
|
60
|
+
function withNoOpAuthProvider(options) {
|
|
61
|
+
return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
|
|
62
|
+
}
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { OrganizationClient } from "./api/resources/organization/client/Client.j
|
|
|
5
5
|
import { RegistryClient } from "./api/resources/registry/client/Client.js";
|
|
6
6
|
import { UserClient } from "./api/resources/user/client/Client.js";
|
|
7
7
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
8
|
-
import { type
|
|
8
|
+
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
|
|
9
9
|
import * as core from "./core/index.js";
|
|
10
10
|
export declare namespace FernApiClient {
|
|
11
11
|
type Options = BaseClientOptions;
|
|
@@ -13,7 +13,7 @@ export declare namespace FernApiClient {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export declare class FernApiClient {
|
|
16
|
-
protected readonly _options:
|
|
16
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<FernApiClient.Options>;
|
|
17
17
|
protected _apiKeys: ApiKeysClient | undefined;
|
|
18
18
|
protected _auth: AuthClient | undefined;
|
|
19
19
|
protected _organization: OrganizationClient | undefined;
|
package/dist/cjs/Client.js
CHANGED
|
@@ -55,7 +55,7 @@ const headers_js_1 = require("./core/headers.js");
|
|
|
55
55
|
const core = __importStar(require("./core/index.js"));
|
|
56
56
|
class FernApiClient {
|
|
57
57
|
constructor(options) {
|
|
58
|
-
this._options = (0, BaseClient_js_1.
|
|
58
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
59
59
|
}
|
|
60
60
|
get apiKeys() {
|
|
61
61
|
var _a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as FernApi from "../../../index.js";
|
|
5
5
|
export declare namespace ApiKeysClient {
|
|
@@ -8,7 +8,7 @@ export declare namespace ApiKeysClient {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare class ApiKeysClient {
|
|
11
|
-
protected readonly _options:
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<ApiKeysClient.Options>;
|
|
12
12
|
constructor(options: ApiKeysClient.Options);
|
|
13
13
|
/**
|
|
14
14
|
* @param {FernApi.CreateApiKeyRequest} request
|
|
@@ -51,7 +51,7 @@ const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
|
51
51
|
const FernApi = __importStar(require("../../../index.js"));
|
|
52
52
|
class ApiKeysClient {
|
|
53
53
|
constructor(options) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @param {FernApi.CreateApiKeyRequest} request
|
|
@@ -68,7 +68,8 @@ class ApiKeysClient {
|
|
|
68
68
|
__create(request, requestOptions) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
|
-
const
|
|
71
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
72
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
72
73
|
const _response = yield core.fetcher({
|
|
73
74
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "api-keys/create"),
|
|
74
75
|
method: "POST",
|
|
@@ -147,7 +148,8 @@ class ApiKeysClient {
|
|
|
147
148
|
__getTokenMetadata(request, requestOptions) {
|
|
148
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
150
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
150
|
-
const
|
|
151
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
152
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
151
153
|
const _response = yield core.fetcher({
|
|
152
154
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "api-keys/metadata"),
|
|
153
155
|
method: "POST",
|
|
@@ -227,7 +229,8 @@ class ApiKeysClient {
|
|
|
227
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
230
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
229
231
|
const { organizationId } = request;
|
|
230
|
-
const
|
|
232
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
233
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
231
234
|
const _response = yield core.fetcher({
|
|
232
235
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `api-keys/organization/${core.url.encodePathParam(organizationId)}`),
|
|
233
236
|
method: "GET",
|
|
@@ -301,7 +304,8 @@ class ApiKeysClient {
|
|
|
301
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
302
305
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
303
306
|
const { tokenId } = request;
|
|
304
|
-
const
|
|
307
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
308
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
305
309
|
const _response = yield core.fetcher({
|
|
306
310
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `api-keys/revoke/${core.url.encodePathParam(tokenId)}`),
|
|
307
311
|
method: "POST",
|
|
@@ -368,7 +372,8 @@ class ApiKeysClient {
|
|
|
368
372
|
__revokeToken(request, requestOptions) {
|
|
369
373
|
return __awaiter(this, void 0, void 0, function* () {
|
|
370
374
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
371
|
-
const
|
|
375
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
376
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
372
377
|
const _response = yield core.fetcher({
|
|
373
378
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "api-keys/revoke"),
|
|
374
379
|
method: "POST",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as FernApi from "../../../index.js";
|
|
5
5
|
export declare namespace AuthClient {
|
|
@@ -8,7 +8,7 @@ export declare namespace AuthClient {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare class AuthClient {
|
|
11
|
-
protected readonly _options:
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<AuthClient.Options>;
|
|
12
12
|
constructor(options: AuthClient.Options);
|
|
13
13
|
/**
|
|
14
14
|
* Look up the Fern organization ID for a GitHub owner.
|
|
@@ -51,7 +51,7 @@ const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
|
51
51
|
const FernApi = __importStar(require("../../../index.js"));
|
|
52
52
|
class AuthClient {
|
|
53
53
|
constructor(options) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Look up the Fern organization ID for a GitHub owner.
|
|
@@ -152,7 +152,8 @@ class AuthClient {
|
|
|
152
152
|
__getAutopilotToken(request, requestOptions) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
154
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
155
|
-
const
|
|
155
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
156
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
156
157
|
const _response = yield core.fetcher({
|
|
157
158
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "auth/autopilot-token"),
|
|
158
159
|
method: "POST",
|
|
@@ -235,7 +236,8 @@ class AuthClient {
|
|
|
235
236
|
__getJwt(request, requestOptions) {
|
|
236
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
238
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
238
|
-
const
|
|
239
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
240
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
239
241
|
const _response = yield core.fetcher({
|
|
240
242
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "auth/jwt"),
|
|
241
243
|
method: "POST",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as FernApi from "../../../index.js";
|
|
5
5
|
export declare namespace OrganizationClient {
|
|
@@ -8,7 +8,7 @@ export declare namespace OrganizationClient {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare class OrganizationClient {
|
|
11
|
-
protected readonly _options:
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<OrganizationClient.Options>;
|
|
12
12
|
constructor(options: OrganizationClient.Options);
|
|
13
13
|
/**
|
|
14
14
|
* @param {FernApi.CreateOrganizationRequest} request
|
|
@@ -62,7 +62,7 @@ const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
|
62
62
|
const FernApi = __importStar(require("../../../index.js"));
|
|
63
63
|
class OrganizationClient {
|
|
64
64
|
constructor(options) {
|
|
65
|
-
this._options = (0, BaseClient_js_1.
|
|
65
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* @param {FernApi.CreateOrganizationRequest} request
|
|
@@ -79,7 +79,8 @@ class OrganizationClient {
|
|
|
79
79
|
__create(request, requestOptions) {
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
81
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
82
|
-
const
|
|
82
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
83
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
83
84
|
const _response = yield core.fetcher({
|
|
84
85
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations/create"),
|
|
85
86
|
method: "POST",
|
|
@@ -159,7 +160,8 @@ class OrganizationClient {
|
|
|
159
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
161
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
161
162
|
const { orgId } = request, _body = __rest(request, ["orgId"]);
|
|
162
|
-
const
|
|
163
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
164
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
163
165
|
const _response = yield core.fetcher({
|
|
164
166
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/${core.url.encodePathParam(orgId)}/update`),
|
|
165
167
|
method: "POST",
|
|
@@ -236,7 +238,8 @@ class OrganizationClient {
|
|
|
236
238
|
const _queryParams = {
|
|
237
239
|
shouldIncludeFernUsers,
|
|
238
240
|
};
|
|
239
|
-
const
|
|
241
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
242
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
240
243
|
const _response = yield core.fetcher({
|
|
241
244
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/${core.url.encodePathParam(orgId)}`),
|
|
242
245
|
method: "GET",
|
|
@@ -312,7 +315,8 @@ class OrganizationClient {
|
|
|
312
315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
313
316
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
314
317
|
const { orgId } = request;
|
|
315
|
-
const
|
|
318
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
319
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
316
320
|
const _response = yield core.fetcher({
|
|
317
321
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/${core.url.encodePathParam(orgId)}`),
|
|
318
322
|
method: "DELETE",
|
|
@@ -382,7 +386,8 @@ class OrganizationClient {
|
|
|
382
386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
383
387
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
384
388
|
const { postmanTeamId } = request;
|
|
385
|
-
const
|
|
389
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
390
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
386
391
|
const _response = yield core.fetcher({
|
|
387
392
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/postman-team/${core.url.encodePathParam(postmanTeamId)}`),
|
|
388
393
|
method: "GET",
|
|
@@ -458,7 +463,8 @@ class OrganizationClient {
|
|
|
458
463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
459
464
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
460
465
|
const { orgId } = request;
|
|
461
|
-
const
|
|
466
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
467
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
462
468
|
const _response = yield core.fetcher({
|
|
463
469
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/${core.url.encodePathParam(orgId)}/postman-team-id`),
|
|
464
470
|
method: "GET",
|
|
@@ -532,7 +538,8 @@ class OrganizationClient {
|
|
|
532
538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
533
539
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
534
540
|
const { organizationId } = request;
|
|
535
|
-
const
|
|
541
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
542
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
536
543
|
const _response = yield core.fetcher({
|
|
537
544
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), `organizations/belongs-to-organization/${core.url.encodePathParam(organizationId)}`),
|
|
538
545
|
method: "POST",
|
|
@@ -609,7 +616,8 @@ class OrganizationClient {
|
|
|
609
616
|
const _queryParams = {
|
|
610
617
|
shouldIncludeFernUsers,
|
|
611
618
|
};
|
|
612
|
-
const
|
|
619
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
620
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
613
621
|
const _response = yield core.fetcher({
|
|
614
622
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations/myself"),
|
|
615
623
|
method: "POST",
|
|
@@ -679,7 +687,8 @@ class OrganizationClient {
|
|
|
679
687
|
__getOrgIdsFromToken(requestOptions) {
|
|
680
688
|
return __awaiter(this, void 0, void 0, function* () {
|
|
681
689
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
682
|
-
const
|
|
690
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
691
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
683
692
|
const _response = yield core.fetcher({
|
|
684
693
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations"),
|
|
685
694
|
method: "POST",
|
|
@@ -734,7 +743,8 @@ class OrganizationClient {
|
|
|
734
743
|
__addUser(request, requestOptions) {
|
|
735
744
|
return __awaiter(this, void 0, void 0, function* () {
|
|
736
745
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
737
|
-
const
|
|
746
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
747
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
738
748
|
const _response = yield core.fetcher({
|
|
739
749
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations/add-user"),
|
|
740
750
|
method: "POST",
|
|
@@ -808,7 +818,8 @@ class OrganizationClient {
|
|
|
808
818
|
__inviteUser(request, requestOptions) {
|
|
809
819
|
return __awaiter(this, void 0, void 0, function* () {
|
|
810
820
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
811
|
-
const
|
|
821
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
822
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
812
823
|
const _response = yield core.fetcher({
|
|
813
824
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations/invite"),
|
|
814
825
|
method: "POST",
|
|
@@ -882,7 +893,8 @@ class OrganizationClient {
|
|
|
882
893
|
__removeUser(request, requestOptions) {
|
|
883
894
|
return __awaiter(this, void 0, void 0, function* () {
|
|
884
895
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
885
|
-
const
|
|
896
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
897
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
886
898
|
const _response = yield core.fetcher({
|
|
887
899
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "organizations/user"),
|
|
888
900
|
method: "DELETE",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as FernApi from "../../../index.js";
|
|
5
5
|
export declare namespace RegistryClient {
|
|
@@ -8,7 +8,7 @@ export declare namespace RegistryClient {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare class RegistryClient {
|
|
11
|
-
protected readonly _options:
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<RegistryClient.Options>;
|
|
12
12
|
constructor(options: RegistryClient.Options);
|
|
13
13
|
/**
|
|
14
14
|
* @param {FernApi.GenerateRegistryTokensRequest} request
|
|
@@ -51,7 +51,7 @@ const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
|
51
51
|
const FernApi = __importStar(require("../../../index.js"));
|
|
52
52
|
class RegistryClient {
|
|
53
53
|
constructor(options) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @param {FernApi.GenerateRegistryTokensRequest} request
|
|
@@ -68,7 +68,8 @@ class RegistryClient {
|
|
|
68
68
|
__generateRegistryTokens(request, requestOptions) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
|
-
const
|
|
71
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
72
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
72
73
|
const _response = yield core.fetcher({
|
|
73
74
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "registry/generate-tokens"),
|
|
74
75
|
method: "POST",
|
|
@@ -227,7 +228,8 @@ class RegistryClient {
|
|
|
227
228
|
__revokeToken(request, requestOptions) {
|
|
228
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
230
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
230
|
-
const
|
|
231
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
232
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
231
233
|
const _response = yield core.fetcher({
|
|
232
234
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "registry/revoke-token"),
|
|
233
235
|
method: "POST",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as FernApi from "../../../index.js";
|
|
5
5
|
export declare namespace UserClient {
|
|
@@ -8,7 +8,7 @@ export declare namespace UserClient {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare class UserClient {
|
|
11
|
-
protected readonly _options:
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<UserClient.Options>;
|
|
12
12
|
constructor(options: UserClient.Options);
|
|
13
13
|
/**
|
|
14
14
|
* @param {UserClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -51,7 +51,7 @@ const serializers = __importStar(require("../../../../serialization/index.js"));
|
|
|
51
51
|
const FernApi = __importStar(require("../../../index.js"));
|
|
52
52
|
class UserClient {
|
|
53
53
|
constructor(options) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @param {UserClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -65,7 +65,8 @@ class UserClient {
|
|
|
65
65
|
__getMyself(requestOptions) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
68
|
-
const
|
|
68
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
69
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
69
70
|
const _response = yield core.fetcher({
|
|
70
71
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "users"),
|
|
71
72
|
method: "GET",
|
|
@@ -123,7 +124,8 @@ class UserClient {
|
|
|
123
124
|
const _queryParams = {
|
|
124
125
|
pageId,
|
|
125
126
|
};
|
|
126
|
-
const
|
|
127
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
128
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
127
129
|
const _response = yield core.fetcher({
|
|
128
130
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "users/organizations"),
|
|
129
131
|
method: "GET",
|
|
@@ -199,7 +201,8 @@ class UserClient {
|
|
|
199
201
|
__linkAccounts(request, requestOptions) {
|
|
200
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
203
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
202
|
-
const
|
|
204
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
205
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
203
206
|
const _response = yield core.fetcher({
|
|
204
207
|
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)), "users/link-accounts"),
|
|
205
208
|
method: "POST",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
declare const TOKEN_PARAM: "token";
|
|
3
|
+
export declare class BearerAuthProvider implements core.AuthProvider {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: BearerAuthProvider.Options);
|
|
6
|
+
static canCreate(options: Partial<BearerAuthProvider.Options>): boolean;
|
|
7
|
+
getAuthRequest({ endpointMetadata, }?: {
|
|
8
|
+
endpointMetadata?: core.EndpointMetadata;
|
|
9
|
+
}): Promise<core.AuthRequest>;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace BearerAuthProvider {
|
|
12
|
+
const AUTH_SCHEME: "HTTPBearer";
|
|
13
|
+
const AUTH_CONFIG_ERROR_MESSAGE: string;
|
|
14
|
+
type Options = AuthOptions;
|
|
15
|
+
type AuthOptions = {
|
|
16
|
+
[TOKEN_PARAM]?: core.Supplier<core.BearerToken>;
|
|
17
|
+
};
|
|
18
|
+
function createInstance(options: Options): core.AuthProvider;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.BearerAuthProvider = void 0;
|
|
47
|
+
const core = __importStar(require("../core/index.js"));
|
|
48
|
+
const TOKEN_PARAM = "token";
|
|
49
|
+
class BearerAuthProvider {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.options = options;
|
|
52
|
+
}
|
|
53
|
+
static canCreate(options) {
|
|
54
|
+
return (options === null || options === void 0 ? void 0 : options[TOKEN_PARAM]) != null;
|
|
55
|
+
}
|
|
56
|
+
getAuthRequest() {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
58
|
+
const token = yield core.Supplier.get(this.options[TOKEN_PARAM]);
|
|
59
|
+
if (token == null) {
|
|
60
|
+
return { headers: {} };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.BearerAuthProvider = BearerAuthProvider;
|
|
69
|
+
(function (BearerAuthProvider) {
|
|
70
|
+
BearerAuthProvider.AUTH_SCHEME = "HTTPBearer";
|
|
71
|
+
BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${TOKEN_PARAM}' when initializing the client`;
|
|
72
|
+
function createInstance(options) {
|
|
73
|
+
return new BearerAuthProvider(options);
|
|
74
|
+
}
|
|
75
|
+
BearerAuthProvider.createInstance = createInstance;
|
|
76
|
+
})(BearerAuthProvider || (exports.BearerAuthProvider = BearerAuthProvider = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BearerAuthProvider = void 0;
|
|
4
|
+
var BearerAuthProvider_js_1 = require("./BearerAuthProvider.js");
|
|
5
|
+
Object.defineProperty(exports, "BearerAuthProvider", { enumerable: true, get: function () { return BearerAuthProvider_js_1.BearerAuthProvider; } });
|