node-appwrite 11.1.0 → 12.0.0-rc.4
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/LICENSE +1 -1
- package/README.md +2 -2
- package/docs/examples/account/add-authenticator.md +12 -0
- package/docs/examples/account/create-anonymous-session.md +9 -0
- package/docs/examples/account/create-email-password-session.md +12 -0
- package/docs/examples/account/create-email-token.md +13 -0
- package/docs/examples/account/create-j-w-t.md +9 -0
- package/docs/examples/account/create-magic-u-r-l-token.md +14 -0
- package/docs/examples/account/create-o-auth2session.md +15 -0
- package/docs/examples/account/create-phone-token.md +12 -0
- package/docs/examples/account/create-phone-verification.md +4 -14
- package/docs/examples/account/create-recovery.md +7 -14
- package/docs/examples/account/create-session.md +12 -0
- package/docs/examples/account/create-verification.md +6 -14
- package/docs/examples/account/create.md +14 -0
- package/docs/examples/account/create2f-a-challenge.md +11 -0
- package/docs/examples/account/delete-authenticator.md +13 -0
- package/docs/examples/account/delete-identity.md +6 -14
- package/docs/examples/account/delete-session.md +6 -14
- package/docs/examples/account/delete-sessions.md +4 -14
- package/docs/examples/account/get-prefs.md +4 -14
- package/docs/examples/account/get-session.md +6 -14
- package/docs/examples/account/get.md +4 -14
- package/docs/examples/account/list-factors.md +10 -0
- package/docs/examples/account/list-identities.md +6 -14
- package/docs/examples/account/list-logs.md +6 -14
- package/docs/examples/account/list-sessions.md +4 -14
- package/docs/examples/account/update-challenge.md +13 -0
- package/docs/examples/account/update-email.md +7 -14
- package/docs/examples/account/update-m-f-a.md +12 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +12 -0
- package/docs/examples/account/update-name.md +6 -14
- package/docs/examples/account/update-password.md +7 -14
- package/docs/examples/account/update-phone-verification.md +7 -14
- package/docs/examples/account/update-phone.md +7 -14
- package/docs/examples/account/update-prefs.md +6 -14
- package/docs/examples/account/update-recovery.md +8 -14
- package/docs/examples/account/update-session.md +6 -14
- package/docs/examples/account/update-status.md +4 -14
- package/docs/examples/account/update-verification.md +7 -14
- package/docs/examples/account/verify-authenticator.md +13 -0
- package/docs/examples/avatars/get-browser.md +9 -14
- package/docs/examples/avatars/get-credit-card.md +9 -14
- package/docs/examples/avatars/get-favicon.md +6 -14
- package/docs/examples/avatars/get-flag.md +9 -14
- package/docs/examples/avatars/get-image.md +8 -14
- package/docs/examples/avatars/get-initials.md +9 -14
- package/docs/examples/avatars/get-q-r.md +9 -14
- package/docs/examples/databases/create-boolean-attribute.md +11 -14
- package/docs/examples/databases/create-collection.md +11 -14
- package/docs/examples/databases/create-datetime-attribute.md +11 -14
- package/docs/examples/databases/create-document.md +10 -14
- package/docs/examples/databases/create-email-attribute.md +11 -14
- package/docs/examples/databases/create-enum-attribute.md +12 -14
- package/docs/examples/databases/create-float-attribute.md +13 -14
- package/docs/examples/databases/create-index.md +11 -14
- package/docs/examples/databases/create-integer-attribute.md +13 -14
- package/docs/examples/databases/create-ip-attribute.md +11 -14
- package/docs/examples/databases/create-relationship-attribute.md +13 -14
- package/docs/examples/databases/create-string-attribute.md +13 -14
- package/docs/examples/databases/create-url-attribute.md +11 -14
- package/docs/examples/databases/create.md +8 -14
- package/docs/examples/databases/delete-attribute.md +8 -14
- package/docs/examples/databases/delete-collection.md +7 -14
- package/docs/examples/databases/delete-document.md +8 -14
- package/docs/examples/databases/delete-index.md +8 -14
- package/docs/examples/databases/delete.md +6 -14
- package/docs/examples/databases/get-attribute.md +8 -14
- package/docs/examples/databases/get-collection.md +7 -14
- package/docs/examples/databases/get-document.md +9 -14
- package/docs/examples/databases/get-index.md +8 -14
- package/docs/examples/databases/get.md +6 -14
- package/docs/examples/databases/list-attributes.md +8 -14
- package/docs/examples/databases/list-collections.md +8 -14
- package/docs/examples/databases/list-documents.md +8 -14
- package/docs/examples/databases/list-indexes.md +8 -14
- package/docs/examples/databases/list.md +7 -14
- package/docs/examples/databases/update-boolean-attribute.md +10 -14
- package/docs/examples/databases/update-collection.md +11 -14
- package/docs/examples/databases/update-datetime-attribute.md +10 -14
- package/docs/examples/databases/update-document.md +10 -14
- package/docs/examples/databases/update-email-attribute.md +10 -14
- package/docs/examples/databases/update-enum-attribute.md +11 -14
- package/docs/examples/databases/update-float-attribute.md +12 -14
- package/docs/examples/databases/update-integer-attribute.md +12 -14
- package/docs/examples/databases/update-ip-attribute.md +10 -14
- package/docs/examples/databases/update-relationship-attribute.md +9 -14
- package/docs/examples/databases/update-string-attribute.md +10 -14
- package/docs/examples/databases/update-url-attribute.md +10 -14
- package/docs/examples/databases/update.md +8 -14
- package/docs/examples/functions/create-build.md +8 -14
- package/docs/examples/functions/create-deployment.md +10 -14
- package/docs/examples/functions/create-execution.md +11 -14
- package/docs/examples/functions/create-variable.md +8 -14
- package/docs/examples/functions/create.md +25 -14
- package/docs/examples/functions/delete-deployment.md +7 -14
- package/docs/examples/functions/delete-variable.md +7 -14
- package/docs/examples/functions/delete.md +6 -14
- package/docs/examples/functions/download-deployment.md +7 -14
- package/docs/examples/functions/get-deployment.md +7 -14
- package/docs/examples/functions/get-execution.md +7 -14
- package/docs/examples/functions/get-variable.md +7 -14
- package/docs/examples/functions/get.md +6 -14
- package/docs/examples/functions/list-deployments.md +8 -14
- package/docs/examples/functions/list-executions.md +8 -14
- package/docs/examples/functions/list-runtimes.md +4 -14
- package/docs/examples/functions/list-variables.md +6 -14
- package/docs/examples/functions/list.md +7 -14
- package/docs/examples/functions/update-deployment.md +7 -14
- package/docs/examples/functions/update-variable.md +9 -14
- package/docs/examples/functions/update.md +21 -14
- package/docs/examples/graphql/mutation.md +6 -14
- package/docs/examples/graphql/query.md +6 -14
- package/docs/examples/health/get-antivirus.md +4 -14
- package/docs/examples/health/get-cache.md +4 -14
- package/docs/examples/health/get-certificate.md +12 -0
- package/docs/examples/health/get-d-b.md +4 -14
- package/docs/examples/health/get-failed-jobs.md +13 -0
- package/docs/examples/health/get-pub-sub.md +4 -14
- package/docs/examples/health/get-queue-builds.md +6 -14
- package/docs/examples/health/get-queue-certificates.md +6 -14
- package/docs/examples/health/get-queue-databases.md +7 -14
- package/docs/examples/health/get-queue-deletes.md +6 -14
- package/docs/examples/health/get-queue-functions.md +6 -14
- package/docs/examples/health/get-queue-logs.md +6 -14
- package/docs/examples/health/get-queue-mails.md +6 -14
- package/docs/examples/health/get-queue-messaging.md +6 -14
- package/docs/examples/health/get-queue-migrations.md +6 -14
- package/docs/examples/health/get-queue-webhooks.md +6 -14
- package/docs/examples/health/get-queue.md +4 -14
- package/docs/examples/health/get-storage-local.md +4 -14
- package/docs/examples/health/get-time.md +4 -14
- package/docs/examples/health/get.md +4 -14
- package/docs/examples/locale/get.md +4 -14
- package/docs/examples/locale/list-codes.md +4 -14
- package/docs/examples/locale/list-continents.md +4 -14
- package/docs/examples/locale/list-countries-e-u.md +4 -14
- package/docs/examples/locale/list-countries-phones.md +4 -14
- package/docs/examples/locale/list-countries.md +4 -14
- package/docs/examples/locale/list-currencies.md +4 -14
- package/docs/examples/locale/list-languages.md +4 -14
- package/docs/examples/messaging/create-apns-provider.md +18 -0
- package/docs/examples/messaging/create-email.md +23 -0
- package/docs/examples/messaging/create-fcm-provider.md +15 -0
- package/docs/examples/messaging/create-mailgun-provider.md +21 -0
- package/docs/examples/messaging/create-msg91provider.md +17 -0
- package/docs/examples/messaging/create-push.md +27 -0
- package/docs/examples/messaging/create-sendgrid-provider.md +19 -0
- package/docs/examples/messaging/create-sms.md +18 -0
- package/docs/examples/messaging/create-smtp-provider.md +25 -0
- package/docs/examples/messaging/create-subscriber.md +14 -0
- package/docs/examples/messaging/create-telesign-provider.md +17 -0
- package/docs/examples/messaging/create-textmagic-provider.md +17 -0
- package/docs/examples/messaging/create-topic.md +14 -0
- package/docs/examples/messaging/create-twilio-provider.md +17 -0
- package/docs/examples/messaging/create-vonage-provider.md +17 -0
- package/docs/examples/messaging/delete-provider.md +12 -0
- package/docs/examples/messaging/delete-subscriber.md +13 -0
- package/docs/examples/messaging/delete-topic.md +12 -0
- package/docs/examples/messaging/delete.md +12 -0
- package/docs/examples/messaging/get-message.md +12 -0
- package/docs/examples/messaging/get-provider.md +12 -0
- package/docs/examples/messaging/get-subscriber.md +13 -0
- package/docs/examples/messaging/get-topic.md +12 -0
- package/docs/examples/messaging/list-message-logs.md +13 -0
- package/docs/examples/messaging/list-messages.md +13 -0
- package/docs/examples/messaging/list-provider-logs.md +13 -0
- package/docs/examples/messaging/list-providers.md +13 -0
- package/docs/examples/messaging/list-subscriber-logs.md +13 -0
- package/docs/examples/messaging/list-subscribers.md +14 -0
- package/docs/examples/messaging/list-targets.md +13 -0
- package/docs/examples/messaging/list-topic-logs.md +13 -0
- package/docs/examples/messaging/list-topics.md +13 -0
- package/docs/examples/messaging/update-a-p-n-s-provider.md +18 -0
- package/docs/examples/messaging/update-email.md +22 -0
- package/docs/examples/messaging/update-f-c-m-provider.md +15 -0
- package/docs/examples/messaging/update-mailgun-provider.md +21 -0
- package/docs/examples/messaging/update-msg91provider.md +17 -0
- package/docs/examples/messaging/update-push.md +27 -0
- package/docs/examples/messaging/update-sendgrid-provider.md +19 -0
- package/docs/examples/messaging/update-sms.md +18 -0
- package/docs/examples/messaging/update-smtp-provider.md +25 -0
- package/docs/examples/messaging/update-telesign-provider.md +17 -0
- package/docs/examples/messaging/update-textmagic-provider.md +17 -0
- package/docs/examples/messaging/update-topic.md +13 -0
- package/docs/examples/messaging/update-twilio-provider.md +17 -0
- package/docs/examples/messaging/update-vonage-provider.md +17 -0
- package/docs/examples/storage/create-bucket.md +15 -14
- package/docs/examples/storage/create-file.md +9 -14
- package/docs/examples/storage/delete-bucket.md +6 -14
- package/docs/examples/storage/delete-file.md +7 -14
- package/docs/examples/storage/get-bucket.md +6 -14
- package/docs/examples/storage/get-file-download.md +7 -14
- package/docs/examples/storage/get-file-preview.md +18 -14
- package/docs/examples/storage/get-file-view.md +7 -14
- package/docs/examples/storage/get-file.md +7 -14
- package/docs/examples/storage/list-buckets.md +7 -14
- package/docs/examples/storage/list-files.md +8 -14
- package/docs/examples/storage/update-bucket.md +15 -14
- package/docs/examples/storage/update-file.md +9 -14
- package/docs/examples/teams/create-membership.md +12 -14
- package/docs/examples/teams/create.md +8 -14
- package/docs/examples/teams/delete-membership.md +7 -14
- package/docs/examples/teams/delete.md +6 -14
- package/docs/examples/teams/get-membership.md +7 -14
- package/docs/examples/teams/get-prefs.md +6 -14
- package/docs/examples/teams/get.md +6 -14
- package/docs/examples/teams/list-memberships.md +8 -14
- package/docs/examples/teams/list.md +7 -14
- package/docs/examples/teams/update-membership-status.md +9 -14
- package/docs/examples/teams/update-membership.md +8 -14
- package/docs/examples/teams/update-name.md +7 -14
- package/docs/examples/teams/update-prefs.md +7 -14
- package/docs/examples/users/create-argon2user.md +9 -14
- package/docs/examples/users/create-bcrypt-user.md +9 -14
- package/docs/examples/users/create-m-d5user.md +9 -14
- package/docs/examples/users/create-p-h-pass-user.md +9 -14
- package/docs/examples/users/create-s-h-a-user.md +10 -14
- package/docs/examples/users/create-scrypt-modified-user.md +12 -14
- package/docs/examples/users/create-scrypt-user.md +14 -14
- package/docs/examples/users/create-session.md +12 -0
- package/docs/examples/users/create-target.md +17 -0
- package/docs/examples/users/create-token.md +14 -0
- package/docs/examples/users/create.md +10 -14
- package/docs/examples/users/delete-authenticator.md +14 -0
- package/docs/examples/users/delete-identity.md +6 -14
- package/docs/examples/users/delete-session.md +7 -14
- package/docs/examples/users/delete-sessions.md +6 -14
- package/docs/examples/users/delete-target.md +13 -0
- package/docs/examples/users/delete.md +6 -14
- package/docs/examples/users/get-prefs.md +6 -14
- package/docs/examples/users/get-target.md +13 -0
- package/docs/examples/users/get.md +6 -14
- package/docs/examples/users/list-factors.md +12 -0
- package/docs/examples/users/list-identities.md +7 -14
- package/docs/examples/users/list-logs.md +7 -14
- package/docs/examples/users/list-memberships.md +6 -14
- package/docs/examples/users/list-sessions.md +6 -14
- package/docs/examples/users/list-targets.md +13 -0
- package/docs/examples/users/list.md +7 -14
- package/docs/examples/users/update-email-verification.md +7 -14
- package/docs/examples/users/update-email.md +7 -14
- package/docs/examples/users/update-labels.md +7 -14
- package/docs/examples/users/update-mfa.md +13 -0
- package/docs/examples/users/update-name.md +7 -14
- package/docs/examples/users/update-password.md +7 -14
- package/docs/examples/users/update-phone-verification.md +7 -14
- package/docs/examples/users/update-phone.md +7 -14
- package/docs/examples/users/update-prefs.md +7 -14
- package/docs/examples/users/update-status.md +7 -14
- package/docs/examples/users/update-target.md +16 -0
- package/index.d.ts +2026 -138
- package/index.js +40 -0
- package/lib/client.js +122 -65
- package/lib/enums/authentication-factor.js +7 -0
- package/lib/enums/authenticator-type.js +5 -0
- package/lib/enums/browser.js +18 -0
- package/lib/enums/compression.js +7 -0
- package/lib/enums/credit-card.js +20 -0
- package/lib/enums/encryption.js +7 -0
- package/lib/enums/execution-method.js +10 -0
- package/lib/enums/flag.js +198 -0
- package/lib/enums/image-format.js +9 -0
- package/lib/enums/image-gravity.js +13 -0
- package/lib/enums/index-type.js +8 -0
- package/lib/enums/message-status.js +7 -0
- package/lib/enums/messaging-provider-type.js +7 -0
- package/lib/enums/name.js +16 -0
- package/lib/enums/o-auth-provider.js +43 -0
- package/lib/enums/password-hash.js +15 -0
- package/lib/enums/relation-mutate.js +7 -0
- package/lib/enums/relationship-type.js +8 -0
- package/lib/enums/runtime.js +40 -0
- package/lib/inputFile.js +88 -16
- package/lib/query.js +56 -38
- package/lib/services/account.js +605 -16
- package/lib/services/avatars.js +5 -3
- package/lib/services/databases.js +6 -4
- package/lib/services/functions.js +51 -87
- package/lib/services/graphql.js +2 -0
- package/lib/services/health.js +52 -0
- package/lib/services/locale.js +2 -0
- package/lib/services/messaging.js +2198 -0
- package/lib/services/storage.js +52 -88
- package/lib/services/teams.js +2 -0
- package/lib/services/users.js +323 -3
- package/package.json +2 -3
package/lib/services/account.js
CHANGED
|
@@ -5,6 +5,8 @@ const client = require('../client.js');
|
|
|
5
5
|
const Stream = require('stream');
|
|
6
6
|
const { promisify } = require('util');
|
|
7
7
|
const fs = require('fs');
|
|
8
|
+
const { File } = require('undici');
|
|
9
|
+
const Query = require('../query.js');
|
|
8
10
|
|
|
9
11
|
class Account extends Service {
|
|
10
12
|
|
|
@@ -31,6 +33,61 @@ class Account extends Service {
|
|
|
31
33
|
}, payload);
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Create account
|
|
38
|
+
*
|
|
39
|
+
* Use this endpoint to allow a new user to register a new account in your
|
|
40
|
+
* project. After the user registration completes successfully, you can use
|
|
41
|
+
* the
|
|
42
|
+
* [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
|
|
43
|
+
* route to start verifying the user email address. To allow the new user to
|
|
44
|
+
* login to their new account, you need to create a new [account
|
|
45
|
+
* session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
|
|
46
|
+
*
|
|
47
|
+
* @param {string} userId
|
|
48
|
+
* @param {string} email
|
|
49
|
+
* @param {string} password
|
|
50
|
+
* @param {string} name
|
|
51
|
+
* @throws {AppwriteException}
|
|
52
|
+
* @returns {Promise}
|
|
53
|
+
*/
|
|
54
|
+
async create(userId, email, password, name) {
|
|
55
|
+
const apiPath = '/account';
|
|
56
|
+
let payload = {};
|
|
57
|
+
if (typeof userId === 'undefined') {
|
|
58
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof email === 'undefined') {
|
|
62
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (typeof password === 'undefined') {
|
|
66
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if (typeof userId !== 'undefined') {
|
|
71
|
+
payload['userId'] = userId;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof email !== 'undefined') {
|
|
75
|
+
payload['email'] = email;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (typeof password !== 'undefined') {
|
|
79
|
+
payload['password'] = password;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (typeof name !== 'undefined') {
|
|
83
|
+
payload['name'] = name;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return await this.client.call('post', apiPath, {
|
|
87
|
+
'content-type': 'application/json',
|
|
88
|
+
}, payload);
|
|
89
|
+
}
|
|
90
|
+
|
|
34
91
|
/**
|
|
35
92
|
* Update email
|
|
36
93
|
*
|
|
@@ -78,7 +135,7 @@ class Account extends Service {
|
|
|
78
135
|
*
|
|
79
136
|
* Get the list of identities for the currently logged in user.
|
|
80
137
|
*
|
|
81
|
-
* @param {string} queries
|
|
138
|
+
* @param {string[]} queries
|
|
82
139
|
* @throws {AppwriteException}
|
|
83
140
|
* @returns {Promise}
|
|
84
141
|
*/
|
|
@@ -96,7 +153,7 @@ class Account extends Service {
|
|
|
96
153
|
}
|
|
97
154
|
|
|
98
155
|
/**
|
|
99
|
-
* Delete
|
|
156
|
+
* Delete identity
|
|
100
157
|
*
|
|
101
158
|
* Delete an identity by its unique ID.
|
|
102
159
|
*
|
|
@@ -117,6 +174,27 @@ class Account extends Service {
|
|
|
117
174
|
}, payload);
|
|
118
175
|
}
|
|
119
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Create JWT
|
|
179
|
+
*
|
|
180
|
+
* Use this endpoint to create a JSON Web Token. You can use the resulting JWT
|
|
181
|
+
* to authenticate on behalf of the current user when working with the
|
|
182
|
+
* Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
|
|
183
|
+
* from its creation and will be invalid if the user will logout in that time
|
|
184
|
+
* frame.
|
|
185
|
+
*
|
|
186
|
+
* @throws {AppwriteException}
|
|
187
|
+
* @returns {Promise}
|
|
188
|
+
*/
|
|
189
|
+
async createJWT() {
|
|
190
|
+
const apiPath = '/account/jwt';
|
|
191
|
+
let payload = {};
|
|
192
|
+
|
|
193
|
+
return await this.client.call('post', apiPath, {
|
|
194
|
+
'content-type': 'application/json',
|
|
195
|
+
}, payload);
|
|
196
|
+
}
|
|
197
|
+
|
|
120
198
|
/**
|
|
121
199
|
* List logs
|
|
122
200
|
*
|
|
@@ -140,6 +218,180 @@ class Account extends Service {
|
|
|
140
218
|
}, payload);
|
|
141
219
|
}
|
|
142
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Update MFA
|
|
223
|
+
*
|
|
224
|
+
* @param {boolean} mfa
|
|
225
|
+
* @throws {AppwriteException}
|
|
226
|
+
* @returns {Promise}
|
|
227
|
+
*/
|
|
228
|
+
async updateMFA(mfa) {
|
|
229
|
+
const apiPath = '/account/mfa';
|
|
230
|
+
let payload = {};
|
|
231
|
+
if (typeof mfa === 'undefined') {
|
|
232
|
+
throw new AppwriteException('Missing required parameter: "mfa"');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
if (typeof mfa !== 'undefined') {
|
|
237
|
+
payload['mfa'] = mfa;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return await this.client.call('patch', apiPath, {
|
|
241
|
+
'content-type': 'application/json',
|
|
242
|
+
}, payload);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Create 2FA Challenge
|
|
247
|
+
*
|
|
248
|
+
* @param {AuthenticationFactor} factor
|
|
249
|
+
* @throws {AppwriteException}
|
|
250
|
+
* @returns {Promise}
|
|
251
|
+
*/
|
|
252
|
+
async create2FAChallenge(factor) {
|
|
253
|
+
const apiPath = '/account/mfa/challenge';
|
|
254
|
+
let payload = {};
|
|
255
|
+
if (typeof factor === 'undefined') {
|
|
256
|
+
throw new AppwriteException('Missing required parameter: "factor"');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if (typeof factor !== 'undefined') {
|
|
261
|
+
payload['factor'] = factor;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return await this.client.call('post', apiPath, {
|
|
265
|
+
'content-type': 'application/json',
|
|
266
|
+
}, payload);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Create MFA Challenge (confirmation)
|
|
271
|
+
*
|
|
272
|
+
* @param {string} challengeId
|
|
273
|
+
* @param {string} otp
|
|
274
|
+
* @throws {AppwriteException}
|
|
275
|
+
* @returns {Promise}
|
|
276
|
+
*/
|
|
277
|
+
async updateChallenge(challengeId, otp) {
|
|
278
|
+
const apiPath = '/account/mfa/challenge';
|
|
279
|
+
let payload = {};
|
|
280
|
+
if (typeof challengeId === 'undefined') {
|
|
281
|
+
throw new AppwriteException('Missing required parameter: "challengeId"');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (typeof otp === 'undefined') {
|
|
285
|
+
throw new AppwriteException('Missing required parameter: "otp"');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
if (typeof challengeId !== 'undefined') {
|
|
290
|
+
payload['challengeId'] = challengeId;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (typeof otp !== 'undefined') {
|
|
294
|
+
payload['otp'] = otp;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return await this.client.call('put', apiPath, {
|
|
298
|
+
'content-type': 'application/json',
|
|
299
|
+
}, payload);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* List Factors
|
|
304
|
+
*
|
|
305
|
+
* @throws {AppwriteException}
|
|
306
|
+
* @returns {Promise}
|
|
307
|
+
*/
|
|
308
|
+
async listFactors() {
|
|
309
|
+
const apiPath = '/account/mfa/factors';
|
|
310
|
+
let payload = {};
|
|
311
|
+
|
|
312
|
+
return await this.client.call('get', apiPath, {
|
|
313
|
+
'content-type': 'application/json',
|
|
314
|
+
}, payload);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Add Authenticator
|
|
319
|
+
*
|
|
320
|
+
* @param {AuthenticatorType} type
|
|
321
|
+
* @throws {AppwriteException}
|
|
322
|
+
* @returns {Promise}
|
|
323
|
+
*/
|
|
324
|
+
async addAuthenticator(type) {
|
|
325
|
+
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
326
|
+
let payload = {};
|
|
327
|
+
if (typeof type === 'undefined') {
|
|
328
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
return await this.client.call('post', apiPath, {
|
|
333
|
+
'content-type': 'application/json',
|
|
334
|
+
}, payload);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Verify Authenticator
|
|
339
|
+
*
|
|
340
|
+
* @param {AuthenticatorType} type
|
|
341
|
+
* @param {string} otp
|
|
342
|
+
* @throws {AppwriteException}
|
|
343
|
+
* @returns {Promise}
|
|
344
|
+
*/
|
|
345
|
+
async verifyAuthenticator(type, otp) {
|
|
346
|
+
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
347
|
+
let payload = {};
|
|
348
|
+
if (typeof type === 'undefined') {
|
|
349
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (typeof otp === 'undefined') {
|
|
353
|
+
throw new AppwriteException('Missing required parameter: "otp"');
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
if (typeof otp !== 'undefined') {
|
|
358
|
+
payload['otp'] = otp;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return await this.client.call('put', apiPath, {
|
|
362
|
+
'content-type': 'application/json',
|
|
363
|
+
}, payload);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Delete Authenticator
|
|
368
|
+
*
|
|
369
|
+
* @param {AuthenticatorType} type
|
|
370
|
+
* @param {string} otp
|
|
371
|
+
* @throws {AppwriteException}
|
|
372
|
+
* @returns {Promise}
|
|
373
|
+
*/
|
|
374
|
+
async deleteAuthenticator(type, otp) {
|
|
375
|
+
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
376
|
+
let payload = {};
|
|
377
|
+
if (typeof type === 'undefined') {
|
|
378
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (typeof otp === 'undefined') {
|
|
382
|
+
throw new AppwriteException('Missing required parameter: "otp"');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
if (typeof otp !== 'undefined') {
|
|
387
|
+
payload['otp'] = otp;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return await this.client.call('delete', apiPath, {
|
|
391
|
+
'content-type': 'application/json',
|
|
392
|
+
}, payload);
|
|
393
|
+
}
|
|
394
|
+
|
|
143
395
|
/**
|
|
144
396
|
* Update name
|
|
145
397
|
*
|
|
@@ -342,11 +594,10 @@ class Account extends Service {
|
|
|
342
594
|
* @param {string} userId
|
|
343
595
|
* @param {string} secret
|
|
344
596
|
* @param {string} password
|
|
345
|
-
* @param {string} passwordAgain
|
|
346
597
|
* @throws {AppwriteException}
|
|
347
598
|
* @returns {Promise}
|
|
348
599
|
*/
|
|
349
|
-
async updateRecovery(userId, secret, password
|
|
600
|
+
async updateRecovery(userId, secret, password) {
|
|
350
601
|
const apiPath = '/account/recovery';
|
|
351
602
|
let payload = {};
|
|
352
603
|
if (typeof userId === 'undefined') {
|
|
@@ -361,10 +612,6 @@ class Account extends Service {
|
|
|
361
612
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
362
613
|
}
|
|
363
614
|
|
|
364
|
-
if (typeof passwordAgain === 'undefined') {
|
|
365
|
-
throw new AppwriteException('Missing required parameter: "passwordAgain"');
|
|
366
|
-
}
|
|
367
|
-
|
|
368
615
|
|
|
369
616
|
if (typeof userId !== 'undefined') {
|
|
370
617
|
payload['userId'] = userId;
|
|
@@ -378,10 +625,6 @@ class Account extends Service {
|
|
|
378
625
|
payload['password'] = password;
|
|
379
626
|
}
|
|
380
627
|
|
|
381
|
-
if (typeof passwordAgain !== 'undefined') {
|
|
382
|
-
payload['passwordAgain'] = passwordAgain;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
628
|
return await this.client.call('put', apiPath, {
|
|
386
629
|
'content-type': 'application/json',
|
|
387
630
|
}, payload);
|
|
@@ -423,6 +666,200 @@ class Account extends Service {
|
|
|
423
666
|
}, payload);
|
|
424
667
|
}
|
|
425
668
|
|
|
669
|
+
/**
|
|
670
|
+
* Create anonymous session
|
|
671
|
+
*
|
|
672
|
+
* Use this endpoint to allow a new user to register an anonymous account in
|
|
673
|
+
* your project. This route will also create a new session for the user. To
|
|
674
|
+
* allow the new user to convert an anonymous account to a normal account, you
|
|
675
|
+
* need to update its [email and
|
|
676
|
+
* password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
|
|
677
|
+
* or create an [OAuth2
|
|
678
|
+
* session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
|
|
679
|
+
*
|
|
680
|
+
* @throws {AppwriteException}
|
|
681
|
+
* @returns {Promise}
|
|
682
|
+
*/
|
|
683
|
+
async createAnonymousSession() {
|
|
684
|
+
const apiPath = '/account/sessions/anonymous';
|
|
685
|
+
let payload = {};
|
|
686
|
+
|
|
687
|
+
return await this.client.call('post', apiPath, {
|
|
688
|
+
'content-type': 'application/json',
|
|
689
|
+
}, payload);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Create email password session
|
|
694
|
+
*
|
|
695
|
+
* Allow the user to login into their account by providing a valid email and
|
|
696
|
+
* password combination. This route will create a new session for the user.
|
|
697
|
+
*
|
|
698
|
+
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
699
|
+
* about session
|
|
700
|
+
* limits](https://appwrite.io/docs/authentication-security#limits).
|
|
701
|
+
*
|
|
702
|
+
* @param {string} email
|
|
703
|
+
* @param {string} password
|
|
704
|
+
* @throws {AppwriteException}
|
|
705
|
+
* @returns {Promise}
|
|
706
|
+
*/
|
|
707
|
+
async createEmailPasswordSession(email, password) {
|
|
708
|
+
const apiPath = '/account/sessions/email';
|
|
709
|
+
let payload = {};
|
|
710
|
+
if (typeof email === 'undefined') {
|
|
711
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (typeof password === 'undefined') {
|
|
715
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
if (typeof email !== 'undefined') {
|
|
720
|
+
payload['email'] = email;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (typeof password !== 'undefined') {
|
|
724
|
+
payload['password'] = password;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return await this.client.call('post', apiPath, {
|
|
728
|
+
'content-type': 'application/json',
|
|
729
|
+
}, payload);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Create session (deprecated)
|
|
734
|
+
*
|
|
735
|
+
* Use this endpoint to create a session from token. Provide the **userId**
|
|
736
|
+
* and **secret** parameters from the successful response of authentication
|
|
737
|
+
* flows initiated by token creation. For example, magic URL and phone login.
|
|
738
|
+
*
|
|
739
|
+
* @param {string} userId
|
|
740
|
+
* @param {string} secret
|
|
741
|
+
* @throws {AppwriteException}
|
|
742
|
+
* @returns {Promise}
|
|
743
|
+
*/
|
|
744
|
+
async updateMagicURLSession(userId, secret) {
|
|
745
|
+
const apiPath = '/account/sessions/magic-url';
|
|
746
|
+
let payload = {};
|
|
747
|
+
if (typeof userId === 'undefined') {
|
|
748
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (typeof secret === 'undefined') {
|
|
752
|
+
throw new AppwriteException('Missing required parameter: "secret"');
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
if (typeof userId !== 'undefined') {
|
|
757
|
+
payload['userId'] = userId;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
if (typeof secret !== 'undefined') {
|
|
761
|
+
payload['secret'] = secret;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
return await this.client.call('put', apiPath, {
|
|
765
|
+
'content-type': 'application/json',
|
|
766
|
+
}, payload);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Create OAuth2 session
|
|
771
|
+
*
|
|
772
|
+
* Allow the user to login to their account using the OAuth2 provider of their
|
|
773
|
+
* choice. Each OAuth2 provider should be enabled from the Appwrite console
|
|
774
|
+
* first. Use the success and failure arguments to provide a redirect URL's
|
|
775
|
+
* back to your app when login is completed.
|
|
776
|
+
*
|
|
777
|
+
* If there is already an active session, the new session will be attached to
|
|
778
|
+
* the logged-in account. If there are no active sessions, the server will
|
|
779
|
+
* attempt to look for a user with the same email address as the email
|
|
780
|
+
* received from the OAuth2 provider and attach the new session to the
|
|
781
|
+
* existing user. If no matching user is found - the server will create a new
|
|
782
|
+
* user.
|
|
783
|
+
*
|
|
784
|
+
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
785
|
+
* about session
|
|
786
|
+
* limits](https://appwrite.io/docs/authentication-security#limits).
|
|
787
|
+
*
|
|
788
|
+
*
|
|
789
|
+
* @param {OAuthProvider} provider
|
|
790
|
+
* @param {string} success
|
|
791
|
+
* @param {string} failure
|
|
792
|
+
* @param {boolean} token
|
|
793
|
+
* @param {string[]} scopes
|
|
794
|
+
* @throws {AppwriteException}
|
|
795
|
+
* @returns {Promise}
|
|
796
|
+
*/
|
|
797
|
+
async createOAuth2Session(provider, success, failure, token, scopes) {
|
|
798
|
+
const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
|
|
799
|
+
let payload = {};
|
|
800
|
+
if (typeof provider === 'undefined') {
|
|
801
|
+
throw new AppwriteException('Missing required parameter: "provider"');
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
if (typeof success !== 'undefined') {
|
|
806
|
+
payload['success'] = success;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
if (typeof failure !== 'undefined') {
|
|
810
|
+
payload['failure'] = failure;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if (typeof token !== 'undefined') {
|
|
814
|
+
payload['token'] = token;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (typeof scopes !== 'undefined') {
|
|
818
|
+
payload['scopes'] = scopes;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
return await this.client.call('get', apiPath, {
|
|
822
|
+
'content-type': 'application/json',
|
|
823
|
+
}, payload);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Create session
|
|
828
|
+
*
|
|
829
|
+
* Use this endpoint to create a session from token. Provide the **userId**
|
|
830
|
+
* and **secret** parameters from the successful response of authentication
|
|
831
|
+
* flows initiated by token creation. For example, magic URL and phone login.
|
|
832
|
+
*
|
|
833
|
+
* @param {string} userId
|
|
834
|
+
* @param {string} secret
|
|
835
|
+
* @throws {AppwriteException}
|
|
836
|
+
* @returns {Promise}
|
|
837
|
+
*/
|
|
838
|
+
async createSession(userId, secret) {
|
|
839
|
+
const apiPath = '/account/sessions/token';
|
|
840
|
+
let payload = {};
|
|
841
|
+
if (typeof userId === 'undefined') {
|
|
842
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (typeof secret === 'undefined') {
|
|
846
|
+
throw new AppwriteException('Missing required parameter: "secret"');
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
if (typeof userId !== 'undefined') {
|
|
851
|
+
payload['userId'] = userId;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (typeof secret !== 'undefined') {
|
|
855
|
+
payload['secret'] = secret;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return await this.client.call('post', apiPath, {
|
|
859
|
+
'content-type': 'application/json',
|
|
860
|
+
}, payload);
|
|
861
|
+
}
|
|
862
|
+
|
|
426
863
|
/**
|
|
427
864
|
* Get session
|
|
428
865
|
*
|
|
@@ -447,11 +884,10 @@ class Account extends Service {
|
|
|
447
884
|
}
|
|
448
885
|
|
|
449
886
|
/**
|
|
450
|
-
* Update
|
|
887
|
+
* Update (or renew) a session
|
|
451
888
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* "refresh" the access token.
|
|
889
|
+
* Extend session's expiry to increase it's lifespan. Extending a session is
|
|
890
|
+
* useful when session length is short such as 5 minutes.
|
|
455
891
|
*
|
|
456
892
|
* @param {string} sessionId
|
|
457
893
|
* @throws {AppwriteException}
|
|
@@ -515,6 +951,159 @@ class Account extends Service {
|
|
|
515
951
|
}, payload);
|
|
516
952
|
}
|
|
517
953
|
|
|
954
|
+
/**
|
|
955
|
+
* Create email token (OTP)
|
|
956
|
+
*
|
|
957
|
+
* Sends the user an email with a secret key for creating a session. If the
|
|
958
|
+
* provided user ID has not be registered, a new user will be created. Use the
|
|
959
|
+
* returned user ID and secret and submit a request to the [POST
|
|
960
|
+
* /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
|
961
|
+
* endpoint to complete the login process. The secret sent to the user's email
|
|
962
|
+
* is valid for 15 minutes.
|
|
963
|
+
*
|
|
964
|
+
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
965
|
+
* about session
|
|
966
|
+
* limits](https://appwrite.io/docs/authentication-security#limits).
|
|
967
|
+
*
|
|
968
|
+
* @param {string} userId
|
|
969
|
+
* @param {string} email
|
|
970
|
+
* @param {boolean} phrase
|
|
971
|
+
* @throws {AppwriteException}
|
|
972
|
+
* @returns {Promise}
|
|
973
|
+
*/
|
|
974
|
+
async createEmailToken(userId, email, phrase) {
|
|
975
|
+
const apiPath = '/account/tokens/email';
|
|
976
|
+
let payload = {};
|
|
977
|
+
if (typeof userId === 'undefined') {
|
|
978
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
if (typeof email === 'undefined') {
|
|
982
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
if (typeof userId !== 'undefined') {
|
|
987
|
+
payload['userId'] = userId;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
if (typeof email !== 'undefined') {
|
|
991
|
+
payload['email'] = email;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
if (typeof phrase !== 'undefined') {
|
|
995
|
+
payload['phrase'] = phrase;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return await this.client.call('post', apiPath, {
|
|
999
|
+
'content-type': 'application/json',
|
|
1000
|
+
}, payload);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Create magic URL token
|
|
1005
|
+
*
|
|
1006
|
+
* Sends the user an email with a secret key for creating a session. If the
|
|
1007
|
+
* provided user ID has not been registered, a new user will be created. When
|
|
1008
|
+
* the user clicks the link in the email, the user is redirected back to the
|
|
1009
|
+
* URL you provided with the secret key and userId values attached to the URL
|
|
1010
|
+
* query string. Use the query string parameters to submit a request to the
|
|
1011
|
+
* [POST
|
|
1012
|
+
* /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
|
1013
|
+
* endpoint to complete the login process. The link sent to the user's email
|
|
1014
|
+
* address is valid for 1 hour. If you are on a mobile device you can leave
|
|
1015
|
+
* the URL parameter empty, so that the login completion will be handled by
|
|
1016
|
+
* your Appwrite instance by default.
|
|
1017
|
+
*
|
|
1018
|
+
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
1019
|
+
* about session
|
|
1020
|
+
* limits](https://appwrite.io/docs/authentication-security#limits).
|
|
1021
|
+
*
|
|
1022
|
+
*
|
|
1023
|
+
* @param {string} userId
|
|
1024
|
+
* @param {string} email
|
|
1025
|
+
* @param {string} url
|
|
1026
|
+
* @param {boolean} phrase
|
|
1027
|
+
* @throws {AppwriteException}
|
|
1028
|
+
* @returns {Promise}
|
|
1029
|
+
*/
|
|
1030
|
+
async createMagicURLToken(userId, email, url, phrase) {
|
|
1031
|
+
const apiPath = '/account/tokens/magic-url';
|
|
1032
|
+
let payload = {};
|
|
1033
|
+
if (typeof userId === 'undefined') {
|
|
1034
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
if (typeof email === 'undefined') {
|
|
1038
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
if (typeof userId !== 'undefined') {
|
|
1043
|
+
payload['userId'] = userId;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
if (typeof email !== 'undefined') {
|
|
1047
|
+
payload['email'] = email;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
if (typeof url !== 'undefined') {
|
|
1051
|
+
payload['url'] = url;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
if (typeof phrase !== 'undefined') {
|
|
1055
|
+
payload['phrase'] = phrase;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return await this.client.call('post', apiPath, {
|
|
1059
|
+
'content-type': 'application/json',
|
|
1060
|
+
}, payload);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Create phone token
|
|
1065
|
+
*
|
|
1066
|
+
* Sends the user an SMS with a secret key for creating a session. If the
|
|
1067
|
+
* provided user ID has not be registered, a new user will be created. Use the
|
|
1068
|
+
* returned user ID and secret and submit a request to the [POST
|
|
1069
|
+
* /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
|
1070
|
+
* endpoint to complete the login process. The secret sent to the user's phone
|
|
1071
|
+
* is valid for 15 minutes.
|
|
1072
|
+
*
|
|
1073
|
+
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
1074
|
+
* about session
|
|
1075
|
+
* limits](https://appwrite.io/docs/authentication-security#limits).
|
|
1076
|
+
*
|
|
1077
|
+
* @param {string} userId
|
|
1078
|
+
* @param {string} phone
|
|
1079
|
+
* @throws {AppwriteException}
|
|
1080
|
+
* @returns {Promise}
|
|
1081
|
+
*/
|
|
1082
|
+
async createPhoneToken(userId, phone) {
|
|
1083
|
+
const apiPath = '/account/tokens/phone';
|
|
1084
|
+
let payload = {};
|
|
1085
|
+
if (typeof userId === 'undefined') {
|
|
1086
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if (typeof phone === 'undefined') {
|
|
1090
|
+
throw new AppwriteException('Missing required parameter: "phone"');
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
if (typeof userId !== 'undefined') {
|
|
1095
|
+
payload['userId'] = userId;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
if (typeof phone !== 'undefined') {
|
|
1099
|
+
payload['phone'] = phone;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
return await this.client.call('post', apiPath, {
|
|
1103
|
+
'content-type': 'application/json',
|
|
1104
|
+
}, payload);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
518
1107
|
/**
|
|
519
1108
|
* Create email verification
|
|
520
1109
|
*
|