@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
|
@@ -8,14 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
12
|
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as serializers from "../../../../serialization/index.mjs";
|
|
15
15
|
import * as FernApi from "../../../index.mjs";
|
|
16
16
|
export class UserClient {
|
|
17
17
|
constructor(options) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* @param {UserClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -29,7 +29,8 @@ export class UserClient {
|
|
|
29
29
|
__getMyself(requestOptions) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
-
const
|
|
32
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
33
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
33
34
|
const _response = yield core.fetcher({
|
|
34
35
|
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"),
|
|
35
36
|
method: "GET",
|
|
@@ -87,7 +88,8 @@ export class UserClient {
|
|
|
87
88
|
const _queryParams = {
|
|
88
89
|
pageId,
|
|
89
90
|
};
|
|
90
|
-
const
|
|
91
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
92
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
91
93
|
const _response = yield core.fetcher({
|
|
92
94
|
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"),
|
|
93
95
|
method: "GET",
|
|
@@ -163,7 +165,8 @@ export class UserClient {
|
|
|
163
165
|
__linkAccounts(request, requestOptions) {
|
|
164
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
167
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
166
|
-
const
|
|
168
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
169
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
167
170
|
const _response = yield core.fetcher({
|
|
168
171
|
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"),
|
|
169
172
|
method: "POST",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as core from "../core/index.mjs";
|
|
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,39 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
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
|
+
import * as core from "../core/index.mjs";
|
|
12
|
+
const TOKEN_PARAM = "token";
|
|
13
|
+
export class BearerAuthProvider {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
static canCreate(options) {
|
|
18
|
+
return (options === null || options === void 0 ? void 0 : options[TOKEN_PARAM]) != null;
|
|
19
|
+
}
|
|
20
|
+
getAuthRequest() {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
22
|
+
const token = yield core.Supplier.get(this.options[TOKEN_PARAM]);
|
|
23
|
+
if (token == null) {
|
|
24
|
+
return { headers: {} };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
(function (BearerAuthProvider) {
|
|
33
|
+
BearerAuthProvider.AUTH_SCHEME = "HTTPBearer";
|
|
34
|
+
BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${TOKEN_PARAM}' when initializing the client`;
|
|
35
|
+
function createInstance(options) {
|
|
36
|
+
return new BearerAuthProvider(options);
|
|
37
|
+
}
|
|
38
|
+
BearerAuthProvider.createInstance = createInstance;
|
|
39
|
+
})(BearerAuthProvider || (BearerAuthProvider = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { base64Decode, base64Encode } from "../base64.mjs";
|
|
2
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
|
+
export const BasicAuth = {
|
|
4
|
+
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
if (basicAuth == null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const token = base64Encode(`${basicAuth.username}:${basicAuth.password}`);
|
|
9
|
+
return `Basic ${token}`;
|
|
10
|
+
},
|
|
11
|
+
fromAuthorizationHeader: (header) => {
|
|
12
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
13
|
+
const decoded = base64Decode(credentials);
|
|
14
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
15
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
16
|
+
if (username == null || password == null) {
|
|
17
|
+
throw new Error("Invalid basic auth");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
username,
|
|
21
|
+
password,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
3
|
+
export declare const BearerToken: {
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
5
|
+
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
8
|
+
export const BearerToken = {
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
10
|
+
fromAuthorizationHeader: (header) => {
|
|
11
|
+
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function base64ToBytes(base64) {
|
|
2
|
+
const binString = atob(base64);
|
|
3
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
4
|
+
}
|
|
5
|
+
function bytesToBase64(bytes) {
|
|
6
|
+
const binString = String.fromCodePoint(...bytes);
|
|
7
|
+
return btoa(binString);
|
|
8
|
+
}
|
|
9
|
+
export function base64Encode(input) {
|
|
10
|
+
if (typeof Buffer !== "undefined") {
|
|
11
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
12
|
+
}
|
|
13
|
+
const bytes = new TextEncoder().encode(input);
|
|
14
|
+
return bytesToBase64(bytes);
|
|
15
|
+
}
|
|
16
|
+
export function base64Decode(input) {
|
|
17
|
+
if (typeof Buffer !== "undefined") {
|
|
18
|
+
return Buffer.from(input, "base64").toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
const bytes = base64ToBytes(input);
|
|
21
|
+
return new TextDecoder().decode(bytes);
|
|
22
|
+
}
|
package/dist/esm/core/index.mjs
CHANGED
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.
|
|
1
|
+
export declare const SDK_VERSION = "2.1.0";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.
|
|
1
|
+
export const SDK_VERSION = "2.1.0";
|