@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
185 lines • 7.93 kB
TypeScript
import { Account } from "../account/index.js";
import { EphemeralKeyPair } from "../account/EphemeralKeyPair.js";
import { KeylessAccount } from "../account/KeylessAccount.js";
import { ProofFetchCallback } from "../account/AbstractKeylessAccount.js";
import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount.js";
import { AccountAddressInput } from "../core/accountAddress.js";
import { ZeroKnowledgeSig } from "../core/crypto/keyless.js";
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions/index.js";
import { HexInput } from "../types/index.js";
import { AptosConfig } from "./aptosConfig.js";
/**
* A class to query all `Keyless` related queries on Aptos.
*
* More documentation on how to integrate Keyless Accounts see the below
* [Aptos Keyless Integration Guide](https://aptos.dev/guides/keyless-accounts/#aptos-keyless-integration-guide).
* @group Keyless
*/
export declare class Keyless {
readonly config: AptosConfig;
/**
* Initializes a new instance of the Aptos class with the provided configuration.
* This allows you to interact with the Aptos blockchain using the specified network settings.
*
* @param config - The configuration settings for connecting to the Aptos network.
*
* @example
* ```typescript
* import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
*
* async function runExample() {
* // Create a new configuration for the Aptos client
* const config = new AptosConfig({ network: Network.TESTNET }); // Specify your desired network
*
* // Initialize the Aptos client with the configuration
* const aptos = new Aptos(config);
*
* console.log("Aptos client initialized:", aptos);
* }
* runExample().catch(console.error);
* ```
* @group Keyless
*/
constructor(config: AptosConfig);
/**
* Fetches the pepper from the Aptos pepper service API.
*
* @param args - The arguments for fetching the pepper.
* @param args.jwt - JWT token.
* @param args.ephemeralKeyPair - The EphemeralKeyPair used to generate the nonce in the JWT token.
* @param args.derivationPath - A derivation path used for creating multiple accounts per user via the BIP-44 standard. Defaults
* to "m/44'/637'/0'/0'/0".
* @returns The pepper which is a Uint8Array of length 31.
*
* @example
* ```typescript
* import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
*
* const config = new AptosConfig({ network: Network.TESTNET });
* const aptos = new Aptos(config);
*
* async function runExample() {
* const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair
* const jwt = "your_jwt_token"; // replace with a real JWT token
*
* // Fetching the pepper using the provided JWT and ephemeral key pair
* const pepper = await aptos.getPepper({
* jwt,
* ephemeralKeyPair,
* // derivationPath: "m/44'/637'/0'/0'/0" // specify your own if needed
* });
*
* console.log("Fetched pepper:", pepper);
* }
* runExample().catch(console.error);
* ```
* @group Keyless
*/
getPepper(args: {
jwt: string;
ephemeralKeyPair: EphemeralKeyPair;
derivationPath?: string;
}): Promise<Uint8Array>;
/**
* Fetches the `pepper_base` from the Aptos pepper service API.
*
* The `pepper_base` is the VUF signature from which the final pepper is derived — a 48-byte compressed
* BLS12-381 G1 point. It is deterministic for a given OIDC identity and independent of the ephemeral key
* and derivation path, making it a stable seed for deriving a confidential-asset decryption key (DK) via
* `@aptos-labs/confidential-asset`'s `TwistedEd25519PrivateKey.fromPepperBase`. Deriving the DK from
* `pepper_base` (rather than the final pepper, which is a one-way hash of it) ensures a leaked pepper does
* not compromise confidentiality.
*
* @param args - The arguments for fetching the pepper base.
* @param args.jwt - JWT token.
* @param args.ephemeralKeyPair - The EphemeralKeyPair used to generate the nonce in the JWT token.
* @param args.uidKey - An optional key in the JWT token to use to set the uidVal in the IdCommitment.
* @param args.derivationPath - A derivation path used for creating multiple accounts per user via the
* BIP-44 standard. Note: `pepper_base` itself does not depend on the derivation path.
* @returns The `pepper_base` as a Uint8Array of length 48.
* @group Keyless
*/
getPepperBase(args: {
jwt: string;
ephemeralKeyPair: EphemeralKeyPair;
uidKey?: string;
derivationPath?: string;
}): Promise<Uint8Array>;
/**
* Fetches a proof from the Aptos prover service API.
*
* @param args - The arguments for fetching the proof.
* @param args.jwt - JWT token.
* @param args.ephemeralKeyPair - The EphemeralKeyPair used to generate the nonce in the JWT token.
* @param args.pepper - The pepper used for the account. If not provided, it will be fetched from the Aptos pepper service.
* @param args.uidKey - A key in the JWT token to use to set the uidVal in the IdCommitment.
*
* @returns The proof which is represented by a ZeroKnowledgeSig.
*
* @example
* ```typescript
* import { Aptos, AptosConfig, Network, EphemeralKeyPair, getPepper } from "@aptos-labs/ts-sdk";
*
* const config = new AptosConfig({ network: Network.TESTNET });
* const aptos = new Aptos(config);
*
* async function runExample() {
* const jwt = "your_jwt_token"; // replace with a real JWT token
* const ephemeralKeyPair = new EphemeralKeyPair(); // create a new ephemeral key pair
*
* // Fetch the proof using the getProof function
* const proof = await aptos.getProof({
* jwt,
* ephemeralKeyPair,
* pepper: await getPepper({}), // fetch the pepper if not provided
* uidKey: "sub", // specify the uid key
* });
*
* console.log("Fetched proof:", proof);
* }
* runExample().catch(console.error);
* ```
* @group Keyless
*/
getProof(args: {
jwt: string;
ephemeralKeyPair: EphemeralKeyPair;
pepper?: HexInput;
uidKey?: string;
}): Promise<ZeroKnowledgeSig>;
deriveKeylessAccount(args: {
jwt: string;
ephemeralKeyPair: EphemeralKeyPair;
uidKey?: string;
pepper?: HexInput;
proofFetchCallback?: ProofFetchCallback;
}): Promise<KeylessAccount>;
deriveKeylessAccount(args: {
jwt: string;
ephemeralKeyPair: EphemeralKeyPair;
jwkAddress: AccountAddressInput;
uidKey?: string;
pepper?: HexInput;
proofFetchCallback?: ProofFetchCallback;
}): Promise<FederatedKeylessAccount>;
/**
* This installs a set of FederatedJWKs at an address for a given iss.
*
* It will fetch the JSON Web Keyset (JWK) set from the well-known endpoint and update the FederatedJWKs at the sender's address
* to reflect it.
*
* @param args.sender The account that will install the JWKs
* @param args.iss the iss claim of the federated OIDC provider.
* @param args.jwksUrl the URL to find the corresponding JWKs. For supported IDP providers this parameter in not necessary.
*
* @returns The pending transaction that results from submission.
* @group Keyless
*/
updateFederatedKeylessJwkSetTransaction(args: {
sender: Account;
iss: string;
jwksUrl?: string;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
}
//# sourceMappingURL=keyless.d.ts.map