react-native-appwrite 0.2.2 → 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 +1193 -269
  6. package/dist/cjs/sdk.js.map +1 -1
  7. package/dist/esm/sdk.js +1193 -270
  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 +1 -1
  105. package/src/client.ts +37 -11
  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 +12 -6
  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
@@ -46,6 +46,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
46
46
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
47
  step((generator = generator.apply(thisArg, _arguments || [])).next());
48
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);
49
55
  }
50
56
 
51
57
  class Service {
@@ -54,11 +60,10 @@ class Service {
54
60
  }
55
61
  static flatten(data, prefix = '') {
56
62
  let output = {};
57
- for (const key in data) {
58
- let value = data[key];
59
- let finalKey = prefix ? `${prefix}[${key}]` : key;
63
+ for (const [key, value] of Object.entries(data)) {
64
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
60
65
  if (Array.isArray(value)) {
61
- output = Object.assign(output, this.flatten(value, finalKey));
66
+ output = Object.assign(Object.assign({}, output), Service.flatten(value, finalKey));
62
67
  }
63
68
  else {
64
69
  output[finalKey] = value;
@@ -69,36 +74,6 @@ class Service {
69
74
  }
70
75
  Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
71
76
 
72
- class Query {
73
- }
74
- Query.equal = (attribute, value) => Query.addQuery(attribute, "equal", value);
75
- Query.notEqual = (attribute, value) => Query.addQuery(attribute, "notEqual", value);
76
- Query.lessThan = (attribute, value) => Query.addQuery(attribute, "lessThan", value);
77
- Query.lessThanEqual = (attribute, value) => Query.addQuery(attribute, "lessThanEqual", value);
78
- Query.greaterThan = (attribute, value) => Query.addQuery(attribute, "greaterThan", value);
79
- Query.greaterThanEqual = (attribute, value) => Query.addQuery(attribute, "greaterThanEqual", value);
80
- Query.isNull = (attribute) => `isNull("${attribute}")`;
81
- Query.isNotNull = (attribute) => `isNotNull("${attribute}")`;
82
- Query.between = (attribute, start, end) => `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`;
83
- Query.startsWith = (attribute, value) => Query.addQuery(attribute, "startsWith", value);
84
- Query.endsWith = (attribute, value) => Query.addQuery(attribute, "endsWith", value);
85
- Query.select = (attributes) => `select([${attributes.map((attr) => `"${attr}"`).join(",")}])`;
86
- Query.search = (attribute, value) => Query.addQuery(attribute, "search", value);
87
- Query.orderDesc = (attribute) => `orderDesc("${attribute}")`;
88
- Query.orderAsc = (attribute) => `orderAsc("${attribute}")`;
89
- Query.cursorAfter = (documentId) => `cursorAfter("${documentId}")`;
90
- Query.cursorBefore = (documentId) => `cursorBefore("${documentId}")`;
91
- Query.limit = (limit) => `limit(${limit})`;
92
- Query.offset = (offset) => `offset(${offset})`;
93
- Query.addQuery = (attribute, method, value) => value instanceof Array
94
- ? `${method}("${attribute}", [${value
95
- .map((v) => Query.parseValues(v))
96
- .join(",")}])`
97
- : `${method}("${attribute}", [${Query.parseValues(value)}])`;
98
- Query.parseValues = (value) => typeof value === "string" || value instanceof String
99
- ? `"${value}"`
100
- : `${value}`;
101
-
102
77
  class AppwriteException extends Error {
103
78
  constructor(message, code = 0, type = '', response = '') {
104
79
  super(message);
@@ -112,19 +87,20 @@ class AppwriteException extends Error {
112
87
  class Client {
113
88
  constructor() {
114
89
  this.config = {
115
- endpoint: 'https://HOSTNAME/v1',
90
+ endpoint: 'https://cloud.appwrite.io/v1',
116
91
  endpointRealtime: '',
117
92
  project: '',
118
93
  jwt: '',
119
94
  locale: '',
95
+ session: '',
120
96
  platform: '',
121
97
  };
122
98
  this.headers = {
123
- 'x-sdk-name': 'Web',
99
+ 'x-sdk-name': 'React Native',
124
100
  'x-sdk-platform': 'client',
125
- 'x-sdk-language': 'web',
126
- 'x-sdk-version': '13.0.2',
127
- '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',
128
104
  };
129
105
  this.realtime = {
130
106
  socket: undefined,
@@ -155,9 +131,12 @@ class Client {
155
131
  }
156
132
  },
157
133
  createSocket: () => {
158
- var _a, _b;
159
- 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();
160
138
  return;
139
+ }
161
140
  const channels = new URLSearchParams();
162
141
  channels.set('project', this.config.project);
163
142
  this.realtime.channels.forEach(channel => {
@@ -166,10 +145,10 @@ class Client {
166
145
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
167
146
  if (url !== this.realtime.url || // Check if URL is present
168
147
  !this.realtime.socket || // Check if WebSocket has not been created
169
- ((_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)
170
149
  ) {
171
150
  if (this.realtime.socket &&
172
- ((_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)
173
152
  ) {
174
153
  this.realtime.reconnect = false;
175
154
  this.realtime.socket.close();
@@ -203,7 +182,7 @@ class Client {
203
182
  });
204
183
  }
205
184
  },
206
- onMessage: (event) => __awaiter(this, void 0, void 0, function* () {
185
+ onMessage: (event) => {
207
186
  try {
208
187
  const message = JSON.parse(event.data);
209
188
  this.realtime.lastMessage = message;
@@ -230,7 +209,7 @@ class Client {
230
209
  catch (e) {
231
210
  console.error(e);
232
211
  }
233
- }),
212
+ },
234
213
  cleanUp: channels => {
235
214
  this.realtime.channels.forEach(channel => {
236
215
  if (channels.includes(channel)) {
@@ -322,6 +301,20 @@ class Client {
322
301
  this.config.locale = value;
323
302
  return this;
324
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
+ }
325
318
  /**
326
319
  * Subscribes to Appwrite events and passes you the payload in realtime.
327
320
  *
@@ -414,6 +407,11 @@ class Client {
414
407
  if (400 <= response.status) {
415
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);
416
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
+ }
417
415
  return data;
418
416
  }
419
417
  catch (e) {
@@ -541,7 +539,7 @@ class Account extends Service {
541
539
  *
542
540
  * Get the list of identities for the currently logged in user.
543
541
  *
544
- * @param {string} queries
542
+ * @param {string[]} queries
545
543
  * @throws {AppwriteException}
546
544
  * @returns {Promise}
547
545
  */
@@ -559,7 +557,7 @@ class Account extends Service {
559
557
  });
560
558
  }
561
559
  /**
562
- * Delete Identity
560
+ * Delete identity
563
561
  *
564
562
  * Delete an identity by its unique ID.
565
563
  *
@@ -625,6 +623,261 @@ class Account extends Service {
625
623
  }, payload);
626
624
  });
627
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
+ }
628
881
  /**
629
882
  * Update name
630
883
  *
@@ -742,7 +995,7 @@ class Account extends Service {
742
995
  * stored as is, and replaces any previous value. The maximum allowed prefs
743
996
  * size is 64kB and throws error if exceeded.
744
997
  *
745
- * @param {Partial<Preferences>} prefs
998
+ * @param {object} prefs
746
999
  * @throws {AppwriteException}
747
1000
  * @returns {Promise}
748
1001
  */
@@ -818,11 +1071,10 @@ class Account extends Service {
818
1071
  * @param {string} userId
819
1072
  * @param {string} secret
820
1073
  * @param {string} password
821
- * @param {string} passwordAgain
822
1074
  * @throws {AppwriteException}
823
1075
  * @returns {Promise}
824
1076
  */
825
- updateRecovery(userId, secret, password, passwordAgain) {
1077
+ updateRecovery(userId, secret, password) {
826
1078
  return __awaiter(this, void 0, void 0, function* () {
827
1079
  if (typeof userId === 'undefined') {
828
1080
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -833,9 +1085,6 @@ class Account extends Service {
833
1085
  if (typeof password === 'undefined') {
834
1086
  throw new AppwriteException('Missing required parameter: "password"');
835
1087
  }
836
- if (typeof passwordAgain === 'undefined') {
837
- throw new AppwriteException('Missing required parameter: "passwordAgain"');
838
- }
839
1088
  const apiPath = '/account/recovery';
840
1089
  const payload = {};
841
1090
  if (typeof userId !== 'undefined') {
@@ -847,9 +1096,6 @@ class Account extends Service {
847
1096
  if (typeof password !== 'undefined') {
848
1097
  payload['password'] = password;
849
1098
  }
850
- if (typeof passwordAgain !== 'undefined') {
851
- payload['passwordAgain'] = passwordAgain;
852
- }
853
1099
  const uri = new URL(this.client.config.endpoint + apiPath);
854
1100
  return yield this.client.call('put', uri, {
855
1101
  'content-type': 'application/json',
@@ -919,7 +1165,7 @@ class Account extends Service {
919
1165
  });
920
1166
  }
921
1167
  /**
922
- * Create email session
1168
+ * Create email password session
923
1169
  *
924
1170
  * Allow the user to login into their account by providing a valid email and
925
1171
  * password combination. This route will create a new session for the user.
@@ -929,25 +1175,398 @@ class Account extends Service {
929
1175
  * limits](https://appwrite.io/docs/authentication-security#limits).
930
1176
  *
931
1177
  * @param {string} email
932
- * @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
933
1549
  * @throws {AppwriteException}
934
1550
  * @returns {Promise}
935
1551
  */
936
- createEmailSession(email, password) {
1552
+ createEmailToken(userId, email, phrase) {
937
1553
  return __awaiter(this, void 0, void 0, function* () {
1554
+ if (typeof userId === 'undefined') {
1555
+ throw new AppwriteException('Missing required parameter: "userId"');
1556
+ }
938
1557
  if (typeof email === 'undefined') {
939
1558
  throw new AppwriteException('Missing required parameter: "email"');
940
1559
  }
941
- if (typeof password === 'undefined') {
942
- throw new AppwriteException('Missing required parameter: "password"');
943
- }
944
- const apiPath = '/account/sessions/email';
1560
+ const apiPath = '/account/tokens/email';
945
1561
  const payload = {};
1562
+ if (typeof userId !== 'undefined') {
1563
+ payload['userId'] = userId;
1564
+ }
946
1565
  if (typeof email !== 'undefined') {
947
1566
  payload['email'] = email;
948
1567
  }
949
- if (typeof password !== 'undefined') {
950
- payload['password'] = password;
1568
+ if (typeof phrase !== 'undefined') {
1569
+ payload['phrase'] = phrase;
951
1570
  }
952
1571
  const uri = new URL(this.client.config.endpoint + apiPath);
953
1572
  return yield this.client.call('post', uri, {
@@ -956,15 +1575,15 @@ class Account extends Service {
956
1575
  });
957
1576
  }
958
1577
  /**
959
- * Create magic URL session
1578
+ * Create magic URL token
960
1579
  *
961
1580
  * Sends the user an email with a secret key for creating a session. If the
962
1581
  * provided user ID has not been registered, a new user will be created. When
963
1582
  * the user clicks the link in the email, the user is redirected back to the
964
1583
  * URL you provided with the secret key and userId values attached to the URL
965
1584
  * query string. Use the query string parameters to submit a request to the
966
- * [PUT
967
- * /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)
968
1587
  * endpoint to complete the login process. The link sent to the user's email
969
1588
  * address is valid for 1 hour. If you are on a mobile device you can leave
970
1589
  * the URL parameter empty, so that the login completion will be handled by
@@ -978,10 +1597,11 @@ class Account extends Service {
978
1597
  * @param {string} userId
979
1598
  * @param {string} email
980
1599
  * @param {string} url
1600
+ * @param {boolean} phrase
981
1601
  * @throws {AppwriteException}
982
1602
  * @returns {Promise}
983
1603
  */
984
- createMagicURLSession(userId, email, url) {
1604
+ createMagicURLToken(userId, email, url, phrase) {
985
1605
  return __awaiter(this, void 0, void 0, function* () {
986
1606
  if (typeof userId === 'undefined') {
987
1607
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -989,7 +1609,7 @@ class Account extends Service {
989
1609
  if (typeof email === 'undefined') {
990
1610
  throw new AppwriteException('Missing required parameter: "email"');
991
1611
  }
992
- const apiPath = '/account/sessions/magic-url';
1612
+ const apiPath = '/account/tokens/magic-url';
993
1613
  const payload = {};
994
1614
  if (typeof userId !== 'undefined') {
995
1615
  payload['userId'] = userId;
@@ -1000,91 +1620,69 @@ class Account extends Service {
1000
1620
  if (typeof url !== 'undefined') {
1001
1621
  payload['url'] = url;
1002
1622
  }
1003
- const uri = new URL(this.client.config.endpoint + apiPath);
1004
- return yield this.client.call('post', uri, {
1005
- 'content-type': 'application/json',
1006
- }, payload);
1007
- });
1008
- }
1009
- /**
1010
- * Create magic URL session (confirmation)
1011
- *
1012
- * Use this endpoint to complete creating the session with the Magic URL. Both
1013
- * the **userId** and **secret** arguments will be passed as query parameters
1014
- * to the redirect URL you have provided when sending your request to the
1015
- * [POST
1016
- * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession)
1017
- * endpoint.
1018
- *
1019
- * Please note that in order to avoid a [Redirect
1020
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
1021
- * the only valid redirect URLs are the ones from domains you have set when
1022
- * adding your platforms in the console interface.
1023
- *
1024
- * @param {string} userId
1025
- * @param {string} secret
1026
- * @throws {AppwriteException}
1027
- * @returns {Promise}
1028
- */
1029
- updateMagicURLSession(userId, secret) {
1030
- return __awaiter(this, void 0, void 0, function* () {
1031
- if (typeof userId === 'undefined') {
1032
- throw new AppwriteException('Missing required parameter: "userId"');
1033
- }
1034
- if (typeof secret === 'undefined') {
1035
- throw new AppwriteException('Missing required parameter: "secret"');
1036
- }
1037
- const apiPath = '/account/sessions/magic-url';
1038
- const payload = {};
1039
- if (typeof userId !== 'undefined') {
1040
- payload['userId'] = userId;
1041
- }
1042
- if (typeof secret !== 'undefined') {
1043
- payload['secret'] = secret;
1623
+ if (typeof phrase !== 'undefined') {
1624
+ payload['phrase'] = phrase;
1044
1625
  }
1045
1626
  const uri = new URL(this.client.config.endpoint + apiPath);
1046
- return yield this.client.call('put', uri, {
1627
+ return yield this.client.call('post', uri, {
1047
1628
  'content-type': 'application/json',
1048
1629
  }, payload);
1049
1630
  });
1050
1631
  }
1051
1632
  /**
1052
- * Create OAuth2 session
1633
+ * Create OAuth2 token
1053
1634
  *
1054
1635
  * Allow the user to login to their account using the OAuth2 provider of their
1055
1636
  * choice. Each OAuth2 provider should be enabled from the Appwrite console
1056
1637
  * first. Use the success and failure arguments to provide a redirect URL's
1057
1638
  * back to your app when login is completed.
1058
1639
  *
1059
- * If there is already an active session, the new session will be attached to
1060
- * the logged-in account. If there are no active sessions, the server will
1061
- * attempt to look for a user with the same email address as the email
1062
- * received from the OAuth2 provider and attach the new session to the
1063
- * existing user. If no matching user is found - the server will create a new
1064
- * 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.
1065
1645
  *
1066
1646
  * A user is limited to 10 active sessions at a time by default. [Learn more
1067
1647
  * about session
1068
1648
  * limits](https://appwrite.io/docs/authentication-security#limits).
1069
1649
  *
1070
- *
1071
- * @param {string} provider
1650
+ * @param {OAuthProvider} provider
1072
1651
  * @param {string} success
1073
1652
  * @param {string} failure
1074
1653
  * @param {string[]} scopes
1075
1654
  * @throws {AppwriteException}
1076
1655
  * @returns {void|string}
1077
1656
  */
1078
- createOAuth2Session(provider, success, failure, scopes) {
1079
- 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;
1080
1678
  }
1081
1679
  /**
1082
- * Create phone session
1680
+ * Create phone token
1083
1681
  *
1084
1682
  * Sends the user an SMS with a secret key for creating a session. If the
1085
1683
  * provided user ID has not be registered, a new user will be created. Use the
1086
- * returned user ID and secret and submit a request to the [PUT
1087
- * /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)
1088
1686
  * endpoint to complete the login process. The secret sent to the user's phone
1089
1687
  * is valid for 15 minutes.
1090
1688
  *
@@ -1097,7 +1695,7 @@ class Account extends Service {
1097
1695
  * @throws {AppwriteException}
1098
1696
  * @returns {Promise}
1099
1697
  */
1100
- createPhoneSession(userId, phone) {
1698
+ createPhoneToken(userId, phone) {
1101
1699
  return __awaiter(this, void 0, void 0, function* () {
1102
1700
  if (typeof userId === 'undefined') {
1103
1701
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -1105,7 +1703,7 @@ class Account extends Service {
1105
1703
  if (typeof phone === 'undefined') {
1106
1704
  throw new AppwriteException('Missing required parameter: "phone"');
1107
1705
  }
1108
- const apiPath = '/account/sessions/phone';
1706
+ const apiPath = '/account/tokens/phone';
1109
1707
  const payload = {};
1110
1708
  if (typeof userId !== 'undefined') {
1111
1709
  payload['userId'] = userId;
@@ -1119,135 +1717,6 @@ class Account extends Service {
1119
1717
  }, payload);
1120
1718
  });
1121
1719
  }
1122
- /**
1123
- * Create phone session (confirmation)
1124
- *
1125
- * Use this endpoint to complete creating a session with SMS. Use the
1126
- * **userId** from the
1127
- * [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession)
1128
- * endpoint and the **secret** received via SMS to successfully update and
1129
- * confirm the phone session.
1130
- *
1131
- * @param {string} userId
1132
- * @param {string} secret
1133
- * @throws {AppwriteException}
1134
- * @returns {Promise}
1135
- */
1136
- updatePhoneSession(userId, secret) {
1137
- return __awaiter(this, void 0, void 0, function* () {
1138
- if (typeof userId === 'undefined') {
1139
- throw new AppwriteException('Missing required parameter: "userId"');
1140
- }
1141
- if (typeof secret === 'undefined') {
1142
- throw new AppwriteException('Missing required parameter: "secret"');
1143
- }
1144
- const apiPath = '/account/sessions/phone';
1145
- const payload = {};
1146
- if (typeof userId !== 'undefined') {
1147
- payload['userId'] = userId;
1148
- }
1149
- if (typeof secret !== 'undefined') {
1150
- payload['secret'] = secret;
1151
- }
1152
- const uri = new URL(this.client.config.endpoint + apiPath);
1153
- return yield this.client.call('put', uri, {
1154
- 'content-type': 'application/json',
1155
- }, payload);
1156
- });
1157
- }
1158
- /**
1159
- * Get session
1160
- *
1161
- * Use this endpoint to get a logged in user's session using a Session ID.
1162
- * Inputting 'current' will return the current session being used.
1163
- *
1164
- * @param {string} sessionId
1165
- * @throws {AppwriteException}
1166
- * @returns {Promise}
1167
- */
1168
- getSession(sessionId) {
1169
- return __awaiter(this, void 0, void 0, function* () {
1170
- if (typeof sessionId === 'undefined') {
1171
- throw new AppwriteException('Missing required parameter: "sessionId"');
1172
- }
1173
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1174
- const payload = {};
1175
- const uri = new URL(this.client.config.endpoint + apiPath);
1176
- return yield this.client.call('get', uri, {
1177
- 'content-type': 'application/json',
1178
- }, payload);
1179
- });
1180
- }
1181
- /**
1182
- * Update OAuth session (refresh tokens)
1183
- *
1184
- * Access tokens have limited lifespan and expire to mitigate security risks.
1185
- * If session was created using an OAuth provider, this route can be used to
1186
- * "refresh" the access token.
1187
- *
1188
- * @param {string} sessionId
1189
- * @throws {AppwriteException}
1190
- * @returns {Promise}
1191
- */
1192
- updateSession(sessionId) {
1193
- return __awaiter(this, void 0, void 0, function* () {
1194
- if (typeof sessionId === 'undefined') {
1195
- throw new AppwriteException('Missing required parameter: "sessionId"');
1196
- }
1197
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1198
- const payload = {};
1199
- const uri = new URL(this.client.config.endpoint + apiPath);
1200
- return yield this.client.call('patch', uri, {
1201
- 'content-type': 'application/json',
1202
- }, payload);
1203
- });
1204
- }
1205
- /**
1206
- * Delete session
1207
- *
1208
- * Logout the user. Use 'current' as the session ID to logout on this device,
1209
- * use a session ID to logout on another device. If you're looking to logout
1210
- * the user on all devices, use [Delete
1211
- * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
1212
- * instead.
1213
- *
1214
- * @param {string} sessionId
1215
- * @throws {AppwriteException}
1216
- * @returns {Promise}
1217
- */
1218
- deleteSession(sessionId) {
1219
- return __awaiter(this, void 0, void 0, function* () {
1220
- if (typeof sessionId === 'undefined') {
1221
- throw new AppwriteException('Missing required parameter: "sessionId"');
1222
- }
1223
- const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1224
- const payload = {};
1225
- const uri = new URL(this.client.config.endpoint + apiPath);
1226
- return yield this.client.call('delete', uri, {
1227
- 'content-type': 'application/json',
1228
- }, payload);
1229
- });
1230
- }
1231
- /**
1232
- * Update status
1233
- *
1234
- * Block the currently logged in user account. Behind the scene, the user
1235
- * record is not deleted but permanently blocked from any access. To
1236
- * completely delete a user, use the Users API instead.
1237
- *
1238
- * @throws {AppwriteException}
1239
- * @returns {Promise}
1240
- */
1241
- updateStatus() {
1242
- return __awaiter(this, void 0, void 0, function* () {
1243
- const apiPath = '/account/status';
1244
- const payload = {};
1245
- const uri = new URL(this.client.config.endpoint + apiPath);
1246
- return yield this.client.call('patch', uri, {
1247
- 'content-type': 'application/json',
1248
- }, payload);
1249
- });
1250
- }
1251
1720
  /**
1252
1721
  * Create email verification
1253
1722
  *
@@ -1402,7 +1871,7 @@ class Avatars extends Service {
1402
1871
  * image at source quality. If dimensions are not specified, the default size
1403
1872
  * of image returned is 100x100px.
1404
1873
  *
1405
- * @param {string} code
1874
+ * @param {Browser} code
1406
1875
  * @param {number} width
1407
1876
  * @param {number} height
1408
1877
  * @param {number} quality
@@ -1444,7 +1913,7 @@ class Avatars extends Service {
1444
1913
  * of image returned is 100x100px.
1445
1914
  *
1446
1915
  *
1447
- * @param {string} code
1916
+ * @param {CreditCard} code
1448
1917
  * @param {number} width
1449
1918
  * @param {number} height
1450
1919
  * @param {number} quality
@@ -1514,7 +1983,7 @@ class Avatars extends Service {
1514
1983
  * of image returned is 100x100px.
1515
1984
  *
1516
1985
  *
1517
- * @param {string} code
1986
+ * @param {Flag} code
1518
1987
  * @param {number} width
1519
1988
  * @param {number} height
1520
1989
  * @param {number} quality
@@ -1721,7 +2190,7 @@ class Databases extends Service {
1721
2190
  * @param {string} databaseId
1722
2191
  * @param {string} collectionId
1723
2192
  * @param {string} documentId
1724
- * @param {Omit<Document, keyof Models.Document>} data
2193
+ * @param {object} data
1725
2194
  * @param {string[]} permissions
1726
2195
  * @throws {AppwriteException}
1727
2196
  * @returns {Promise}
@@ -1801,7 +2270,7 @@ class Databases extends Service {
1801
2270
  * @param {string} databaseId
1802
2271
  * @param {string} collectionId
1803
2272
  * @param {string} documentId
1804
- * @param {Partial<Omit<Document, keyof Models.Document>>} data
2273
+ * @param {object} data
1805
2274
  * @param {string[]} permissions
1806
2275
  * @throws {AppwriteException}
1807
2276
  * @returns {Promise}
@@ -1910,7 +2379,7 @@ class Functions extends Service {
1910
2379
  * @param {string} body
1911
2380
  * @param {boolean} async
1912
2381
  * @param {string} xpath
1913
- * @param {string} method
2382
+ * @param {ExecutionMethod} method
1914
2383
  * @param {object} headers
1915
2384
  * @throws {AppwriteException}
1916
2385
  * @returns {Promise}
@@ -2192,6 +2661,74 @@ class Locale extends Service {
2192
2661
  }
2193
2662
  }
2194
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
+
2195
2732
  class Storage extends Service {
2196
2733
  constructor(client) {
2197
2734
  super(client);
@@ -2298,6 +2835,7 @@ class Storage extends Service {
2298
2835
  catch (e) {
2299
2836
  }
2300
2837
  }
2838
+ let timestamp = new Date().getTime();
2301
2839
  while (offset < size) {
2302
2840
  let end = Math.min(offset + Service.CHUNK_SIZE - 1, size - 1);
2303
2841
  apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
@@ -2310,8 +2848,8 @@ class Storage extends Service {
2310
2848
  length: Service.CHUNK_SIZE
2311
2849
  });
2312
2850
  var path = `data:${file.type};base64,${chunk}`;
2313
- if (reactNative.Platform.OS.toLowerCase() == 'android') {
2314
- path = FileSystem__namespace.cacheDirectory + '/tmp_chunk';
2851
+ if (reactNative.Platform.OS.toLowerCase() === 'android') {
2852
+ path = FileSystem__namespace.cacheDirectory + '/tmp_chunk_' + timestamp;
2315
2853
  yield FileSystem__namespace.writeAsStringAsync(path, chunk, { encoding: FileSystem__namespace.EncodingType.Base64 });
2316
2854
  }
2317
2855
  payload['file'] = { uri: path, name: file.name, type: file.type };
@@ -2460,7 +2998,7 @@ class Storage extends Service {
2460
2998
  * @param {string} fileId
2461
2999
  * @param {number} width
2462
3000
  * @param {number} height
2463
- * @param {string} gravity
3001
+ * @param {ImageGravity} gravity
2464
3002
  * @param {number} quality
2465
3003
  * @param {number} borderWidth
2466
3004
  * @param {string} borderColor
@@ -2468,7 +3006,7 @@ class Storage extends Service {
2468
3006
  * @param {number} opacity
2469
3007
  * @param {number} rotation
2470
3008
  * @param {string} background
2471
- * @param {string} output
3009
+ * @param {ImageFormat} output
2472
3010
  * @throws {AppwriteException}
2473
3011
  * @returns {URL}
2474
3012
  */
@@ -2988,6 +3526,50 @@ class Teams extends Service {
2988
3526
  }
2989
3527
  }
2990
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
+
2991
3573
  class Permission {
2992
3574
  }
2993
3575
  Permission.read = (role) => {
@@ -3100,14 +3682,355 @@ class Role {
3100
3682
  }
3101
3683
  }
3102
3684
 
3685
+ var _a, _ID_hexTimestamp;
3103
3686
  class ID {
3104
3687
  static custom(id) {
3105
3688
  return id;
3106
3689
  }
3107
- static unique() {
3108
- 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;
3109
3699
  }
3110
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 = {}));
3111
4034
 
3112
4035
  exports.Account = Account;
3113
4036
  exports.AppwriteException = AppwriteException;
@@ -3118,6 +4041,7 @@ exports.Functions = Functions;
3118
4041
  exports.Graphql = Graphql;
3119
4042
  exports.ID = ID;
3120
4043
  exports.Locale = Locale;
4044
+ exports.Messaging = Messaging;
3121
4045
  exports.Permission = Permission;
3122
4046
  exports.Query = Query;
3123
4047
  exports.Role = Role;