mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 19:28:09 +00:00
25 lines
472 B
JavaScript
25 lines
472 B
JavaScript
import token from "~/pages/api/auth/Token";
|
|
|
|
export default class SecurityClient {
|
|
static #token = "";
|
|
|
|
contructor() {}
|
|
|
|
static setToken(token) {
|
|
this.#token = token;
|
|
}
|
|
|
|
static async fetchCall(resource, options) {
|
|
let req = new Request(resource, options);
|
|
|
|
if (this.#token == "") {
|
|
this.setToken(await token());
|
|
}
|
|
|
|
if (this.#token) {
|
|
req.headers.set("Authorization", "Bearer " + this.#token);
|
|
return fetch(req);
|
|
}
|
|
}
|
|
}
|