Skip to content

Commit 863cb54

Browse files
committed
chore: add documentation for react native sdk
1 parent 19acaad commit 863cb54

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

packages/sdk-platforms/react-native/react-native-zksync-sso/src/passkey/authenticate.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import {
1010
arrayBufferToBase64Url
1111
} from './utils';
1212

13+
/**
14+
* Authenticates a user using their platform passkey and returns the authentication data.
15+
*
16+
* @param message - The challenge message to authenticate against, as an ArrayBuffer
17+
* @param rpId - The relying party ID used for passkey authentication
18+
* @returns A Promise that resolves to an ArrayBuffer containing the encoded authentication payload
19+
*/
1320
export const authenticateWithPasskey = async (
1421
message: ArrayBuffer,
1522
rpId: string

packages/sdk-platforms/react-native/react-native-zksync-sso/src/passkey/authenticate/authenticator.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22
import { type PasskeyAuthenticatorAsync } from 'react-native-zksync-sso';
33
import { authenticateWithPasskey } from '../authenticate';
44

5+
/**
6+
* Authenticator class that implements passkey-based authentication.
7+
* This class handles the signing of messages using platform-specific passkey authentication.
8+
*/
59
export class Authenticator implements PasskeyAuthenticatorAsync {
610
private rpId: string;
711

12+
/**
13+
* Creates a new Authenticator instance.
14+
* @param rpId - The relying party ID used for passkey authentication
15+
*/
816
constructor(rpId: string) {
917
this.rpId = rpId;
1018
}
1119

20+
/**
21+
* Signs a message using the platform's passkey authentication.
22+
* @param message - The message to sign as an ArrayBuffer
23+
* @returns A Promise that resolves to the signed message as an ArrayBuffer
24+
*/
1225
async signMessage(
1326
message: ArrayBuffer,
1427
): Promise<ArrayBuffer> {

packages/sdk-platforms/react-native/react-native-zksync-sso/src/passkey/register.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,34 @@ import {
1515
base64ToArrayBuffer
1616
} from './utils';
1717

18+
/**
19+
* Information about the relying party (RP) for passkey registration
20+
*/
1821
export interface RPInfo {
1922
name: string;
2023
id: string;
2124
}
2225

26+
/**
27+
* Information about the account being registered
28+
*/
2329
export interface AccountInfo {
2430
name: string;
2531
userID: string;
2632
rp: RPInfo;
2733
}
2834

35+
/**
36+
* Registers a new account using a platform passkey and deploys it.
37+
* This function handles the creation of a new passkey and the deployment of the account
38+
* with the generated credentials.
39+
*
40+
* @param accountInfo - Information about the account to register
41+
* @param secretAccountSalt - Salt used for account derivation
42+
* @param challenge - Challenge string for passkey creation
43+
* @param config - Configuration for deployment
44+
* @returns A Promise that resolves to the deployed Account
45+
*/
2946
export const registerAccountWithUniqueId = async (
3047
accountInfo: AccountInfo,
3148
secretAccountSalt: string,

0 commit comments

Comments
 (0)