next-auth-hashpack
Version:
Authenticate with Hashpack wallet using NextAuthJs library.
26 lines (25 loc) • 1.39 kB
TypeScript
import { NextApiRequest, NextApiResponse } from "next";
import { HederaNetworkType } from "./hashpackProvider";
export interface InitializingResponse {
signature: Uint8Array;
serverSigningAccount: string;
payload: any;
}
export interface IPreInitializingCallback {
network: HederaNetworkType;
accountId: string;
data?: any;
}
export type PreInitializingCallback = ({ network, accountId, data }: IPreInitializingCallback) => void;
/**
* call this function from a route that spouse to initiate the authentication with hashpack wallet. it signs a data and pass it to client.
* @param req {NextApiRequest}
* @param res {NextApiResponse}
* @param ServerAccountId {string} Sever's account Id on Hedera Hashgraph network
* @param ServerPrivateKey {PrivateKey} Server's account private key on Hedera Hashgraph
* @param data {any} the data you are going to sign
* @param network {'testnet' | 'mainnet' | previewnet} using Hedera's testnet or mainnet
* @param preInitializingCallback runs after validation, receives accountId and optionally original data
* @returns {Promise<void>}
*/
export declare function authInitializer(req: NextApiRequest, res: NextApiResponse, ServerAccountId: string, ServerPrivateKey: string, data: any, network?: HederaNetworkType, preInitializingCallback?: PreInitializingCallback, debug?: boolean): Promise<void>;