feat(jslib): getRaw can return authenticated url
ci/woodpecker/push/woodpecker Pipeline was successful Details

feat/plugins-backend
Tomáš Mládek 2024-04-08 21:40:14 +02:00
parent a30ef465a3
commit 3b32597fb6
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@upnd/upend", "name": "@upnd/upend",
"version": "0.5.2", "version": "0.5.3",
"description": "Client library to interact with the UpEnd system.", "description": "Client library to interact with the UpEnd system.",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -231,8 +231,15 @@ export class UpEndApi {
}); });
} }
public getRaw(address: Address, preview = false) { public getRaw(
return `${this.apiUrl}/${preview ? "thumb" : "raw"}/${address}`; address: Address,
config?: { preview?: boolean; authenticated?: boolean },
) {
let result = `${this.apiUrl}/${config?.preview ? "thumb" : "raw"}/${address}`;
if (config?.authenticated) {
result += `?key=${this.key}`;
}
return result;
} }
public async fetchRaw( public async fetchRaw(
@ -241,7 +248,7 @@ export class UpEndApi {
options?: ApiFetchOptions, options?: ApiFetchOptions,
) { ) {
dbg("Getting %s raw (preview = %s)", address, preview); dbg("Getting %s raw (preview = %s)", address, preview);
return await this.fetch(this.getRaw(address, preview), options); return await this.fetch(this.getRaw(address, { preview }), options);
} }
public async refreshVault(options?: ApiFetchOptions) { public async refreshVault(options?: ApiFetchOptions) {