node-appwrite 11.0.0 → 11.1.0

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/lib/client.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const os = require('os');
2
2
  const URL = require('url').URL;
3
+ const https = require("https");
3
4
  const axios = require('axios');
4
5
  const FormData = require('form-data');
5
6
  const AppwriteException = require('./exception.js');
@@ -12,11 +13,11 @@ class Client {
12
13
  this.headers = {
13
14
  'accept-encoding': '*',
14
15
  'content-type': '',
15
- 'user-agent' : `AppwriteNodeJSSDK/11.0.0 (${os.type()}; ${os.version()}; ${os.arch()})`,
16
+ 'user-agent' : `AppwriteNodeJSSDK/11.1.0 (${os.type()}; ${os.version()}; ${os.arch()})`,
16
17
  'x-sdk-name': 'Node.js',
17
18
  'x-sdk-platform': 'server',
18
19
  'x-sdk-language': 'nodejs',
19
- 'x-sdk-version': '11.0.0',
20
+ 'x-sdk-version': '11.1.0',
20
21
  'X-Appwrite-Response-Format' : '1.4.0',
21
22
  };
22
23
  this.selfSigned = false;
@@ -118,11 +119,6 @@ class Client {
118
119
  }
119
120
 
120
121
  async call(method, path = '', headers = {}, params = {}, responseType = 'json') {
121
- if(this.selfSigned) { // Allow self signed requests
122
- process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
123
- }
124
-
125
-
126
122
  headers = Object.assign({}, this.headers, headers);
127
123
 
128
124
  let contentType = headers['content-type'].toLowerCase();
@@ -162,6 +158,10 @@ class Client {
162
158
  json: (contentType.startsWith('application/json')),
163
159
  responseType: responseType
164
160
  };
161
+ if (this.selfSigned) {
162
+ // Allow self signed requests
163
+ options.httpsAgent = new https.Agent({ rejectUnauthorized: false });
164
+ }
165
165
  try {
166
166
  let response = await axios(options);
167
167
  return response.data;
package/lib/query.js CHANGED
@@ -24,7 +24,7 @@ class Query {
24
24
  `isNotNull("${attribute}")`;
25
25
 
26
26
  static between = (attribute, start, end) =>
27
- Query.addQuery(attribute, "between", [start, end]);
27
+ `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`
28
28
 
29
29
  static startsWith = (attribute, value) =>
30
30
  Query.addQuery(attribute, "startsWith", value);
@@ -15,7 +15,7 @@ class Account extends Service {
15
15
 
16
16
 
17
17
  /**
18
- * Get Account
18
+ * Get account
19
19
  *
20
20
  * Get the currently logged in user.
21
21
  *
@@ -32,7 +32,7 @@ class Account extends Service {
32
32
  }
33
33
 
34
34
  /**
35
- * Update Email
35
+ * Update email
36
36
  *
37
37
  * Update currently logged in user account email address. After changing user
38
38
  * address, the user confirmation status will get reset. A new confirmation
@@ -118,7 +118,7 @@ class Account extends Service {
118
118
  }
119
119
 
120
120
  /**
121
- * List Logs
121
+ * List logs
122
122
  *
123
123
  * Get the list of latest security activity logs for the currently logged in
124
124
  * user. Each log returns user IP address, location and date and time of log.
@@ -141,7 +141,7 @@ class Account extends Service {
141
141
  }
142
142
 
143
143
  /**
144
- * Update Name
144
+ * Update name
145
145
  *
146
146
  * Update currently logged in user account name.
147
147
  *
@@ -167,7 +167,7 @@ class Account extends Service {
167
167
  }
168
168
 
169
169
  /**
170
- * Update Password
170
+ * Update password
171
171
  *
172
172
  * Update currently logged in user password. For validation, user is required
173
173
  * to pass in the new password, and the old password. For users created with
@@ -200,12 +200,12 @@ class Account extends Service {
200
200
  }
201
201
 
202
202
  /**
203
- * Update Phone
203
+ * Update phone
204
204
  *
205
205
  * Update the currently logged in user's phone number. After updating the
206
206
  * phone number, the phone verification status will be reset. A confirmation
207
207
  * SMS is not sent automatically, however you can use the [POST
208
- * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification)
208
+ * /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
209
209
  * endpoint to send a confirmation SMS.
210
210
  *
211
211
  * @param {string} phone
@@ -239,7 +239,7 @@ class Account extends Service {
239
239
  }
240
240
 
241
241
  /**
242
- * Get Account Preferences
242
+ * Get account preferences
243
243
  *
244
244
  * Get the preferences as a key-value object for the currently logged in user.
245
245
  *
@@ -256,7 +256,7 @@ class Account extends Service {
256
256
  }
257
257
 
258
258
  /**
259
- * Update Preferences
259
+ * Update preferences
260
260
  *
261
261
  * Update currently logged in user account preferences. The object you pass is
262
262
  * stored as is, and replaces any previous value. The maximum allowed prefs
@@ -284,16 +284,16 @@ class Account extends Service {
284
284
  }
285
285
 
286
286
  /**
287
- * Create Password Recovery
287
+ * Create password recovery
288
288
  *
289
289
  * Sends the user an email with a temporary secret key for password reset.
290
290
  * When the user clicks the confirmation link he is redirected back to your
291
291
  * app password reset URL with the secret key and email address values
292
292
  * attached to the URL query string. Use the query string params to submit a
293
293
  * request to the [PUT
294
- * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to
295
- * complete the process. The verification link sent to the user's email
296
- * address is valid for 1 hour.
294
+ * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
295
+ * endpoint to complete the process. The verification link sent to the user's
296
+ * email address is valid for 1 hour.
297
297
  *
298
298
  * @param {string} email
299
299
  * @param {string} url
@@ -326,12 +326,13 @@ class Account extends Service {
326
326
  }
327
327
 
328
328
  /**
329
- * Create Password Recovery (confirmation)
329
+ * Create password recovery (confirmation)
330
330
  *
331
331
  * Use this endpoint to complete the user account password reset. Both the
332
332
  * **userId** and **secret** arguments will be passed as query parameters to
333
333
  * the redirect URL you have provided when sending your request to the [POST
334
- * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint.
334
+ * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
335
+ * endpoint.
335
336
  *
336
337
  * Please note that in order to avoid a [Redirect
337
338
  * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
@@ -387,7 +388,7 @@ class Account extends Service {
387
388
  }
388
389
 
389
390
  /**
390
- * List Sessions
391
+ * List sessions
391
392
  *
392
393
  * Get the list of active sessions across different devices for the currently
393
394
  * logged in user.
@@ -405,7 +406,7 @@ class Account extends Service {
405
406
  }
406
407
 
407
408
  /**
408
- * Delete Sessions
409
+ * Delete sessions
409
410
  *
410
411
  * Delete all sessions from the user account and remove any sessions cookies
411
412
  * from the end client.
@@ -423,7 +424,7 @@ class Account extends Service {
423
424
  }
424
425
 
425
426
  /**
426
- * Get Session
427
+ * Get session
427
428
  *
428
429
  * Use this endpoint to get a logged in user's session using a Session ID.
429
430
  * Inputting 'current' will return the current session being used.
@@ -446,7 +447,7 @@ class Account extends Service {
446
447
  }
447
448
 
448
449
  /**
449
- * Update OAuth Session (Refresh Tokens)
450
+ * Update OAuth session (refresh tokens)
450
451
  *
451
452
  * Access tokens have limited lifespan and expire to mitigate security risks.
452
453
  * If session was created using an OAuth provider, this route can be used to
@@ -470,12 +471,13 @@ class Account extends Service {
470
471
  }
471
472
 
472
473
  /**
473
- * Delete Session
474
+ * Delete session
474
475
  *
475
476
  * Logout the user. Use 'current' as the session ID to logout on this device,
476
477
  * use a session ID to logout on another device. If you're looking to logout
477
478
  * the user on all devices, use [Delete
478
- * Sessions](/docs/client/account#accountDeleteSessions) instead.
479
+ * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
480
+ * instead.
479
481
  *
480
482
  * @param {string} sessionId
481
483
  * @throws {AppwriteException}
@@ -495,7 +497,7 @@ class Account extends Service {
495
497
  }
496
498
 
497
499
  /**
498
- * Update Status
500
+ * Update status
499
501
  *
500
502
  * Block the currently logged in user account. Behind the scene, the user
501
503
  * record is not deleted but permanently blocked from any access. To
@@ -514,7 +516,7 @@ class Account extends Service {
514
516
  }
515
517
 
516
518
  /**
517
- * Create Email Verification
519
+ * Create email verification
518
520
  *
519
521
  * Use this endpoint to send a verification message to your user email address
520
522
  * to confirm they are the valid owners of that address. Both the **userId**
@@ -523,8 +525,8 @@ class Account extends Service {
523
525
  * should redirect the user back to your app and allow you to complete the
524
526
  * verification process by verifying both the **userId** and **secret**
525
527
  * parameters. Learn more about how to [complete the verification
526
- * process](/docs/client/account#accountUpdateEmailVerification). The
527
- * verification link sent to the user's email address is valid for 7 days.
528
+ * process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
529
+ * The verification link sent to the user's email address is valid for 7 days.
528
530
  *
529
531
  * Please note that in order to avoid a [Redirect
530
532
  * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
@@ -554,7 +556,7 @@ class Account extends Service {
554
556
  }
555
557
 
556
558
  /**
557
- * Create Email Verification (confirmation)
559
+ * Create email verification (confirmation)
558
560
  *
559
561
  * Use this endpoint to complete the user email verification process. Use both
560
562
  * the **userId** and **secret** parameters that were attached to your app URL
@@ -592,14 +594,16 @@ class Account extends Service {
592
594
  }
593
595
 
594
596
  /**
595
- * Create Phone Verification
597
+ * Create phone verification
596
598
  *
597
599
  * Use this endpoint to send a verification SMS to the currently logged in
598
600
  * user. This endpoint is meant for use after updating a user's phone number
599
- * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone)
601
+ * using the
602
+ * [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone)
600
603
  * endpoint. Learn more about how to [complete the verification
601
- * process](/docs/client/account#accountUpdatePhoneVerification). The
602
- * verification code sent to the user's phone number is valid for 15 minutes.
604
+ * process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification).
605
+ * The verification code sent to the user's phone number is valid for 15
606
+ * minutes.
603
607
  *
604
608
  * @throws {AppwriteException}
605
609
  * @returns {Promise}
@@ -614,7 +618,7 @@ class Account extends Service {
614
618
  }
615
619
 
616
620
  /**
617
- * Create Phone Verification (confirmation)
621
+ * Create phone verification (confirmation)
618
622
  *
619
623
  * Use this endpoint to complete the user phone verification process. Use the
620
624
  * **userId** and **secret** that were sent to your user's phone number to
@@ -15,12 +15,13 @@ class Avatars extends Service {
15
15
 
16
16
 
17
17
  /**
18
- * Get Browser Icon
18
+ * Get browser icon
19
19
  *
20
20
  * You can use this endpoint to show different browser icons to your users.
21
21
  * The code argument receives the browser code as it appears in your user [GET
22
- * /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
23
- * width, height and quality arguments to change the output settings.
22
+ * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
23
+ * endpoint. Use width, height and quality arguments to change the output
24
+ * settings.
24
25
  *
25
26
  * When one dimension is specified and the other is 0, the image is scaled
26
27
  * with preserved aspect ratio. If both dimensions are 0, the API provides an
@@ -60,7 +61,7 @@ class Avatars extends Service {
60
61
  }
61
62
 
62
63
  /**
63
- * Get Credit Card Icon
64
+ * Get credit card icon
64
65
  *
65
66
  * The credit card endpoint will return you the icon of the credit card
66
67
  * provider you need. Use width, height and quality arguments to change the
@@ -105,7 +106,7 @@ class Avatars extends Service {
105
106
  }
106
107
 
107
108
  /**
108
- * Get Favicon
109
+ * Get favicon
109
110
  *
110
111
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
111
112
  * website URL.
@@ -133,12 +134,12 @@ class Avatars extends Service {
133
134
  }
134
135
 
135
136
  /**
136
- * Get Country Flag
137
+ * Get country flag
137
138
  *
138
139
  * You can use this endpoint to show different country flags icons to your
139
140
  * users. The code argument receives the 2 letter country code. Use width,
140
141
  * height and quality arguments to change the output settings. Country codes
141
- * follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard.
142
+ * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
142
143
  *
143
144
  * When one dimension is specified and the other is 0, the image is scaled
144
145
  * with preserved aspect ratio. If both dimensions are 0, the API provides an
@@ -179,7 +180,7 @@ class Avatars extends Service {
179
180
  }
180
181
 
181
182
  /**
182
- * Get Image from URL
183
+ * Get image from URL
183
184
  *
184
185
  * Use this endpoint to fetch a remote image URL and crop it to any image size
185
186
  * you want. This endpoint is very useful if you need to crop and display
@@ -224,7 +225,7 @@ class Avatars extends Service {
224
225
  }
225
226
 
226
227
  /**
227
- * Get User Initials
228
+ * Get user initials
228
229
  *
229
230
  * Use this endpoint to show your user initials avatar icon on your website or
230
231
  * app. By default, this route will try to print your logged-in user name or
@@ -276,7 +277,7 @@ class Avatars extends Service {
276
277
  }
277
278
 
278
279
  /**
279
- * Get QR Code
280
+ * Get QR code
280
281
  *
281
282
  * Converts a given plain text to a QR code image. You can use the query
282
283
  * parameters to change the size and style of the resulting image.