diff --git a/sdks/js/package.json b/sdks/js/package.json index ed103fe..1599835 100644 --- a/sdks/js/package.json +++ b/sdks/js/package.json @@ -1,6 +1,6 @@ { "name": "@upnd/upend", - "version": "0.5.2", + "version": "0.5.3", "description": "Client library to interact with the UpEnd system.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/sdks/js/src/api.ts b/sdks/js/src/api.ts index 083c355..942ba18 100644 --- a/sdks/js/src/api.ts +++ b/sdks/js/src/api.ts @@ -231,8 +231,15 @@ export class UpEndApi { }); } - public getRaw(address: Address, preview = false) { - return `${this.apiUrl}/${preview ? "thumb" : "raw"}/${address}`; + public getRaw( + 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( @@ -241,7 +248,7 @@ export class UpEndApi { options?: ApiFetchOptions, ) { 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) {