@sovrano-io/auth-sdk
Version:
Sovrano wallet auth sdk for koinos dapps
75 lines (74 loc) • 1.96 kB
TypeScript
import { TransactionJson } from "koilib";
/**
* Represents the request to the authorizer
*/
export type AuthorizerRequest = {
/** The transaction that needs to be signed */
transactionJson: TransactionJson;
/** The URL to redirect to after authorization */
redirectUrl: string;
/** The address of the user */
address: string;
/** The finality of the request */
mode: "sign" | "broadcast";
};
/**
* Represents the response from the authorizer request
*/
export type AuthorizerResponse = {
/** Indicates a successful authorization */
type: "success";
/** The signed transaction that was authorized */
transactionJson: TransactionJson;
} | {
/** Indicates an error during authorization */
type: "error";
/** The error code */
errorCode: number;
/** The error message */
errorMessage: string;
};
export declare class Authorizer {
/**
* Get the URL to redirect to for authorization
* @param data
* @returns
*/
static getRequestUrl(data: AuthorizerRequest): string;
/**
* Get the URL to redirect to after authorization
*
* @param data
* @param url
* @returns
*/
static getResponseUrl(data: AuthorizerResponse, url: string): string;
/**
* Encode the request data
* @param data
* @returns
*/
static encodeRequest(data: AuthorizerRequest): string;
/**
* Decode the request data
* @param data
* @returns
*/
static decodeRequest(data: string): AuthorizerRequest;
/**
* Encode the response data
* @returns
*/
static encodeResponse(data: AuthorizerResponse): string;
/**
* Decode the response data
* @param data
* @returns
*/
static decodeResponse(data: string): AuthorizerResponse;
/**
* Get the response data from the URL
* @returns
*/
static getResponse(responseUrl: string): AuthorizerResponse;
}