Skip to content

Commit

Permalink
[passkey] add more doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
alex4506 committed Jul 25, 2024
1 parent 438ea68 commit 994c318
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions src/api/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,83 @@ export class Passkey {
}

/**
* Given a credentialId and a transaction, it prompts the client to sign the transaction
* Given a credentialId and a transaction, it prompts the client to sign the transaction then submits it.
*
* @param args.credentialId The credential ID of the passkey
* @param args.publicKey The public key associated with the passkey
* @param args.transaction The transaction to sign
* @param args.rpID The relying party ID
* @param args.timeout The timeout for the operation
* @param args.options The options for the operation
* @returns The pending transaction response
*/
async signAndSubmitWithPasskey(args: {
credentialId: string | Uint8Array;
publicKey: PublicKey;
transaction: AnyRawTransaction;
timeout?: number;
rpID: string;
timeout?: number;
options?: {
allowCredentials?: AllowCredentialOption[];
};
}): Promise<PendingTransactionResponse> {
return signAndSubmitWithPasskey({ aptosConfig: this.config, ...args });
}

/**
* Given a credentialId and a transaction, it prompts the client to sign the transaction.
*
* @param args.credentialId The credential ID of the passkey
* @param args.publicKey The public key associated with the passkey
* @param args.transaction The transaction to sign
* @param args.rpID The relying party ID
* @param args.timeout The timeout for the operation
* @param args.options The options for the operation
* @returns The account authenticator
*/

async signWithPasskey(args: {
credentialId: string | Uint8Array;
publicKey: PublicKey;
transaction: AnyRawTransaction;
timeout?: number;
rpID: string;
timeout?: number;
options?: {
allowCredentials?: AllowCredentialOption[];
};
}): Promise<AccountAuthenticator> {
return signWithPasskey({ ...args });
}

/**
* Given a public key, it returns the account address associated with the passkey.
* @param args.publicKey The public key associated with the passkey
* @returns The account address
*/

async getPasskeyAccountAddress(args: { publicKey: HexInput }): Promise<AccountAddress> {
return getPasskeyAccountAddress(args);
}

/**
* Generates registration options for a passkey.
* @param args.rpName The relying party name
* @param args.rpID The relying party ID
* @param args.userName The user name
* @param args.userID The user ID
* @param args.challenge The challenge
* @param args.userDisplayName The user display name
* @param args.timeout The timeout for the operation
* @param args.attestationType The attestation type
* @param args.authenticatorAttachment The authenticator attachment
* @returns The registration options
*/

async generateRegistrationOptions(args: {
rpName: string;
rpID: string;
userID?: Uint8Array;
userName: string;
userID?: Uint8Array;
challenge?: string | Uint8Array;
userDisplayName?: string;
timeout?: number;
Expand All @@ -79,12 +114,24 @@ export class Passkey {
return generateRegistrationOptions(args);
}

/**
* Registers a credential for a passkey.
* @param creationOptionsJSON
* @returns The registration response
*/

async registerCredential(
creationOptionsJSON: PublicKeyCredentialCreationOptionsJSON,
): Promise<RegistrationResponseJSON> {
return registerCredential(creationOptionsJSON);
}

/**
* Parses the public key from a registration response.
* @param response The registration response
* @returns The public key
*/

parsePublicKey(response: RegistrationResponseJSON): PublicKey {
return parsePublicKey(response);
}
Expand Down

0 comments on commit 994c318

Please sign in to comment.