@aptos-labs/siwa
Version:
Library of utilities for Sign in with Aptos
65 lines • 2.58 kB
TypeScript
import { type Aptos, type PublicKey, type Signature } from "@aptos-labs/ts-sdk";
import type { AptosSignInBoundFields, AptosSignInInput } from "@aptos-labs/wallet-standard";
import type { VerificationResult, VerificationResultWithData } from "./types.js";
/**
* Create a SIWA message from the input following the ABNF format defined in the Sign in with Aptos specifications.
*
* @param input The input to create the SIWA message from.
*
* @returns The SIWA message text.
*/
export declare function createSignInMessage(input: AptosSignInInput & AptosSignInBoundFields): string;
/**
* Generate a signing message using the SIWA signing algorithm.
* ( sha3_256(b"SIGN_IN_WITH_APTOS::" ) || <message> )
*
* @param message The SIWA message to sign.
*
* @returns The signing message.
*/
export declare function createSignInSigningMessage(message: string): Uint8Array;
/**
* Parse a SIWA message into an `AptosSignInInput` object with the required fields.
*
* @param text The SIWA message to parse.
*
* @returns The parsed `AptosSignInInput` object with the required fields.
*/
export declare function parseSignInMessage(text: string): VerificationResultWithData<AptosSignInInput & AptosSignInBoundFields>;
/**
* Verifies a SIWA plain text message against expected `AptosSignInInput` fields (including required fields).
*
* @param params.publicKey The public key of the user that is signing in.
* @param params.expected The expected fields to verify against the input.
* @param params.message The SIWA plain text message to verify.
*
* @param options.aptosConfig The Aptos configuration to use for the verification.
* @param options.excludedResources The resources to exclude from the verification.
*
* @returns The verification result.
*/
export declare function verifySignInMessage(params: {
publicKey: PublicKey;
expected: AptosSignInInput & {
domain: string;
};
input: AptosSignInInput & AptosSignInBoundFields;
}, options?: {
aptos?: Aptos;
excludedResources?: string[];
}): Promise<VerificationResult>;
/**
* Using the `publicKey` and `signature`, verify that the `signature` is valid for the `message`.
*
* @param output The `AptosSignInOutput` to verify against the input.
*
* @returns The `AptosSignInInput` fields that are parsed from the message.
*/
export declare function verifySignInSignature(output: {
publicKey: PublicKey;
signature: Signature;
input: AptosSignInInput & AptosSignInBoundFields;
}, options?: {
aptos?: Aptos;
}): Promise<VerificationResult>;
//# sourceMappingURL=core.d.ts.map