feat(jslib): getRaw can return authenticated url
This commit is contained in:
parent
49420e53c2
commit
143a2c8ad2
2 changed files with 11 additions and 4 deletions
|
@ -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",
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue