Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update API calls to use v2 (#2159)

Leendert de Borst3a37642da969
diff --git a/apps/browser-extension/src/utils/WebApiService.ts b/apps/browser-extension/src/utils/WebApiService.ts
index 25d10bd3f..5fe490312 100644
--- a/apps/browser-extension/src/utils/WebApiService.ts
+++ b/apps/browser-extension/src/utils/WebApiService.ts
@@ -37,11 +37,12 @@ type TokenResponse = {
*/
export class WebApiService {
/**
- * Get the base URL for the API from settings.
+ * Get the base URL for the API from settings. This client speaks the v2 API exclusively — every endpoint
+ * (vault, auth, email, favicon, ...) is resolved under the /v2/ prefix.
*/
private async getBaseUrl(): Promise<string> {
const apiUrl = await this.getApiUrl();
- return apiUrl.replace(/\/$/, '') + '/v1/';
+ return apiUrl.replace(/\/$/, '') + '/v2/';
}
/**
diff --git a/apps/browser-extension/src/utils/auth/SrpAuthService.ts b/apps/browser-extension/src/utils/auth/SrpAuthService.ts
index b0d0eb40b..9a7ea8fa4 100644
--- a/apps/browser-extension/src/utils/auth/SrpAuthService.ts
+++ b/apps/browser-extension/src/utils/auth/SrpAuthService.ts
@@ -337,7 +337,7 @@ export class SrpAuthService {
const registerRequest = await SrpAuthService.prepareRegistration(username, password);
// Normalize the API URL
- const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v1/';
+ const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v2/';
// Send registration request to API
const response = await fetch(`${baseUrl}Auth/register`, {
@@ -393,7 +393,7 @@ export class SrpAuthService {
error?: string;
}> {
try {
- const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v1/';
+ const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v2/';
const normalizedUsername = SrpAuthService.normalizeUsername(username);
// Step 1: Initiate login
diff --git a/apps/browser-extension/tests/global-setup.ts b/apps/browser-extension/tests/global-setup.ts
index 86324ffd6..cd8d6da07 100644
--- a/apps/browser-extension/tests/global-setup.ts
+++ b/apps/browser-extension/tests/global-setup.ts
@@ -17,7 +17,7 @@ const DEFAULT_API_URL = process.env.ALIASVAULT_API_URL || 'http://localhost:5100
* testable with this suite because the tests share one IP against a persistent DB.
*/
async function setServerSetting(apiUrl: string, key: string, value: string): Promise<void> {
- const url = `${apiUrl.replace(/\/$/, '')}/v1/Test/server-settings`;
+ const url = `${apiUrl.replace(/\/$/, '')}/v2/Test/server-settings`;
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
diff --git a/apps/browser-extension/tests/helpers/test-api.ts b/apps/browser-extension/tests/helpers/test-api.ts
index 04436e019..8ae54d3ee 100644
--- a/apps/browser-extension/tests/helpers/test-api.ts
+++ b/apps/browser-extension/tests/helpers/test-api.ts
@@ -302,7 +302,7 @@ async function uploadInitialVault(
username: string,
encryptionKey: Uint8Array
): Promise<void> {
- const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v1/';
+ const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v2/';
// Create an empty vault database
const vaultBase64 = createEmptyVaultDatabase();
@@ -361,7 +361,7 @@ export async function registerTestUser(
password: string
): Promise<TokenModel> {
// Normalize the API URL
- const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v1/';
+ const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v2/';
// Prepare registration data
const { request: registerRequest, encryptionKey } = await prepareRegistration(username, password);
@@ -422,7 +422,7 @@ export async function createTestUser(apiBaseUrl: string): Promise<TestUser> {
*/
export async function isApiAvailable(apiBaseUrl: string): Promise<boolean> {
try {
- const response = await fetch(`${apiBaseUrl.replace(/\/$/, '')}/v1/Auth/status`, {
+ const response = await fetch(`${apiBaseUrl.replace(/\/$/, '')}/v2/Auth/status`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -443,7 +443,7 @@ export async function isApiAvailable(apiBaseUrl: string): Promise<boolean> {
* @returns The TOTP secret that can be used to generate codes
*/
export async function enableTwoFactor(apiBaseUrl: string, token: string): Promise<string> {
- const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v1/';
+ const baseUrl = apiBaseUrl.replace(/\/$/, '') + '/v2/';
// Step 1: Enable 2FA to get the secret
const enableResponse = await fetch(`${baseUrl}TwoFactorAuth/enable`, {