react-native-appwrite 0.2.1 → 0.3.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.
Files changed (131) hide show
  1. package/.github/workflows/publish.yml +13 -4
  2. package/CHANGELOG.md +1 -1
  3. package/LICENSE +1 -1
  4. package/README.md +22 -9
  5. package/dist/cjs/sdk.js +1196 -273
  6. package/dist/cjs/sdk.js.map +1 -1
  7. package/dist/esm/sdk.js +1196 -273
  8. package/dist/esm/sdk.js.map +1 -1
  9. package/docs/examples/account/create-anonymous-session.md +6 -13
  10. package/docs/examples/account/create-email-password-session.md +14 -0
  11. package/docs/examples/account/create-email-token.md +15 -0
  12. package/docs/examples/account/create-j-w-t.md +6 -13
  13. package/docs/examples/account/create-magic-u-r-l-token.md +16 -0
  14. package/docs/examples/account/create-mfa-authenticator.md +13 -0
  15. package/docs/examples/account/create-mfa-challenge.md +13 -0
  16. package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
  17. package/docs/examples/account/create-o-auth2session.md +10 -9
  18. package/docs/examples/account/create-o-auth2token.md +15 -0
  19. package/docs/examples/account/create-phone-token.md +14 -0
  20. package/docs/examples/account/create-phone-verification.md +6 -13
  21. package/docs/examples/account/create-push-target.md +15 -0
  22. package/docs/examples/account/create-recovery.md +9 -13
  23. package/docs/examples/account/create-session.md +14 -0
  24. package/docs/examples/account/create-verification.md +8 -13
  25. package/docs/examples/account/create.md +11 -13
  26. package/docs/examples/account/delete-identity.md +8 -13
  27. package/docs/examples/account/delete-mfa-authenticator.md +14 -0
  28. package/docs/examples/account/delete-push-target.md +13 -0
  29. package/docs/examples/account/delete-session.md +8 -13
  30. package/docs/examples/account/delete-sessions.md +6 -13
  31. package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
  32. package/docs/examples/account/get-prefs.md +6 -13
  33. package/docs/examples/account/get-session.md +8 -13
  34. package/docs/examples/account/get.md +6 -13
  35. package/docs/examples/account/list-identities.md +8 -13
  36. package/docs/examples/account/list-logs.md +8 -13
  37. package/docs/examples/account/list-mfa-factors.md +11 -0
  38. package/docs/examples/account/list-sessions.md +6 -13
  39. package/docs/examples/account/update-email.md +9 -13
  40. package/docs/examples/account/update-m-f-a.md +13 -0
  41. package/docs/examples/account/update-magic-u-r-l-session.md +9 -13
  42. package/docs/examples/account/update-mfa-authenticator.md +14 -0
  43. package/docs/examples/account/update-mfa-challenge.md +14 -0
  44. package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
  45. package/docs/examples/account/update-name.md +8 -13
  46. package/docs/examples/account/update-password.md +9 -13
  47. package/docs/examples/account/update-phone-session.md +9 -13
  48. package/docs/examples/account/update-phone-verification.md +9 -13
  49. package/docs/examples/account/update-phone.md +9 -13
  50. package/docs/examples/account/update-prefs.md +8 -13
  51. package/docs/examples/account/update-push-target.md +14 -0
  52. package/docs/examples/account/update-recovery.md +10 -13
  53. package/docs/examples/account/update-session.md +8 -13
  54. package/docs/examples/account/update-status.md +6 -13
  55. package/docs/examples/account/update-verification.md +9 -13
  56. package/docs/examples/avatars/get-browser.md +11 -9
  57. package/docs/examples/avatars/get-credit-card.md +11 -9
  58. package/docs/examples/avatars/get-favicon.md +8 -9
  59. package/docs/examples/avatars/get-flag.md +11 -9
  60. package/docs/examples/avatars/get-image.md +10 -9
  61. package/docs/examples/avatars/get-initials.md +11 -9
  62. package/docs/examples/avatars/get-q-r.md +11 -9
  63. package/docs/examples/databases/create-document.md +12 -13
  64. package/docs/examples/databases/delete-document.md +10 -13
  65. package/docs/examples/databases/get-document.md +11 -13
  66. package/docs/examples/databases/list-documents.md +10 -13
  67. package/docs/examples/databases/update-document.md +12 -13
  68. package/docs/examples/functions/create-execution.md +13 -13
  69. package/docs/examples/functions/get-execution.md +9 -13
  70. package/docs/examples/functions/list-executions.md +10 -13
  71. package/docs/examples/graphql/mutation.md +8 -13
  72. package/docs/examples/graphql/query.md +8 -13
  73. package/docs/examples/locale/get.md +6 -13
  74. package/docs/examples/locale/list-codes.md +6 -13
  75. package/docs/examples/locale/list-continents.md +6 -13
  76. package/docs/examples/locale/list-countries-e-u.md +6 -13
  77. package/docs/examples/locale/list-countries-phones.md +6 -13
  78. package/docs/examples/locale/list-countries.md +6 -13
  79. package/docs/examples/locale/list-currencies.md +6 -13
  80. package/docs/examples/locale/list-languages.md +6 -13
  81. package/docs/examples/messaging/create-subscriber.md +15 -0
  82. package/docs/examples/messaging/delete-subscriber.md +14 -0
  83. package/docs/examples/storage/create-file.md +11 -13
  84. package/docs/examples/storage/delete-file.md +9 -13
  85. package/docs/examples/storage/get-file-download.md +9 -9
  86. package/docs/examples/storage/get-file-preview.md +20 -9
  87. package/docs/examples/storage/get-file-view.md +9 -9
  88. package/docs/examples/storage/get-file.md +9 -13
  89. package/docs/examples/storage/list-files.md +10 -13
  90. package/docs/examples/storage/update-file.md +11 -13
  91. package/docs/examples/teams/create-membership.md +14 -13
  92. package/docs/examples/teams/create.md +10 -13
  93. package/docs/examples/teams/delete-membership.md +9 -13
  94. package/docs/examples/teams/delete.md +8 -13
  95. package/docs/examples/teams/get-membership.md +9 -13
  96. package/docs/examples/teams/get-prefs.md +8 -13
  97. package/docs/examples/teams/get.md +8 -13
  98. package/docs/examples/teams/list-memberships.md +10 -13
  99. package/docs/examples/teams/list.md +9 -13
  100. package/docs/examples/teams/update-membership-status.md +11 -13
  101. package/docs/examples/teams/update-membership.md +10 -13
  102. package/docs/examples/teams/update-name.md +9 -13
  103. package/docs/examples/teams/update-prefs.md +9 -13
  104. package/package.json +4 -3
  105. package/src/client.ts +39 -13
  106. package/src/enums/authentication-factor.ts +6 -0
  107. package/src/enums/authenticator-type.ts +3 -0
  108. package/src/enums/browser.ts +16 -0
  109. package/src/enums/credit-card.ts +18 -0
  110. package/src/enums/execution-method.ts +8 -0
  111. package/src/enums/flag.ts +197 -0
  112. package/src/enums/image-format.ts +7 -0
  113. package/src/enums/image-gravity.ts +11 -0
  114. package/src/enums/o-auth-provider.ts +41 -0
  115. package/src/id.ts +23 -4
  116. package/src/index.ts +13 -2
  117. package/src/models.ts +174 -0
  118. package/src/query.ts +61 -34
  119. package/src/service.ts +4 -7
  120. package/src/services/account.ts +643 -119
  121. package/src/services/avatars.ts +12 -6
  122. package/src/services/databases.ts +7 -4
  123. package/src/services/functions.ts +6 -2
  124. package/src/services/graphql.ts +3 -0
  125. package/src/services/locale.ts +3 -0
  126. package/src/services/messaging.ts +84 -0
  127. package/src/services/storage.ts +13 -7
  128. package/src/services/teams.ts +3 -0
  129. package/docs/examples/account/create-email-session.md +0 -18
  130. package/docs/examples/account/create-magic-u-r-l-session.md +0 -18
  131. package/docs/examples/account/create-phone-session.md +0 -18
package/dist/cjs/sdk.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Device = require('expo-device');
3
+ var reactNative = require('react-native');
4
4
  var FileSystem = require('expo-file-system');
5
5
 
