diff --git a/CHANGELOG.md b/CHANGELOG.md index e1022c5..0a606ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 15.2.0 + +* Added: Realtime connections now send the configured JWT for authentication. + ## 15.1.1 * Breaking: Removed `getQueuePriorityBuilds` from `Health` along with the `/health/queue/builds-priority` endpoint diff --git a/README.md b/README.md index 20798f7..0929c51 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/package-lock.json b/package-lock.json index 73c53af..456743a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "15.1.1", + "version": "15.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "15.1.1", + "version": "15.2.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index 2057481..91fc794 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "15.1.1", + "version": "15.2.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index d31c15c..a9b8cc4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -392,7 +392,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '15.1.1', + 'x-sdk-version': '15.2.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -717,7 +717,11 @@ class Client { const encodedProject = encodeURIComponent((this.config.project as string) ?? ''); // URL carries only the project; channels/queries are sent via subscribe message. - const queryParams = 'project=' + encodedProject; + let queryParams = 'project=' + encodedProject; + + if (this.config.jwt) { + queryParams += '&jwt=' + encodeURIComponent(this.config.jwt as string); + } const url = this.config.endpointRealtime + '/realtime?' + queryParams; diff --git a/src/services/realtime.ts b/src/services/realtime.ts index 7aebdaa..ebd4131 100644 --- a/src/services/realtime.ts +++ b/src/services/realtime.ts @@ -205,7 +205,12 @@ export class Realtime { } // URL carries only the project; channels/queries are sent via the subscribe message. - const queryParams = `project=${projectId}`; + let queryParams = `project=${projectId}`; + + const jwt = this.client.config.jwt; + if (jwt) { + queryParams += `&jwt=${encodeURIComponent(jwt)}`; + } const endpoint = this.client.config.endpointRealtime !== '' diff --git a/src/services/usage.ts b/src/services/usage.ts index 73cc1a2..1cef4ed 100644 --- a/src/services/usage.ts +++ b/src/services/usage.ts @@ -23,7 +23,7 @@ export class Usage { * @param {string} params.resource - Resource type filter (singular form). Common values: function, site, database, bucket, file, webhook, team, user, project. * @param {string} params.resourceId - Resource id filter. * @param {string} params.interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, country, region, hostname, osName, clientType, clientName, deviceName, teamId, resourceId. + * @param {string[]} params.dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resource, country, region, hostname, osName, clientType, clientName, deviceName, teamId, resourceId. * @param {string} params.startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} params.endAt - Range end in ISO 8601. Defaults to the current time. * @param {string} params.orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. @@ -47,7 +47,7 @@ export class Usage { * @param {string} resource - Resource type filter (singular form). Common values: function, site, database, bucket, file, webhook, team, user, project. * @param {string} resourceId - Resource id filter. * @param {string} interval - Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. - * @param {string[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, country, region, hostname, osName, clientType, clientName, deviceName, teamId, resourceId. + * @param {string[]} dimensions - Break-down dimensions (max 10). Allowed: path, method, status, service, resource, country, region, hostname, osName, clientType, clientName, deviceName, teamId, resourceId. * @param {string} startAt - Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). * @param {string} endAt - Range end in ISO 8601. Defaults to the current time. * @param {string} orderBy - Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value.