UNPKG

@safe-global/protocol-kit

Version:

SDK that facilitates the interaction with Safe Smart Accounts

57 lines 3.53 kB
import { PasskeyArgType, PasskeyCoordinates } from '../../types'; /** * Decodes a Base64-encoded ECDSA public key for React Native and extracts the x and y coordinates. * * This function handles both ASN.1 DER-encoded keys and uncompressed keys. It decodes a Base64-encoded * public key, checks its format, and extracts the x and y coordinates using the `@noble/curves` library. * The coordinates are returned as hexadecimal strings prefixed with '0x'. * * @param {string} publicKey - The Base64-encoded public key to decode. * @returns {PasskeyCoordinates} An object containing the x and y coordinates of the public key. * @throws {Error} Throws an error if the key is empty or if the coordinates cannot be extracted. */ export declare function decodePublicKeyForReactNative(publicKey: string): Promise<PasskeyCoordinates>; /** * Decodes an ECDSA public key for the web platform and extracts the x and y coordinates. * * This function uses the Web Crypto API to import a public key in SPKI format and then * exports it to a JWK format to retrieve the x and y coordinates. The coordinates are * returned as hexadecimal strings prefixed with '0x'. * * @param {ArrayBuffer} publicKey - The public key in SPKI format to decode. * @returns {Promise<PasskeyCoordinates>} A promise that resolves to an object containing * the x and y coordinates of the public key. * @throws {Error} Throws an error if the key coordinates cannot be extracted. */ export declare function decodePublicKeyForWeb(publicKey: ArrayBuffer): Promise<PasskeyCoordinates>; /** * Decodes the x and y coordinates of the public key from a created public key credential response. * * @param {AuthenticatorResponse} response * @returns {PasskeyCoordinates} Object containing the coordinates derived from the public key of the passkey. * @throws {Error} Throws an error if the coordinates could not be extracted via `p256.ProjectivePoint.fromHex` */ export declare function decodePublicKey(response: AuthenticatorResponse): Promise<PasskeyCoordinates>; /** * Extracts and returns the passkey data (coordinates and rawId) from a given passkey Credential. * * @param {Credential} passkeyCredential - The passkey credential generated via `navigator.credentials.create()` or other method in another platforms. * @returns {Promise<PasskeyArgType>} A promise that resolves to an object containing the coordinates and the rawId derived from the passkey. * This is the important information in the Safe account context and should be stored securely as it is used to verify the passkey and to instantiate the SDK * as a signer (`Safe.init()) * @throws {Error} Throws an error if the coordinates could not be extracted */ export declare function extractPasskeyData(passkeyCredential: Credential): Promise<PasskeyArgType>; /** * Retrieves the default FCLP256 Verifier address for a given blockchain network. * * This function fetches the deployment information for the FCLP256 Verifier and * returns the verifier address associated with the specified chain ID. It ensures * that the correct version and release status are used. * * @param {string} chainId - The ID of the blockchain network to retrieve the verifier address for. * @returns {string} The FCLP256 Verifier address for the specified chain ID. * @throws {Error} Throws an error if the deployment information or address cannot be found. */ export declare function getDefaultFCLP256VerifierAddress(chainId: string): string; //# sourceMappingURL=extractPasskeyData.d.ts.map