6
6
  function _interopNamespace(e) {
@@ -21,7 +21,6 @@ function _interopNamespace(e) {
21
21
  return Object.freeze(n);
22
22
  }
23
23
 
24
- var Device__namespace = /*#__PURE__*/_interopNamespace(Device);
25
24
  var FileSystem__namespace = /*#__PURE__*/_interopNamespace(FileSystem);
26
25
 
27
26
  /******************************************************************************
@@ -47,6 +46,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
47
46
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48
47
  step((generator = generator.apply(thisArg, _arguments || [])).next());
49
48
  });
49
+ }
50
+
51
+ function __classPrivateFieldGet(receiver, state, kind, f) {
52
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
53
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
54
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
50
55
  }
51
56
 
52
57
  class Service {
@@ -55,11 +60,10 @@ class Service {
55
60
  }
56
61
  static flatten(data, prefix = '') {
57
62
  let output = {};
58
- for (const key in data) {
59
- let value = data[key];
60
- let finalKey = prefix ? `${prefix}[${key}]` : key;
63
+ for (const [key, value] of Object.entries(data)) {
64
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
61
65
  if (Array.isArray(value)) {
62
- output = Object.assign(output, this.flatten(value, finalKey));
66
+ output = Object.assign(Object.assign({}, output), Service.flatten(value, finalKey));
63
67
  }
64
68
  else {
65
69
  output[finalKey] = value;
@@ -70,36 +74,6 @@ class Service {
70
74
  }
71
75
  Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
72
76
 
73
- class Query {
74
- }
75
- Query.equal = (attribute, value) => Query.addQuery(attribute, "equal", value);
76
- Query.notEqual = (attribute, value) => Query.addQuery(attribute, "notEqual", value);
77
- Query.lessThan = (attribute, value) => Query.addQuery(attribute, "lessThan", value);
78
- Query.lessThanEqual = (attribute, value) => Query.addQuery(attribute, "lessThanEqual", value);
79
- Query.greaterThan = (attribute, value) => Query.addQuery(attribute, "greaterThan", value);
80
- Query.greaterThanEqual = (attribute, value) => Query.addQuery(attribute, "greaterThanEqual", value);
81
- Query.isNull = (attribute) => `isNull("${attribute}")`;
82
- Query.isNotNull = (attribute) => `isNotNull("${attribute}")`;
83
- Query.between = (attribute, start, end) => `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`;
84
- Query.startsWith = (attribute, value) => Query.addQuery(attribute, "startsWith", value);
85
- Query.endsWith = (attribute, value) => Query.addQuery(attribute, "endsWith", value);
86
- Query.select = (attributes) => `select([${attributes.map((attr) => `"${attr}"`).join(",")}])`;
87
- Query.search = (attribute, value) => Query.addQuery(attribute, "search", value);
88
- Query.orderDesc = (attribute) => `orderDesc("${attribute}")`;
89
- Query.orderAsc = (attribute) => `orderAsc("${attribute}")`;
90
- Query.cursorAfter = (documentId) => `cursorAfter("${documentId}")`;
91
- Query.cursorBefore = (documentId) => `cursorBefore("${documentId}")`;
92
- Query.limit = (limit) => `limit(${limit})`;
93
- Query.offset = (offset) => `offset(${offset})`;
94
- Query.addQuery = (attribute, method, value) => value instanceof Array
95
- ? `${method}("${attribute}", [${value
96
- .map((v) => Query.parseValues(v))
97
- .join(",")}])`
98
- : `${method}("${attribute}", [${Query.parseValues(value)}])`;
99
- Query.parseValues = (value) => typeof value === "string" || value instanceof String
100
- ? `"${value}"`
101
- : `${value}`;
102
-
103
77
  class AppwriteException extends Error {
104
78
  constructor(message, code = 0, type = '', response = '') {
105
79
  super(message);
@@ -113,19 +87,20 @@ class AppwriteException extends Error {
113
87
  class Client {
114
88
  constructor() {
115
89
  this.config = {
116
- endpoint: 'https://HOSTNAME/v1',
90
+ endpoint: 'https://cloud.appwrite.io/v1',
117
91
  endpointRealtime: '',
118
92
  project: '',
119
93
  jwt: '',
120
94
  locale: '',
95
+ session: '',
121
96
  platform: '',
122
97
  };
123
98
  this.headers = {
124
- 'x-sdk-name': 'Web',
99
+ 'x-sdk-name': 'React Native',
125
100
  'x-sdk-platform': 'client',
126
- 'x-sdk-language': 'web',
127
- 'x-sdk-version': '13.0.2',
128
- 'X-Appwrite-Response-Format': '1.4.0',
101
+ 'x-sdk-language': 'reactnative',
102
+ 'x-sdk-version': '0.3.0',
103
+ 'X-Appwrite-Response-Format': '1.5.0',
129
104
  };
130
105
  this.realtime = {
131
106
  socket: undefined,
@@ -156,9 +131,12 @@ class Client {
156
131
  }
157
132
  },
158
133
  createSocket: () => {
159
- var _a, _b;
160
- if (this.realtime.channels.size < 1)
134
+ var _a, _b, _c;
135
+ if (this.realtime.channels.size < 1) {
136
+ this.realtime.reconnect = false;
137
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.close();
161
138
  return;
139
+ }
162
140
  const channels = new URLSearchParams();
163
141
  channels.set('project', this.config.project);
164
142
  this.realtime.channels.forEach(channel => {
@@ -167,10 +145,10 @@ class Client {
167
145
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
168
146
  if (url !== this.realtime.url || // Check if URL is present
169
147
  !this.realtime.socket || // Check if WebSocket has not been created
170
- ((_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
148
+ ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
171
149
  ) {
172
150
  if (this.realtime.socket &&
173
- ((_b = this.realtime.socket) === null || _b === void 0 ? void 0 : _b.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
151
+ ((_c = this.realtime.socket) === null || _c === void 0 ? void 0 : _c.readyState) < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
174
152
  ) {
175
153
  this.realtime.reconnect = false;
176
154
  this.realtime.socket.close();
@@ -179,7 +157,7 @@ class Client {
179
157
  // @ts-ignore
180
158
  this.realtime.socket = new WebSocket(url, undefined, {
181
159
  headers: {
182
- Origin: `appwrite-${Device__namespace.osName}://${this.config.platform}`
160
+ Origin: `appwrite-${reactNative.Platform.OS}://${this.config.platform}`
183
161
  }
184
162
  });
185
163
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
@@ -204,7 +182,7 @@ class Client {
204
182
  });
205
183
  }
206
184
  },
207
- onMessage: (event) => __awaiter(this, void 0, void 0, function* () {
185
+ onMessage: (event) => {
208
186
  try {
209
187
  const message = JSON.parse(event.data);
210
188
  this.realtime.lastMessage = message;
@@ -231,7 +209,7 @@ class Client {
231
209
  catch (e) {
232
210
  console.error(e);
233
211
  }
234
- }),
212
+ },
235
213
  cleanUp: channels => {
236
214
  this.realtime.channels.forEach(channel => {
237
215
  if (channels.includes(channel)) {
@@ -323,6 +301,20 @@ class Client {
323
301
  this.config.locale = value;
324
302
  return this;
325
303
  }
304
+ /**
305
+ * Set Session
306
+ *
307
+ * The user session to authenticate with
308
+ *
309
+ * @param value string
310
+ *
311
+ * @return {this}
312
+ */
313
+ setSession(value) {
314
+ this.headers['X-Appwrite-Session'] = value;
315
+ this.config.session = value;
316
+ return this;
317
+ }
326
318
  /**
327
319
  * Subscribes to Appwrite events and passes you the payload in realtime.
328
320
  *
@@ -368,7 +360,7 @@ class Client {
368
360
  return __awaiter(this, void 0, void 0, function* () {
369
361
  method = method.toUpperCase();
370
362
  headers = Object.assign({}, this.headers, headers);
371
- headers.Origin = `appwrite-${Device__namespace.osName}://${this.config.platform}`;
363
+ headers.Origin = `appwrite-${reactNative.Platform.OS}://${this.config.platform}`;
372
364
  let options = {
373
365
  method,
374
366
  headers,
@@ -415,6 +407,11 @@ class Client {
415
407
  if (400 <= response.status) {
416
408
  throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, data);
417
409
  }
410
+ const cookieFallback = response.headers.get('X-Fallback-Cookies');
411
+ if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
412
+ window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');
413
+ window.localStorage.setItem('cookieFallback', cookieFallback);
414
+ }
418
415
  return data;
419
416
  }
420
417
  catch (e) {
@@ -542,7 +539,7 @@ class Account extends Service {
542
539
  *
543
540
  * Get the list of identities for the currently logged in user.
544
541
  *
545
- * @param {string} queries
542
+ * @param {string[]} queries
546
543
  * @throws {AppwriteException}
547
544
  * @returns {Promise}
548
545
  */
@@ -560,7 +557,7 @@ class Account extends Service {
560
557
  });
561
558
  }
