diff --git a/CHANGELOG.md b/CHANGELOG.md index 588ec87..a282565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 28.1.0 + +* Added: `Apps` service to create and manage OAuth2 apps, their secrets, keys, and installations +* Added: `Oauth2` service for authorization, consent, device, PAR, and token flows +* Added: `App`, `AppSecret`, `AppKey`, `AppScope` and `Oauth2*` response models + ## 28.0.0 * Breaking: removed `Account.listLogs` and the `Log`, `LogList` models diff --git a/README.md b/README.md index bee9ad2..a9d1bd4 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from 'appwrite'; 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 - + ``` ## Getting Started diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md new file mode 100644 index 0000000..fc90377 --- /dev/null +++ b/docs/examples/apps/create-installation-token.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Apps } from 'appwrite'; + +const client = new Client() + .setEndpoint('https://', // optional
+ refreshToken: '', // optional
+ deviceCode: '', // optional
+ clientId: '', // optional
+ clientSecret: '', // optional
+ codeVerifier: '', // optional
+ redirectUri: 'https://example.com', // optional
+ resource: '', // optional
+ audience: '', // optional
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md
new file mode 100644
index 0000000..43c159f
--- /dev/null
+++ b/docs/examples/oauth2/get-grant.md
@@ -0,0 +1,15 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.getGrant({
+ grantId: '',
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md
new file mode 100644
index 0000000..2efdecf
--- /dev/null
+++ b/docs/examples/oauth2/list-organizations.md
@@ -0,0 +1,17 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.listOrganizations({
+ limit: 1, // optional
+ offset: 0, // optional
+ search: '', // optional
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md
new file mode 100644
index 0000000..bf7ed6a
--- /dev/null
+++ b/docs/examples/oauth2/list-projects.md
@@ -0,0 +1,17 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.listProjects({
+ limit: 1, // optional
+ offset: 0, // optional
+ search: '', // optional
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/logout-post.md b/docs/examples/oauth2/logout-post.md
new file mode 100644
index 0000000..9f19e4b
--- /dev/null
+++ b/docs/examples/oauth2/logout-post.md
@@ -0,0 +1,20 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.logoutPost({
+ idTokenHint: '', // optional
+ logoutHint: '', // optional
+ clientId: '', // optional
+ postLogoutRedirectUri: 'https://example.com', // optional
+ state: '', // optional
+ uiLocales: '', // optional
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/logout.md b/docs/examples/oauth2/logout.md
new file mode 100644
index 0000000..df14c7a
--- /dev/null
+++ b/docs/examples/oauth2/logout.md
@@ -0,0 +1,20 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.logout({
+ idTokenHint: '', // optional
+ logoutHint: '', // optional
+ clientId: '', // optional
+ postLogoutRedirectUri: 'https://example.com', // optional
+ state: '', // optional
+ uiLocales: '', // optional
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md
new file mode 100644
index 0000000..fe6f869
--- /dev/null
+++ b/docs/examples/oauth2/reject.md
@@ -0,0 +1,15 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.reject({
+ grantId: '',
+});
+
+console.log(result);
+```
diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md
new file mode 100644
index 0000000..1998f5e
--- /dev/null
+++ b/docs/examples/oauth2/revoke.md
@@ -0,0 +1,18 @@
+```javascript
+import { Client, Oauth2 } from 'appwrite';
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const oauth2 = new Oauth2(client);
+
+const result = await oauth2.revoke({
+ token: '',
+ tokenTypeHint: 'access_token', // optional
+ clientId: '', // optional
+ clientSecret: '', // optional
+});
+
+console.log(result);
+```
diff --git a/package-lock.json b/package-lock.json
index 632c697..5f28bd4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "appwrite",
- "version": "28.0.0",
+ "version": "28.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "appwrite",
- "version": "28.0.0",
+ "version": "28.1.0",
"license": "BSD-3-Clause",
"dependencies": {
"json-bigint": "1.0.0"
diff --git a/package.json b/package.json
index 4e3da6a..92fb84e 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
- "version": "28.0.0",
+ "version": "28.1.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
diff --git a/src/client.ts b/src/client.ts
index 89e59bd..83690d6 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -397,7 +397,7 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
- 'x-sdk-version': '28.0.0',
+ 'x-sdk-version': '28.1.0',
'X-Appwrite-Response-Format': '2.3.0',
};
diff --git a/src/index.ts b/src/index.ts
index 81ea122..02956e9 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -9,6 +9,7 @@
*/
export { Client, Query, AppwriteException } from './client';
export { Account } from './services/account';
+export { Apps } from './services/apps';
export { Avatars } from './services/avatars';
export { Databases } from './services/databases';
export { DocumentsDB } from './services/documents-db';
@@ -16,6 +17,7 @@ export { Functions } from './services/functions';
export { Graphql } from './services/graphql';
export { Locale } from './services/locale';
export { Messaging } from './services/messaging';
+export { Oauth2 } from './services/oauth-2';
export { Organization } from './services/organization';
export { Presences } from './services/presences';
export { Storage } from './services/storage';
diff --git a/src/models.ts b/src/models.ts
index dda14b4..9b12125 100644
--- a/src/models.ts
+++ b/src/models.ts
@@ -1444,6 +1444,226 @@ export namespace Models {
expired: boolean;
};
+ /**
+ * App
+ */
+ export type App = {
+ /**
+ * App ID.
+ */
+ $id: string;
+ /**
+ * App creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * App update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Application name.
+ */
+ name: string;
+ /**
+ * Application description shown to users during OAuth2 consent.
+ */
+ description: string;
+ /**
+ * Application homepage URL shown to users during OAuth2 consent.
+ */
+ clientUri: string;
+ /**
+ * Application logo URL shown to users during OAuth2 consent.
+ */
+ logoUri: string;
+ /**
+ * Application privacy policy URL shown to users during OAuth2 consent.
+ */
+ privacyPolicyUrl: string;
+ /**
+ * Application terms of service URL shown to users during OAuth2 consent.
+ */
+ termsUrl: string;
+ /**
+ * Application support or security contact emails.
+ */
+ contacts: string[];
+ /**
+ * Application tagline shown to users during OAuth2 consent.
+ */
+ tagline: string;
+ /**
+ * Application tags shown to users during OAuth2 consent.
+ */
+ tags: string[];
+ /**
+ * Application labels. Read-only for clients; only a server SDK using a project API key can update them.
+ */
+ labels: string[];
+ /**
+ * Application image URLs shown to users during OAuth2 consent.
+ */
+ images: string[];
+ /**
+ * Application support URL shown to users during OAuth2 consent.
+ */
+ supportUrl: string;
+ /**
+ * Application data deletion URL shown to users during OAuth2 consent.
+ */
+ dataDeletionUrl: string;
+ /**
+ * List of authorized redirect URIs. These URIs can be used to redirect users after they authenticate.
+ */
+ redirectUris: string[];
+ /**
+ * List of authorized post-logout redirect URIs for OpenID Connect RP-Initiated Logout. The logout endpoint only redirects users to URIs in this list after ending their session.
+ */
+ postLogoutRedirectUris: string[];
+ /**
+ * Whether the app is enabled or not.
+ */
+ enabled: boolean;
+ /**
+ * OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot keep a client secret (PKCE required); `confidential` for server-side clients that authenticate with a client secret.
+ */
+ type: string;
+ /**
+ * Whether this client may use the OAuth2 Device Authorization Grant (RFC 8628).
+ */
+ deviceFlow: boolean;
+ /**
+ * ID of team that owns the application, if owned by team. Otherwise, user ID will be used.
+ */
+ teamId: string;
+ /**
+ * ID of user who owns the application, if owned by user. Otherwise, team ID will be used.
+ */
+ userId: string;
+ /**
+ * Scopes the application requests when installed on a team. Organization-level and project-level scopes only.
+ */
+ installationScopes: string[];
+ /**
+ * URL users are redirected to after creating or updating an installation of this application. Empty for no redirect.
+ */
+ installationRedirectUrl: string;
+ /**
+ * List of application secrets.
+ */
+ secrets: AppSecret[];
+ };
+
+ /**
+ * AppSecret
+ */
+ export type AppSecret = {
+ /**
+ * Secret ID.
+ */
+ $id: string;
+ /**
+ * Secret creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Secret update time in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Application ID this secret belongs to.
+ */
+ appId: string;
+ /**
+ * Always empty. The application client secret is returned only once, in the response of the createSecret method.
+ */
+ secret: string;
+ /**
+ * Last few characters of the client secret, used to help identify it.
+ */
+ hint: string;
+ /**
+ * ID of the user who created the secret.
+ */
+ createdById: string;
+ /**
+ * Name of the user who created the secret.
+ */
+ createdByName: string;
+ /**
+ * Time the secret was last used for authentication in ISO 8601 format. Null if never used.
+ */
+ lastAccessedAt?: string;
+ };
+
+ /**
+ * AppSecretPlaintext
+ */
+ export type AppSecretPlaintext = {
+ /**
+ * Secret ID.
+ */
+ $id: string;
+ /**
+ * Secret creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Secret update time in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Application ID this secret belongs to.
+ */
+ appId: string;
+ /**
+ * Application client secret. Returned only when the secret is created; subsequent reads always return an empty value.
+ */
+ secret: string;
+ /**
+ * Last few characters of the client secret, used to help identify it.
+ */
+ hint: string;
+ /**
+ * ID of the user who created the secret.
+ */
+ createdById: string;
+ /**
+ * Name of the user who created the secret.
+ */
+ createdByName: string;
+ /**
+ * Time the secret was last used for authentication in ISO 8601 format. Null if never used.
+ */
+ lastAccessedAt?: string;
+ };
+
+ /**
+ * AppScope
+ */
+ export type AppScope = {
+ /**
+ * Scope value as requested by apps.
+ */
+ value: string;
+ /**
+ * Human-readable description of what the scope grants.
+ */
+ description: string;
+ /**
+ * What the scope grants access to. One of `account`, `project`, or `organization`. Only `project` and `organization` scopes are installable.
+ */
+ type: string;
+ /**
+ * Scope category, used to group scopes on consent and installation screens.
+ */
+ category: string;
+ /**
+ * Whether the scope is deprecated. Deprecated scopes can still be requested but should not be offered for new grants.
+ */
+ deprecated: boolean;
+ };
+
/**
* AppInstallation
*/
@@ -1490,6 +1710,214 @@ export namespace Models {
lastAccessedAt?: string;
};
+ /**
+ * AppKey
+ */
+ export type AppKey = {
+ /**
+ * App key ID.
+ */
+ $id: string;
+ /**
+ * App key creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * App key update time in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Application ID this app key belongs to.
+ */
+ appId: string;
+ /**
+ * App key secret.
+ */
+ secret: string;
+ /**
+ * Last few characters of the app key secret, used to help identify it.
+ */
+ hint: string;
+ /**
+ * ID of the user who created the app key.
+ */
+ createdById: string;
+ /**
+ * Name of the user who created the app key.
+ */
+ createdByName: string;
+ /**
+ * Time the app key was last used for authentication in ISO 8601 format. Null if never used.
+ */
+ lastAccessedAt?: string;
+ };
+
+ /**
+ * OAuth2 Authorize
+ */
+ export type Oauth2Authorize = {
+ /**
+ * OAuth2 grant ID. Set when the user must give explicit consent; pass it to the approve or reject endpoint. Empty when a redirect URL is returned instead.
+ */
+ grantId: string;
+ /**
+ * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required.
+ */
+ redirectUrl: string;
+ };
+
+ /**
+ * OAuth2 Approve
+ */
+ export type Oauth2Approve = {
+ /**
+ * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`.
+ */
+ redirectUrl: string;
+ };
+
+ /**
+ * OAuth2 Reject
+ */
+ export type Oauth2Reject = {
+ /**
+ * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error.
+ */
+ redirectUrl: string;
+ };
+
+ /**
+ * OAuth2 Grant
+ */
+ export type Oauth2Grant = {
+ /**
+ * Grant ID.
+ */
+ $id: string;
+ /**
+ * Grant creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Grant update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * ID of the user the grant belongs to.
+ */
+ userId: string;
+ /**
+ * ID of the OAuth2 client (app) the grant was requested for.
+ */
+ appId: string;
+ /**
+ * Requested OAuth2 scopes the user is being asked to consent to.
+ */
+ scopes: string[];
+ /**
+ * Requested RFC 8707 resource indicators the user is being asked to consent to.
+ */
+ resources: string[];
+ /**
+ * Requested authorization_details the user is being asked to consent to, as a JSON string. Each entry has a `type` plus project-defined fields.
+ */
+ authorizationDetails: string;
+ /**
+ * OIDC prompt directive the consent screen should honor. Space-separated list of: login, consent, select_account.
+ */
+ prompt: string;
+ /**
+ * Redirect URI the user will be sent to after the flow completes.
+ */
+ redirectUri: string;
+ /**
+ * Unix timestamp of when the user last authenticated.
+ */
+ authTime: number;
+ /**
+ * Grant expiration time in ISO 8601 format.
+ */
+ expire: string;
+ };
+
+ /**
+ * OAuth2 Device Authorization
+ */
+ export type Oauth2DeviceAuthorization = {
+ /**
+ * Device verification code used by the client to poll the token endpoint.
+ */
+ device_code: string;
+ /**
+ * Short code the end user enters on the verification page.
+ */
+ user_code: string;
+ /**
+ * URL where the end user enters the user code.
+ */
+ verification_uri: string;
+ /**
+ * Verification URL with the user code prefilled as a query parameter.
+ */
+ verification_uri_complete: string;
+ /**
+ * Lifetime of the device code and user code in seconds.
+ */
+ expires_in: number;
+ /**
+ * Minimum polling interval for the token endpoint in seconds.
+ */
+ interval: number;
+ };
+
+ /**
+ * OAuth2 PAR
+ */
+ export type Oauth2PAR = {
+ /**
+ * Authorization request handle to pass to the authorize endpoint.
+ */
+ request_uri: string;
+ /**
+ * Lifetime of the authorization request handle in seconds.
+ */
+ expires_in: number;
+ };
+
+ /**
+ * OAuth2 Token
+ */
+ export type Oauth2Token = {
+ /**
+ * OAuth2 access token.
+ */
+ access_token: string;
+ /**
+ * OAuth2 token type.
+ */
+ token_type: string;
+ /**
+ * Access token lifetime in seconds.
+ */
+ expires_in: number;
+ /**
+ * OAuth2 refresh token.
+ */
+ refresh_token: string;
+ /**
+ * Space-separated scopes granted to the access token.
+ */
+ scope: string;
+ /**
+ * Granted RFC 9396 authorization details as a JSON string.
+ */
+ authorization_details?: string;
+ /**
+ * OpenID Connect ID token. Returned when the `openid` scope is granted.
+ */
+ id_token?: string;
+ };
+
/**
* OAuth2 Consent
*/
@@ -1586,6 +2014,62 @@ export namespace Models {
expire: string;
};
+ /**
+ * OAuth2 Project
+ */
+ export type Oauth2Project = {
+ /**
+ * Project ID.
+ */
+ $id: string;
+ /**
+ * Region ID the project is deployed in.
+ */
+ region: string;
+ /**
+ * API endpoint of the region the project is deployed in. Empty when the region has no public hostname configured.
+ */
+ endpoint: string;
+ };
+
+ /**
+ * OAuth2 Organization
+ */
+ export type Oauth2Organization = {
+ /**
+ * Organization ID.
+ */
+ $id: string;
+ };
+
+ /**
+ * OAuth2 accessible projects list
+ */
+ export type Oauth2ProjectList = {
+ /**
+ * Total number of projects that matched your query.
+ */
+ total: number;
+ /**
+ * List of projects.
+ */
+ projects: Oauth2Project[];
+ };
+
+ /**
+ * OAuth2 accessible organizations list
+ */
+ export type Oauth2OrganizationList = {
+ /**
+ * Total number of organizations that matched your query.
+ */
+ total: number;
+ /**
+ * List of organizations.
+ */
+ organizations: Oauth2Organization[];
+ };
+
/**
* OAuth2 consents list
*/
@@ -1614,6 +2098,48 @@ export namespace Models {
tokens: Oauth2ConsentToken[];
};
+ /**
+ * Apps list
+ */
+ export type AppsList = {
+ /**
+ * Total number of apps that matched your query.
+ */
+ total: number;
+ /**
+ * List of apps.
+ */
+ apps: App[];
+ };
+
+ /**
+ * App secrets list
+ */
+ export type AppSecretList = {
+ /**
+ * Total number of secrets that matched your query.
+ */
+ total: number;
+ /**
+ * List of secrets.
+ */
+ secrets: AppSecret[];
+ };
+
+ /**
+ * App scopes list
+ */
+ export type AppScopeList = {
+ /**
+ * Total number of scopes that matched your query.
+ */
+ total: number;
+ /**
+ * List of scopes.
+ */
+ scopes: AppScope[];
+ };
+
/**
* App installations list
*/
@@ -1627,4 +2153,18 @@ export namespace Models {
*/
installations: AppInstallation[];
};
+
+ /**
+ * App keys list
+ */
+ export type AppKeyList = {
+ /**
+ * Total number of keys that matched your query.
+ */
+ total: number;
+ /**
+ * List of keys.
+ */
+ keys: AppKey[];
+ };
}
diff --git a/src/services/apps.ts b/src/services/apps.ts
new file mode 100644
index 0000000..b746385
--- /dev/null
+++ b/src/services/apps.ts
@@ -0,0 +1,1807 @@
+import { AppwriteException, Client, type Payload } from '../client';
+import type { Models } from '../models';
+
+export class Apps {
+ client: Client;
+
+ constructor(client: Client) {
+ this.client = client;
+ }
+
+ /**
+ * List applications.
+ *
+ * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ list(params?: {
+ queries?: string[];
+ total?: boolean;
+ }): Promise;
+ /**
+ * List applications.
+ *
+ * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ list(queries?: string[], total?: boolean): Promise;
+ list(
+ paramsOrFirst?: { queries?: string[]; total?: boolean } | string[],
+ ...rest: [boolean?]
+ ): Promise {
+ let params: { queries?: string[]; total?: boolean };
+
+ if (
+ (typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
+ (paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst))
+ ) {
+ params = (paramsOrFirst || {}) as {
+ queries?: string[];
+ total?: boolean;
+ };
+ } else {
+ params = {
+ queries: paramsOrFirst as string[],
+ total: rest[0] as boolean,
+ };
+ }
+
+ const queries = params.queries;
+ const total = params.total;
+
+ const apiPath = '/apps';
+ const payload: Payload = {};
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+ if (typeof total !== 'undefined') {
+ payload['total'] = total;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Create a new application.
+ *
+ * @param {string} params.appId - Application ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
+ * @param {string} params.name - Application name.
+ * @param {string[]} params.redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment.
+ * @param {string} params.description - Application description shown to users during OAuth2 consent.
+ * @param {string} params.clientUri - Application homepage URL shown to users during OAuth2 consent.
+ * @param {string} params.logoUri - Application logo URL shown to users during OAuth2 consent.
+ * @param {string} params.privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent.
+ * @param {string} params.termsUrl - Application terms of service URL shown to users during OAuth2 consent.
+ * @param {string[]} params.contacts - Application support or security contact emails. Maximum of 100 contacts are allowed.
+ * @param {string} params.tagline - Application tagline shown to users during OAuth2 consent.
+ * @param {string[]} params.tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long.
+ * @param {string[]} params.images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed.
+ * @param {string} params.supportUrl - Application support URL shown to users during OAuth2 consent.
+ * @param {string} params.dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent.
+ * @param {string[]} params.postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list.
+ * @param {boolean} params.enabled - Is application enabled?
+ * @param {string} params.type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`.
+ * @param {boolean} params.deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false.
+ * @param {string} params.teamId - Team unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ create(params: {
+ appId: string;
+ name: string;
+ redirectUris: string[];
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ postLogoutRedirectUris?: string[];
+ enabled?: boolean;
+ type?: string;
+ deviceFlow?: boolean;
+ teamId?: string;
+ }): Promise;
+ /**
+ * Create a new application.
+ *
+ * @param {string} appId - Application ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
+ * @param {string} name - Application name.
+ * @param {string[]} redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment.
+ * @param {string} description - Application description shown to users during OAuth2 consent.
+ * @param {string} clientUri - Application homepage URL shown to users during OAuth2 consent.
+ * @param {string} logoUri - Application logo URL shown to users during OAuth2 consent.
+ * @param {string} privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent.
+ * @param {string} termsUrl - Application terms of service URL shown to users during OAuth2 consent.
+ * @param {string[]} contacts - Application support or security contact emails. Maximum of 100 contacts are allowed.
+ * @param {string} tagline - Application tagline shown to users during OAuth2 consent.
+ * @param {string[]} tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long.
+ * @param {string[]} images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed.
+ * @param {string} supportUrl - Application support URL shown to users during OAuth2 consent.
+ * @param {string} dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent.
+ * @param {string[]} postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list.
+ * @param {boolean} enabled - Is application enabled?
+ * @param {string} type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`.
+ * @param {boolean} deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false.
+ * @param {string} teamId - Team unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ create(
+ appId: string,
+ name: string,
+ redirectUris: string[],
+ description?: string,
+ clientUri?: string,
+ logoUri?: string,
+ privacyPolicyUrl?: string,
+ termsUrl?: string,
+ contacts?: string[],
+ tagline?: string,
+ tags?: string[],
+ images?: string[],
+ supportUrl?: string,
+ dataDeletionUrl?: string,
+ postLogoutRedirectUris?: string[],
+ enabled?: boolean,
+ type?: string,
+ deviceFlow?: boolean,
+ teamId?: string,
+ ): Promise;
+ create(
+ paramsOrFirst:
+ | {
+ appId: string;
+ name: string;
+ redirectUris: string[];
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ postLogoutRedirectUris?: string[];
+ enabled?: boolean;
+ type?: string;
+ deviceFlow?: boolean;
+ teamId?: string;
+ }
+ | string,
+ ...rest: [
+ string?,
+ string[]?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string[]?,
+ string?,
+ string[]?,
+ string[]?,
+ string?,
+ string?,
+ string[]?,
+ boolean?,
+ string?,
+ boolean?,
+ string?,
+ ]
+ ): Promise {
+ let params: {
+ appId: string;
+ name: string;
+ redirectUris: string[];
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ postLogoutRedirectUris?: string[];
+ enabled?: boolean;
+ type?: string;
+ deviceFlow?: boolean;
+ teamId?: string;
+ };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ name: string;
+ redirectUris: string[];
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ postLogoutRedirectUris?: string[];
+ enabled?: boolean;
+ type?: string;
+ deviceFlow?: boolean;
+ teamId?: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ name: rest[0] as string,
+ redirectUris: rest[1] as string[],
+ description: rest[2] as string,
+ clientUri: rest[3] as string,
+ logoUri: rest[4] as string,
+ privacyPolicyUrl: rest[5] as string,
+ termsUrl: rest[6] as string,
+ contacts: rest[7] as string[],
+ tagline: rest[8] as string,
+ tags: rest[9] as string[],
+ images: rest[10] as string[],
+ supportUrl: rest[11] as string,
+ dataDeletionUrl: rest[12] as string,
+ postLogoutRedirectUris: rest[13] as string[],
+ enabled: rest[14] as boolean,
+ type: rest[15] as string,
+ deviceFlow: rest[16] as boolean,
+ teamId: rest[17] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const name = params.name;
+ const redirectUris = params.redirectUris;
+ const description = params.description;
+ const clientUri = params.clientUri;
+ const logoUri = params.logoUri;
+ const privacyPolicyUrl = params.privacyPolicyUrl;
+ const termsUrl = params.termsUrl;
+ const contacts = params.contacts;
+ const tagline = params.tagline;
+ const tags = params.tags;
+ const images = params.images;
+ const supportUrl = params.supportUrl;
+ const dataDeletionUrl = params.dataDeletionUrl;
+ const postLogoutRedirectUris = params.postLogoutRedirectUris;
+ const enabled = params.enabled;
+ const type = params.type;
+ const deviceFlow = params.deviceFlow;
+ const teamId = params.teamId;
+
+ if (typeof appId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+ if (typeof redirectUris === 'undefined') {
+ throw new AppwriteException(
+ 'Missing required parameter: "redirectUris"',
+ );
+ }
+ const apiPath = '/apps';
+ const payload: Payload = {};
+ if (typeof appId !== 'undefined') {
+ payload['appId'] = appId;
+ }
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+ if (typeof description !== 'undefined') {
+ payload['description'] = description;
+ }
+ if (typeof clientUri !== 'undefined') {
+ payload['clientUri'] = clientUri;
+ }
+ if (typeof logoUri !== 'undefined') {
+ payload['logoUri'] = logoUri;
+ }
+ if (typeof privacyPolicyUrl !== 'undefined') {
+ payload['privacyPolicyUrl'] = privacyPolicyUrl;
+ }
+ if (typeof termsUrl !== 'undefined') {
+ payload['termsUrl'] = termsUrl;
+ }
+ if (typeof contacts !== 'undefined') {
+ payload['contacts'] = contacts;
+ }
+ if (typeof tagline !== 'undefined') {
+ payload['tagline'] = tagline;
+ }
+ if (typeof tags !== 'undefined') {
+ payload['tags'] = tags;
+ }
+ if (typeof images !== 'undefined') {
+ payload['images'] = images;
+ }
+ if (typeof supportUrl !== 'undefined') {
+ payload['supportUrl'] = supportUrl;
+ }
+ if (typeof dataDeletionUrl !== 'undefined') {
+ payload['dataDeletionUrl'] = dataDeletionUrl;
+ }
+ if (typeof redirectUris !== 'undefined') {
+ payload['redirectUris'] = redirectUris;
+ }
+ if (typeof postLogoutRedirectUris !== 'undefined') {
+ payload['postLogoutRedirectUris'] = postLogoutRedirectUris;
+ }
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+ if (typeof type !== 'undefined') {
+ payload['type'] = type;
+ }
+ if (typeof deviceFlow !== 'undefined') {
+ payload['deviceFlow'] = deviceFlow;
+ }
+ if (typeof teamId !== 'undefined') {
+ payload['teamId'] = teamId;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * List scopes an application can request when installed on a team.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listInstallationScopes(): Promise {
+ const apiPath = '/apps/scopes/installations';
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * List scopes an application can request during the OAuth2 flow.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listOAuth2Scopes(): Promise {
+ const apiPath = '/apps/scopes/oauth2';
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Get an application by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ get(params: { appId: string }): Promise;
+ /**
+ * Get an application by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ get(appId: string): Promise;
+ get(paramsOrFirst: { appId: string } | string): Promise {
+ let params: { appId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ };
+ }
+
+ const appId = params.appId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Update an application by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.name - Application name.
+ * @param {string} params.description - Application description shown to users during OAuth2 consent.
+ * @param {string} params.clientUri - Application homepage URL shown to users during OAuth2 consent.
+ * @param {string} params.logoUri - Application logo URL shown to users during OAuth2 consent.
+ * @param {string} params.privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent.
+ * @param {string} params.termsUrl - Application terms of service URL shown to users during OAuth2 consent.
+ * @param {string[]} params.contacts - Application support or security contact emails. Maximum of 100 contacts are allowed.
+ * @param {string} params.tagline - Application tagline shown to users during OAuth2 consent.
+ * @param {string[]} params.tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long.
+ * @param {string[]} params.images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed.
+ * @param {string} params.supportUrl - Application support URL shown to users during OAuth2 consent.
+ * @param {string} params.dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent.
+ * @param {boolean} params.enabled - Is application enabled?
+ * @param {string[]} params.redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment.
+ * @param {string[]} params.postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list.
+ * @param {string} params.type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`.
+ * @param {boolean} params.deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false.
+ * @param {string[]} params.installationScopes - Scopes the application requests when installed on a team. Only scopes allowed by the project's OAuth2 server installation scopes configuration are accepted; use the list installation scopes endpoint to discover available values. Maximum of 100 scopes are allowed.
+ * @param {string} params.installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ update(params: {
+ appId: string;
+ name: string;
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ enabled?: boolean;
+ redirectUris?: string[];
+ postLogoutRedirectUris?: string[];
+ type?: string;
+ deviceFlow?: boolean;
+ installationScopes?: string[];
+ installationRedirectUrl?: string;
+ }): Promise;
+ /**
+ * Update an application by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} name - Application name.
+ * @param {string} description - Application description shown to users during OAuth2 consent.
+ * @param {string} clientUri - Application homepage URL shown to users during OAuth2 consent.
+ * @param {string} logoUri - Application logo URL shown to users during OAuth2 consent.
+ * @param {string} privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent.
+ * @param {string} termsUrl - Application terms of service URL shown to users during OAuth2 consent.
+ * @param {string[]} contacts - Application support or security contact emails. Maximum of 100 contacts are allowed.
+ * @param {string} tagline - Application tagline shown to users during OAuth2 consent.
+ * @param {string[]} tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long.
+ * @param {string[]} images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed.
+ * @param {string} supportUrl - Application support URL shown to users during OAuth2 consent.
+ * @param {string} dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent.
+ * @param {boolean} enabled - Is application enabled?
+ * @param {string[]} redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment.
+ * @param {string[]} postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list.
+ * @param {string} type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`.
+ * @param {boolean} deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false.
+ * @param {string[]} installationScopes - Scopes the application requests when installed on a team. Only scopes allowed by the project's OAuth2 server installation scopes configuration are accepted; use the list installation scopes endpoint to discover available values. Maximum of 100 scopes are allowed.
+ * @param {string} installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ update(
+ appId: string,
+ name: string,
+ description?: string,
+ clientUri?: string,
+ logoUri?: string,
+ privacyPolicyUrl?: string,
+ termsUrl?: string,
+ contacts?: string[],
+ tagline?: string,
+ tags?: string[],
+ images?: string[],
+ supportUrl?: string,
+ dataDeletionUrl?: string,
+ enabled?: boolean,
+ redirectUris?: string[],
+ postLogoutRedirectUris?: string[],
+ type?: string,
+ deviceFlow?: boolean,
+ installationScopes?: string[],
+ installationRedirectUrl?: string,
+ ): Promise;
+ update(
+ paramsOrFirst:
+ | {
+ appId: string;
+ name: string;
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ enabled?: boolean;
+ redirectUris?: string[];
+ postLogoutRedirectUris?: string[];
+ type?: string;
+ deviceFlow?: boolean;
+ installationScopes?: string[];
+ installationRedirectUrl?: string;
+ }
+ | string,
+ ...rest: [
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string[]?,
+ string?,
+ string[]?,
+ string[]?,
+ string?,
+ string?,
+ boolean?,
+ string[]?,
+ string[]?,
+ string?,
+ boolean?,
+ string[]?,
+ string?,
+ ]
+ ): Promise {
+ let params: {
+ appId: string;
+ name: string;
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ enabled?: boolean;
+ redirectUris?: string[];
+ postLogoutRedirectUris?: string[];
+ type?: string;
+ deviceFlow?: boolean;
+ installationScopes?: string[];
+ installationRedirectUrl?: string;
+ };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ name: string;
+ description?: string;
+ clientUri?: string;
+ logoUri?: string;
+ privacyPolicyUrl?: string;
+ termsUrl?: string;
+ contacts?: string[];
+ tagline?: string;
+ tags?: string[];
+ images?: string[];
+ supportUrl?: string;
+ dataDeletionUrl?: string;
+ enabled?: boolean;
+ redirectUris?: string[];
+ postLogoutRedirectUris?: string[];
+ type?: string;
+ deviceFlow?: boolean;
+ installationScopes?: string[];
+ installationRedirectUrl?: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ name: rest[0] as string,
+ description: rest[1] as string,
+ clientUri: rest[2] as string,
+ logoUri: rest[3] as string,
+ privacyPolicyUrl: rest[4] as string,
+ termsUrl: rest[5] as string,
+ contacts: rest[6] as string[],
+ tagline: rest[7] as string,
+ tags: rest[8] as string[],
+ images: rest[9] as string[],
+ supportUrl: rest[10] as string,
+ dataDeletionUrl: rest[11] as string,
+ enabled: rest[12] as boolean,
+ redirectUris: rest[13] as string[],
+ postLogoutRedirectUris: rest[14] as string[],
+ type: rest[15] as string,
+ deviceFlow: rest[16] as boolean,
+ installationScopes: rest[17] as string[],
+ installationRedirectUrl: rest[18] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const name = params.name;
+ const description = params.description;
+ const clientUri = params.clientUri;
+ const logoUri = params.logoUri;
+ const privacyPolicyUrl = params.privacyPolicyUrl;
+ const termsUrl = params.termsUrl;
+ const contacts = params.contacts;
+ const tagline = params.tagline;
+ const tags = params.tags;
+ const images = params.images;
+ const supportUrl = params.supportUrl;
+ const dataDeletionUrl = params.dataDeletionUrl;
+ const enabled = params.enabled;
+ const redirectUris = params.redirectUris;
+ const postLogoutRedirectUris = params.postLogoutRedirectUris;
+ const type = params.type;
+ const deviceFlow = params.deviceFlow;
+ const installationScopes = params.installationScopes;
+ const installationRedirectUrl = params.installationRedirectUrl;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+ const apiPath = '/apps/{appId}'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+ if (typeof description !== 'undefined') {
+ payload['description'] = description;
+ }
+ if (typeof clientUri !== 'undefined') {
+ payload['clientUri'] = clientUri;
+ }
+ if (typeof logoUri !== 'undefined') {
+ payload['logoUri'] = logoUri;
+ }
+ if (typeof privacyPolicyUrl !== 'undefined') {
+ payload['privacyPolicyUrl'] = privacyPolicyUrl;
+ }
+ if (typeof termsUrl !== 'undefined') {
+ payload['termsUrl'] = termsUrl;
+ }
+ if (typeof contacts !== 'undefined') {
+ payload['contacts'] = contacts;
+ }
+ if (typeof tagline !== 'undefined') {
+ payload['tagline'] = tagline;
+ }
+ if (typeof tags !== 'undefined') {
+ payload['tags'] = tags;
+ }
+ if (typeof images !== 'undefined') {
+ payload['images'] = images;
+ }
+ if (typeof supportUrl !== 'undefined') {
+ payload['supportUrl'] = supportUrl;
+ }
+ if (typeof dataDeletionUrl !== 'undefined') {
+ payload['dataDeletionUrl'] = dataDeletionUrl;
+ }
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+ if (typeof redirectUris !== 'undefined') {
+ payload['redirectUris'] = redirectUris;
+ }
+ if (typeof postLogoutRedirectUris !== 'undefined') {
+ payload['postLogoutRedirectUris'] = postLogoutRedirectUris;
+ }
+ if (typeof type !== 'undefined') {
+ payload['type'] = type;
+ }
+ if (typeof deviceFlow !== 'undefined') {
+ payload['deviceFlow'] = deviceFlow;
+ }
+ if (typeof installationScopes !== 'undefined') {
+ payload['installationScopes'] = installationScopes;
+ }
+ if (typeof installationRedirectUrl !== 'undefined') {
+ payload['installationRedirectUrl'] = installationRedirectUrl;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('put', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Delete an application by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ delete(params: { appId: string }): Promise<{}>;
+ /**
+ * Delete an application by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ delete(appId: string): Promise<{}>;
+ delete(paramsOrFirst: { appId: string } | string): Promise<{}> {
+ let params: { appId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ };
+ }
+
+ const appId = params.appId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('delete', uri, apiHeaders, payload);
+ }
+
+ /**
+ * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listInstallations(params: {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ }): Promise;
+ /**
+ * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ listInstallations(
+ appId: string,
+ queries?: string[],
+ total?: boolean,
+ ): Promise;
+ listInstallations(
+ paramsOrFirst:
+ { appId: string; queries?: string[]; total?: boolean } | string,
+ ...rest: [string[]?, boolean?]
+ ): Promise {
+ let params: { appId: string; queries?: string[]; total?: boolean };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ queries: rest[0] as string[],
+ total: rest[1] as boolean,
+ };
+ }
+
+ const appId = params.appId;
+ const queries = params.queries;
+ const total = params.total;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/installations'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+ if (typeof total !== 'undefined') {
+ payload['total'] = total;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ getInstallation(params: {
+ appId: string;
+ installationId: string;
+ }): Promise;
+ /**
+ * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ getInstallation(
+ appId: string,
+ installationId: string,
+ ): Promise;
+ getInstallation(
+ paramsOrFirst: { appId: string; installationId: string } | string,
+ ...rest: [string?]
+ ): Promise {
+ let params: { appId: string; installationId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ installationId: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ installationId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const installationId = params.installationId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof installationId === 'undefined' || installationId === '') {
+ throw new AppwriteException(
+ 'Missing required parameter: "installationId"',
+ );
+ }
+ const apiPath = '/apps/{appId}/installations/{installationId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace(
+ '{installationId}',
+ encodeURIComponent(String(installationId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Delete an installation of an application by its unique ID. Requires a caller with update access to the app. Previously issued installation access tokens are revoked.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ deleteInstallation(params: {
+ appId: string;
+ installationId: string;
+ }): Promise<{}>;
+ /**
+ * Delete an installation of an application by its unique ID. Requires a caller with update access to the app. Previously issued installation access tokens are revoked.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ deleteInstallation(appId: string, installationId: string): Promise<{}>;
+ deleteInstallation(
+ paramsOrFirst: { appId: string; installationId: string } | string,
+ ...rest: [string?]
+ ): Promise<{}> {
+ let params: { appId: string; installationId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ installationId: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ installationId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const installationId = params.installationId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof installationId === 'undefined' || installationId === '') {
+ throw new AppwriteException(
+ 'Missing required parameter: "installationId"',
+ );
+ }
+ const apiPath = '/apps/{appId}/installations/{installationId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace(
+ '{installationId}',
+ encodeURIComponent(String(installationId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('delete', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createInstallationToken(params: {
+ appId: string;
+ installationId: string;
+ }): Promise;
+ /**
+ * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} installationId - Installation unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createInstallationToken(
+ appId: string,
+ installationId: string,
+ ): Promise;
+ createInstallationToken(
+ paramsOrFirst: { appId: string; installationId: string } | string,
+ ...rest: [string?]
+ ): Promise {
+ let params: { appId: string; installationId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ installationId: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ installationId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const installationId = params.installationId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof installationId === 'undefined' || installationId === '') {
+ throw new AppwriteException(
+ 'Missing required parameter: "installationId"',
+ );
+ }
+ const apiPath = '/apps/{appId}/installations/{installationId}/tokens'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace(
+ '{installationId}',
+ encodeURIComponent(String(installationId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * List app keys for an application.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listKeys(params: {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ }): Promise;
+ /**
+ * List app keys for an application.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ listKeys(
+ appId: string,
+ queries?: string[],
+ total?: boolean,
+ ): Promise;
+ listKeys(
+ paramsOrFirst:
+ { appId: string; queries?: string[]; total?: boolean } | string,
+ ...rest: [string[]?, boolean?]
+ ): Promise {
+ let params: { appId: string; queries?: string[]; total?: boolean };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ queries: rest[0] as string[],
+ total: rest[1] as boolean,
+ };
+ }
+
+ const appId = params.appId;
+ const queries = params.queries;
+ const total = params.total;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/keys'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+ if (typeof total !== 'undefined') {
+ payload['total'] = total;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Create a new app key for an application. App keys carry no scopes; send one in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header to list the application's installations and create installation access tokens.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createKey(params: { appId: string }): Promise;
+ /**
+ * Create a new app key for an application. App keys carry no scopes; send one in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header to list the application's installations and create installation access tokens.
+ *
+ * @param {string} appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createKey(appId: string): Promise;
+ createKey(
+ paramsOrFirst: { appId: string } | string,
+ ): Promise {
+ let params: { appId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ };
+ }
+
+ const appId = params.appId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/keys'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Get an app key by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.keyId - App key unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ getKey(params: { appId: string; keyId: string }): Promise;
+ /**
+ * Get an app key by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} keyId - App key unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ getKey(appId: string, keyId: string): Promise;
+ getKey(
+ paramsOrFirst: { appId: string; keyId: string } | string,
+ ...rest: [string?]
+ ): Promise {
+ let params: { appId: string; keyId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string; keyId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ keyId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const keyId = params.keyId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof keyId === 'undefined' || keyId === '') {
+ throw new AppwriteException('Missing required parameter: "keyId"');
+ }
+ const apiPath = '/apps/{appId}/keys/{keyId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace('{keyId}', encodeURIComponent(String(keyId)));
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Delete an app key by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.keyId - App key unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ deleteKey(params: { appId: string; keyId: string }): Promise<{}>;
+ /**
+ * Delete an app key by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} keyId - App key unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ deleteKey(appId: string, keyId: string): Promise<{}>;
+ deleteKey(
+ paramsOrFirst: { appId: string; keyId: string } | string,
+ ...rest: [string?]
+ ): Promise<{}> {
+ let params: { appId: string; keyId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string; keyId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ keyId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const keyId = params.keyId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof keyId === 'undefined' || keyId === '') {
+ throw new AppwriteException('Missing required parameter: "keyId"');
+ }
+ const apiPath = '/apps/{appId}/keys/{keyId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace('{keyId}', encodeURIComponent(String(keyId)));
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('delete', uri, apiHeaders, payload);
+ }
+
+ /**
+ * List client secrets for an application.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listSecrets(params: {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ }): Promise;
+ /**
+ * List client secrets for an application.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ listSecrets(
+ appId: string,
+ queries?: string[],
+ total?: boolean,
+ ): Promise;
+ listSecrets(
+ paramsOrFirst:
+ { appId: string; queries?: string[]; total?: boolean } | string,
+ ...rest: [string[]?, boolean?]
+ ): Promise {
+ let params: { appId: string; queries?: string[]; total?: boolean };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ queries?: string[];
+ total?: boolean;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ queries: rest[0] as string[],
+ total: rest[1] as boolean,
+ };
+ }
+
+ const appId = params.appId;
+ const queries = params.queries;
+ const total = params.total;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/secrets'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+ if (typeof total !== 'undefined') {
+ payload['total'] = total;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Create a new client secret for an application.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createSecret(params: { appId: string }): Promise;
+ /**
+ * Create a new client secret for an application.
+ *
+ * @param {string} appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createSecret(appId: string): Promise;
+ createSecret(
+ paramsOrFirst: { appId: string } | string,
+ ): Promise {
+ let params: { appId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ };
+ }
+
+ const appId = params.appId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/secrets'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Get an application client secret by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.secretId - Secret unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ getSecret(params: {
+ appId: string;
+ secretId: string;
+ }): Promise;
+ /**
+ * Get an application client secret by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} secretId - Secret unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ getSecret(appId: string, secretId: string): Promise;
+ getSecret(
+ paramsOrFirst: { appId: string; secretId: string } | string,
+ ...rest: [string?]
+ ): Promise {
+ let params: { appId: string; secretId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ secretId: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ secretId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const secretId = params.secretId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof secretId === 'undefined' || secretId === '') {
+ throw new AppwriteException(
+ 'Missing required parameter: "secretId"',
+ );
+ }
+ const apiPath = '/apps/{appId}/secrets/{secretId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace('{secretId}', encodeURIComponent(String(secretId)));
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Delete an application client secret by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.secretId - Secret unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ deleteSecret(params: { appId: string; secretId: string }): Promise<{}>;
+ /**
+ * Delete an application client secret by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} secretId - Secret unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ deleteSecret(appId: string, secretId: string): Promise<{}>;
+ deleteSecret(
+ paramsOrFirst: { appId: string; secretId: string } | string,
+ ...rest: [string?]
+ ): Promise<{}> {
+ let params: { appId: string; secretId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ appId: string;
+ secretId: string;
+ };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ secretId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const secretId = params.secretId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof secretId === 'undefined' || secretId === '') {
+ throw new AppwriteException(
+ 'Missing required parameter: "secretId"',
+ );
+ }
+ const apiPath = '/apps/{appId}/secrets/{secretId}'
+ .replace('{appId}', encodeURIComponent(String(appId)))
+ .replace('{secretId}', encodeURIComponent(String(secretId)));
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('delete', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Transfer an application to another team by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @param {string} params.teamId - Team ID of the team to transfer application to.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ updateTeam(params: { appId: string; teamId: string }): Promise;
+ /**
+ * Transfer an application to another team by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @param {string} teamId - Team ID of the team to transfer application to.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ updateTeam(appId: string, teamId: string): Promise;
+ updateTeam(
+ paramsOrFirst: { appId: string; teamId: string } | string,
+ ...rest: [string?]
+ ): Promise {
+ let params: { appId: string; teamId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string; teamId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ teamId: rest[0] as string,
+ };
+ }
+
+ const appId = params.appId;
+ const teamId = params.teamId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+ const apiPath = '/apps/{appId}/team'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ if (typeof teamId !== 'undefined') {
+ payload['teamId'] = teamId;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('patch', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Revoke all tokens for an application by its unique ID.
+ *
+ * @param {string} params.appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ deleteTokens(params: { appId: string }): Promise<{}>;
+ /**
+ * Revoke all tokens for an application by its unique ID.
+ *
+ * @param {string} appId - Application unique ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ deleteTokens(appId: string): Promise<{}>;
+ deleteTokens(paramsOrFirst: { appId: string } | string): Promise<{}> {
+ let params: { appId: string };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as { appId: string };
+ } else {
+ params = {
+ appId: paramsOrFirst as string,
+ };
+ }
+
+ const appId = params.appId;
+
+ if (typeof appId === 'undefined' || appId === '') {
+ throw new AppwriteException('Missing required parameter: "appId"');
+ }
+ const apiPath = '/apps/{appId}/tokens'.replace(
+ '{appId}',
+ encodeURIComponent(String(appId)),
+ );
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'X-Appwrite-Project': this.client.config.project,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('delete', uri, apiHeaders, payload);
+ }
+}
diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts
new file mode 100644
index 0000000..921f690
--- /dev/null
+++ b/src/services/oauth-2.ts
@@ -0,0 +1,1822 @@
+import { AppwriteException, Client, type Payload } from '../client';
+import type { Models } from '../models';
+
+export class Oauth2 {
+ client: Client;
+
+ constructor(client: Client) {
+ this.client = client;
+ }
+
+ /**
+ * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} params.grantId - Grant ID made during authorization, provided to consent screen in URL search params.
+ * @param {string} params.authorizationDetails - Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details.
+ * @param {string} params.scope - Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ approve(params: {
+ grantId: string;
+ authorizationDetails?: string;
+ scope?: string;
+ }): Promise;
+ /**
+ * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} grantId - Grant ID made during authorization, provided to consent screen in URL search params.
+ * @param {string} authorizationDetails - Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details.
+ * @param {string} scope - Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ approve(
+ grantId: string,
+ authorizationDetails?: string,
+ scope?: string,
+ ): Promise;
+ approve(
+ paramsOrFirst:
+ | { grantId: string; authorizationDetails?: string; scope?: string }
+ | string,
+ ...rest: [string?, string?]
+ ): Promise {
+ let params: {
+ grantId: string;
+ authorizationDetails?: string;
+ scope?: string;
+ };
+
+ if (
+ paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst)
+ ) {
+ params = (paramsOrFirst || {}) as {
+ grantId: string;
+ authorizationDetails?: string;
+ scope?: string;
+ };
+ } else {
+ params = {
+ grantId: paramsOrFirst as string,
+ authorizationDetails: rest[0] as string,
+ scope: rest[1] as string,
+ };
+ }
+
+ const grantId = params.grantId;
+ const authorizationDetails = params.authorizationDetails;
+ const scope = params.scope;
+
+ if (typeof grantId === 'undefined') {
+ throw new AppwriteException(
+ 'Missing required parameter: "grantId"',
+ );
+ }
+ const apiPath = '/oauth2/{project_id}/approve'.replace(
+ '{project_id}',
+ encodeURIComponent(String(this.client.config.project)),
+ );
+ const payload: Payload = {};
+ if (typeof grantId !== 'undefined') {
+ payload['grant_id'] = grantId;
+ }
+ if (typeof authorizationDetails !== 'undefined') {
+ payload['authorization_details'] = authorizationDetails;
+ }
+ if (typeof scope !== 'undefined') {
+ payload['scope'] = scope;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} params.redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not.
+ * @param {string} params.responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
+ * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
+ * @param {string} params.state - OAuth2 state. You receive this back in the redirect URI.
+ * @param {string} params.nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
+ * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public.
+ * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public.
+ * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
+ * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
+ * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ authorize(params?: {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ }): Promise;
+ /**
+ * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not.
+ * @param {string} responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
+ * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
+ * @param {string} state - OAuth2 state. You receive this back in the redirect URI.
+ * @param {string} nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
+ * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public.
+ * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public.
+ * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
+ * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
+ * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ authorize(
+ clientId?: string,
+ redirectUri?: string,
+ responseType?: string,
+ scope?: string,
+ state?: string,
+ nonce?: string,
+ codeChallenge?: string,
+ codeChallengeMethod?: string,
+ prompt?: string,
+ maxAge?: number,
+ authorizationDetails?: string,
+ resource?: string,
+ audience?: string,
+ requestUri?: string,
+ ): Promise;
+ authorize(
+ paramsOrFirst?:
+ | {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ }
+ | string,
+ ...rest: [
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ number?,
+ string?,
+ string?,
+ string?,
+ string?,
+ ]
+ ): Promise {
+ let params: {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ };
+
+ if (
+ (typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
+ (paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst))
+ ) {
+ params = (paramsOrFirst || {}) as {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ };
+ } else {
+ params = {
+ clientId: paramsOrFirst as string,
+ redirectUri: rest[0] as string,
+ responseType: rest[1] as string,
+ scope: rest[2] as string,
+ state: rest[3] as string,
+ nonce: rest[4] as string,
+ codeChallenge: rest[5] as string,
+ codeChallengeMethod: rest[6] as string,
+ prompt: rest[7] as string,
+ maxAge: rest[8] as number,
+ authorizationDetails: rest[9] as string,
+ resource: rest[10] as string,
+ audience: rest[11] as string,
+ requestUri: rest[12] as string,
+ };
+ }
+
+ const clientId = params.clientId;
+ const redirectUri = params.redirectUri;
+ const responseType = params.responseType;
+ const scope = params.scope;
+ const state = params.state;
+ const nonce = params.nonce;
+ const codeChallenge = params.codeChallenge;
+ const codeChallengeMethod = params.codeChallengeMethod;
+ const prompt = params.prompt;
+ const maxAge = params.maxAge;
+ const authorizationDetails = params.authorizationDetails;
+ const resource = params.resource;
+ const audience = params.audience;
+ const requestUri = params.requestUri;
+
+ const apiPath = '/oauth2/{project_id}/authorize'.replace(
+ '{project_id}',
+ encodeURIComponent(String(this.client.config.project)),
+ );
+ const payload: Payload = {};
+ if (typeof clientId !== 'undefined') {
+ payload['client_id'] = clientId;
+ }
+ if (typeof redirectUri !== 'undefined') {
+ payload['redirect_uri'] = redirectUri;
+ }
+ if (typeof responseType !== 'undefined') {
+ payload['response_type'] = responseType;
+ }
+ if (typeof scope !== 'undefined') {
+ payload['scope'] = scope;
+ }
+ if (typeof state !== 'undefined') {
+ payload['state'] = state;
+ }
+ if (typeof nonce !== 'undefined') {
+ payload['nonce'] = nonce;
+ }
+ if (typeof codeChallenge !== 'undefined') {
+ payload['code_challenge'] = codeChallenge;
+ }
+ if (typeof codeChallengeMethod !== 'undefined') {
+ payload['code_challenge_method'] = codeChallengeMethod;
+ }
+ if (typeof prompt !== 'undefined') {
+ payload['prompt'] = prompt;
+ }
+ if (typeof maxAge !== 'undefined') {
+ payload['max_age'] = maxAge;
+ }
+ if (typeof authorizationDetails !== 'undefined') {
+ payload['authorization_details'] = authorizationDetails;
+ }
+ if (typeof resource !== 'undefined') {
+ payload['resource'] = resource;
+ }
+ if (typeof audience !== 'undefined') {
+ payload['audience'] = audience;
+ }
+ if (typeof requestUri !== 'undefined') {
+ payload['request_uri'] = requestUri;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ accept: 'application/json',
+ };
+
+ return this.client.call('get', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} params.redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not.
+ * @param {string} params.responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
+ * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
+ * @param {string} params.state - OAuth2 state. You receive this back in the redirect URI.
+ * @param {string} params.nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
+ * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public.
+ * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public.
+ * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
+ * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
+ * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ authorizePost(params?: {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ }): Promise;
+ /**
+ * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect.
+ *
+ * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not.
+ * @param {string} responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
+ * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
+ * @param {string} state - OAuth2 state. You receive this back in the redirect URI.
+ * @param {string} nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
+ * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public.
+ * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public.
+ * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
+ * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
+ * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ authorizePost(
+ clientId?: string,
+ redirectUri?: string,
+ responseType?: string,
+ scope?: string,
+ state?: string,
+ nonce?: string,
+ codeChallenge?: string,
+ codeChallengeMethod?: string,
+ prompt?: string,
+ maxAge?: number,
+ authorizationDetails?: string,
+ resource?: string,
+ audience?: string,
+ requestUri?: string,
+ ): Promise;
+ authorizePost(
+ paramsOrFirst?:
+ | {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ }
+ | string,
+ ...rest: [
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ string?,
+ number?,
+ string?,
+ string?,
+ string?,
+ string?,
+ ]
+ ): Promise {
+ let params: {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ };
+
+ if (
+ (typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
+ (paramsOrFirst &&
+ typeof paramsOrFirst === 'object' &&
+ !Array.isArray(paramsOrFirst))
+ ) {
+ params = (paramsOrFirst || {}) as {
+ clientId?: string;
+ redirectUri?: string;
+ responseType?: string;
+ scope?: string;
+ state?: string;
+ nonce?: string;
+ codeChallenge?: string;
+ codeChallengeMethod?: string;
+ prompt?: string;
+ maxAge?: number;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ requestUri?: string;
+ };
+ } else {
+ params = {
+ clientId: paramsOrFirst as string,
+ redirectUri: rest[0] as string,
+ responseType: rest[1] as string,
+ scope: rest[2] as string,
+ state: rest[3] as string,
+ nonce: rest[4] as string,
+ codeChallenge: rest[5] as string,
+ codeChallengeMethod: rest[6] as string,
+ prompt: rest[7] as string,
+ maxAge: rest[8] as number,
+ authorizationDetails: rest[9] as string,
+ resource: rest[10] as string,
+ audience: rest[11] as string,
+ requestUri: rest[12] as string,
+ };
+ }
+
+ const clientId = params.clientId;
+ const redirectUri = params.redirectUri;
+ const responseType = params.responseType;
+ const scope = params.scope;
+ const state = params.state;
+ const nonce = params.nonce;
+ const codeChallenge = params.codeChallenge;
+ const codeChallengeMethod = params.codeChallengeMethod;
+ const prompt = params.prompt;
+ const maxAge = params.maxAge;
+ const authorizationDetails = params.authorizationDetails;
+ const resource = params.resource;
+ const audience = params.audience;
+ const requestUri = params.requestUri;
+
+ const apiPath = '/oauth2/{project_id}/authorize'.replace(
+ '{project_id}',
+ encodeURIComponent(String(this.client.config.project)),
+ );
+ const payload: Payload = {};
+ if (typeof clientId !== 'undefined') {
+ payload['client_id'] = clientId;
+ }
+ if (typeof redirectUri !== 'undefined') {
+ payload['redirect_uri'] = redirectUri;
+ }
+ if (typeof responseType !== 'undefined') {
+ payload['response_type'] = responseType;
+ }
+ if (typeof scope !== 'undefined') {
+ payload['scope'] = scope;
+ }
+ if (typeof state !== 'undefined') {
+ payload['state'] = state;
+ }
+ if (typeof nonce !== 'undefined') {
+ payload['nonce'] = nonce;
+ }
+ if (typeof codeChallenge !== 'undefined') {
+ payload['code_challenge'] = codeChallenge;
+ }
+ if (typeof codeChallengeMethod !== 'undefined') {
+ payload['code_challenge_method'] = codeChallengeMethod;
+ }
+ if (typeof prompt !== 'undefined') {
+ payload['prompt'] = prompt;
+ }
+ if (typeof maxAge !== 'undefined') {
+ payload['max_age'] = maxAge;
+ }
+ if (typeof authorizationDetails !== 'undefined') {
+ payload['authorization_details'] = authorizationDetails;
+ }
+ if (typeof resource !== 'undefined') {
+ payload['resource'] = resource;
+ }
+ if (typeof audience !== 'undefined') {
+ payload['audience'] = audience;
+ }
+ if (typeof requestUri !== 'undefined') {
+ payload['request_uri'] = requestUri;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ };
+
+ return this.client.call('post', uri, apiHeaders, payload);
+ }
+
+ /**
+ * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval.
+ *
+ * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`.
+ * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createDeviceAuthorization(params?: {
+ clientId?: string;
+ scope?: string;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ }): Promise;
+ /**
+ * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval.
+ *
+ * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
+ * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`.
+ * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
+ * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
+ * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createDeviceAuthorization(
+ clientId?: string,
+ scope?: string,
+ authorizationDetails?: string,
+ resource?: string,
+ audience?: string,
+ ): Promise;
+ createDeviceAuthorization(
+ paramsOrFirst?:
+ | {
+ clientId?: string;
+ scope?: string;
+ authorizationDetails?: string;
+ resource?: string;
+ audience?: string;
+ }
+ | string,
+ ...rest: [string?, string?, string?, string?]
+ ): Promise