Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log

## 1.2.0

* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification`
* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in
* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models

## 1.1.0

* Added: `Account.createRecoveryOTP` and `Account.updateRecoveryOTP` for code-based password recovery
Expand Down
13 changes: 13 additions & 0 deletions docs/examples/account/create-passkey-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.createPasskeyToken();

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/account/create-passkey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.createPasskey({
passkeyId: '<PASSKEY_ID>', // optional
name: '<NAME>', // optional
});

console.log(result);
```
15 changes: 15 additions & 0 deletions docs/examples/account/delete-passkey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.deletePasskey({
passkeyId: '<PASSKEY_ID>',
});

console.log(result);
```
15 changes: 15 additions & 0 deletions docs/examples/account/get-passkey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.getPasskey({
passkeyId: '<PASSKEY_ID>',
});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/account/list-passkeys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.listPasskeys({
queries: [], // optional
total: false, // optional
});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/account/update-passkey-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.updatePasskeyToken({
challengeId: '<CHALLENGE_ID>',
credential: {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example sends an empty passkey credential

The endpoint requires the JSON credential returned by the authenticator, but this example passes {}, so copying it always results in a rejected sign-in request. The registration verification example has the same empty-credential placeholder.

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/examples/account/update-passkey-token.md
Line: 12

Comment:
**Example sends an empty passkey credential**

The endpoint requires the JSON credential returned by the authenticator, but this example passes `{}`, so copying it always results in a rejected sign-in request. The registration verification example has the same empty-credential placeholder.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · documentation · Reply if this doesn't apply.

});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/account/update-passkey-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.updatePasskeyVerification({
passkeyId: '<PASSKEY_ID>',
credential: {},
});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/account/update-passkey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Account } from 'react-native-appwrite';

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const account = new Account(client);

const result = await account.updatePasskey({
passkeyId: '<PASSKEY_ID>',
name: '<NAME>',
});

console.log(result);
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
"version": "1.1.0",
"version": "1.2.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Client {
'x-sdk-name': 'React Native',
'x-sdk-platform': 'client',
'x-sdk-language': 'reactnative',
'x-sdk-version': '1.1.0',
'x-sdk-version': '1.2.0',
'X-Appwrite-Response-Format': '2.3.0',
};

Expand Down
96 changes: 96 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,102 @@ export namespace Models {
expire: string;
};

/**
* Token Secret
*/
export type TokenSecret = {
/**
* Token ID.
*/
$id: string;
/**
* Token creation date in ISO 8601 format.
*/
$createdAt: string;
/**
* User ID.
*/
userId: string;
/**
* Token secret key. Exchange it for a session with the create session endpoint.
*/
secret: string;
/**
* Token expiration date in ISO 8601 format.
*/
expire: string;
/**
* Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email.
*/
phrase: string;
};

/**
* Passkey
*/
export type Passkey = {
/**
* Passkey ID.
*/
$id: string;
/**
* Passkey creation date in ISO 8601 format.
*/
$createdAt: string;
/**
* Passkey update date in ISO 8601 format.
*/
$updatedAt: string;
/**
* Passkey name.
*/
name: string;
/**
* Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in.
*/
accessedAt: string;
};

/**
* Passkey Challenge
*/
export type PasskeyChallenge = {
/**
* Challenge ID. When signing in, pass it back with the credential to receive a token.
*/
$id: string;
/**
* Challenge creation date in ISO 8601 format.
*/
$createdAt: string;
/**
* ID of the passkey being registered. Empty for sign-in challenges.
*/
passkeyId: string;
/**
* Challenge expiration date in ISO 8601 format.
*/
expire: string;
/**
* WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in.
*/
publicKey: object;
};

/**
* Passkeys List
*/
export type PasskeyList = {
/**
* Total number of passkeys that matched your query.
*/
total: number;
/**
* List of passkeys.
*/
passkeys: Passkey[];
};

/**
* MFA Recovery Codes
*/
Expand Down
Loading
Loading