562
559
  /**
563
- * Delete Identity
560
+ * Delete identity
564
561
  *
565
562
  * Delete an identity by its unique ID.
566
563
  *
@@ -626,6 +623,261 @@ class Account extends Service {
626
623
  }, payload);
627
624
  });
628
625
  }
626
+ /**
627
+ * Update MFA
628
+ *
629
+ * Enable or disable MFA on an account.
630
+ *
631
+ * @param {boolean} mfa
632
+ * @throws {AppwriteException}
633
+ * @returns {Promise}
634
+ */
635
+ updateMFA(mfa) {
636
+ return __awaiter(this, void 0, void 0, function* () {
637
+ if (typeof mfa === 'undefined') {
638
+ throw new AppwriteException('Missing required parameter: "mfa"');
639
+ }
640
+ const apiPath = '/account/mfa';
641
+ const payload = {};
642
+ if (typeof mfa !== 'undefined') {
643
+ payload['mfa'] = mfa;
644
+ }
645
+ const uri = new URL(this.client.config.endpoint + apiPath);
646
+ return yield this.client.call('patch', uri, {
647
+ 'content-type': 'application/json',
648
+ }, payload);
649
+ });
650
+ }
651
+ /**
652
+ * Add Authenticator
653
+ *
654
+ * Add an authenticator app to be used as an MFA factor. Verify the
655
+ * authenticator using the [verify
656
+ * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
657
+ * method.
658
+ *
659
+ * @param {AuthenticatorType} type
660
+ * @throws {AppwriteException}
661
+ * @returns {Promise}
662
+ */
663
+ createMfaAuthenticator(type) {
664
+ return __awaiter(this, void 0, void 0, function* () {
665
+ if (typeof type === 'undefined') {
666
+ throw new AppwriteException('Missing required parameter: "type"');
667
+ }
668
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
669
+ const payload = {};
670
+ const uri = new URL(this.client.config.endpoint + apiPath);
671
+ return yield this.client.call('post', uri, {
672
+ 'content-type': 'application/json',
673
+ }, payload);
674
+ });
675
+ }
676
+ /**
677
+ * Verify Authenticator
678
+ *
679
+ * Verify an authenticator app after adding it using the [add
680
+ * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
681
+ * method. add
682
+ *
683
+ * @param {AuthenticatorType} type
684
+ * @param {string} otp
685
+ * @throws {AppwriteException}
686
+ * @returns {Promise}
687
+ */
688
+ updateMfaAuthenticator(type, otp) {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ if (typeof type === 'undefined') {
691
+ throw new AppwriteException('Missing required parameter: "type"');
692
+ }
693
+ if (typeof otp === 'undefined') {
694
+ throw new AppwriteException('Missing required parameter: "otp"');
695
+ }
696
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
697
+ const payload = {};
698
+ if (typeof otp !== 'undefined') {
699
+ payload['otp'] = otp;
700
+ }
701
+ const uri = new URL(this.client.config.endpoint + apiPath);
702
+ return yield this.client.call('put', uri, {
703
+ 'content-type': 'application/json',
704
+ }, payload);
705
+ });
706
+ }
707
+ /**
708
+ * Delete Authenticator
709
+ *
710
+ * Delete an authenticator for a user by ID.
711
+ *
712
+ * @param {AuthenticatorType} type
713
+ * @param {string} otp
714
+ * @throws {AppwriteException}
715
+ * @returns {Promise}
716
+ */
717
+ deleteMfaAuthenticator(type, otp) {
718
+ return __awaiter(this, void 0, void 0, function* () {
719
+ if (typeof type === 'undefined') {
720
+ throw new AppwriteException('Missing required parameter: "type"');
721
+ }
722
+ if (typeof otp === 'undefined') {
723
+ throw new AppwriteException('Missing required parameter: "otp"');
724
+ }
725
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
726
+ const payload = {};
727
+ if (typeof otp !== 'undefined') {
728
+ payload['otp'] = otp;
729
+ }
730
+ const uri = new URL(this.client.config.endpoint + apiPath);
731
+ return yield this.client.call('delete', uri, {
732
+ 'content-type': 'application/json',
733
+ }, payload);
734
+ });
735
+ }
736
+ /**
737
+ * Create 2FA Challenge
738
+ *
739
+ * Begin the process of MFA verification after sign-in. Finish the flow with
740
+ * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
741
+ * method.
742
+ *
743
+ * @param {AuthenticationFactor} factor
744
+ * @throws {AppwriteException}
745
+ * @returns {Promise}
746
+ */
747
+ createMfaChallenge(factor) {
748
+ return __awaiter(this, void 0, void 0, function* () {
749
+ if (typeof factor === 'undefined') {
750
+ throw new AppwriteException('Missing required parameter: "factor"');
751
+ }
752
+ const apiPath = '/account/mfa/challenge';
753
+ const payload = {};
754
+ if (typeof factor !== 'undefined') {
755
+ payload['factor'] = factor;
756
+ }
757
+ const uri = new URL(this.client.config.endpoint + apiPath);
758
+ return yield this.client.call('post', uri, {
759
+ 'content-type': 'application/json',
760
+ }, payload);
761
+ });
762
+ }
763
+ /**
764
+ * Create MFA Challenge (confirmation)
765
+ *
766
+ * Complete the MFA challenge by providing the one-time password. Finish the
767
+ * process of MFA verification by providing the one-time password. To begin
768
+ * the flow, use
769
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
770
+ * method.
771
+ *
772
+ * @param {string} challengeId
773
+ * @param {string} otp
774
+ * @throws {AppwriteException}
775
+ * @returns {Promise}
776
+ */
777
+ updateMfaChallenge(challengeId, otp) {
778
+ return __awaiter(this, void 0, void 0, function* () {
779
+ if (typeof challengeId === 'undefined') {
780
+ throw new AppwriteException('Missing required parameter: "challengeId"');
781
+ }
782
+ if (typeof otp === 'undefined') {
783
+ throw new AppwriteException('Missing required parameter: "otp"');
784
+ }
785
+ const apiPath = '/account/mfa/challenge';
786
+ const payload = {};
787
+ if (typeof challengeId !== 'undefined') {
788
+ payload['challengeId'] = challengeId;
789
+ }
790
+ if (typeof otp !== 'undefined') {
791
+ payload['otp'] = otp;
792
+ }
793
+ const uri = new URL(this.client.config.endpoint + apiPath);
794
+ return yield this.client.call('put', uri, {
795
+ 'content-type': 'application/json',
796
+ }, payload);
797
+ });
798
+ }
799
+ /**
800
+ * List Factors
801
+ *
802
+ * List the factors available on the account to be used as a MFA challange.
803
+ *
804
+ * @throws {AppwriteException}
805
+ * @returns {Promise}
806
+ */
807
+ listMfaFactors() {
808
+ return __awaiter(this, void 0, void 0, function* () {
809
+ const apiPath = '/account/mfa/factors';
810
+ const payload = {};
811
+ const uri = new URL(this.client.config.endpoint + apiPath);
812
+ return yield this.client.call('get', uri, {
813
+ 'content-type': 'application/json',
814
+ }, payload);
815
+ });
816
+ }
817
+ /**
818
+ * Get MFA Recovery Codes
819
+ *
820
+ * Get recovery codes that can be used as backup for MFA flow. Before getting
821
+ * codes, they must be generated using
822
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
823
+ * method. An OTP challenge is required to read recovery codes.
824
+ *
825
+ * @throws {AppwriteException}
826
+ * @returns {Promise}
827
+ */
828
+ getMfaRecoveryCodes() {
829
+ return __awaiter(this, void 0, void 0, function* () {
830
+ const apiPath = '/account/mfa/recovery-codes';
831
+ const payload = {};
832
+ const uri = new URL(this.client.config.endpoint + apiPath);
833
+ return yield this.client.call('get', uri, {
834
+ 'content-type': 'application/json',
835
+ }, payload);
836
+ });
837
+ }
838
+ /**
839
+ * Create MFA Recovery Codes
840
+ *
841
+ * Generate recovery codes as backup for MFA flow. It's recommended to
842
+ * generate and show then immediately after user successfully adds their
843
+ * authehticator. Recovery codes can be used as a MFA verification type in
844
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
845
+ * method.
846
+ *
847
+ * @throws {AppwriteException}
848
+ * @returns {Promise}
849
+ */
850
+ createMfaRecoveryCodes() {
851
+ return __awaiter(this, void 0, void 0, function* () {
852
+ const apiPath = '/account/mfa/recovery-codes';
853
+ const payload = {};
854
+ const uri = new URL(this.client.config.endpoint + apiPath);
855
+ return yield this.client.call('post', uri, {
856
+ 'content-type': 'application/json',
857
+ }, payload);
858
+ });
859
+ }
860
+ /**
861
+ * Regenerate MFA Recovery Codes
862
+ *
863
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before
864
+ * regenerating codes, they must be first generated using
865
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
866
+ * method. An OTP challenge is required to regenreate recovery codes.
867
+ *
868
+ * @throws {AppwriteException}
869
+ * @returns {Promise}
870
+ */
871
+ updateMfaRecoveryCodes() {
872
+ return __awaiter(this, void 0, void 0, function* () {
873
+ const apiPath = '/account/mfa/recovery-codes';
874
+ const payload = {};
875
+ const uri = new URL(this.client.config.endpoint + apiPath);
876
+ return yield this.client.call('patch', uri, {
877
+ 'content-type': 'application/json',
878
+ }, payload);
879
+ });
880
+ }
629
881
  /**
630
882
  * Update name
631
883
  *
@@ -743,7 +995,7 @@ class Account extends Service {
743
995
  * stored as is, and replaces any previous value. The maximum allowed prefs
744
996
  * size is 64kB and throws error if exceeded.
745
997
  *
746
- * @param {Partial<Preferences>} prefs
998
+ * @param {object} prefs
747
999
  * @throws {AppwriteException}
748
1000
  * @returns {Promise}
749
1001
  */
@@ -819,11 +1071,10 @@ class Account extends Service {
819
1071
  * @param {string} userId
820
1072
  * @param {string} secret
821
1073
  * @param {string} password
822
- * @param {string} passwordAgain
823
1074
  * @throws {AppwriteException}
824
1075
  * @returns {Promise}
825
1076
  */
826
- updateRecovery(userId, secret, password, passwordAgain) {
1077
+ updateRecovery(userId, secret, password) {
827
1078
  return __awaiter(this, void 0, void 0, function* () {
828
1079
  if (typeof userId === 'undefined') {
829
1080
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -834,9 +1085,6 @@ class Account extends Service {
834
1085
  if (typeof password === 'undefined') {
835
1086
  throw new AppwriteException('Missing required parameter: "password"');
836
1087
  }
837
- if (typeof passwordAgain === 'undefined') {
838
- throw new AppwriteException('Missing required parameter: "passwordAgain"');
839
- }
840
1088
  const apiPath = '/account/recovery';
841
1089
  const payload = {};
842
1090
  if (typeof userId !== 'undefined') {
@@ -848,9 +1096,6 @@ class Account extends Service {
848
1096
  if (typeof password !== 'undefined') {
849
1097
  payload['password'] = password;
850
1098
  }
851
- if (typeof passwordAgain !== 'undefined') {
852
- payload['passwordAgain'] = passwordAgain;
853
- }
854
1099
  const uri = new URL(this.client.config.endpoint + apiPath);
855
1100
  return yield this.client.call('put', uri, {
856
1101
  'content-type': 'application/json',
@@ -920,7 +1165,7 @@ class Account extends Service {
920
1165
  });
921
1166
  }
922
1167
  /**
923
- * Create email session
1168
+ * Create email password session
924
1169
  *
925
1170
  * Allow the user to login into their account by providing a valid email and
926
1171
  * password combination. This route will create a new session for the user.
@@ -930,25 +1175,398 @@ class Account extends Service {
930
1175
  * limits](https://appwrite.io/docs/authentication-security#limits).
931
1176
  *
932
1177
  * @param {string} email
933
- * @param {string} password
1178
+ * @param {string} password
1179
+ * @throws {AppwriteException}
1180
+ * @returns {Promise}
1181
+ */
1182
+ createEmailPasswordSession(email, password) {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ if (typeof email === 'undefined') {
1185
+ throw new AppwriteException('Missing required parameter: "email"');
1186
+ }
1187
+ if (typeof password === 'undefined') {
1188
+ throw new AppwriteException('Missing required parameter: "password"');
1189
+ }
1190
+ const apiPath = '/account/sessions/email';
1191
+ const payload = {};
1192
+ if (typeof email !== 'undefined') {
1193
+ payload['email'] = email;
1194
+ }
1195
+ if (typeof password !== 'undefined') {
1196
+ payload['password'] = password;
1197
+ }
1198
+ const uri = new URL(this.client.config.endpoint + apiPath);
1199
+ return yield this.client.call('post', uri, {
1200
+ 'content-type': 'application/json',
1201
+ }, payload);
1202
+ });
1203
+ }
1204
+ /**
1205
+ * Update magic URL session
1206
+ *
1207
+ * Use this endpoint to create a session from token. Provide the **userId**
1208
+ * and **secret** parameters from the successful response of authentication
1209
+ * flows initiated by token creation. For example, magic URL and phone login.
1210
+ *
1211
+ * @param {string} userId
1212
+ * @param {string} secret
1213
+ * @throws {AppwriteException}
1214
+ * @returns {Promise}
1215
+ */
1216
+ updateMagicURLSession(userId, secret) {
1217
+ return __awaiter(this, void 0, void 0, function* () {
1218
+ if (typeof userId === 'undefined') {
1219
+ throw new AppwriteException('Missing required parameter: "userId"');
1220
+ }
1221
+ if (typeof secret === 'undefined') {
1222
+ throw new AppwriteException('Missing required parameter: "secret"');
1223
+ }
1224
+ const apiPath = '/account/sessions/magic-url';
1225
+ const payload = {};
1226
+ if (typeof userId !== 'undefined') {
1227
+ payload['userId'] = userId;
1228
+ }
1229
+ if (typeof secret !== 'undefined') {
1230
+ payload['secret'] = secret;
1231
+ }
1232
+ const uri = new URL(this.client.config.endpoint + apiPath);
1233
+ return yield this.client.call('put', uri, {
1234
+ 'content-type': 'application/json',
1235
+ }, payload);
1236
+ });
1237
+ }
1238
+ /**
1239
+ * Create OAuth2 session
1240
+ *
1241
+ * Allow the user to login to their account using the OAuth2 provider of their
1242
+ * choice. Each OAuth2 provider should be enabled from the Appwrite console
1243
+ * first. Use the success and failure arguments to provide a redirect URL's
1244
+ * back to your app when login is completed.
1245
+ *
1246
+ * If there is already an active session, the new session will be attached to
1247
+ * the logged-in account. If there are no active sessions, the server will
1248
+ * attempt to look for a user with the same email address as the email
1249
+ * received from the OAuth2 provider and attach the new session to the
1250
+ * existing user. If no matching user is found - the server will create a new
1251
+ * user.
1252
+ *
1253
+ * A user is limited to 10 active sessions at a time by default. [Learn more
1254
+ * about session
1255
+ * limits](https://appwrite.io/docs/authentication-security#limits).
1256
+ *
1257
+ *
1258
+ * @param {OAuthProvider} provider
1259
+ * @param {string} success
1260
+ * @param {string} failure
1261
+ * @param {string[]} scopes
1262
+ * @throws {AppwriteException}
1263
+ * @returns {void|string}
1264
+ */
1265
+ createOAuth2Session(provider, success, failure, scopes) {
1266
+ if (typeof provider === 'undefined') {
1267
+ throw new AppwriteException('Missing required parameter: "provider"');
1268
+ }
1269
+ const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
1270
+ const payload = {};
1271
+ if (typeof success !== 'undefined') {
1272
+ payload['success'] = success;
1273
+ }
1274
+ if (typeof failure !== 'undefined') {
1275
+ payload['failure'] = failure;
1276
+ }
1277
+ if (typeof scopes !== 'undefined') {
1278
+ payload['scopes'] = scopes;
1279
+ }
1280
+ const uri = new URL(this.client.config.endpoint + apiPath);
1281
+ payload['project'] = this.client.config.project;
1282
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1283
+ uri.searchParams.append(key, value);
1284
+ }
1285
+ return uri;
1286
+ }
1287
+ /**
1288
+ * Update phone session
1289
+ *
1290
+ * Use this endpoint to create a session from token. Provide the **userId**
1291
+ * and **secret** parameters from the successful response of authentication
1292
+ * flows initiated by token creation. For example, magic URL and phone login.
1293
+ *
1294
+ * @param {string} userId
1295
+ * @param {string} secret
1296
+ * @throws {AppwriteException}
1297
+ * @returns {Promise}
1298
+ */
1299
+ updatePhoneSession(userId, secret) {
1300
+ return __awaiter(this, void 0, void 0, function* () {
1301
+ if (typeof userId === 'undefined') {
1302
+ throw new AppwriteException('Missing required parameter: "userId"');
1303
+ }
1304
+ if (typeof secret === 'undefined') {
1305
+ throw new AppwriteException('Missing required parameter: "secret"');
1306
+ }
1307
+ const apiPath = '/account/sessions/phone';
1308
+ const payload = {};
1309
+ if (typeof userId !== 'undefined') {
1310
+ payload['userId'] = userId;
1311
+ }
1312
+ if (typeof secret !== 'undefined') {
1313
+ payload['secret'] = secret;
1314
+ }
1315
+ const uri = new URL(this.client.config.endpoint + apiPath);
1316
+ return yield this.client.call('put', uri, {
1317
+ 'content-type': 'application/json',
1318
+ }, payload);
1319
+ });
1320
+ }
1321
+ /**
1322
+ * Create session
1323
+ *
1324
+ * Use this endpoint to create a session from token. Provide the **userId**
1325
+ * and **secret** parameters from the successful response of authentication
1326
+ * flows initiated by token creation. For example, magic URL and phone login.
1327
+ *
1328
+ * @param {string} userId
1329
+ * @param {string} secret
1330
+ * @throws {AppwriteException}
1331
+ * @returns {Promise}
1332
+ */
1333
+ createSession(userId, secret) {
1334
+ return __awaiter(this, void 0, void 0, function* () {
1335
+ if (typeof userId === 'undefined') {
1336
+ throw new AppwriteException('Missing required parameter: "userId"');
1337
+ }
1338
+ if (typeof secret === 'undefined') {
1339
+ throw new AppwriteException('Missing required parameter: "secret"');
1340
+ }
1341
+ const apiPath = '/account/sessions/token';
1342
+ const payload = {};
1343
+ if (typeof userId !== 'undefined') {
1344
+ payload['userId'] = userId;
1345
+ }
1346
+ if (typeof secret !== 'undefined') {
1347
+ payload['secret'] = secret;
1348
+ }
1349
+ const uri = new URL(this.client.config.endpoint + apiPath);
1350
+ return yield this.client.call('post', uri, {
1351
+ 'content-type': 'application/json',
1352
+ }, payload);
1353
+ });
1354
+ }
1355
+ /**
1356
+ * Get session
1357
+ *
1358
+ * Use this endpoint to get a logged in user's session using a Session ID.
1359
+ * Inputting 'current' will return the current session being used.
1360
+ *
1361
+ * @param {string} sessionId
1362
+ * @throws {AppwriteException}
1363
+ * @returns {Promise}
1364
+ */
1365
+ getSession(sessionId) {
1366
+ return __awaiter(this, void 0, void 0, function* () {
1367
+ if (typeof sessionId === 'undefined') {
1368
+ throw new AppwriteException('Missing required parameter: "sessionId"');
1369
+ }
1370
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1371
+ const payload = {};
1372
+ const uri = new URL(this.client.config.endpoint + apiPath);
1373
+ return yield this.client.call('get', uri, {
1374
+ 'content-type': 'application/json',
1375
+ }, payload);
1376
+ });
1377
+ }
1378
+ /**
1379
+ * Update session
1380
+ *
1381
+ * Use this endpoint to extend a session's length. Extending a session is
1382
+ * useful when session expiry is short. If the session was created using an
1383
+ * OAuth provider, this endpoint refreshes the access token from the provider.
1384
+ *
1385
+ * @param {string} sessionId
1386
+ * @throws {AppwriteException}
1387
+ * @returns {Promise}
1388
+ */
1389
+ updateSession(sessionId) {
1390
+ return __awaiter(this, void 0, void 0, function* () {
1391
+ if (typeof sessionId === 'undefined') {
1392
+ throw new AppwriteException('Missing required parameter: "sessionId"');
1393
+ }
1394
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1395
+ const payload = {};
1396
+ const uri = new URL(this.client.config.endpoint + apiPath);
1397
+ return yield this.client.call('patch', uri, {
1398
+ 'content-type': 'application/json',
1399
+ }, payload);
1400
+ });
1401
+ }
1402
+ /**
1403
+ * Delete session
1404
+ *
1405
+ * Logout the user. Use 'current' as the session ID to logout on this device,
1406
+ * use a session ID to logout on another device. If you're looking to logout
1407
+ * the user on all devices, use [Delete
1408
+ * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
1409
+ * instead.
1410
+ *
1411
+ * @param {string} sessionId
1412
+ * @throws {AppwriteException}
1413
+ * @returns {Promise}
1414
+ */
1415
+ deleteSession(sessionId) {
1416
+ return __awaiter(this, void 0, void 0, function* () {
1417
+ if (typeof sessionId === 'undefined') {
1418
+ throw new AppwriteException('Missing required parameter: "sessionId"');
1419
+ }
1420
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1421
+ const payload = {};
1422
+ const uri = new URL(this.client.config.endpoint + apiPath);
1423
+ return yield this.client.call('delete', uri, {
1424
+ 'content-type': 'application/json',
1425
+ }, payload);
1426
+ });
1427
+ }
1428
+ /**
1429
+ * Update status
1430
+ *
1431
+ * Block the currently logged in user account. Behind the scene, the user
1432
+ * record is not deleted but permanently blocked from any access. To
1433
+ * completely delete a user, use the Users API instead.
1434
+ *
1435
+ * @throws {AppwriteException}
1436
+ * @returns {Promise}
1437
+ */
1438
+ updateStatus() {
1439
+ return __awaiter(this, void 0, void 0, function* () {
1440
+ const apiPath = '/account/status';
1441
+ const payload = {};
1442
+ const uri = new URL(this.client.config.endpoint + apiPath);
1443
+ return yield this.client.call('patch', uri, {
1444
+ 'content-type': 'application/json',
1445
+ }, payload);
1446
+ });
1447
+ }
1448
+ /**
1449
+ * Create push target
1450
+ *
1451
+ *
1452
+ * @param {string} targetId
1453
+ * @param {string} identifier
1454
+ * @param {string} providerId
1455
+ * @throws {AppwriteException}
1456
+ * @returns {Promise}
1457
+ */
1458
+ createPushTarget(targetId, identifier, providerId) {
1459
+ return __awaiter(this, void 0, void 0, function* () {
1460
+ if (typeof targetId === 'undefined') {
1461
+ throw new AppwriteException('Missing required parameter: "targetId"');
1462
+ }
1463
+ if (typeof identifier === 'undefined') {
1464
+ throw new AppwriteException('Missing required parameter: "identifier"');
1465
+ }
1466
+ const apiPath = '/account/targets/push';
1467
+ const payload = {};
1468
+ if (typeof targetId !== 'undefined') {
1469
+ payload['targetId'] = targetId;
1470
+ }
1471
+ if (typeof identifier !== 'undefined') {
1472
+ payload['identifier'] = identifier;
1473
+ }
1474
+ if (typeof providerId !== 'undefined') {
1475
+ payload['providerId'] = providerId;
1476
+ }
1477
+ const uri = new URL(this.client.config.endpoint + apiPath);
1478
+ return yield this.client.call('post', uri, {
1479
+ 'content-type': 'application/json',
1480
+ }, payload);
1481
+ });
1482
+ }
1483
+ /**
1484
+ * Update push target
1485
+ *
1486
+ *
1487
+ * @param {string} targetId
1488
+ * @param {string} identifier
1489
+ * @throws {AppwriteException}
1490
+ * @returns {Promise}
1491
+ */
1492
+ updatePushTarget(targetId, identifier) {
1493
+ return __awaiter(this, void 0, void 0, function* () {
1494
+ if (typeof targetId === 'undefined') {
1495
+ throw new AppwriteException('Missing required parameter: "targetId"');
1496
+ }
1497
+ if (typeof identifier === 'undefined') {
1498
+ throw new AppwriteException('Missing required parameter: "identifier"');
1499
+ }
1500
+ const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
1501
+ const payload = {};
1502
+ if (typeof identifier !== 'undefined') {
1503
+ payload['identifier'] = identifier;
1504
+ }
1505
+ const uri = new URL(this.client.config.endpoint + apiPath);
1506
+ return yield this.client.call('put', uri, {
1507
+ 'content-type': 'application/json',
1508
+ }, payload);
1509
+ });
1510
+ }
1511
+ /**
1512
+ * Delete push target
1513
+ *
1514
+ *
1515
+ * @param {string} targetId
1516
+ * @throws {AppwriteException}
1517
+ * @returns {Promise}
1518
+ */
1519
+ deletePushTarget(targetId) {
1520
+ return __awaiter(this, void 0, void 0, function* () {
1521
+ if (typeof targetId === 'undefined') {
1522
+ throw new AppwriteException('Missing required parameter: "targetId"');
1523
+ }
1524
+ const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
1525
+ const payload = {};
1526
+ const uri = new URL(this.client.config.endpoint + apiPath);
1527
+ return yield this.client.call('delete', uri, {
1528
+ 'content-type': 'application/json',
1529
+ }, payload);
1530
+ });
1531
+ }
1532
+ /**
1533
+ * Create email token (OTP)
1534
+ *
1535
+ * Sends the user an email with a secret key for creating a session. If the
1536
+ * provided user ID has not be registered, a new user will be created. Use the
1537
+ * returned user ID and secret and submit a request to the [POST
1538
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1539
+ * endpoint to complete the login process. The secret sent to the user's email
1540
+ * is valid for 15 minutes.
1541
+ *
1542
+ * A user is limited to 10 active sessions at a time by default. [Learn more
1543
+ * about session
1544
+ * limits](https://appwrite.io/docs/authentication-security#limits).
1545
+ *
1546
+ * @param {string} userId
1547
+ * @param {string} email
1548
+ * @param {boolean} phrase
934
1549
  * @throws {AppwriteException}
935
1550
  * @returns {Promise}
936
1551
  */
937
- createEmailSession(email, password) {
1552
+ createEmailToken(userId, email, phrase) {
938
1553
  return __awaiter(this, void 0, void 0, function* () {
1554
+ if (typeof userId === 'undefined') {
1555
+ throw new AppwriteException('Missing required parameter: "userId"');
1556
+ }
939
1557
  if (typeof email === 'undefined') {
940
1558
  throw new AppwriteException('Missing required parameter: "email"');
941
1559
  }
942
- if (typeof password === 'undefined') {
943
- throw new AppwriteException('Missing required parameter: "password"');
944
- }
945
- const apiPath = '/account/sessions/email';
1560
+ const apiPath = '/account/tokens/email';
946
1561
  const payload = {};
1562
+ if (typeof userId !== 'undefined') {
1563
+ payload['userId'] = userId;
1564
+ }
947
1565
  if (typeof email !== 'undefined') {
948
1566
  payload['email'] = email;
949
1567
  }
950
- if (typeof password !== 'undefined') {
951
- payload['password'] = password;
1568
+ if (typeof phrase !== 'undefined') {
1569
+ payload['phrase'] = phrase;
952
1570
  }
953
1571
  const uri = new URL(this.client.config.endpoint + apiPath);
954
1572
  return yield this.client.call('post', uri, {
@@ -957,15 +1575,15 @@ class Account extends Service {
957
1575
  });
958
1576
  }
959
1577
  /**
960
- * Create magic URL session
1578
+ * Create magic URL token
961
1579
  *
962
1580
  * Sends the user an email with a secret key for creating a session. If the
963
1581
  * provided user ID has not been registered, a new user will be created. When
964
1582
  * the user clicks the link in the email, the user is redirected back to the
965
1583
  * URL you provided with the secret key and userId values attached to the URL
966
1584
  * query string. Use the query string parameters to submit a request to the
967
- * [PUT
968
- * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession)
1585
+ * [POST
1586
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
969
1587
  * endpoint to complete the login process. The link sent to the user's email
970
1588
  * address is valid for 1 hour. If you are on a mobile device you can leave
971
1589
  * the URL parameter empty, so that the login completion will be handled by
@@ -979,10 +1597,11 @@ class Account extends Service {
979
1597
  * @param {string} userId
980
1598
  * @param {string} email
981
1599
  * @param {string} url
1600
+ * @param {boolean} phrase
982
1601
  * @throws {AppwriteException}
983
1602
  * @returns {Promise}
984
1603
  */
985
- createMagicURLSession(userId, email, url) {
1604
+ createMagicURLToken(userId, email, url, phrase) {
986
1605
  return __awaiter(this, void 0, void 0, function* () {
987
1606
  if (typeof userId === 'undefined') {
988
1607
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -990,7 +1609,7 @@ class Account extends Service {
990
1609
  if (typeof email === 'undefined') {
991
1610
  throw new AppwriteException('Missing required parameter: "email"');
992
1611
  }
993
- const apiPath = '/account/sessions/magic-url';
1612
+ const apiPath = '/account/tokens/magic-url';
994
1613
  const payload = {};
995
1614
  if (typeof userId !== 'undefined') {
996
1615
  payload['userId'] = userId;
@@ -1001,91 +1620,69 @@ class Account extends Service {
1001
1620
  if (typeof url !== 'undefined') {
1002
1621
  payload['url'] = url;
1003
1622
  }
1004
- const uri = new URL(this.client.config.endpoint + apiPath);
1005
- return yield this.client.call('post', uri, {
1006
- 'content-type': 'application/json',
1007
- }, payload);
1008
- });
1009
- }
1010
- /**
1011
- * Create magic URL session (confirmation)
1012
- *
1013
- * Use this endpoint to complete creating the session with the Magic URL. Both
1014
- * the **userId** and **secret** arguments will be passed as query parameters
1015
- * to the redirect URL you have provided when sending your request to the
1016
- * [POST
1017
- * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession)
1018
- * endpoint.
1019
- *
1020
- * Please note that in order to avoid a [Redirect
1021
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
1022
- * the only valid redirect URLs are the ones from domains you have set when
1023
- * adding your platforms in the console interface.
1024
- *
1025
- * @param {string} userId
1026
- * @param {string} secret
1027
- * @throws {AppwriteException}
1028
- * @returns {Promise}
1029
- */
1030
- updateMagicURLSession(userId, secret) {
1031
- return __awaiter(this, void 0, void 0, function* () {
1032
- if (typeof userId === 'undefined') {
1033
- throw new AppwriteException('Missing required parameter: "userId"');
1034
- }
1035
- if (typeof secret === 'undefined') {
1036
- throw new AppwriteException('Missing required parameter: "secret"');
1037
- }
1038
- const apiPath = '/account/sessions/magic-url';
1039
- const payload = {};
1040
- if (typeof userId !== 'undefined') {
1041
- payload['userId'] = userId;
1042
- }
1043
- if (typeof secret !== 'undefined') {
1044
- payload['secret'] = secret;
1623
+ if (typeof phrase !== 'undefined') {
1624
+ payload['phrase'] = phrase;
1045
1625
  }
1046
1626
  const uri = new URL(this.client.config.endpoint + apiPath);
1047
- return yield this.client.call('put', uri, {
1627
+ return yield this.client.call('post', uri, {
1048
1628
  'content-type': 'application/json',
1049
1629
  }, payload);
1050
1630
  });
1051
1631
  }
1052
1632
  /**
1053
- * Create OAuth2 session
1633
+ * Create OAuth2 token
1054
1634
  *
1055
1635
  * Allow the user to login to their account using the OAuth2 provider of their
1056
1636
  * choice. Each OAuth2 provider should be enabled from the Appwrite console
1057
1637
  * first. Use the success and failure arguments to provide a redirect URL's
1058
1638
  * back to your app when login is completed.
1059
1639
  *
1060
- * If there is already an active session, the new session will be attached to
1061
- * the logged-in account. If there are no active sessions, the server will
1062
- * attempt to look for a user with the same email address as the email
1063
- * received from the OAuth2 provider and attach the new session to the
1064
- * existing user. If no matching user is found - the server will create a new
1065
- * user.
1640
+ * If authentication succeeds, `userId` and `secret` of a token will be
1641
+ * appended to the success URL as query parameters. These can be used to
1642
+ * create a new session using the [Create
1643
+ * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1644
+ * endpoint.
1066
1645
  *
1067
1646
  * A user is limited to 10 active sessions at a time by default. [Learn more
1068
1647
  * about session
1069
1648
  * limits](https://appwrite.io/docs/authentication-security#limits).
1070
1649
  *
1071
- *
1072
- * @param {string} provider
1650
+ * @param {OAuthProvider} provider
1073
1651
  * @param {string} success
1074
1652
  * @param {string} failure
1075
1653
  * @param {string[]} scopes
1076
1654
  * @throws {AppwriteException}
1077
1655
  * @returns {void|string}
1078
1656
  */
1079
- createOAuth2Session(provider, success, failure, scopes) {
1080
- throw new AppwriteException('Not yet supported');
1657
+ createOAuth2Token(provider, success, failure, scopes) {
1658
+ if (typeof provider === 'undefined') {
1659
+ throw new AppwriteException('Missing required parameter: "provider"');
1660
+ }
1661
+ const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider);
1662
+ const payload = {};
1663
+ if (typeof success !== 'undefined') {
1664
+ payload['success'] = success;
1665
+ }
1666
+ if (typeof failure !== 'undefined') {
1667
+ payload['failure'] = failure;
1668
+ }
1669
+ if (typeof scopes !== 'undefined') {
1670
+ payload['scopes'] = scopes;
1671
+ }
1672
+ const uri = new URL(this.client.config.endpoint + apiPath);
1673
+ payload['project'] = this.client.config.project;
1674
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1675
+ uri.searchParams.append(key, value);
1676
+ }
1677
+ return uri;
1081
1678
  }
1082
1679
  /**
1083
- * Create phone session
1680
+ * Create phone token
1084
1681
  *
1085
1682
  * Sends the user an SMS with a secret key for creating a session. If the
1086
1683
  * provided user ID has not be registered, a new user will be created. Use the
1087
- * returned user ID and secret and submit a request to the [PUT
1088
- * /account/sessions/phone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession)
1684
+ * returned user ID and secret and submit a request to the [POST
1685
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1089
1686
  * endpoint to complete the login process. The secret sent to the user's phone
1090
1687
  * is valid for 15 minutes.
1091
1688
  *
@@ -1098,7 +1695,7 @@ class Account extends Service {
1098
1695
  * @throws {AppwriteException}
1099
1696
  * @returns {Promise}
1100
1697
  */
1101
- createPhoneSession(userId, phone) {
1698
+ createPhoneToken(userId, phone) {
1102
1699
  return __awaiter(this, void 0, void 0, function* () {
1103
1700
  if (typeof userId === 'undefined') {
1104
1701
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -1106,7 +1703,7 @@ class Account extends Service {
1106
1703
  if (typeof phone === 'undefined') {
1107
1704
  throw new AppwriteException('Missing required parameter: "phone"');
1108
1705
  }
1109
- const apiPath = '/account/sessions/phone';
1706
+ const apiPath = '/account/tokens/phone';
1110
1707
  const payload = {};
1111
1708
  if (typeof userId !== 'undefined') {
1112
1709
  payload['userId'] = userId;
@@ -1120,135 +1717,6 @@ class Account extends Service {
1120
1717
  }, payload);
1121
1718
  });
1122
1719
  }
1123
- /**
1124
- * Create phone session (confirmation)
1125
- *
1126
- * Use this endpoint to complete creating a session with SMS. Use the
1127
- * **userId** from the
1128
- * [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession)
1129
- * endpoint and the **secret** received via SMS to successfully update and
1130
- * confirm the phone session.
1131
- *
1132
- * @param {string} userId
1133
- * @param {string} secret
1134
- * @throws {AppwriteException}
1135
- * @returns {Promise}
1136
- */
1137
- updatePhoneSession(userId, secret) {
1138
- return __awaiter(this, void 0, void 0, function* () {
1139
- if (typeof userId === 'undefined') {
1140
- throw new AppwriteException('Missing required parameter: "userId"');
1141
- }
1142
- if (typeof secret === 'undefined') {
1143
- throw new AppwriteException('Missing required parameter: "secret"');
1144
- }
1145
- const apiPath = '/account/sessions/phone';
1146
- const payload = {};
1147
- if (typeof userId !== 'undefined') {
1148
- payload['userId'] = userId;
1149
- }
1150
- if (typeof secret !== 'undefined') {
1151
- payload['secret'] = secret;
1152
- }
1153
- const uri = new URL(this.client.config.endpoint + apiPath);
1154
- return yield this.client.call('put', uri, {
1155
- 'content-type': 'application/json',
1156
- }, payload);
1157
- });
1158
- }
1159
- /**
1160
- * Get session
1161
- *
1162
- * Use this endpoint to get a logged in user's session using a Session ID.
1163
- * Inputting 'current' will return the current session being used.
1164
- *
1165
- * @param {string} sessionId
1166
- * @throws {AppwriteException}
1167
- * @returns {Promise}
1168
- */
1169
- getSession(sessionId) {
1170
- return __awaiter(this, void 0, void 0, function* () {
1171
- if (typeof sessionId === 'undefined') {
1172
- throw new AppwriteException('Missing required parameter: "sessionId"');
1173
- }
1174
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1175
- const payload = {};
1176
- const uri = new URL(this.client.config.endpoint + apiPath);
1177
- return yield this.client.call('get', uri, {
1178
- 'content-type': 'application/json',
1179
- }, payload);
1180
- });
1181
- }
1182
- /**
1183
- * Update OAuth session (refresh tokens)
1184
- *
1185
- * Access tokens have limited lifespan and expire to mitigate security risks.
1186
- * If session was created using an OAuth provider, this route can be used to
1187
- * "refresh" the access token.
1188
- *
1189
- * @param {string} sessionId
1190
- * @throws {AppwriteException}
1191
- * @returns {Promise}
1192
- */
1193
- updateSession(sessionId) {
1194
- return __awaiter(this, void 0, void 0, function* () {
1195
- if (typeof sessionId === 'undefined') {
1196
- throw new AppwriteException('Missing required parameter: "sessionId"');
1197
- }
1198
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1199
- const payload = {};
1200
- const uri = new URL(this.client.config.endpoint + apiPath);
1201
- return yield this.client.call('patch', uri, {
1202
- 'content-type': 'application/json',
1203
- }, payload);
1204
- });
1205
- }
1206
- /**
1207
- * Delete session
1208
- *
1209
- * Logout the user. Use 'current' as the session ID to logout on this device,
1210
- * use a session ID to logout on another device. If you're looking to logout
1211
- * the user on all devices, use [Delete
1212
- * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
1213
- * instead.
1214
- *
1215
- * @param {string} sessionId
1216
- * @throws {AppwriteException}
1217
- * @returns {Promise}
1218
- */
1219
- deleteSession(sessionId) {
1220
- return __awaiter(this, void 0, void 0, function* () {
1221
- if (typeof sessionId === 'undefined') {
1222
- throw new AppwriteException('Missing required parameter: "sessionId"');
1223
- }
1224
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1225
- const payload = {};
1226
- const uri = new URL(this.client.config.endpoint + apiPath);
1227
- return yield this.client.call('delete', uri, {
1228
- 'content-type': 'application/json',
1229
- }, payload);
1230
- });
1231
- }
1232
- /**
1233
- * Update status
1234
- *
1235
- * Block the currently logged in user account. Behind the scene, the user
1236
- * record is not deleted but permanently blocked from any access. To
1237
- * completely delete a user, use the Users API instead.
1238
- *
1239
- * @throws {AppwriteException}
1240
- * @returns {Promise}
1241
- */
1242
- updateStatus() {
1243
- return __awaiter(this, void 0, void 0, function* () {
1244
- const apiPath = '/account/status';
1245
- const payload = {};
1246
- const uri = new URL(this.client.config.endpoint + apiPath);
1247
- return yield this.client.call('patch', uri, {
1248
- 'content-type': 'application/json',
1249
- }, payload);
1250
- });
1251
- }
1252
1720
  /**
1253
1721
  * Create email verification
1254
1722
  *
@@ -1403,7 +1871,7 @@ class Avatars extends Service {
1403
1871
  * image at source quality. If dimensions are not specified, the default size
1404
1872
  * of image returned is 100x100px.
1405
1873
  *
1406
- * @param {string} code
1874
+ * @param {Browser} code
1407
1875
  * @param {number} width
1408
1876
  * @param {number} height
1409
1877
  * @param {number} quality
@@ -1445,7 +1913,7 @@ class Avatars extends Service {
1445
1913
  * of image returned is 100x100px.
1446
1914
  *
1447
1915
  *
1448
- * @param {string} code
1916
+ * @param {CreditCard} code
1449
1917
  * @param {number} width
1450
1918
  * @param {number} height
1451
1919
  * @param {number} quality
@@ -1515,7 +1983,7 @@ class Avatars extends Service {
1515
1983
  * of image returned is 100x100px.
1516
1984
  *
1517
1985
  *
1518
- * @param {string} code
1986
+ * @param {Flag} code
1519
1987
  * @param {number} width
1520
1988
  * @param {number} height
1521
1989
  * @param {number} quality
@@ -1722,7 +2190,7 @@ class Databases extends Service {
1722
2190
  * @param {string} databaseId
1723
2191
  * @param {string} collectionId
1724
2192
  * @param {string} documentId
1725
- * @param {Omit<Document, keyof Models.Document>} data
2193
+ * @param {object} data
1726
2194
  * @param {string[]} permissions
1727
2195
  * @throws {AppwriteException}
1728
2196
  * @returns {Promise}
@@ -1802,7 +2270,7 @@ class Databases extends Service {
1802
2270
  * @param {string} databaseId
1803
2271
  * @param {string} collectionId
1804
2272
  * @param {string} documentId
1805
- * @param {Partial<Omit<Document, keyof Models.Document>>} data
2273
+ * @param {object} data
1806
2274
  * @param {string[]} permissions
1807
2275
  * @throws {AppwriteException}
1808
2276
  * @returns {Promise}
@@ -1911,7 +2379,7 @@ class Functions extends Service {
1911
2379
  * @param {string} body
1912
2380
  * @param {boolean} async
1913
2381
  * @param {string} xpath
1914
- * @param {string} method
2382
+ * @param {ExecutionMethod} method
1915
2383
  * @param {object} headers
1916
2384
  * @throws {AppwriteException}
1917
2385
  * @returns {Promise}
@@ -2193,6 +2661,74 @@ class Locale extends Service {
2193
2661
  }
2194
2662
  }
2195
2663
 
2664
+ class Messaging extends Service {
2665
+ constructor(client) {
2666
+ super(client);
2667
+ }
2668
+ /**
2669
+ * Create subscriber
2670
+ *
2671
+ * Create a new subscriber.
2672
+ *
2673
+ * @param {string} topicId
2674
+ * @param {string} subscriberId
2675
+ * @param {string} targetId
2676
+ * @throws {AppwriteException}
2677
+ * @returns {Promise}
2678
+ */
2679
+ createSubscriber(topicId, subscriberId, targetId) {
2680
+ return __awaiter(this, void 0, void 0, function* () {
2681
+ if (typeof topicId === 'undefined') {
2682
+ throw new AppwriteException('Missing required parameter: "topicId"');
2683
+ }
2684
+ if (typeof subscriberId === 'undefined') {
2685
+ throw new AppwriteException('Missing required parameter: "subscriberId"');
2686
+ }
2687
+ if (typeof targetId === 'undefined') {
2688
+ throw new AppwriteException('Missing required parameter: "targetId"');
2689
+ }
2690
+ const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId);
2691
+ const payload = {};
2692
+ if (typeof subscriberId !== 'undefined') {
2693
+ payload['subscriberId'] = subscriberId;
2694
+ }
2695
+ if (typeof targetId !== 'undefined') {
2696
+ payload['targetId'] = targetId;
2697
+ }
2698
+ const uri = new URL(this.client.config.endpoint + apiPath);
2699
+ return yield this.client.call('post', uri, {
2700
+ 'content-type': 'application/json',
2701
+ }, payload);
2702
+ });
2703
+ }
2704
+ /**
2705
+ * Delete subscriber
2706
+ *
2707
+ * Delete a subscriber by its unique ID.
2708
+ *
2709
+ * @param {string} topicId
2710
+ * @param {string} subscriberId
2711
+ * @throws {AppwriteException}
2712
+ * @returns {Promise}
2713
+ */
2714
+ deleteSubscriber(topicId, subscriberId) {
2715
+ return __awaiter(this, void 0, void 0, function* () {
2716
+ if (typeof topicId === 'undefined') {
2717
+ throw new AppwriteException('Missing required parameter: "topicId"');
2718
+ }
2719
+ if (typeof subscriberId === 'undefined') {
2720
+ throw new AppwriteException('Missing required parameter: "subscriberId"');
2721
+ }
2722
+ const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId);
2723
+ const payload = {};
2724
+ const uri = new URL(this.client.config.endpoint + apiPath);
2725
+ return yield this.client.call('delete', uri, {
2726
+ 'content-type': 'application/json',
2727
+ }, payload);
2728
+ });
2729
+ }
2730
+ }
2731
+
2196
2732
  class Storage extends Service {
2197
2733
  constructor(client) {
2198
2734
  super(client);
@@ -2299,6 +2835,7 @@ class Storage extends Service {
2299
2835
  catch (e) {
2300
2836
  }
2301
2837
  }
2838
+ let timestamp = new Date().getTime();
2302
2839
  while (offset < size) {
2303
2840
  let end = Math.min(offset + Service.CHUNK_SIZE - 1, size - 1);
2304
2841
  apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
@@ -2311,8 +2848,8 @@ class Storage extends Service {
2311
2848
  length: Service.CHUNK_SIZE
2312
2849
  });
2313
2850
  var path = `data:${file.type};base64,${chunk}`;
2314
- if (Device__namespace.osName == 'Android') {
2315
- path = FileSystem__namespace.cacheDirectory + '/tmp_chunk';
2851
+ if (reactNative.Platform.OS.toLowerCase() === 'android') {
2852
+ path = FileSystem__namespace.cacheDirectory + '/tmp_chunk_' + timestamp;
2316
2853
  yield FileSystem__namespace.writeAsStringAsync(path, chunk, { encoding: FileSystem__namespace.EncodingType.Base64 });
2317
2854
  }
2318
2855
  payload['file'] = { uri: path, name: file.name, type: file.type };
@@ -2461,7 +2998,7 @@ class Storage extends Service {
2461
2998
  * @param {string} fileId
2462
2999
  * @param {number} width
2463
3000
  * @param {number} height
2464
- * @param {string} gravity
3001
+ * @param {ImageGravity} gravity
2465
3002
  * @param {number} quality
2466
3003
  * @param {number} borderWidth
2467
3004
  * @param {string} borderColor
@@ -2469,7 +3006,7 @@ class Storage extends Service {
2469
3006
  * @param {number} opacity
2470
3007
  * @param {number} rotation
2471
3008
  * @param {string} background
2472
- * @param {string} output
3009
+ * @param {ImageFormat} output
2473
3010
  * @throws {AppwriteException}
2474
3011
  * @returns {URL}
2475
3012
  */
@@ -2989,6 +3526,50 @@ class Teams extends Service {
2989
3526
  }
2990
3527
  }
2991
3528
 
3529
+ class Query {
3530
+ constructor(method, attribute, values) {
3531
+ this.method = method;
3532
+ this.attribute = attribute;
3533
+ if (values !== undefined) {
3534
+ if (Array.isArray(values)) {
3535
+ this.values = values;
3536
+ }
3537
+ else {
3538
+ this.values = [values];
3539
+ }
3540
+ }
3541
+ }
3542
+ toString() {
3543
+ return JSON.stringify({
3544
+ method: this.method,
3545
+ attribute: this.attribute,
3546
+ values: this.values,
3547
+ });
3548
+ }
3549
+ }
3550
+ Query.equal = (attribute, value) => new Query("equal", attribute, value).toString();
3551
+ Query.notEqual = (attribute, value) => new Query("notEqual", attribute, value).toString();
3552
+ Query.lessThan = (attribute, value) => new Query("lessThan", attribute, value).toString();
3553
+ Query.lessThanEqual = (attribute, value) => new Query("lessThanEqual", attribute, value).toString();
3554
+ Query.greaterThan = (attribute, value) => new Query("greaterThan", attribute, value).toString();
3555
+ Query.greaterThanEqual = (attribute, value) => new Query("greaterThanEqual", attribute, value).toString();
3556
+ Query.isNull = (attribute) => new Query("isNull", attribute).toString();
3557
+ Query.isNotNull = (attribute) => new Query("isNotNull", attribute).toString();
3558
+ Query.between = (attribute, start, end) => new Query("between", attribute, [start, end]).toString();
3559
+ Query.startsWith = (attribute, value) => new Query("startsWith", attribute, value).toString();
3560
+ Query.endsWith = (attribute, value) => new Query("endsWith", attribute, value).toString();
3561
+ Query.select = (attributes) => new Query("select", undefined, attributes).toString();
3562
+ Query.search = (attribute, value) => new Query("search", attribute, value).toString();
3563
+ Query.orderDesc = (attribute) => new Query("orderDesc", attribute).toString();
3564
+ Query.orderAsc = (attribute) => new Query("orderAsc", attribute).toString();
3565
+ Query.cursorAfter = (documentId) => new Query("cursorAfter", undefined, documentId).toString();
3566
+ Query.cursorBefore = (documentId) => new Query("cursorBefore", undefined, documentId).toString();
3567
+ Query.limit = (limit) => new Query("limit", undefined, limit).toString();
3568
+ Query.offset = (offset) => new Query("offset", undefined, offset).toString();
3569
+ Query.contains = (attribute, value) => new Query("contains", attribute, value).toString();
3570
+ Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
3571
+ Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
3572
+
2992
3573
  class Permission {
2993
3574
  }
2994
3575
  Permission.read = (role) => {
@@ -3101,14 +3682,355 @@ class Role {
3101
3682
  }
3102
3683
  }
3103
3684
 
3685
+ var _a, _ID_hexTimestamp;
3104
3686
  class ID {
3105
3687
  static custom(id) {
3106
3688
  return id;
3107
3689
  }
3108
- static unique() {
3109
- return 'unique()';
3690
+ static unique(padding = 7) {
3691
+ // Generate a unique ID with padding to have a longer ID
3692
+ const baseId = __classPrivateFieldGet(ID, _a, "m", _ID_hexTimestamp).call(ID);
3693
+ let randomPadding = '';
3694
+ for (let i = 0; i < padding; i++) {
3695
+ const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
3696
+ randomPadding += randomHexDigit;
3697
+ }
3698
+ return baseId + randomPadding;
3110
3699
  }
3111
3700
  }
3701
+ _a = ID, _ID_hexTimestamp = function _ID_hexTimestamp() {
3702
+ const now = new Date();
3703
+ const sec = Math.floor(now.getTime() / 1000);
3704
+ const msec = now.getMilliseconds();
3705
+ // Convert to hexadecimal
3706
+ const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
3707
+ return hexTimestamp;
3708
+ };
3709
+
3710
+ exports.AuthenticatorType = void 0;
3711
+ (function (AuthenticatorType) {
3712
+ AuthenticatorType["Totp"] = "totp";
3713
+ })(exports.AuthenticatorType || (exports.AuthenticatorType = {}));
3714
+
3715
+ exports.AuthenticationFactor = void 0;
3716
+ (function (AuthenticationFactor) {
3717
+ AuthenticationFactor["Email"] = "email";
3718
+ AuthenticationFactor["Phone"] = "phone";
3719
+ AuthenticationFactor["Totp"] = "totp";
3720
+ AuthenticationFactor["Recoverycode"] = "recoverycode";
3721
+ })(exports.AuthenticationFactor || (exports.AuthenticationFactor = {}));
3722
+
3723
+ exports.OAuthProvider = void 0;
3724
+ (function (OAuthProvider) {
3725
+ OAuthProvider["Amazon"] = "amazon";
3726
+ OAuthProvider["Apple"] = "apple";
3727
+ OAuthProvider["Auth0"] = "auth0";
3728
+ OAuthProvider["Authentik"] = "authentik";
3729
+ OAuthProvider["Autodesk"] = "autodesk";
3730
+ OAuthProvider["Bitbucket"] = "bitbucket";
3731
+ OAuthProvider["Bitly"] = "bitly";
3732
+ OAuthProvider["Box"] = "box";
3733
+ OAuthProvider["Dailymotion"] = "dailymotion";
3734
+ OAuthProvider["Discord"] = "discord";
3735
+ OAuthProvider["Disqus"] = "disqus";
3736
+ OAuthProvider["Dropbox"] = "dropbox";
3737
+ OAuthProvider["Etsy"] = "etsy";
3738
+ OAuthProvider["Facebook"] = "facebook";
3739
+ OAuthProvider["Github"] = "github";
3740
+ OAuthProvider["Gitlab"] = "gitlab";
3741
+ OAuthProvider["Google"] = "google";
3742
+ OAuthProvider["Linkedin"] = "linkedin";
3743
+ OAuthProvider["Microsoft"] = "microsoft";
3744
+ OAuthProvider["Notion"] = "notion";
3745
+ OAuthProvider["Oidc"] = "oidc";
3746
+ OAuthProvider["Okta"] = "okta";
3747
+ OAuthProvider["Paypal"] = "paypal";
3748
+ OAuthProvider["PaypalSandbox"] = "paypalSandbox";
3749
+ OAuthProvider["Podio"] = "podio";
3750
+ OAuthProvider["Salesforce"] = "salesforce";
3751
+ OAuthProvider["Slack"] = "slack";
3752
+ OAuthProvider["Spotify"] = "spotify";
3753
+ OAuthProvider["Stripe"] = "stripe";
3754
+ OAuthProvider["Tradeshift"] = "tradeshift";
3755
+ OAuthProvider["TradeshiftBox"] = "tradeshiftBox";
3756
+ OAuthProvider["Twitch"] = "twitch";
3757
+ OAuthProvider["Wordpress"] = "wordpress";
3758
+ OAuthProvider["Yahoo"] = "yahoo";
3759
+ OAuthProvider["Yammer"] = "yammer";
3760
+ OAuthProvider["Yandex"] = "yandex";
3761
+ OAuthProvider["Zoho"] = "zoho";
3762
+ OAuthProvider["Zoom"] = "zoom";
3763
+ OAuthProvider["Mock"] = "mock";
3764
+ })(exports.OAuthProvider || (exports.OAuthProvider = {}));
3765
+
3766
+ exports.Browser = void 0;
3767
+ (function (Browser) {
3768
+ Browser["AvantBrowser"] = "aa";
3769
+ Browser["AndroidWebViewBeta"] = "an";
3770
+ Browser["GoogleChrome"] = "ch";
3771
+ Browser["GoogleChromeIOS"] = "ci";
3772
+ Browser["GoogleChromeMobile"] = "cm";
3773
+ Browser["Chromium"] = "cr";
3774
+ Browser["MozillaFirefox"] = "ff";
3775
+ Browser["Safari"] = "sf";
3776
+ Browser["MobileSafari"] = "mf";
3777
+ Browser["MicrosoftEdge"] = "ps";
3778
+ Browser["MicrosoftEdgeIOS"] = "oi";
3779
+ Browser["OperaMini"] = "om";
3780
+ Browser["Opera"] = "op";
3781
+ Browser["OperaNext"] = "on";
3782
+ })(exports.Browser || (exports.Browser = {}));
3783
+
3784
+ exports.CreditCard = void 0;
3785
+ (function (CreditCard) {
3786
+ CreditCard["AmericanExpress"] = "amex";
3787
+ CreditCard["Argencard"] = "argencard";
3788
+ CreditCard["Cabal"] = "cabal";
3789
+ CreditCard["Consosud"] = "censosud";
3790
+ CreditCard["DinersClub"] = "diners";
3791
+ CreditCard["Discover"] = "discover";
3792
+ CreditCard["Elo"] = "elo";
3793
+ CreditCard["Hipercard"] = "hipercard";
3794
+ CreditCard["JCB"] = "jcb";
3795
+ CreditCard["Mastercard"] = "mastercard";
3796
+ CreditCard["Naranja"] = "naranja";
3797
+ CreditCard["TarjetaShopping"] = "targeta-shopping";
3798
+ CreditCard["UnionChinaPay"] = "union-china-pay";
3799
+ CreditCard["Visa"] = "visa";
3800
+ CreditCard["MIR"] = "mir";
3801
+ CreditCard["Maestro"] = "maestro";
3802
+ })(exports.CreditCard || (exports.CreditCard = {}));
3803
+
3804
+ exports.Flag = void 0;
3805
+ (function (Flag) {
3806
+ Flag["Afghanistan"] = "af";
3807
+ Flag["Angola"] = "ao";
3808
+ Flag["Albania"] = "al";
3809
+ Flag["Andorra"] = "ad";
3810
+ Flag["UnitedArabEmirates"] = "ae";
3811
+ Flag["Argentina"] = "ar";
3812
+ Flag["Armenia"] = "am";
3813
+ Flag["AntiguaAndBarbuda"] = "ag";
3814
+ Flag["Australia"] = "au";
3815
+ Flag["Austria"] = "at";
3816
+ Flag["Azerbaijan"] = "az";
3817
+ Flag["Burundi"] = "bi";
3818
+ Flag["Belgium"] = "be";
3819
+ Flag["Benin"] = "bj";
3820
+ Flag["BurkinaFaso"] = "bf";
3821
+ Flag["Bangladesh"] = "bd";
3822
+ Flag["Bulgaria"] = "bg";
3823
+ Flag["Bahrain"] = "bh";
3824
+ Flag["Bahamas"] = "bs";
3825
+ Flag["BosniaAndHerzegovina"] = "ba";
3826
+ Flag["Belarus"] = "by";
3827
+ Flag["Belize"] = "bz";
3828
+ Flag["Bolivia"] = "bo";
3829
+ Flag["Brazil"] = "br";
3830
+ Flag["Barbados"] = "bb";
3831
+ Flag["BruneiDarussalam"] = "bn";
3832
+ Flag["Bhutan"] = "bt";
3833
+ Flag["Botswana"] = "bw";
3834
+ Flag["CentralAfricanRepublic"] = "cf";
3835
+ Flag["Canada"] = "ca";
3836
+ Flag["Switzerland"] = "ch";
3837
+ Flag["Chile"] = "cl";
3838
+ Flag["China"] = "cn";
3839
+ Flag["CoteDIvoire"] = "ci";
3840
+ Flag["Cameroon"] = "cm";
3841
+ Flag["DemocraticRepublicOfTheCongo"] = "cd";
3842
+ Flag["RepublicOfTheCongo"] = "cg";
3843
+ Flag["Colombia"] = "co";
3844
+ Flag["Comoros"] = "km";
3845
+ Flag["CapeVerde"] = "cv";
3846
+ Flag["CostaRica"] = "cr";
3847
+ Flag["Cuba"] = "cu";
3848
+ Flag["Cyprus"] = "cy";
3849
+ Flag["CzechRepublic"] = "cz";
3850
+ Flag["Germany"] = "de";
3851
+ Flag["Djibouti"] = "dj";
3852
+ Flag["Dominica"] = "dm";
3853
+ Flag["Denmark"] = "dk";
3854
+ Flag["DominicanRepublic"] = "do";
3855
+ Flag["Algeria"] = "dz";
3856
+ Flag["Ecuador"] = "ec";
3857
+ Flag["Egypt"] = "eg";
3858
+ Flag["Eritrea"] = "er";
3859
+ Flag["Spain"] = "es";
3860
+ Flag["Estonia"] = "ee";
3861
+ Flag["Ethiopia"] = "et";
3862
+ Flag["Finland"] = "fi";
3863
+ Flag["Fiji"] = "fj";
3864
+ Flag["France"] = "fr";
3865
+ Flag["MicronesiaFederatedStatesOf"] = "fm";
3866
+ Flag["Gabon"] = "ga";
3867
+ Flag["UnitedKingdom"] = "gb";
3868
+ Flag["Georgia"] = "ge";
3869
+ Flag["Ghana"] = "gh";
3870
+ Flag["Guinea"] = "gn";
3871
+ Flag["Gambia"] = "gm";
3872
+ Flag["GuineaBissau"] = "gw";
3873
+ Flag["EquatorialGuinea"] = "gq";
3874
+ Flag["Greece"] = "gr";
3875
+ Flag["Grenada"] = "gd";
3876
+ Flag["Guatemala"] = "gt";
3877
+ Flag["Guyana"] = "gy";
3878
+ Flag["Honduras"] = "hn";
3879
+ Flag["Croatia"] = "hr";
3880
+ Flag["Haiti"] = "ht";
3881
+ Flag["Hungary"] = "hu";
3882
+ Flag["Indonesia"] = "id";
3883
+ Flag["India"] = "in";
3884
+ Flag["Ireland"] = "ie";
3885
+ Flag["IranIslamicRepublicOf"] = "ir";
3886
+ Flag["Iraq"] = "iq";
3887
+ Flag["Iceland"] = "is";
3888
+ Flag["Israel"] = "il";
3889
+ Flag["Italy"] = "it";
3890
+ Flag["Jamaica"] = "jm";
3891
+ Flag["Jordan"] = "jo";
3892
+ Flag["Japan"] = "jp";
3893
+ Flag["Kazakhstan"] = "kz";
3894
+ Flag["Kenya"] = "ke";
3895
+ Flag["Kyrgyzstan"] = "kg";
3896
+ Flag["Cambodia"] = "kh";
3897
+ Flag["Kiribati"] = "ki";
3898
+ Flag["SaintKittsAndNevis"] = "kn";
3899
+ Flag["SouthKorea"] = "kr";
3900
+ Flag["Kuwait"] = "kw";
3901
+ Flag["LaoPeopleSDemocraticRepublic"] = "la";
3902
+ Flag["Lebanon"] = "lb";
3903
+ Flag["Liberia"] = "lr";
3904
+ Flag["Libya"] = "ly";
3905
+ Flag["SaintLucia"] = "lc";
3906
+ Flag["Liechtenstein"] = "li";
3907
+ Flag["SriLanka"] = "lk";
3908
+ Flag["Lesotho"] = "ls";
3909
+ Flag["Lithuania"] = "lt";
3910
+ Flag["Luxembourg"] = "lu";
3911
+ Flag["Latvia"] = "lv";
3912
+ Flag["Morocco"] = "ma";
3913
+ Flag["Monaco"] = "mc";
3914
+ Flag["Moldova"] = "md";
3915
+ Flag["Madagascar"] = "mg";
3916
+ Flag["Maldives"] = "mv";
3917
+ Flag["Mexico"] = "mx";
3918
+ Flag["MarshallIslands"] = "mh";
3919
+ Flag["NorthMacedonia"] = "mk";
3920
+ Flag["Mali"] = "ml";
3921
+ Flag["Malta"] = "mt";
3922
+ Flag["Myanmar"] = "mm";
3923
+ Flag["Montenegro"] = "me";
3924
+ Flag["Mongolia"] = "mn";
3925
+ Flag["Mozambique"] = "mz";
3926
+ Flag["Mauritania"] = "mr";
3927
+ Flag["Mauritius"] = "mu";
3928
+ Flag["Malawi"] = "mw";
3929
+ Flag["Malaysia"] = "my";
3930
+ Flag["Namibia"] = "na";
3931
+ Flag["Niger"] = "ne";
3932
+ Flag["Nigeria"] = "ng";
3933
+ Flag["Nicaragua"] = "ni";
3934
+ Flag["Netherlands"] = "nl";
3935
+ Flag["Norway"] = "no";
3936
+ Flag["Nepal"] = "np";
3937
+ Flag["Nauru"] = "nr";
3938
+ Flag["NewZealand"] = "nz";
3939
+ Flag["Oman"] = "om";
3940
+ Flag["Pakistan"] = "pk";
3941
+ Flag["Panama"] = "pa";
3942
+ Flag["Peru"] = "pe";
3943
+ Flag["Philippines"] = "ph";
3944
+ Flag["Palau"] = "pw";
3945
+ Flag["PapuaNewGuinea"] = "pg";
3946
+ Flag["Poland"] = "pl";
3947
+ Flag["FrenchPolynesia"] = "pf";
3948
+ Flag["NorthKorea"] = "kp";
3949
+ Flag["Portugal"] = "pt";
3950
+ Flag["Paraguay"] = "py";
3951
+ Flag["Qatar"] = "qa";
3952
+ Flag["Romania"] = "ro";
3953
+ Flag["Russia"] = "ru";
3954
+ Flag["Rwanda"] = "rw";
3955
+ Flag["SaudiArabia"] = "sa";
3956
+ Flag["Sudan"] = "sd";
3957
+ Flag["Senegal"] = "sn";
3958
+ Flag["Singapore"] = "sg";
3959
+ Flag["SolomonIslands"] = "sb";
3960
+ Flag["SierraLeone"] = "sl";
3961
+ Flag["ElSalvador"] = "sv";
3962
+ Flag["SanMarino"] = "sm";
3963
+ Flag["Somalia"] = "so";
3964
+ Flag["Serbia"] = "rs";
3965
+ Flag["SouthSudan"] = "ss";
3966
+ Flag["SaoTomeAndPrincipe"] = "st";
3967
+ Flag["Suriname"] = "sr";
3968
+ Flag["Slovakia"] = "sk";
3969
+ Flag["Slovenia"] = "si";
3970
+ Flag["Sweden"] = "se";
3971
+ Flag["Eswatini"] = "sz";
3972
+ Flag["Seychelles"] = "sc";
3973
+ Flag["Syria"] = "sy";
3974
+ Flag["Chad"] = "td";
3975
+ Flag["Togo"] = "tg";
3976
+ Flag["Thailand"] = "th";
3977
+ Flag["Tajikistan"] = "tj";
3978
+ Flag["Turkmenistan"] = "tm";
3979
+ Flag["TimorLeste"] = "tl";
3980
+ Flag["Tonga"] = "to";
3981
+ Flag["TrinidadAndTobago"] = "tt";
3982
+ Flag["Tunisia"] = "tn";
3983
+ Flag["Turkey"] = "tr";
3984
+ Flag["Tuvalu"] = "tv";
3985
+ Flag["Tanzania"] = "tz";
3986
+ Flag["Uganda"] = "ug";
3987
+ Flag["Ukraine"] = "ua";
3988
+ Flag["Uruguay"] = "uy";
3989
+ Flag["UnitedStates"] = "us";
3990
+ Flag["Uzbekistan"] = "uz";
3991
+ Flag["VaticanCity"] = "va";
3992
+ Flag["SaintVincentAndTheGrenadines"] = "vc";
3993
+ Flag["Venezuela"] = "ve";
3994
+ Flag["Vietnam"] = "vn";
3995
+ Flag["Vanuatu"] = "vu";
3996
+ Flag["Samoa"] = "ws";
3997
+ Flag["Yemen"] = "ye";
3998
+ Flag["SouthAfrica"] = "za";
3999
+ Flag["Zambia"] = "zm";
4000
+ Flag["Zimbabwe"] = "zw";
4001
+ })(exports.Flag || (exports.Flag = {}));
4002
+
4003
+ exports.ExecutionMethod = void 0;
4004
+ (function (ExecutionMethod) {
4005
+ ExecutionMethod["GET"] = "GET";
4006
+ ExecutionMethod["POST"] = "POST";
4007
+ ExecutionMethod["PUT"] = "PUT";
4008
+ ExecutionMethod["PATCH"] = "PATCH";
4009
+ ExecutionMethod["DELETE"] = "DELETE";
4010
+ ExecutionMethod["OPTIONS"] = "OPTIONS";
4011
+ })(exports.ExecutionMethod || (exports.ExecutionMethod = {}));
4012
+
4013
+ exports.ImageGravity = void 0;
4014
+ (function (ImageGravity) {
4015
+ ImageGravity["Center"] = "center";
4016
+ ImageGravity["TopLeft"] = "top-left";
4017
+ ImageGravity["Top"] = "top";
4018
+ ImageGravity["TopRight"] = "top-right";
4019
+ ImageGravity["Left"] = "left";
4020
+ ImageGravity["Right"] = "right";
4021
+ ImageGravity["BottomLeft"] = "bottom-left";
4022
+ ImageGravity["Bottom"] = "bottom";
4023
+ ImageGravity["BottomRight"] = "bottom-right";
4024
+ })(exports.ImageGravity || (exports.ImageGravity = {}));
4025
+
4026
+ exports.ImageFormat = void 0;
4027
+ (function (ImageFormat) {
4028
+ ImageFormat["Jpg"] = "jpg";
4029
+ ImageFormat["Jpeg"] = "jpeg";
4030
+ ImageFormat["Gif"] = "gif";
4031
+ ImageFormat["Png"] = "png";
4032
+ ImageFormat["Webp"] = "webp";
4033
+ })(exports.ImageFormat || (exports.ImageFormat = {}));
3112
4034
 
3113
4035
  exports.Account = Account;
3114
4036
  exports.AppwriteException = AppwriteException;
@@ -3119,6 +4041,7 @@ exports.Functions = Functions;
3119
4041
  exports.Graphql = Graphql;
3120
4042
  exports.ID = ID;
3121
4043
  exports.Locale = Locale;
4044
+ exports.Messaging = Messaging;
3122
4045
  exports.Permission = Permission;
3123
4046
  exports.Query = Query;
3124
4047
  exports.Role = Role;