next-auth-hashpack
Version:
Authenticate with Hashpack wallet using NextAuthJs library.
48 lines (47 loc) • 2.11 kB
TypeScript
import * as React from "react";
import { HashConnect } from "hashconnect/dist/esm/hashconnect";
import { SignInOptions } from "next-auth/react";
import { HashConnectConnectionState } from "hashconnect/dist/esm/types";
export type AuthenticationResponse = {
success: boolean;
error?: string;
signedPayload?: Uint8Array;
userSignature?: Uint8Array;
};
export interface IAuthHashConnectIntegration {
hashConnect: HashConnect;
network: HederaNetworkType;
hashConnectTopic: string;
hashConnectState?: HashConnectConnectionState;
pairedAccountId: string;
signInOptions?: SignInOptions;
authInitializerApiRoute?: string;
}
export interface IAuthHashPackButton extends IAuthHashConnectIntegration {
children?: React.ReactNode;
id?: string;
className?: string;
style?: any;
onError?: (error: string) => void;
onStart?: () => void;
onSuccess?: (accountId?: string) => void;
}
type HederaNetworkType = 'mainnet' | 'testnet' | 'previewnet';
interface IHashpackAuthenticationHookProps {
hashConnect: HashConnect;
network: HederaNetworkType;
hashConnectTopic: string;
pairedAccountId: string;
signInOptions?: SignInOptions;
authInitializerApiRoute?: string;
onSuccess?: (accountId?: string) => void;
}
export declare const useHashpackAuthentication: ({ hashConnect, network, hashConnectTopic, pairedAccountId, signInOptions, authInitializerApiRoute, onSuccess }: IHashpackAuthenticationHookProps) => {
authenticate: (ApiRouteUrl?: string) => Promise<void>;
sign: (authenticationResponse: any, onSuccess?: ((accountId?: string) => void) | undefined) => Promise<void>;
error: string;
};
export declare const HashpackButton: (props: IAuthHashPackButton) => import("@emotion/react/jsx-runtime").JSX.Element;
export declare const ProvidersCard: (props: IAuthHashConnectIntegration) => import("@emotion/react/jsx-runtime").JSX.Element;
export declare const SignInSection: (props: IAuthHashConnectIntegration) => import("@emotion/react/jsx-runtime").JSX.Element;
export {};