@synqauth/plugin-siws
A Synq plugin for Sign In With Solana from your own UI.
@synqauth/plugin-siws
MountRequest
Type. Calls the app's route mount, from its own page: what
type MountRequest = (path: string, init?: RequestInit) => Promise<Response>;SIWS_PLUGIN_ID
Constant. The plugin's id: its server half's routes are under it, and its actions under it in usePlugin.
const SIWS_PLUGIN_ID: "siws"SiwsActions
Interface. The browser half's actions.
interface SiwsActions {
signIn: (wallet: Wallet, options?: SiwsSignInOptions) => Promise<SiwsResult<null>>;
}siwsPlugin
Function. The SIWS plugin's browser half: a wallet's sign-in from the app's own page, through the route mount.
function siwsPlugin(options?: SiwsPluginOptions): SiwsPluginSiwsPlugin
Interface. The SIWS plugin's browser half, in SynqClientPlugin's shape: for <SynqProvider plugins> or @synqauth/nextjs/client.
interface SiwsPlugin {
readonly id: typeof SIWS_PLUGIN_ID;
actions: (request: MountRequest) => SiwsActions;
}SiwsPluginOptions
Interface. What siwsPlugin() takes.
interface SiwsPluginOptions {
navigate?: (url: string) => void;
fetch?: typeof fetch;
}SiwsResult
Type. A call's outcome: its data, or the SynqError it failed with.
type SiwsResult<T> = {
readonly data: T;
readonly error: null;
} | {
readonly data: null;
readonly error: SynqError;
};SiwsSignInOptions
Interface. What signIn takes besides the wallet.
interface SiwsSignInOptions {
returnTo?: string;
account?: WalletAccount;
}@synqauth/plugin-siws/server
SiwsRouteContext
Interface. What a server plugin's route is handed: the part of
interface SiwsRouteContext {
readonly issuer: string;
readonly clientId: string;
}siwsServerPlugin
Function. The SIWS plugin's server half, for synqAuth({ plugins }): it tells the page which issuer and app to ask for a sign-in request.
function siwsServerPlugin(): SiwsServerPluginSiwsServerPlugin
Interface. The server half, in
interface SiwsServerPlugin {
readonly id: 'siws';
readonly routes: {
readonly 'GET /config': (context: SiwsRouteContext, request: Request) => Response;
};
}See every package.