@lumeweb/portal-sdk 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/account.d.ts +7 -0
- package/dist/esm/account.js +16 -4
- package/dist/esm/account.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/account.d.ts
CHANGED
|
@@ -65,6 +65,13 @@ declare class AccountApi {
|
|
|
65
65
|
* @returns Result containing login response or error
|
|
66
66
|
*/
|
|
67
67
|
login(loginRequest: LoginRequest): Promise<Result<LoginResponse>>;
|
|
68
|
+
/**
|
|
69
|
+
* Exchange an API key JWT for a login JWT.
|
|
70
|
+
* The API key is sent as the raw Authorization header value (not Bearer).
|
|
71
|
+
* @param apiKey API key JWT to exchange
|
|
72
|
+
* @returns Result containing login response with the login JWT
|
|
73
|
+
*/
|
|
74
|
+
loginWithApiKey(apiKey: string): Promise<Result<LoginResponse>>;
|
|
68
75
|
/**
|
|
69
76
|
* Logout from the account service
|
|
70
77
|
* @returns Result indicating success or failure
|
package/dist/esm/account.js
CHANGED
|
@@ -108,6 +108,20 @@ var AccountApi = class {
|
|
|
108
108
|
return result;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
+
* Exchange an API key JWT for a login JWT.
|
|
112
|
+
* The API key is sent as the raw Authorization header value (not Bearer).
|
|
113
|
+
* @param apiKey API key JWT to exchange
|
|
114
|
+
* @returns Result containing login response with the login JWT
|
|
115
|
+
*/
|
|
116
|
+
async loginWithApiKey(apiKey) {
|
|
117
|
+
const result = await this.fetchJson("/api/auth/key", {
|
|
118
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
119
|
+
method: "POST"
|
|
120
|
+
});
|
|
121
|
+
if (result.success && result.data?.token) this.setToken(result.data.token);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
111
125
|
* Logout from the account service
|
|
112
126
|
* @returns Result indicating success or failure
|
|
113
127
|
*/
|
|
@@ -311,11 +325,9 @@ var AccountApi = class {
|
|
|
311
325
|
* @private
|
|
312
326
|
*/
|
|
313
327
|
buildOptions(init = {}) {
|
|
314
|
-
const headers = {
|
|
315
|
-
"Content-Type": "application/json",
|
|
316
|
-
...init.headers
|
|
317
|
-
};
|
|
328
|
+
const headers = { "Content-Type": "application/json" };
|
|
318
329
|
if (this.jwtToken) headers.Authorization = `Bearer ${this.jwtToken}`;
|
|
330
|
+
Object.assign(headers, init.headers);
|
|
319
331
|
return {
|
|
320
332
|
...init,
|
|
321
333
|
credentials: "include",
|
package/dist/esm/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","names":[],"sources":["../../src/account.ts"],"sourcesContent":["import type { RequestInit } from \"@/types\";\nimport {\n AccountError,\n handleFetchError,\n handleUnknownError,\n OperationPollingOptions,\n Result,\n} from \"@/types\";\n\nimport {\n AccountInfoResponse,\n GetApiAccountQuotaHistoryParams,\n LoginRequest,\n LoginResponse,\n OperationDetailResponse,\n OperationFiltersResponseResponse,\n OperationListItemResponse,\n OTPDisableRequest,\n OTPGenerateResponse,\n OTPValidateRequest,\n OTPVerifyRequest,\n PasswordResetRequest,\n PasswordResetVerifyRequest,\n PongResponse,\n QuotaHistoryResponse,\n QuotaStatusResponse,\n RegisterRequest,\n ResendVerifyEmailRequest,\n UploadLimitResponse,\n VerifyEmailRequest,\n} from \"@/account/generated\";\nimport type {\n OperationsListParams,\n} from \"@/query-utils\";\nimport { buildOperationsQueryParams } from \"@/query-utils\";\nimport { delay, parseResponse, poll } from \"@/http-utils\";\n\n/**\n * Operation status constants\n */\nconst OPERATION_STATUS = {\n COMPLETED: \"completed\",\n FAILED: \"failed\",\n ERROR: \"error\",\n PENDING: \"pending\",\n RUNNING: \"running\",\n} as const;\n\n/**\n * Default settled states for operations\n */\nconst DEFAULT_SETTLED_STATES = [\n OPERATION_STATUS.COMPLETED,\n OPERATION_STATUS.FAILED,\n OPERATION_STATUS.ERROR,\n] as const;\n\ntype SettledState = typeof DEFAULT_SETTLED_STATES[number];\n\nexport { DEFAULT_SETTLED_STATES, OPERATION_STATUS, type SettledState };\n\nexport class AccountApi {\n private _jwtToken?: string;\n private readonly apiUrl: string;\n\n /**\n * Gets the current JWT token\n * @returns {string|undefined} The current JWT token or undefined if not set\n */\n private get jwtToken(): string | undefined {\n return this._jwtToken;\n }\n\n /**\n * Creates a new AccountApi instance\n * @param {string} apiUrl - The base API URL\n */\n constructor(apiUrl: string) {\n const apiUrlParsed = new URL(apiUrl);\n apiUrlParsed.hostname = `account.${apiUrlParsed.hostname}`;\n this.apiUrl = apiUrlParsed.toString();\n }\n\n /**\n * Clears the current JWT token\n */\n public clearToken(): void {\n this._jwtToken = undefined;\n }\n\n /**\n * Confirm a password reset\n * @param passwordResetVerifyRequest Password reset verification details\n * @returns Result indicating success or failure\n */\n public async confirmPasswordReset(\n passwordResetVerifyRequest: PasswordResetVerifyRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/password-reset/confirm\", {\n body: JSON.stringify(passwordResetVerifyRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Disable OTP for two-factor authentication\n * @param otpDisableRequest OTP disable request details\n * @returns Result indicating success or failure\n */\n public async disableOtp(\n otpDisableRequest: OTPDisableRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/otp/disable\", {\n body: JSON.stringify(otpDisableRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Generate OTP for two-factor authentication\n * @returns Result containing OTP response\n */\n public async generateOtp(): Promise<Result<OTPGenerateResponse>> {\n return this.fetchJson<OTPGenerateResponse>(\"/api/auth/otp/generate\", {\n method: \"GET\",\n });\n }\n\n /**\n * Get account information\n * @returns Result containing account info\n */\n public async info(): Promise<Result<AccountInfoResponse>> {\n return this.fetchJson<AccountInfoResponse>(\"/api/account\", {\n method: \"GET\",\n });\n }\n\n public async quota(): Promise<Result<QuotaStatusResponse>> {\n return this.fetchJson<QuotaStatusResponse>(\"/api/account/quota\", {\n method: \"GET\",\n });\n }\n\n public async quotaHistory(\n params?: GetApiAccountQuotaHistoryParams,\n ): Promise<Result<QuotaHistoryResponse>> {\n const url = new URL(\"/api/account/quota/history\", this.apiUrl);\n\n if (params) {\n if (params.start_date) {\n url.searchParams.set(\"start_date\", params.start_date);\n }\n if (params.end_date) {\n url.searchParams.set(\"end_date\", params.end_date);\n }\n if (params.type) {\n url.searchParams.set(\"type\", params.type);\n }\n }\n\n return this.fetchJson<QuotaHistoryResponse>(url.toString(), {\n method: \"GET\",\n });\n }\n\n /**\n * Login to the account service\n * @param loginRequest Login credentials\n * @returns Result containing login response or error\n */\n public async login(\n loginRequest: LoginRequest,\n ): Promise<Result<LoginResponse>> {\n const result = await this.fetchJson<LoginResponse>(\"/api/auth/login\", {\n body: JSON.stringify(loginRequest),\n method: \"POST\",\n });\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Logout from the account service\n * @returns Result indicating success or failure\n */\n public async logout(): Promise<Result<void>> {\n const result = await this.fetchJson<void>(\"/api/auth/logout\", {\n method: \"POST\",\n });\n\n if (result.success) {\n this.clearToken();\n }\n\n return result;\n }\n\n /**\n * Check authentication status\n * @returns Result containing ping response\n */\n public async ping(): Promise<Result<PongResponse>> {\n const result = await this.fetchJson<PongResponse>(\"/api/auth/ping\", {\n method: \"POST\",\n });\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Register a new account\n * @param registerRequest Registration details\n * @returns Result indicating success or failure\n */\n public async register(\n registerRequest: RegisterRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/register\", {\n body: JSON.stringify(registerRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Request account deletion\n * @returns Result indicating success or failure\n */\n public async requestAccountDeletion(): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/delete\", {\n method: \"DELETE\",\n });\n }\n\n /**\n * Request email verification to be resent\n * @param resendRequest Email details for verification\n * @returns Result indicating success or failure\n */\n public async requestEmailVerification(\n resendRequest: ResendVerifyEmailRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/verify-email/resend\", {\n body: JSON.stringify(resendRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Request a password reset\n * @param passwordResetRequest Password reset request details\n * @returns Result indicating success or failure\n */\n public async requestPasswordReset(\n passwordResetRequest: PasswordResetRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/password-reset/request\", {\n body: JSON.stringify(passwordResetRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Sets the JWT token for authentication\n * @param {string} token - The JWT token to set\n */\n public setToken(token: string): void {\n this._jwtToken = token;\n }\n\n /**\n * Update account email address\n * @param email New email address\n * @param password Current password for verification\n * @returns Result indicating success or failure\n */\n public async updateEmail(\n email: string,\n password: string,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/update-email\", {\n body: JSON.stringify({ email, password }),\n method: \"POST\",\n });\n }\n\n /**\n * Update account password\n * @param currentPassword Current password for verification\n * @param newPassword New password to set\n * @returns Result indicating success or failure\n */\n public async updatePassword(\n currentPassword: string,\n newPassword: string,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/update-password\", {\n body: JSON.stringify({\n current_password: currentPassword,\n new_password: newPassword,\n }),\n method: \"POST\",\n });\n }\n\n /**\n * Get upload limit information\n * @returns Result containing upload limit info\n */\n public async uploadLimit(): Promise<Result<UploadLimitResponse>> {\n return this.fetchJson<UploadLimitResponse>(\"/api/upload-limit\", {\n method: \"GET\",\n });\n }\n\n /**\n * Validate OTP for two-factor authentication login\n * @param otpValidateRequest OTP validation details\n * @returns Result containing login response\n */\n public async validateOtp(\n otpValidateRequest: OTPValidateRequest,\n ): Promise<Result<LoginResponse>> {\n const result = await this.fetchJson<LoginResponse>(\n \"/api/auth/otp/validate\",\n {\n body: JSON.stringify(otpValidateRequest),\n method: \"POST\",\n },\n );\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Verify email address\n * @param verifyEmailRequest Email verification details\n * @param login Optional flag to enable auto-login after verification\n * @returns Result indicating success or failure\n */\n public async verifyEmail(\n verifyEmailRequest: VerifyEmailRequest,\n login?: boolean,\n ): Promise<Result<void>> {\n const url = new URL(\"/api/account/verify-email\", this.apiUrl);\n if (login === true) {\n url.searchParams.set(\"login\", \"true\");\n }\n return this.fetchJson<void>(url.toString(), {\n body: JSON.stringify(verifyEmailRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Verify OTP for enabling two-factor authentication\n * @param otpVerifyRequest OTP verification details\n * @returns Result indicating success or failure\n */\n public async verifyOtp(\n otpVerifyRequest: OTPVerifyRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/otp/verify\", {\n body: JSON.stringify(otpVerifyRequest),\n method: \"POST\",\n });\n }\n\n /**\n * List operations with filtering, searching, and pagination\n * \n * @param params Query parameters using query-builder helpers\n * @returns Result containing list of operations\n * \n * @example\n * ```ts\n * const result = await accountApi.listOperations({\n * filters: [\n * { field: \"status\", operator: \"eq\", value: \"completed\" },\n * { field: \"operation\", operator: \"in\", value: [\"upload\", \"download\"] }\n * ],\n * sorters: [{ field: \"id\", order: \"desc\" }],\n * pagination: { start: 0, end: 20, page: 1, pageSize: 20 },\n * search: \"myfile\"\n * });\n * ```\n */\n public async listOperations(\n params?: OperationsListParams,\n ): Promise<Result<OperationListItemResponse>> {\n const url = new URL(\"/api/operations\", this.apiUrl);\n \n if (params) {\n const searchParams = buildOperationsQueryParams(params);\n searchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n }\n \n return this.fetchJson<OperationListItemResponse>(url.toString(), {\n method: \"GET\",\n });\n }\n\n /**\n * Get detailed information for a specific operation\n * @param id The operation ID\n * @returns Result containing operation details\n */\n public async getOperation(\n id: number,\n ): Promise<Result<OperationDetailResponse>> {\n return this.fetchJson<OperationDetailResponse>(`/api/operations/${id}`, {\n method: \"GET\",\n });\n }\n\n /**\n * Get available filter values for operations\n * @returns Result containing filter options\n */\n public async getOperationFilters(): Promise<Result<OperationFiltersResponseResponse>> {\n return this.fetchJson<OperationFiltersResponseResponse>(\"/api/operations/filters\", {\n method: \"GET\",\n });\n }\n\n /**\n * Wait for an operation to complete or reach a settled state\n * @param id The operation ID to wait for\n * @param options Polling options (interval, timeout, settledStates)\n * @returns Result containing the final operation details\n */\n public async waitForOperation(\n id: number,\n options: OperationPollingOptions = {},\n ): Promise<Result<OperationDetailResponse>> {\n const {\n interval = 2000,\n timeout = 300000,\n settledStates = DEFAULT_SETTLED_STATES,\n } = options;\n\n const settledStatesSet = new Set(settledStates);\n\n return poll(\n () => this.getOperation(id),\n (operation) => {\n return !!(operation.status && settledStatesSet.has(operation.status.toLowerCase()));\n },\n { interval, timeout },\n );\n }\n\n /**\n * Builds fetch options with authorization headers\n * @param {RequestInit} [init] - Optional initial request options\n * @returns {RequestInit} The constructed request options\n * @private\n */\n private buildOptions(init: RequestInit = {}): RequestInit {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...init.headers!,\n };\n\n if (this.jwtToken) {\n headers.Authorization = `Bearer ${this.jwtToken}`;\n }\n\n return {\n ...init,\n credentials: \"include\",\n headers,\n };\n }\n\n /**\n * Makes a JSON request to the API\n * @template T\n * @param {string} input - The API endpoint path or absolute URL\n * @param {RequestInit} [init] - Optional request initialization\n * @returns {Promise<Result<T>>} Promise resolving to the result\n * @private\n */\n private async fetchJson<T>(\n input: string,\n init: RequestInit = {},\n ): Promise<Result<T>> {\n try {\n const response = await fetch(\n new URL(input, this.apiUrl).toString(),\n this.buildOptions(init),\n );\n\n if (!response.ok) {\n return {\n error: await handleFetchError(response),\n success: false,\n };\n }\n\n const data = await parseResponse<T>(response);\n return {\n data,\n success: true,\n };\n } catch (e) {\n let error: AccountError;\n if (e instanceof Response) {\n error = await handleFetchError(e);\n } else {\n error = await handleUnknownError(e);\n }\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AAC;;;;;;CAOJ,MAAa,sBAAyE;AACpF,SAAO,KAAK,UAA4C,2BAA2B,EACjF,QAAQ,OACT,CAAC;;;;;;;;CASJ,MAAa,iBACX,IACA,UAAmC,EAAE,EACK;EAC1C,MAAM,EACJ,WAAW,KACX,UAAU,KACV,gBAAgB,2BACd;EAEJ,MAAM,mBAAmB,IAAI,IAAI,cAAc;AAE/C,SAAO,WACC,KAAK,aAAa,GAAG,GAC1B,cAAc;AACb,UAAO,CAAC,EAAE,UAAU,UAAU,iBAAiB,IAAI,UAAU,OAAO,aAAa,CAAC;KAEpF;GAAE;GAAU;GAAS,CACtB;;;;;;;;CASH,AAAQ,aAAa,OAAoB,EAAE,EAAe;EACxD,MAAM,UAAkC;GACtC,gBAAgB;GAChB,GAAG,KAAK;GACT;AAED,MAAI,KAAK,SACP,SAAQ,gBAAgB,UAAU,KAAK;AAGzC,SAAO;GACL,GAAG;GACH,aAAa;GACb;GACD;;;;;;;;;;CAWH,MAAc,UACZ,OACA,OAAoB,EAAE,EACF;AACpB,MAAI;GACF,MAAM,WAAW,MAAM,MACrB,IAAI,IAAI,OAAO,KAAK,OAAO,CAAC,UAAU,EACtC,KAAK,aAAa,KAAK,CACxB;AAED,OAAI,CAAC,SAAS,GACZ,QAAO;IACL,OAAO,MAAM,iBAAiB,SAAS;IACvC,SAAS;IACV;AAIH,UAAO;IACL,YAFiB,cAAiB,SAAS;IAG3C,SAAS;IACV;WACM,GAAG;GACV,IAAI;AACJ,OAAI,aAAa,SACf,SAAQ,MAAM,iBAAiB,EAAE;OAEjC,SAAQ,MAAM,mBAAmB,EAAE;AAErC,UAAO;IACL;IACA,SAAS;IACV"}
|
|
1
|
+
{"version":3,"file":"account.js","names":[],"sources":["../../src/account.ts"],"sourcesContent":["import type { RequestInit } from \"@/types\";\nimport {\n AccountError,\n handleFetchError,\n handleUnknownError,\n OperationPollingOptions,\n Result,\n} from \"@/types\";\n\nimport {\n AccountInfoResponse,\n GetApiAccountQuotaHistoryParams,\n LoginRequest,\n LoginResponse,\n OperationDetailResponse,\n OperationFiltersResponseResponse,\n OperationListItemResponse,\n OTPDisableRequest,\n OTPGenerateResponse,\n OTPValidateRequest,\n OTPVerifyRequest,\n PasswordResetRequest,\n PasswordResetVerifyRequest,\n PongResponse,\n QuotaHistoryResponse,\n QuotaStatusResponse,\n RegisterRequest,\n ResendVerifyEmailRequest,\n UploadLimitResponse,\n VerifyEmailRequest,\n} from \"@/account/generated\";\nimport type {\n OperationsListParams,\n} from \"@/query-utils\";\nimport { buildOperationsQueryParams } from \"@/query-utils\";\nimport { delay, parseResponse, poll } from \"@/http-utils\";\n\n/**\n * Operation status constants\n */\nconst OPERATION_STATUS = {\n COMPLETED: \"completed\",\n FAILED: \"failed\",\n ERROR: \"error\",\n PENDING: \"pending\",\n RUNNING: \"running\",\n} as const;\n\n/**\n * Default settled states for operations\n */\nconst DEFAULT_SETTLED_STATES = [\n OPERATION_STATUS.COMPLETED,\n OPERATION_STATUS.FAILED,\n OPERATION_STATUS.ERROR,\n] as const;\n\ntype SettledState = typeof DEFAULT_SETTLED_STATES[number];\n\nexport { DEFAULT_SETTLED_STATES, OPERATION_STATUS, type SettledState };\n\nexport class AccountApi {\n private _jwtToken?: string;\n private readonly apiUrl: string;\n\n /**\n * Gets the current JWT token\n * @returns {string|undefined} The current JWT token or undefined if not set\n */\n private get jwtToken(): string | undefined {\n return this._jwtToken;\n }\n\n /**\n * Creates a new AccountApi instance\n * @param {string} apiUrl - The base API URL\n */\n constructor(apiUrl: string) {\n const apiUrlParsed = new URL(apiUrl);\n apiUrlParsed.hostname = `account.${apiUrlParsed.hostname}`;\n this.apiUrl = apiUrlParsed.toString();\n }\n\n /**\n * Clears the current JWT token\n */\n public clearToken(): void {\n this._jwtToken = undefined;\n }\n\n /**\n * Confirm a password reset\n * @param passwordResetVerifyRequest Password reset verification details\n * @returns Result indicating success or failure\n */\n public async confirmPasswordReset(\n passwordResetVerifyRequest: PasswordResetVerifyRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/password-reset/confirm\", {\n body: JSON.stringify(passwordResetVerifyRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Disable OTP for two-factor authentication\n * @param otpDisableRequest OTP disable request details\n * @returns Result indicating success or failure\n */\n public async disableOtp(\n otpDisableRequest: OTPDisableRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/otp/disable\", {\n body: JSON.stringify(otpDisableRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Generate OTP for two-factor authentication\n * @returns Result containing OTP response\n */\n public async generateOtp(): Promise<Result<OTPGenerateResponse>> {\n return this.fetchJson<OTPGenerateResponse>(\"/api/auth/otp/generate\", {\n method: \"GET\",\n });\n }\n\n /**\n * Get account information\n * @returns Result containing account info\n */\n public async info(): Promise<Result<AccountInfoResponse>> {\n return this.fetchJson<AccountInfoResponse>(\"/api/account\", {\n method: \"GET\",\n });\n }\n\n public async quota(): Promise<Result<QuotaStatusResponse>> {\n return this.fetchJson<QuotaStatusResponse>(\"/api/account/quota\", {\n method: \"GET\",\n });\n }\n\n public async quotaHistory(\n params?: GetApiAccountQuotaHistoryParams,\n ): Promise<Result<QuotaHistoryResponse>> {\n const url = new URL(\"/api/account/quota/history\", this.apiUrl);\n\n if (params) {\n if (params.start_date) {\n url.searchParams.set(\"start_date\", params.start_date);\n }\n if (params.end_date) {\n url.searchParams.set(\"end_date\", params.end_date);\n }\n if (params.type) {\n url.searchParams.set(\"type\", params.type);\n }\n }\n\n return this.fetchJson<QuotaHistoryResponse>(url.toString(), {\n method: \"GET\",\n });\n }\n\n /**\n * Login to the account service\n * @param loginRequest Login credentials\n * @returns Result containing login response or error\n */\n public async login(\n loginRequest: LoginRequest,\n ): Promise<Result<LoginResponse>> {\n const result = await this.fetchJson<LoginResponse>(\"/api/auth/login\", {\n body: JSON.stringify(loginRequest),\n method: \"POST\",\n });\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Exchange an API key JWT for a login JWT.\n * The API key is sent as the raw Authorization header value (not Bearer).\n * @param apiKey API key JWT to exchange\n * @returns Result containing login response with the login JWT\n */\n public async loginWithApiKey(\n apiKey: string,\n ): Promise<Result<LoginResponse>> {\n const result = await this.fetchJson<LoginResponse>(\"/api/auth/key\", {\n headers: { Authorization: `Bearer ${apiKey}` } as Record<string, string>,\n method: \"POST\",\n });\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Logout from the account service\n * @returns Result indicating success or failure\n */\n public async logout(): Promise<Result<void>> {\n const result = await this.fetchJson<void>(\"/api/auth/logout\", {\n method: \"POST\",\n });\n\n if (result.success) {\n this.clearToken();\n }\n\n return result;\n }\n\n /**\n * Check authentication status\n * @returns Result containing ping response\n */\n public async ping(): Promise<Result<PongResponse>> {\n const result = await this.fetchJson<PongResponse>(\"/api/auth/ping\", {\n method: \"POST\",\n });\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Register a new account\n * @param registerRequest Registration details\n * @returns Result indicating success or failure\n */\n public async register(\n registerRequest: RegisterRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/register\", {\n body: JSON.stringify(registerRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Request account deletion\n * @returns Result indicating success or failure\n */\n public async requestAccountDeletion(): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/delete\", {\n method: \"DELETE\",\n });\n }\n\n /**\n * Request email verification to be resent\n * @param resendRequest Email details for verification\n * @returns Result indicating success or failure\n */\n public async requestEmailVerification(\n resendRequest: ResendVerifyEmailRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/verify-email/resend\", {\n body: JSON.stringify(resendRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Request a password reset\n * @param passwordResetRequest Password reset request details\n * @returns Result indicating success or failure\n */\n public async requestPasswordReset(\n passwordResetRequest: PasswordResetRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/password-reset/request\", {\n body: JSON.stringify(passwordResetRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Sets the JWT token for authentication\n * @param {string} token - The JWT token to set\n */\n public setToken(token: string): void {\n this._jwtToken = token;\n }\n\n /**\n * Update account email address\n * @param email New email address\n * @param password Current password for verification\n * @returns Result indicating success or failure\n */\n public async updateEmail(\n email: string,\n password: string,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/update-email\", {\n body: JSON.stringify({ email, password }),\n method: \"POST\",\n });\n }\n\n /**\n * Update account password\n * @param currentPassword Current password for verification\n * @param newPassword New password to set\n * @returns Result indicating success or failure\n */\n public async updatePassword(\n currentPassword: string,\n newPassword: string,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/account/update-password\", {\n body: JSON.stringify({\n current_password: currentPassword,\n new_password: newPassword,\n }),\n method: \"POST\",\n });\n }\n\n /**\n * Get upload limit information\n * @returns Result containing upload limit info\n */\n public async uploadLimit(): Promise<Result<UploadLimitResponse>> {\n return this.fetchJson<UploadLimitResponse>(\"/api/upload-limit\", {\n method: \"GET\",\n });\n }\n\n /**\n * Validate OTP for two-factor authentication login\n * @param otpValidateRequest OTP validation details\n * @returns Result containing login response\n */\n public async validateOtp(\n otpValidateRequest: OTPValidateRequest,\n ): Promise<Result<LoginResponse>> {\n const result = await this.fetchJson<LoginResponse>(\n \"/api/auth/otp/validate\",\n {\n body: JSON.stringify(otpValidateRequest),\n method: \"POST\",\n },\n );\n\n if (result.success && result.data?.token) {\n this.setToken(result.data.token);\n }\n\n return result;\n }\n\n /**\n * Verify email address\n * @param verifyEmailRequest Email verification details\n * @param login Optional flag to enable auto-login after verification\n * @returns Result indicating success or failure\n */\n public async verifyEmail(\n verifyEmailRequest: VerifyEmailRequest,\n login?: boolean,\n ): Promise<Result<void>> {\n const url = new URL(\"/api/account/verify-email\", this.apiUrl);\n if (login === true) {\n url.searchParams.set(\"login\", \"true\");\n }\n return this.fetchJson<void>(url.toString(), {\n body: JSON.stringify(verifyEmailRequest),\n method: \"POST\",\n });\n }\n\n /**\n * Verify OTP for enabling two-factor authentication\n * @param otpVerifyRequest OTP verification details\n * @returns Result indicating success or failure\n */\n public async verifyOtp(\n otpVerifyRequest: OTPVerifyRequest,\n ): Promise<Result<void>> {\n return this.fetchJson<void>(\"/api/auth/otp/verify\", {\n body: JSON.stringify(otpVerifyRequest),\n method: \"POST\",\n });\n }\n\n /**\n * List operations with filtering, searching, and pagination\n * \n * @param params Query parameters using query-builder helpers\n * @returns Result containing list of operations\n * \n * @example\n * ```ts\n * const result = await accountApi.listOperations({\n * filters: [\n * { field: \"status\", operator: \"eq\", value: \"completed\" },\n * { field: \"operation\", operator: \"in\", value: [\"upload\", \"download\"] }\n * ],\n * sorters: [{ field: \"id\", order: \"desc\" }],\n * pagination: { start: 0, end: 20, page: 1, pageSize: 20 },\n * search: \"myfile\"\n * });\n * ```\n */\n public async listOperations(\n params?: OperationsListParams,\n ): Promise<Result<OperationListItemResponse>> {\n const url = new URL(\"/api/operations\", this.apiUrl);\n \n if (params) {\n const searchParams = buildOperationsQueryParams(params);\n searchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n }\n \n return this.fetchJson<OperationListItemResponse>(url.toString(), {\n method: \"GET\",\n });\n }\n\n /**\n * Get detailed information for a specific operation\n * @param id The operation ID\n * @returns Result containing operation details\n */\n public async getOperation(\n id: number,\n ): Promise<Result<OperationDetailResponse>> {\n return this.fetchJson<OperationDetailResponse>(`/api/operations/${id}`, {\n method: \"GET\",\n });\n }\n\n /**\n * Get available filter values for operations\n * @returns Result containing filter options\n */\n public async getOperationFilters(): Promise<Result<OperationFiltersResponseResponse>> {\n return this.fetchJson<OperationFiltersResponseResponse>(\"/api/operations/filters\", {\n method: \"GET\",\n });\n }\n\n /**\n * Wait for an operation to complete or reach a settled state\n * @param id The operation ID to wait for\n * @param options Polling options (interval, timeout, settledStates)\n * @returns Result containing the final operation details\n */\n public async waitForOperation(\n id: number,\n options: OperationPollingOptions = {},\n ): Promise<Result<OperationDetailResponse>> {\n const {\n interval = 2000,\n timeout = 300000,\n settledStates = DEFAULT_SETTLED_STATES,\n } = options;\n\n const settledStatesSet = new Set(settledStates);\n\n return poll(\n () => this.getOperation(id),\n (operation) => {\n return !!(operation.status && settledStatesSet.has(operation.status.toLowerCase()));\n },\n { interval, timeout },\n );\n }\n\n /**\n * Builds fetch options with authorization headers\n * @param {RequestInit} [init] - Optional initial request options\n * @returns {RequestInit} The constructed request options\n * @private\n */\n private buildOptions(init: RequestInit = {}): RequestInit {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (this.jwtToken) {\n headers.Authorization = `Bearer ${this.jwtToken}`;\n }\n\n // Custom headers from init take precedence over defaults\n Object.assign(headers, init.headers);\n\n return {\n ...init,\n credentials: \"include\",\n headers,\n };\n }\n\n /**\n * Makes a JSON request to the API\n * @template T\n * @param {string} input - The API endpoint path or absolute URL\n * @param {RequestInit} [init] - Optional request initialization\n * @returns {Promise<Result<T>>} Promise resolving to the result\n * @private\n */\n private async fetchJson<T>(\n input: string,\n init: RequestInit = {},\n ): Promise<Result<T>> {\n try {\n const response = await fetch(\n new URL(input, this.apiUrl).toString(),\n this.buildOptions(init),\n );\n\n if (!response.ok) {\n return {\n error: await handleFetchError(response),\n success: false,\n };\n }\n\n const data = await parseResponse<T>(response);\n return {\n data,\n success: true,\n };\n } catch (e) {\n let error: AccountError;\n if (e instanceof Response) {\n error = await handleFetchError(e);\n } else {\n error = await handleUnknownError(e);\n }\n return {\n error,\n success: false,\n };\n }\n }\n}\n"],"mappings":";;;;;;;;AAwCA,MAAM,mBAAmB;CACvB,WAAW;CACX,QAAQ;CACR,OAAO;CACP,SAAS;CACT,SAAS;CACV;;;;AAKD,MAAM,yBAAyB;CAC7B,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAClB;AAMD,IAAa,aAAb,MAAwB;CACtB,AAAQ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