react-native-appwrite 0.15.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/sdk.js +431 -21
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +431 -21
- package/dist/esm/sdk.js.map +1 -1
- package/docs/examples/account/create-email-verification.md +13 -0
- package/docs/examples/account/update-email-verification.md +14 -0
- package/docs/examples/databases/create-document.md +2 -1
- package/docs/examples/databases/create-operations.md +24 -0
- package/docs/examples/databases/create-transaction.md +13 -0
- package/docs/examples/databases/decrement-document-attribute.md +2 -1
- package/docs/examples/databases/delete-document.md +2 -1
- package/docs/examples/databases/delete-transaction.md +13 -0
- package/docs/examples/databases/get-document.md +2 -1
- package/docs/examples/databases/get-transaction.md +13 -0
- package/docs/examples/databases/increment-document-attribute.md +2 -1
- package/docs/examples/databases/list-documents.md +2 -1
- package/docs/examples/databases/list-transactions.md +13 -0
- package/docs/examples/databases/update-document.md +2 -1
- package/docs/examples/databases/update-transaction.md +15 -0
- package/docs/examples/databases/upsert-document.md +2 -1
- package/docs/examples/tablesdb/create-operations.md +24 -0
- package/docs/examples/tablesdb/create-row.md +2 -1
- package/docs/examples/tablesdb/create-transaction.md +13 -0
- package/docs/examples/tablesdb/decrement-row-column.md +2 -1
- package/docs/examples/tablesdb/delete-row.md +2 -1
- package/docs/examples/tablesdb/delete-transaction.md +13 -0
- package/docs/examples/tablesdb/get-row.md +2 -1
- package/docs/examples/tablesdb/get-transaction.md +13 -0
- package/docs/examples/tablesdb/increment-row-column.md +2 -1
- package/docs/examples/tablesdb/list-rows.md +2 -1
- package/docs/examples/tablesdb/list-transactions.md +13 -0
- package/docs/examples/tablesdb/update-row.md +2 -1
- package/docs/examples/tablesdb/update-transaction.md +15 -0
- package/docs/examples/tablesdb/upsert-row.md +2 -1
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/models.ts +44 -0
- package/src/services/account.ts +123 -4
- package/src/services/databases.ts +414 -56
- package/src/services/tables-db.ts +426 -68
- package/types/models.d.ts +42 -0
- package/types/services/account.d.ts +49 -0
- package/types/services/databases.d.ts +155 -8
- package/types/services/tables-db.d.ts +167 -20
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, Account } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const account = new Account(client);
|
|
8
|
+
|
|
9
|
+
const result = await account.createEmailVerification({
|
|
10
|
+
url: 'https://example.com'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Client, Account } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const account = new Account(client);
|
|
8
|
+
|
|
9
|
+
const result = await account.updateEmailVerification({
|
|
10
|
+
userId: '<USER_ID>',
|
|
11
|
+
secret: '<SECRET>'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
console.log(result);
|
|
@@ -17,7 +17,8 @@ const result = await databases.createDocument({
|
|
|
17
17
|
"age": 30,
|
|
18
18
|
"isAdmin": false
|
|
19
19
|
},
|
|
20
|
-
permissions: ["read("any")"] // optional
|
|
20
|
+
permissions: ["read("any")"], // optional
|
|
21
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
console.log(result);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.createOperations({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>',
|
|
11
|
+
operations: [
|
|
12
|
+
{
|
|
13
|
+
"action": "create",
|
|
14
|
+
"databaseId": "<DATABASE_ID>",
|
|
15
|
+
"collectionId": "<COLLECTION_ID>",
|
|
16
|
+
"documentId": "<DOCUMENT_ID>",
|
|
17
|
+
"data": {
|
|
18
|
+
"name": "Walter O'Brien"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
] // optional
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.createTransaction({
|
|
10
|
+
ttl: 60 // optional
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -12,7 +12,8 @@ const result = await databases.decrementDocumentAttribute({
|
|
|
12
12
|
documentId: '<DOCUMENT_ID>',
|
|
13
13
|
attribute: '',
|
|
14
14
|
value: 0, // optional
|
|
15
|
-
min: 0 // optional
|
|
15
|
+
min: 0, // optional
|
|
16
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
console.log(result);
|
|
@@ -9,7 +9,8 @@ const databases = new Databases(client);
|
|
|
9
9
|
const result = await databases.deleteDocument({
|
|
10
10
|
databaseId: '<DATABASE_ID>',
|
|
11
11
|
collectionId: '<COLLECTION_ID>',
|
|
12
|
-
documentId: '<DOCUMENT_ID>'
|
|
12
|
+
documentId: '<DOCUMENT_ID>',
|
|
13
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.deleteTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -10,7 +10,8 @@ const result = await databases.getDocument({
|
|
|
10
10
|
databaseId: '<DATABASE_ID>',
|
|
11
11
|
collectionId: '<COLLECTION_ID>',
|
|
12
12
|
documentId: '<DOCUMENT_ID>',
|
|
13
|
-
queries: [] // optional
|
|
13
|
+
queries: [], // optional
|
|
14
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.getTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -12,7 +12,8 @@ const result = await databases.incrementDocumentAttribute({
|
|
|
12
12
|
documentId: '<DOCUMENT_ID>',
|
|
13
13
|
attribute: '',
|
|
14
14
|
value: 0, // optional
|
|
15
|
-
max: 0 // optional
|
|
15
|
+
max: 0, // optional
|
|
16
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
console.log(result);
|
|
@@ -9,7 +9,8 @@ const databases = new Databases(client);
|
|
|
9
9
|
const result = await databases.listDocuments({
|
|
10
10
|
databaseId: '<DATABASE_ID>',
|
|
11
11
|
collectionId: '<COLLECTION_ID>',
|
|
12
|
-
queries: [] // optional
|
|
12
|
+
queries: [], // optional
|
|
13
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.listTransactions({
|
|
10
|
+
queries: [] // optional
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -11,7 +11,8 @@ const result = await databases.updateDocument({
|
|
|
11
11
|
collectionId: '<COLLECTION_ID>',
|
|
12
12
|
documentId: '<DOCUMENT_ID>',
|
|
13
13
|
data: {}, // optional
|
|
14
|
-
permissions: ["read("any")"] // optional
|
|
14
|
+
permissions: ["read("any")"], // optional
|
|
15
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
console.log(result);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Client, Databases } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const databases = new Databases(client);
|
|
8
|
+
|
|
9
|
+
const result = await databases.updateTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>',
|
|
11
|
+
commit: false, // optional
|
|
12
|
+
rollback: false // optional
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
console.log(result);
|
|
@@ -11,7 +11,8 @@ const result = await databases.upsertDocument({
|
|
|
11
11
|
collectionId: '<COLLECTION_ID>',
|
|
12
12
|
documentId: '<DOCUMENT_ID>',
|
|
13
13
|
data: {},
|
|
14
|
-
permissions: ["read("any")"] // optional
|
|
14
|
+
permissions: ["read("any")"], // optional
|
|
15
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
console.log(result);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.createOperations({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>',
|
|
11
|
+
operations: [
|
|
12
|
+
{
|
|
13
|
+
"action": "create",
|
|
14
|
+
"databaseId": "<DATABASE_ID>",
|
|
15
|
+
"tableId": "<TABLE_ID>",
|
|
16
|
+
"rowId": "<ROW_ID>",
|
|
17
|
+
"data": {
|
|
18
|
+
"name": "Walter O'Brien"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
] // optional
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.createTransaction({
|
|
10
|
+
ttl: 60 // optional
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
|
|
|
9
9
|
const result = await tablesDB.deleteRow({
|
|
10
10
|
databaseId: '<DATABASE_ID>',
|
|
11
11
|
tableId: '<TABLE_ID>',
|
|
12
|
-
rowId: '<ROW_ID>'
|
|
12
|
+
rowId: '<ROW_ID>',
|
|
13
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.deleteTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.getTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
|
|
|
9
9
|
const result = await tablesDB.listRows({
|
|
10
10
|
databaseId: '<DATABASE_ID>',
|
|
11
11
|
tableId: '<TABLE_ID>',
|
|
12
|
-
queries: [] // optional
|
|
12
|
+
queries: [], // optional
|
|
13
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
console.log(result);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.listTransactions({
|
|
10
|
+
queries: [] // optional
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log(result);
|
|
@@ -11,7 +11,8 @@ const result = await tablesDB.updateRow({
|
|
|
11
11
|
tableId: '<TABLE_ID>',
|
|
12
12
|
rowId: '<ROW_ID>',
|
|
13
13
|
data: {}, // optional
|
|
14
|
-
permissions: ["read("any")"] // optional
|
|
14
|
+
permissions: ["read("any")"], // optional
|
|
15
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
console.log(result);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Client, TablesDB } from "react-native-appwrite";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const tablesDB = new TablesDB(client);
|
|
8
|
+
|
|
9
|
+
const result = await tablesDB.updateTransaction({
|
|
10
|
+
transactionId: '<TRANSACTION_ID>',
|
|
11
|
+
commit: false, // optional
|
|
12
|
+
rollback: false // optional
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
console.log(result);
|
|
@@ -11,7 +11,8 @@ const result = await tablesDB.upsertRow({
|
|
|
11
11
|
tableId: '<TABLE_ID>',
|
|
12
12
|
rowId: '<ROW_ID>',
|
|
13
13
|
data: {}, // optional
|
|
14
|
-
permissions: ["read("any")"] // optional
|
|
14
|
+
permissions: ["read("any")"], // optional
|
|
15
|
+
transactionId: '<TRANSACTION_ID>' // optional
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
console.log(result);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-native-appwrite",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.17.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "dist/cjs/sdk.js",
|
|
8
8
|
"exports": {
|
package/src/client.ts
CHANGED
package/src/models.ts
CHANGED
|
@@ -215,6 +215,20 @@ export namespace Models {
|
|
|
215
215
|
localeCodes: LocaleCode[];
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Transaction List
|
|
220
|
+
*/
|
|
221
|
+
export type TransactionList = {
|
|
222
|
+
/**
|
|
223
|
+
* Total number of transactions that matched your query.
|
|
224
|
+
*/
|
|
225
|
+
total: number;
|
|
226
|
+
/**
|
|
227
|
+
* List of transactions.
|
|
228
|
+
*/
|
|
229
|
+
transactions: Transaction[];
|
|
230
|
+
}
|
|
231
|
+
|
|
218
232
|
/**
|
|
219
233
|
* Row
|
|
220
234
|
*/
|
|
@@ -1238,6 +1252,36 @@ export namespace Models {
|
|
|
1238
1252
|
recoveryCode: boolean;
|
|
1239
1253
|
}
|
|
1240
1254
|
|
|
1255
|
+
/**
|
|
1256
|
+
* Transaction
|
|
1257
|
+
*/
|
|
1258
|
+
export type Transaction = {
|
|
1259
|
+
/**
|
|
1260
|
+
* Transaction ID.
|
|
1261
|
+
*/
|
|
1262
|
+
$id: string;
|
|
1263
|
+
/**
|
|
1264
|
+
* Transaction creation time in ISO 8601 format.
|
|
1265
|
+
*/
|
|
1266
|
+
$createdAt: string;
|
|
1267
|
+
/**
|
|
1268
|
+
* Transaction update date in ISO 8601 format.
|
|
1269
|
+
*/
|
|
1270
|
+
$updatedAt: string;
|
|
1271
|
+
/**
|
|
1272
|
+
* Current status of the transaction. One of: pending, committing, committed, rolled_back, failed.
|
|
1273
|
+
*/
|
|
1274
|
+
status: string;
|
|
1275
|
+
/**
|
|
1276
|
+
* Number of operations in the transaction.
|
|
1277
|
+
*/
|
|
1278
|
+
operations: number;
|
|
1279
|
+
/**
|
|
1280
|
+
* Expiration time in ISO 8601 format.
|
|
1281
|
+
*/
|
|
1282
|
+
expiresAt: string;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1241
1285
|
/**
|
|
1242
1286
|
* Subscriber
|
|
1243
1287
|
*/
|
package/src/services/account.ts
CHANGED
|
@@ -2427,6 +2427,62 @@ export class Account extends Service {
|
|
|
2427
2427
|
* @throws {AppwriteException}
|
|
2428
2428
|
* @returns {Promise}
|
|
2429
2429
|
*/
|
|
2430
|
+
createEmailVerification(params: { url: string }): Promise<Models.Token>;
|
|
2431
|
+
/**
|
|
2432
|
+
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
|
|
2433
|
+
*
|
|
2434
|
+
* Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
|
|
2435
|
+
*
|
|
2436
|
+
*
|
|
2437
|
+
* @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
|
2438
|
+
* @throws {AppwriteException}
|
|
2439
|
+
* @returns {Promise<Models.Token>}
|
|
2440
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2441
|
+
*/
|
|
2442
|
+
createEmailVerification(url: string): Promise<Models.Token>;
|
|
2443
|
+
createEmailVerification(
|
|
2444
|
+
paramsOrFirst: { url: string } | string
|
|
2445
|
+
): Promise<Models.Token> {
|
|
2446
|
+
let params: { url: string };
|
|
2447
|
+
|
|
2448
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2449
|
+
params = (paramsOrFirst || {}) as { url: string };
|
|
2450
|
+
} else {
|
|
2451
|
+
params = {
|
|
2452
|
+
url: paramsOrFirst as string
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
const url = params.url;
|
|
2457
|
+
|
|
2458
|
+
if (typeof url === 'undefined') {
|
|
2459
|
+
throw new AppwriteException('Missing required parameter: "url"');
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
const apiPath = '/account/verifications/email';
|
|
2463
|
+
const payload: Payload = {};
|
|
2464
|
+
|
|
2465
|
+
if (typeof url !== 'undefined') {
|
|
2466
|
+
payload['url'] = url;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2470
|
+
return this.client.call('post', uri, {
|
|
2471
|
+
'content-type': 'application/json',
|
|
2472
|
+
}, payload);
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
|
|
2477
|
+
*
|
|
2478
|
+
* Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
|
|
2479
|
+
*
|
|
2480
|
+
*
|
|
2481
|
+
* @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
|
2482
|
+
* @throws {AppwriteException}
|
|
2483
|
+
* @returns {Promise}
|
|
2484
|
+
* @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.
|
|
2485
|
+
*/
|
|
2430
2486
|
createVerification(params: { url: string }): Promise<Models.Token>;
|
|
2431
2487
|
/**
|
|
2432
2488
|
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
|
|
@@ -2459,7 +2515,7 @@ export class Account extends Service {
|
|
|
2459
2515
|
throw new AppwriteException('Missing required parameter: "url"');
|
|
2460
2516
|
}
|
|
2461
2517
|
|
|
2462
|
-
const apiPath = '/account/
|
|
2518
|
+
const apiPath = '/account/verifications/email';
|
|
2463
2519
|
const payload: Payload = {};
|
|
2464
2520
|
|
|
2465
2521
|
if (typeof url !== 'undefined') {
|
|
@@ -2480,6 +2536,69 @@ export class Account extends Service {
|
|
|
2480
2536
|
* @throws {AppwriteException}
|
|
2481
2537
|
* @returns {Promise}
|
|
2482
2538
|
*/
|
|
2539
|
+
updateEmailVerification(params: { userId: string, secret: string }): Promise<Models.Token>;
|
|
2540
|
+
/**
|
|
2541
|
+
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
|
|
2542
|
+
*
|
|
2543
|
+
* @param {string} userId - User ID.
|
|
2544
|
+
* @param {string} secret - Valid verification token.
|
|
2545
|
+
* @throws {AppwriteException}
|
|
2546
|
+
* @returns {Promise<Models.Token>}
|
|
2547
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2548
|
+
*/
|
|
2549
|
+
updateEmailVerification(userId: string, secret: string): Promise<Models.Token>;
|
|
2550
|
+
updateEmailVerification(
|
|
2551
|
+
paramsOrFirst: { userId: string, secret: string } | string,
|
|
2552
|
+
...rest: [(string)?]
|
|
2553
|
+
): Promise<Models.Token> {
|
|
2554
|
+
let params: { userId: string, secret: string };
|
|
2555
|
+
|
|
2556
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
2557
|
+
params = (paramsOrFirst || {}) as { userId: string, secret: string };
|
|
2558
|
+
} else {
|
|
2559
|
+
params = {
|
|
2560
|
+
userId: paramsOrFirst as string,
|
|
2561
|
+
secret: rest[0] as string
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
const userId = params.userId;
|
|
2566
|
+
const secret = params.secret;
|
|
2567
|
+
|
|
2568
|
+
if (typeof userId === 'undefined') {
|
|
2569
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
if (typeof secret === 'undefined') {
|
|
2573
|
+
throw new AppwriteException('Missing required parameter: "secret"');
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
const apiPath = '/account/verifications/email';
|
|
2577
|
+
const payload: Payload = {};
|
|
2578
|
+
|
|
2579
|
+
if (typeof userId !== 'undefined') {
|
|
2580
|
+
payload['userId'] = userId;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
if (typeof secret !== 'undefined') {
|
|
2584
|
+
payload['secret'] = secret;
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2588
|
+
return this.client.call('put', uri, {
|
|
2589
|
+
'content-type': 'application/json',
|
|
2590
|
+
}, payload);
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
|
|
2595
|
+
*
|
|
2596
|
+
* @param {string} params.userId - User ID.
|
|
2597
|
+
* @param {string} params.secret - Valid verification token.
|
|
2598
|
+
* @throws {AppwriteException}
|
|
2599
|
+
* @returns {Promise}
|
|
2600
|
+
* @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.
|
|
2601
|
+
*/
|
|
2483
2602
|
updateVerification(params: { userId: string, secret: string }): Promise<Models.Token>;
|
|
2484
2603
|
/**
|
|
2485
2604
|
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
|
|
@@ -2517,7 +2636,7 @@ export class Account extends Service {
|
|
|
2517
2636
|
throw new AppwriteException('Missing required parameter: "secret"');
|
|
2518
2637
|
}
|
|
2519
2638
|
|
|
2520
|
-
const apiPath = '/account/
|
|
2639
|
+
const apiPath = '/account/verifications/email';
|
|
2521
2640
|
const payload: Payload = {};
|
|
2522
2641
|
|
|
2523
2642
|
if (typeof userId !== 'undefined') {
|
|
@@ -2541,7 +2660,7 @@ export class Account extends Service {
|
|
|
2541
2660
|
* @returns {Promise}
|
|
2542
2661
|
*/
|
|
2543
2662
|
createPhoneVerification(): Promise<Models.Token> {
|
|
2544
|
-
const apiPath = '/account/
|
|
2663
|
+
const apiPath = '/account/verifications/phone';
|
|
2545
2664
|
const payload: Payload = {};
|
|
2546
2665
|
|
|
2547
2666
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
@@ -2595,7 +2714,7 @@ export class Account extends Service {
|
|
|
2595
2714
|
throw new AppwriteException('Missing required parameter: "secret"');
|
|
2596
2715
|
}
|
|
2597
2716
|
|
|
2598
|
-
const apiPath = '/account/
|
|
2717
|
+
const apiPath = '/account/verifications/phone';
|
|
2599
2718
|
const payload: Payload = {};
|
|
2600
2719
|
|
|
2601
2720
|
if (typeof userId !== 'undefined') {
|