Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 20.1.0

* Deprecate `createVerification` method in `Account` service
* Add `createEmailVerification` method in `Account` service

## 17.2.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
Expand Down
12 changes: 12 additions & 0 deletions docs/examples/account/create-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const sdk = require('node-appwrite');

const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.createEmailVerification({
url: 'https://example.com'
});
13 changes: 13 additions & 0 deletions docs/examples/account/update-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const sdk = require('node-appwrite');

const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

const account = new sdk.Account(client);

const result = await account.updateEmailVerification({
userId: '<USER_ID>',
secret: '<SECRET>'
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "node-appwrite",
"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": "20.0.0",
"version": "20.1.0",
"license": "BSD-3-Clause",
"main": "dist/index.js",
"type": "commonjs",
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppwriteException extends Error {
}

function getUserAgent() {
let ua = 'AppwriteNodeJSSDK/20.0.0';
let ua = 'AppwriteNodeJSSDK/20.1.0';

// `process` is a global in Node.js, but not fully available in all runtimes.
const platform: string[] = [];
Expand Down Expand Up @@ -82,7 +82,7 @@ class Client {
'x-sdk-name': 'Node.js',
'x-sdk-platform': 'server',
'x-sdk-language': 'nodejs',
'x-sdk-version': '20.0.0',
'x-sdk-version': '20.1.0',
'user-agent' : getUserAgent(),
'X-Appwrite-Response-Format': '1.8.0',
};
Expand Down
137 changes: 133 additions & 4 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,68 @@ export class Account {
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
*/
createEmailVerification(params: { url: string }): Promise<Models.Token>;
/**
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
*
* 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.
*
*
* @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
createEmailVerification(url: string): Promise<Models.Token>;
createEmailVerification(
paramsOrFirst: { url: string } | string
): Promise<Models.Token> {
let params: { url: string };

if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { url: string };
} else {
params = {
url: paramsOrFirst as string
};
}

const url = params.url;

if (typeof url === 'undefined') {
throw new AppwriteException('Missing required parameter: "url"');
}

const apiPath = '/account/verifications/email';
const payload: Payload = {};
if (typeof url !== 'undefined') {
payload['url'] = url;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
'content-type': 'application/json',
}

return this.client.call(
'post',
uri,
apiHeaders,
payload,
);
}

/**
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
*
* 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.
*
*
* @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
* @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.
*/
createVerification(params: { url: string }): Promise<Models.Token>;
/**
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
Expand Down Expand Up @@ -2480,7 +2542,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "url"');
}

const apiPath = '/account/verification';
const apiPath = '/account/verifications/email';
const payload: Payload = {};
if (typeof url !== 'undefined') {
payload['url'] = url;
Expand All @@ -2507,6 +2569,73 @@ export class Account {
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
*/
updateEmailVerification(params: { userId: string, secret: string }): Promise<Models.Token>;
/**
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
*
* @param {string} userId - User ID.
* @param {string} secret - Valid verification token.
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
updateEmailVerification(userId: string, secret: string): Promise<Models.Token>;
updateEmailVerification(
paramsOrFirst: { userId: string, secret: string } | string,
...rest: [(string)?]
): Promise<Models.Token> {
let params: { userId: string, secret: string };

if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { userId: string, secret: string };
} else {
params = {
userId: paramsOrFirst as string,
secret: rest[0] as string
};
}

const userId = params.userId;
const secret = params.secret;

if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof secret === 'undefined') {
throw new AppwriteException('Missing required parameter: "secret"');
}

const apiPath = '/account/verifications/email';
const payload: Payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
}
if (typeof secret !== 'undefined') {
payload['secret'] = secret;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
'content-type': 'application/json',
}

return this.client.call(
'put',
uri,
apiHeaders,
payload,
);
}

/**
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
*
* @param {string} params.userId - User ID.
* @param {string} params.secret - Valid verification token.
* @throws {AppwriteException}
* @returns {Promise<Models.Token>}
* @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.
*/
updateVerification(params: { userId: string, secret: string }): Promise<Models.Token>;
/**
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
Expand Down Expand Up @@ -2543,7 +2672,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "secret"');
}

const apiPath = '/account/verification';
const apiPath = '/account/verifications/email';
const payload: Payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
Expand Down Expand Up @@ -2573,7 +2702,7 @@ export class Account {
*/
createPhoneVerification(): Promise<Models.Token> {

const apiPath = '/account/verification/phone';
const apiPath = '/account/verifications/phone';
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -2633,7 +2762,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "secret"');
}

const apiPath = '/account/verification/phone';
const apiPath = '/account/verifications/phone';
const payload: Payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
Expand Down
4 changes: 2 additions & 2 deletions src/services/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ export class Functions {
/**
* Create a deployment based on a template.
*
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details.
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details.
*
* @param {string} params.functionId - Function ID.
* @param {string} params.repository - Repository name of the template.
Expand All @@ -893,7 +893,7 @@ export class Functions {
/**
* Create a deployment based on a template.
*
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details.
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details.
*
* @param {string} functionId - Function ID.
* @param {string} repository - Repository name of the template.
Expand Down
4 changes: 2 additions & 2 deletions src/services/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ export class Sites {
/**
* Create a deployment based on a template.
*
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details.
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details.
*
* @param {string} params.siteId - Site ID.
* @param {string} params.repository - Repository name of the template.
Expand All @@ -892,7 +892,7 @@ export class Sites {
/**
* Create a deployment based on a template.
*
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details.
* Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details.
*
* @param {string} siteId - Site ID.
* @param {string} repository - Repository name of the template.
Expand Down
Loading