diff --git a/README.md b/README.md
index 3bcab1e..d4a9ff2 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
To install with a CDN (content delivery network) add the following scripts to the bottom of your
tag, but before you use any Appwrite services:
```html
-
+
```
diff --git a/docs/examples/account/create-magic-u-r-l-session.md b/docs/examples/account/create-email-password-session.md
similarity index 82%
rename from docs/examples/account/create-magic-u-r-l-session.md
rename to docs/examples/account/create-email-password-session.md
index 6917aa2..bfc76ab 100644
--- a/docs/examples/account/create-magic-u-r-l-session.md
+++ b/docs/examples/account/create-email-password-session.md
@@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;
-const promise = account.createMagicURLSession('[USER_ID]', 'email@example.com');
+const promise = account.createEmailPasswordSession('email@example.com', 'password');
promise.then(function (response) {
console.log(response); // Success
diff --git a/docs/examples/account/create-email-session.md b/docs/examples/account/create-magic-u-r-l-token.md
similarity index 83%
rename from docs/examples/account/create-email-session.md
rename to docs/examples/account/create-magic-u-r-l-token.md
index 1981277..f80a8d9 100644
--- a/docs/examples/account/create-email-session.md
+++ b/docs/examples/account/create-magic-u-r-l-token.md
@@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;
-const promise = account.createEmailSession('email@example.com', 'password');
+const promise = account.createMagicURLToken('[USER_ID]', 'email@example.com');
promise.then(function (response) {
console.log(response); // Success
diff --git a/docs/examples/account/create-phone-session.md b/docs/examples/account/create-phone-token.md
similarity index 84%
rename from docs/examples/account/create-phone-session.md
rename to docs/examples/account/create-phone-token.md
index 85e7d68..19ef360 100644
--- a/docs/examples/account/create-phone-session.md
+++ b/docs/examples/account/create-phone-token.md
@@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;
-const promise = account.createPhoneSession('[USER_ID]', '+12065550100');
+const promise = account.createPhoneToken('[USER_ID]', '+12065550100');
promise.then(function (response) {
console.log(response); // Success
diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/create-session.md
similarity index 85%
rename from docs/examples/account/update-phone-session.md
rename to docs/examples/account/create-session.md
index 4b47389..d1c1c50 100644
--- a/docs/examples/account/update-phone-session.md
+++ b/docs/examples/account/create-session.md
@@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;
-const promise = account.updatePhoneSession('[USER_ID]', '[SECRET]');
+const promise = account.createSession('[USER_ID]', '[SECRET]');
promise.then(function (response) {
console.log(response); // Success
diff --git a/docs/examples/account/update-push-target.md b/docs/examples/account/update-push-target.md
new file mode 100644
index 0000000..e939dba
--- /dev/null
+++ b/docs/examples/account/update-push-target.md
@@ -0,0 +1,17 @@
+import { Client, Account } from "@appwrite.io/console";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+;
+
+const promise = account.updatePushTarget('[TARGET_ID]', '[IDENTIFIER]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md
index 46e5c61..43c6e1c 100644
--- a/docs/examples/account/update-recovery.md
+++ b/docs/examples/account/update-recovery.md
@@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;
-const promise = account.updateRecovery('[USER_ID]', '[SECRET]', '', '');
+const promise = account.updateRecovery('[USER_ID]', '[SECRET]', '');
promise.then(function (response) {
console.log(response); // Success
diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md
new file mode 100644
index 0000000..e148092
--- /dev/null
+++ b/docs/examples/users/create-session.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "@appwrite.io/console";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createSession('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md
new file mode 100644
index 0000000..c9f7f2d
--- /dev/null
+++ b/docs/examples/users/create-token.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "@appwrite.io/console";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createToken('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/package.json b/package.json
index 1099ae2..6d51d64 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "@appwrite.io/console",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
- "version": "0.6.0-rc.4",
+ "version": "0.6.0-rc.5",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
diff --git a/src/client.ts b/src/client.ts
index 552f8ab..b5a2ea4 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -104,7 +104,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
- 'x-sdk-version': '0.6.0-rc.4',
+ 'x-sdk-version': '0.6.0-rc.5',
'X-Appwrite-Response-Format': '1.4.0',
};
diff --git a/src/models.ts b/src/models.ts
index d1deb78..2bee4cd 100644
--- a/src/models.ts
+++ b/src/models.ts
@@ -1420,6 +1420,10 @@ export namespace Models {
* Returns true if this the current user session.
*/
factors: number;
+ /**
+ * Secret used to authenticate the user. Only included if the request was made with an API key
+ */
+ secret: string;
}
/**
* Identity
@@ -1490,6 +1494,10 @@ export namespace Models {
* Token expiration date in ISO 8601 format.
*/
expire: string;
+ /**
+ * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email.
+ */
+ securityPhrase: string;
}
/**
* JWT
diff --git a/src/services/account.ts b/src/services/account.ts
index d59c490..3444165 100644
--- a/src/services/account.ts
+++ b/src/services/account.ts
@@ -151,7 +151,7 @@ export class Account extends Service {
}
/**
- * Delete Identity
+ * Delete identity
*
* Delete an identity by its unique ID.
*
@@ -616,11 +616,10 @@ export class Account extends Service {
* @param {string} userId
* @param {string} secret
* @param {string} password
- * @param {string} passwordAgain
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise {
+ async updateRecovery(userId: string, secret: string, password: string): Promise {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@@ -633,10 +632,6 @@ export class Account extends Service {
throw new AppwriteException('Missing required parameter: "password"');
}
- if (typeof passwordAgain === 'undefined') {
- throw new AppwriteException('Missing required parameter: "passwordAgain"');
- }
-
const apiPath = '/account/recovery';
const payload: Payload = {};
@@ -652,10 +647,6 @@ export class Account extends Service {
payload['password'] = password;
}
- if (typeof passwordAgain !== 'undefined') {
- payload['passwordAgain'] = passwordAgain;
- }
-
const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('put', uri, {
'content-type': 'application/json',
@@ -725,7 +716,7 @@ export class Account extends Service {
}
/**
- * Create email session
+ * Create email password session
*
* Allow the user to login into their account by providing a valid email and
* password combination. This route will create a new session for the user.
@@ -739,7 +730,7 @@ export class Account extends Service {
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createEmailSession(email: string, password: string): Promise {
+ async createEmailPasswordSession(email: string, password: string): Promise {
if (typeof email === 'undefined') {
throw new AppwriteException('Missing required parameter: "email"');
}
@@ -766,75 +757,11 @@ export class Account extends Service {
}
/**
- * Create magic URL session
- *
- * Sends the user an email with a secret key for creating a session. If the
- * provided user ID has not been registered, a new user will be created. When
- * the user clicks the link in the email, the user is redirected back to the
- * URL you provided with the secret key and userId values attached to the URL
- * query string. Use the query string parameters to submit a request to the
- * [PUT
- * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession)
- * endpoint to complete the login process. The link sent to the user's email
- * address is valid for 1 hour. If you are on a mobile device you can leave
- * the URL parameter empty, so that the login completion will be handled by
- * your Appwrite instance by default.
- *
- * A user is limited to 10 active sessions at a time by default. [Learn more
- * about session
- * limits](https://appwrite.io/docs/authentication-security#limits).
- *
- *
- * @param {string} userId
- * @param {string} email
- * @param {string} url
- * @throws {AppwriteException}
- * @returns {Promise}
- */
- async createMagicURLSession(userId: string, email: string, url?: string): Promise {
- if (typeof userId === 'undefined') {
- throw new AppwriteException('Missing required parameter: "userId"');
- }
-
- if (typeof email === 'undefined') {
- throw new AppwriteException('Missing required parameter: "email"');
- }
-
- const apiPath = '/account/sessions/magic-url';
- const payload: Payload = {};
-
- if (typeof userId !== 'undefined') {
- payload['userId'] = userId;
- }
-
- if (typeof email !== 'undefined') {
- payload['email'] = email;
- }
-
- if (typeof url !== 'undefined') {
- payload['url'] = url;
- }
-
- const uri = new URL(this.client.config.endpoint + apiPath);
- return await this.client.call('post', uri, {
- 'content-type': 'application/json',
- }, payload);
- }
-
- /**
- * Create magic URL session (confirmation)
+ * Create session (deprecated)
*
- * Use this endpoint to complete creating the session with the Magic URL. Both
- * the **userId** and **secret** arguments will be passed as query parameters
- * to the redirect URL you have provided when sending your request to the
- * [POST
- * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession)
- * endpoint.
- *
- * Please note that in order to avoid a [Redirect
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
- * the only valid redirect URLs are the ones from domains you have set when
- * adding your platforms in the console interface.
+ * Use this endpoint to create a session from token. Provide the **userId**
+ * and **secret** parameters from the successful response of authentication
+ * flows initiated by token creation. For example, magic URL and phone login.
*
* @param {string} userId
* @param {string} secret
@@ -890,11 +817,12 @@ export class Account extends Service {
* @param {string} provider
* @param {string} success
* @param {string} failure
+ * @param {boolean} token
* @param {string[]} scopes
* @throws {AppwriteException}
* @returns {void|string}
*/
- createOAuth2Session(provider: string, success?: string, failure?: string, scopes?: string[]): void | URL {
+ createOAuth2Session(provider: string, success?: string, failure?: string, token?: boolean, scopes?: string[]): void | URL {
if (typeof provider === 'undefined') {
throw new AppwriteException('Missing required parameter: "provider"');
}
@@ -910,6 +838,10 @@ export class Account extends Service {
payload['failure'] = failure;
}
+ if (typeof token !== 'undefined') {
+ payload['token'] = token;
+ }
+
if (typeof scopes !== 'undefined') {
payload['scopes'] = scopes;
}
@@ -929,65 +861,18 @@ export class Account extends Service {
}
/**
- * Create phone session
+ * Create session
*
- * Sends the user an SMS with a secret key for creating a session. If the
- * provided user ID has not be registered, a new user will be created. Use the
- * returned user ID and secret and submit a request to the [PUT
- * /account/sessions/phone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession)
- * endpoint to complete the login process. The secret sent to the user's phone
- * is valid for 15 minutes.
- *
- * A user is limited to 10 active sessions at a time by default. [Learn more
- * about session
- * limits](https://appwrite.io/docs/authentication-security#limits).
- *
- * @param {string} userId
- * @param {string} phone
- * @throws {AppwriteException}
- * @returns {Promise}
- */
- async createPhoneSession(userId: string, phone: string): Promise {
- if (typeof userId === 'undefined') {
- throw new AppwriteException('Missing required parameter: "userId"');
- }
-
- if (typeof phone === 'undefined') {
- throw new AppwriteException('Missing required parameter: "phone"');
- }
-
- const apiPath = '/account/sessions/phone';
- const payload: Payload = {};
-
- if (typeof userId !== 'undefined') {
- payload['userId'] = userId;
- }
-
- if (typeof phone !== 'undefined') {
- payload['phone'] = phone;
- }
-
- const uri = new URL(this.client.config.endpoint + apiPath);
- return await this.client.call('post', uri, {
- 'content-type': 'application/json',
- }, payload);
- }
-
- /**
- * Create phone session (confirmation)
- *
- * Use this endpoint to complete creating a session with SMS. Use the
- * **userId** from the
- * [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession)
- * endpoint and the **secret** received via SMS to successfully update and
- * confirm the phone session.
+ * Use this endpoint to create a session from token. Provide the **userId**
+ * and **secret** parameters from the successful response of authentication
+ * flows initiated by token creation. For example, magic URL and phone login.
*
* @param {string} userId
* @param {string} secret
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updatePhoneSession(userId: string, secret: string): Promise {
+ async createSession(userId: string, secret: string): Promise {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@@ -996,7 +881,7 @@ export class Account extends Service {
throw new AppwriteException('Missing required parameter: "secret"');
}
- const apiPath = '/account/sessions/phone';
+ const apiPath = '/account/sessions/token';
const payload: Payload = {};
if (typeof userId !== 'undefined') {
@@ -1008,7 +893,7 @@ export class Account extends Service {
}
const uri = new URL(this.client.config.endpoint + apiPath);
- return await this.client.call('put', uri, {
+ return await this.client.call('post', uri, {
'content-type': 'application/json',
}, payload);
}
@@ -1109,6 +994,143 @@ export class Account extends Service {
}, payload);
}
+ /**
+ * Update Account's push target
+ *
+ *
+ * @param {string} targetId
+ * @param {string} identifier
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePushTarget(targetId: string, identifier: string): Promise {
+ if (typeof targetId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "targetId"');
+ }
+
+ if (typeof identifier === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "identifier"');
+ }
+
+ const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
+ const payload: Payload = {};
+
+ if (typeof identifier !== 'undefined') {
+ payload['identifier'] = identifier;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create magic URL token
+ *
+ * Sends the user an email with a secret key for creating a session. If the
+ * provided user ID has not been registered, a new user will be created. When
+ * the user clicks the link in the email, the user is redirected back to the
+ * URL you provided with the secret key and userId values attached to the URL
+ * query string. Use the query string parameters to submit a request to the
+ * [PUT
+ * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession)
+ * endpoint to complete the login process. The link sent to the user's email
+ * address is valid for 1 hour. If you are on a mobile device you can leave
+ * the URL parameter empty, so that the login completion will be handled by
+ * your Appwrite instance by default.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session
+ * limits](https://appwrite.io/docs/authentication-security#limits).
+ *
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} url
+ * @param {boolean} securityPhrase
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMagicURLToken(userId: string, email: string, url?: string, securityPhrase?: boolean): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ const apiPath = '/account/tokens/magic-url';
+ const payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof securityPhrase !== 'undefined') {
+ payload['securityPhrase'] = securityPhrase;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create phone token
+ *
+ * Sends the user an SMS with a secret key for creating a session. If the
+ * provided user ID has not be registered, a new user will be created. Use the
+ * returned user ID and secret and submit a request to the [PUT
+ * /account/sessions/phone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession)
+ * endpoint to complete the login process. The secret sent to the user's phone
+ * is valid for 15 minutes.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session
+ * limits](https://appwrite.io/docs/authentication-security#limits).
+ *
+ * @param {string} userId
+ * @param {string} phone
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPhoneToken(userId: string, phone: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof phone === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "phone"');
+ }
+
+ const apiPath = '/account/tokens/phone';
+ const payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof phone !== 'undefined') {
+ payload['phone'] = phone;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
/**
* Create email verification
*
diff --git a/src/services/messaging.ts b/src/services/messaging.ts
index e74e456..91af238 100644
--- a/src/services/messaging.ts
+++ b/src/services/messaging.ts
@@ -47,6 +47,8 @@ export class Messaging extends Service {
* @param {string[]} topics
* @param {string[]} users
* @param {string[]} targets
+ * @param {string[]} cc
+ * @param {string[]} bcc
* @param {string} description
* @param {string} status
* @param {boolean} html
@@ -54,7 +56,7 @@ export class Messaging extends Service {
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createEmailMessage(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], description?: string, status?: string, html?: boolean, scheduledAt?: string): Promise {
+ async createEmailMessage(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], description?: string, status?: string, html?: boolean, scheduledAt?: string): Promise {
if (typeof messageId === 'undefined') {
throw new AppwriteException('Missing required parameter: "messageId"');
}
@@ -94,6 +96,14 @@ export class Messaging extends Service {
payload['targets'] = targets;
}
+ if (typeof cc !== 'undefined') {
+ payload['cc'] = cc;
+ }
+
+ if (typeof bcc !== 'undefined') {
+ payload['bcc'] = bcc;
+ }
+
if (typeof description !== 'undefined') {
payload['description'] = description;
}
@@ -129,11 +139,13 @@ export class Messaging extends Service {
* @param {string} content
* @param {string} status
* @param {boolean} html
+ * @param {string[]} cc
+ * @param {string[]} bcc
* @param {string} scheduledAt
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, description?: string, content?: string, status?: string, html?: boolean, scheduledAt?: string): Promise {
+ async updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, description?: string, content?: string, status?: string, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string): Promise {
if (typeof messageId === 'undefined') {
throw new AppwriteException('Missing required parameter: "messageId"');
}
@@ -173,6 +185,14 @@ export class Messaging extends Service {
payload['html'] = html;
}
+ if (typeof cc !== 'undefined') {
+ payload['cc'] = cc;
+ }
+
+ if (typeof bcc !== 'undefined') {
+ payload['bcc'] = bcc;
+ }
+
if (typeof scheduledAt !== 'undefined') {
payload['scheduledAt'] = scheduledAt;
}
@@ -309,13 +329,13 @@ export class Messaging extends Service {
* @param {string} sound
* @param {string} color
* @param {string} tag
- * @param {string} badge
+ * @param {number} badge
* @param {string} status
* @param {string} scheduledAt
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updatePushNotification(messageId: string, topics?: string[], users?: string[], targets?: string[], description?: string, title?: string, body?: string, data?: object, action?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: string, status?: string, scheduledAt?: string): Promise {
+ async updatePushNotification(messageId: string, topics?: string[], users?: string[], targets?: string[], description?: string, title?: string, body?: string, data?: object, action?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, status?: string, scheduledAt?: string): Promise {
if (typeof messageId === 'undefined') {
throw new AppwriteException('Missing required parameter: "messageId"');
}
@@ -597,12 +617,11 @@ export class Messaging extends Service {
* @param {string} authKeyId
* @param {string} teamId
* @param {string} bundleId
- * @param {string} endpoint
* @param {boolean} enabled
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, endpoint?: string, enabled?: boolean): Promise {
+ async createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, enabled?: boolean): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -638,10 +657,6 @@ export class Messaging extends Service {
payload['bundleId'] = bundleId;
}
- if (typeof endpoint !== 'undefined') {
- payload['endpoint'] = endpoint;
- }
-
if (typeof enabled !== 'undefined') {
payload['enabled'] = enabled;
}
@@ -663,11 +678,10 @@ export class Messaging extends Service {
* @param {string} authKeyId
* @param {string} teamId
* @param {string} bundleId
- * @param {string} endpoint
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, endpoint?: string): Promise {
+ async updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -699,10 +713,6 @@ export class Messaging extends Service {
payload['bundleId'] = bundleId;
}
- if (typeof endpoint !== 'undefined') {
- payload['endpoint'] = endpoint;
- }
-
const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('patch', uri, {
'content-type': 'application/json',
@@ -715,12 +725,12 @@ export class Messaging extends Service {
*
* @param {string} providerId
* @param {string} name
- * @param {string} serverKey
+ * @param {object} serviceAccountJSON
* @param {boolean} enabled
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createFcmProvider(providerId: string, name: string, serverKey?: string, enabled?: boolean): Promise {
+ async createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -740,8 +750,8 @@ export class Messaging extends Service {
payload['name'] = name;
}
- if (typeof serverKey !== 'undefined') {
- payload['serverKey'] = serverKey;
+ if (typeof serviceAccountJSON !== 'undefined') {
+ payload['serviceAccountJSON'] = serviceAccountJSON;
}
if (typeof enabled !== 'undefined') {
@@ -761,11 +771,11 @@ export class Messaging extends Service {
* @param {string} providerId
* @param {string} name
* @param {boolean} enabled
- * @param {string} serverKey
+ * @param {object} serviceAccountJSON
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serverKey?: string): Promise {
+ async updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -781,8 +791,8 @@ export class Messaging extends Service {
payload['enabled'] = enabled;
}
- if (typeof serverKey !== 'undefined') {
- payload['serverKey'] = serverKey;
+ if (typeof serviceAccountJSON !== 'undefined') {
+ payload['serviceAccountJSON'] = serviceAccountJSON;
}
const uri = new URL(this.client.config.endpoint + apiPath);
@@ -797,15 +807,18 @@ export class Messaging extends Service {
*
* @param {string} providerId
* @param {string} name
- * @param {string} from
* @param {string} apiKey
* @param {string} domain
* @param {boolean} isEuRegion
* @param {boolean} enabled
+ * @param {string} fromName
+ * @param {string} fromEmail
+ * @param {string} replyToName
+ * @param {string} replyToEmail
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createMailgunProvider(providerId: string, name: string, from?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean): Promise {
+ async createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -825,10 +838,6 @@ export class Messaging extends Service {
payload['name'] = name;
}
- if (typeof from !== 'undefined') {
- payload['from'] = from;
- }
-
if (typeof apiKey !== 'undefined') {
payload['apiKey'] = apiKey;
}
@@ -845,6 +854,22 @@ export class Messaging extends Service {
payload['enabled'] = enabled;
}
+ if (typeof fromName !== 'undefined') {
+ payload['fromName'] = fromName;
+ }
+
+ if (typeof fromEmail !== 'undefined') {
+ payload['fromEmail'] = fromEmail;
+ }
+
+ if (typeof replyToName !== 'undefined') {
+ payload['replyToName'] = replyToName;
+ }
+
+ if (typeof replyToEmail !== 'undefined') {
+ payload['replyToEmail'] = replyToEmail;
+ }
+
const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('post', uri, {
'content-type': 'application/json',
@@ -857,15 +882,18 @@ export class Messaging extends Service {
*
* @param {string} providerId
* @param {string} name
- * @param {boolean} enabled
- * @param {boolean} isEuRegion
- * @param {string} from
* @param {string} apiKey
* @param {string} domain
+ * @param {boolean} isEuRegion
+ * @param {boolean} enabled
+ * @param {string} fromName
+ * @param {string} fromEmail
+ * @param {string} replyToName
+ * @param {string} replyToEmail
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateMailgunProvider(providerId: string, name?: string, enabled?: boolean, isEuRegion?: boolean, from?: string, apiKey?: string, domain?: string): Promise {
+ async updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -877,24 +905,36 @@ export class Messaging extends Service {
payload['name'] = name;
}
- if (typeof enabled !== 'undefined') {
- payload['enabled'] = enabled;
+ if (typeof apiKey !== 'undefined') {
+ payload['apiKey'] = apiKey;
+ }
+
+ if (typeof domain !== 'undefined') {
+ payload['domain'] = domain;
}
if (typeof isEuRegion !== 'undefined') {
payload['isEuRegion'] = isEuRegion;
}
- if (typeof from !== 'undefined') {
- payload['from'] = from;
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
}
- if (typeof apiKey !== 'undefined') {
- payload['apiKey'] = apiKey;
+ if (typeof fromName !== 'undefined') {
+ payload['fromName'] = fromName;
}
- if (typeof domain !== 'undefined') {
- payload['domain'] = domain;
+ if (typeof fromEmail !== 'undefined') {
+ payload['fromEmail'] = fromEmail;
+ }
+
+ if (typeof replyToName !== 'undefined') {
+ payload['replyToName'] = replyToName;
+ }
+
+ if (typeof replyToEmail !== 'undefined') {
+ payload['replyToEmail'] = replyToEmail;
}
const uri = new URL(this.client.config.endpoint + apiPath);
@@ -1011,13 +1051,16 @@ export class Messaging extends Service {
*
* @param {string} providerId
* @param {string} name
- * @param {string} from
* @param {string} apiKey
* @param {boolean} enabled
+ * @param {string} fromName
+ * @param {string} fromEmail
+ * @param {string} replyToName
+ * @param {string} replyToEmail
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createSendgridProvider(providerId: string, name: string, from?: string, apiKey?: string, enabled?: boolean): Promise {
+ async createSendgridProvider(providerId: string, name: string, apiKey?: string, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -1037,10 +1080,6 @@ export class Messaging extends Service {
payload['name'] = name;
}
- if (typeof from !== 'undefined') {
- payload['from'] = from;
- }
-
if (typeof apiKey !== 'undefined') {
payload['apiKey'] = apiKey;
}
@@ -1049,6 +1088,22 @@ export class Messaging extends Service {
payload['enabled'] = enabled;
}
+ if (typeof fromName !== 'undefined') {
+ payload['fromName'] = fromName;
+ }
+
+ if (typeof fromEmail !== 'undefined') {
+ payload['fromEmail'] = fromEmail;
+ }
+
+ if (typeof replyToName !== 'undefined') {
+ payload['replyToName'] = replyToName;
+ }
+
+ if (typeof replyToEmail !== 'undefined') {
+ payload['replyToEmail'] = replyToEmail;
+ }
+
const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('post', uri, {
'content-type': 'application/json',
@@ -1063,11 +1118,14 @@ export class Messaging extends Service {
* @param {string} name
* @param {boolean} enabled
* @param {string} apiKey
- * @param {string} from
+ * @param {string} fromName
+ * @param {string} fromEmail
+ * @param {string} replyToName
+ * @param {string} replyToEmail
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, from?: string): Promise {
+ async updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise {
if (typeof providerId === 'undefined') {
throw new AppwriteException('Missing required parameter: "providerId"');
}
@@ -1087,8 +1145,20 @@ export class Messaging extends Service {
payload['apiKey'] = apiKey;
}
- if (typeof from !== 'undefined') {
- payload['from'] = from;
+ if (typeof fromName !== 'undefined') {
+ payload['fromName'] = fromName;
+ }
+
+ if (typeof fromEmail !== 'undefined') {
+ payload['fromEmail'] = fromEmail;
+ }
+
+ if (typeof replyToName !== 'undefined') {
+ payload['replyToName'] = replyToName;
+ }
+
+ if (typeof replyToEmail !== 'undefined') {
+ payload['replyToEmail'] = replyToEmail;
}
const uri = new URL(this.client.config.endpoint + apiPath);
diff --git a/src/services/users.ts b/src/services/users.ts
index 6f05e2c..01299e7 100644
--- a/src/services/users.ts
+++ b/src/services/users.ts
@@ -221,7 +221,7 @@ export class Users extends Service {
}
/**
- * Delete Identity
+ * Delete identity
*
* Delete an identity by its unique ID.
*
@@ -960,6 +960,34 @@ export class Users extends Service {
}, payload);
}
+ /**
+ * Create session
+ *
+ * Creates a session for a user. Returns an immediately usable session object.
+ *
+ * If you want to generate a token for a custom authentication flow, use the
+ * [POST
+ * /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken)
+ * endpoint.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createSession(userId: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId);
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
/**
* Delete user sessions
*
@@ -1226,6 +1254,43 @@ export class Users extends Service {
}, payload);
}
+ /**
+ * Create token
+ *
+ * Returns a token with a secret key for creating a session. If the provided
+ * user ID has not be registered, a new user will be created. Use the returned
+ * user ID and secret and submit a request to the [PUT
+ * /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession)
+ * endpoint to complete the login process.
+ *
+ * @param {string} userId
+ * @param {number} length
+ * @param {number} expire
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createToken(userId: string, length?: number, expire?: number): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ const apiPath = '/users/{userId}/tokens'.replace('{userId}', userId);
+ const payload: Payload = {};
+
+ if (typeof length !== 'undefined') {
+ payload['length'] = length;
+ }
+
+ if (typeof expire !== 'undefined') {
+ payload['expire'] = expire;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
/**
* Update email verification
*