@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
33 lines • 1.25 kB
JavaScript
// This file was auto-generated by Fern from our API Definition.
import * as core from "../core/index.js";
import * as errors from "../errors/index.js";
const TOKEN_PARAM = "token";
export class BearerAuthProvider {
options;
constructor(options) {
this.options = options;
}
static canCreate(options) {
return options?.[TOKEN_PARAM] != null;
}
async getAuthRequest({ endpointMetadata, } = {}) {
const token = await core.EndpointSupplier.get(this.options[TOKEN_PARAM], { endpointMetadata });
if (token == null) {
throw new errors.CoinbaseApiError({
message: BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE,
});
}
return {
headers: { Authorization: `Bearer ${token}` },
};
}
}
(function (BearerAuthProvider) {
BearerAuthProvider.AUTH_SCHEME = "apiKeyAuth";
BearerAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${TOKEN_PARAM}' when initializing the client`;
function createInstance(options) {
return new BearerAuthProvider(options);
}
BearerAuthProvider.createInstance = createInstance;
})(BearerAuthProvider || (BearerAuthProvider = {}));
//# sourceMappingURL=BearerAuthProvider.js.map