UNPKG

@sovrano-io/auth-sdk

Version:

Sovrano wallet auth sdk for koinos dapps

70 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Connector = void 0; const utils_1 = require("./utils"); const config_1 = require("./config"); class Connector { /** * Get the URL to redirect to for connection * @param data * @returns */ static getRequestUrl(data) { const encodedData = this.encodeRequest(data); return `${(0, config_1.getConfig)().baseUrl}/connect?data=${encodedData}`; } /** * Get the URL to redirect to after connection * @param data * @param url * @returns */ static getResponseUrl(data, url) { const encodedData = this.encodeResponse(data); return `${url}?data=${encodedData}`; } /** * Encode the connection request data * @param data * @returns */ static encodeRequest(data) { return (0, utils_1.encodeParams)(data); } /** * Decode the connection request data * @param data * @returns */ static decodeRequest(data) { return (0, utils_1.decodeParams)(data); } /** * Encode the connection response data * @param data * @returns */ static encodeResponse(data) { return (0, utils_1.encodeParams)(data); } /** * Decode the connection response data * @param data * @returns */ static decodeResponse(data) { return (0, utils_1.decodeParams)(data); } /** * Get the response from the URL * @param responseUrl * @returns */ static getResponse(responseUrl) { const url = new URL(responseUrl); const data = url.searchParams.get('data'); return this.decodeResponse(data); } } exports.Connector = Connector; //# sourceMappingURL=Connector.js.map