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

Filter by extension

Filter by extension


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

## 22.3.0

* Added: Regional cloud endpoints are now derived from your configured endpoint in `init` and `push`
* Added: `push` creates a default function proxy rule when an existing function is missing one
* Added: `push` aborts and asks you to re-run when tablesDB deletions change the config
* Fixed: Unauthorized sessions now retry an OAuth token refresh before logging out
* Fixed: Auth security policies `limit`, `sessionsLimit`, and `passwordHistory` now accept null for unlimited
* Updated: `push` applies service, protocol, auth method, and policy updates concurrently
* Updated: Verbose error logs now include `code`, `type`, and `response` details

## 22.2.2

* Fixed: Release binaries now embed `@napi-rs/keyring` native bindings for all targets
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using

```sh
$ appwrite -v
22.2.2
22.3.0
```

### Install using prebuilt binaries
Expand Down Expand Up @@ -83,7 +83,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
Once the installation completes, you can verify your install using
```
$ appwrite -v
22.2.2
22.3.0
```

## Getting Started
Expand Down
4 changes: 2 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# You can use "View source" of this page to see the full script.

# REPO
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.2/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.2/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.3.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.3.0/appwrite-cli-win-arm64.exe"

$APPWRITE_BINARY_NAME = "appwrite.exe"

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ verifyMacOSCodeSignature() {
downloadBinary() {
echo "[2/5] Downloading executable for $OS ($ARCH) ..."

GITHUB_LATEST_VERSION="22.2.2"
GITHUB_LATEST_VERSION="22.3.0"
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"

Expand Down
14 changes: 13 additions & 1 deletion lib/auth/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inquirer from "inquirer";
import { Account, type Models } from "@appwrite.io/console";
import { sdkForConsole } from "../sdks.js";
import { getValidAccessToken, sdkForConsole } from "../sdks.js";
import { globalConfig, normalizeCloudConsoleEndpoint } from "../config.js";
import {
EXECUTABLE_NAME,
Expand Down Expand Up @@ -138,6 +138,18 @@ export const getCurrentAccount = async (): Promise<Models.User | null> => {
return account;
} catch (err) {
if (isGuestUnauthorizedError(err)) {
try {
await getValidAccessToken(globalConfig.getEndpoint(), {
forceRefresh: true,
});
const refreshedClient = await sdkForConsole();
const refreshedAccount = await new Account(refreshedClient).get();
globalConfig.setEmail(refreshedAccount.email);
return refreshedAccount;
} catch (_refreshError) {
// Fall through to local cleanup only after refresh recovery fails.
}

removeCurrentSession();
}
return null;
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ const SettingsSchema = z
security: z
.object({
duration: z.union([z.number(), z.bigint()]).optional(),
limit: z.union([z.number(), z.bigint()]).optional(),
sessionsLimit: z.union([z.number(), z.bigint()]).optional(),
passwordHistory: z.union([z.number(), z.bigint()]).optional(),
limit: z.union([z.number(), z.bigint()]).nullable().optional(),
sessionsLimit: z.union([z.number(), z.bigint()]).nullable().optional(),
passwordHistory: z.union([z.number(), z.bigint()]).nullable().optional(),
passwordDictionary: z.boolean().optional(),
personalDataCheck: z.boolean().optional(),
sessionAlerts: z.boolean().optional(),
Expand Down
15 changes: 8 additions & 7 deletions lib/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ const getExistingProjectSummary = async (
};
};

const getRegionalCloudEndpoint = (region: string): string => {
const url = new URL(globalConfig.getEndpoint() || DEFAULT_ENDPOINT);
url.hostname = `${region}.${url.hostname}`;
return url.toString().replace(/\/$/, "");
};

const printInitProjectSuccess = (message: string): void => {
console.log(`${chalk.green.bold("✓")} ${chalk.green(message)}`);
};
Expand Down Expand Up @@ -359,7 +365,6 @@ const initProject = async ({
}

localConfig.clear(); // Clear the config to avoid any conflicts
const url = new URL(DEFAULT_ENDPOINT);

if (answers.start === "new") {
let projectIdToCreate;
Expand Down Expand Up @@ -394,9 +399,7 @@ const initProject = async ({
localConfig.setProject(response["$id"], response.name ?? "");
localConfig.setOrganizationId(answers.organization);
if (answers.region) {
localConfig.setEndpoint(
`https://${answers.region}.${url.host}${url.pathname}`,
);
localConfig.setEndpoint(getRegionalCloudEndpoint(answers.region));
}
} else {
let selectedProject;
Expand All @@ -417,9 +420,7 @@ const initProject = async ({
localConfig.setOrganizationId(answers.organization);

if (isCloud() && selectedProject.region) {
localConfig.setEndpoint(
`https://${selectedProject.region}.${url.host}${url.pathname}`,
);
localConfig.setEndpoint(getRegionalCloudEndpoint(selectedProject.region));
}
}

Expand Down
Loading