UNPKG

@atproto/oauth-client

Version:

OAuth client for ATPROTO PDS. This package serves as common base for environment-specific implementations (NodeJS, Browser, React-Native).

48 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OAuthResponseError = void 0; const fetch_1 = require("@atproto-labs/fetch"); class OAuthResponseError extends Error { constructor(response, payload) { const error = (0, fetch_1.ifString)((0, fetch_1.ifObject)(payload)?.['error']); const errorDescription = (0, fetch_1.ifString)((0, fetch_1.ifObject)(payload)?.['error_description']); const messageError = error ? `"${error}"` : 'unknown'; const messageDesc = errorDescription ? `: ${errorDescription}` : ''; const message = `OAuth ${messageError} error${messageDesc}`; super(message); Object.defineProperty(this, "response", { enumerable: true, configurable: true, writable: true, value: response }); Object.defineProperty(this, "payload", { enumerable: true, configurable: true, writable: true, value: payload }); Object.defineProperty(this, "error", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "errorDescription", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.error = error; this.errorDescription = errorDescription; } get status() { return this.response.status; } get headers() { return this.response.headers; } } exports.OAuthResponseError = OAuthResponseError; //# sourceMappingURL=oauth-response-error.js.map