@faable/sdk-base 1.0.5 → 1.0.7

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.
@@ -19,7 +19,7 @@ export const createClientCredentials = (params) => {
19
19
  if (!auth_domain) {
20
20
  throw new Error(`No domain set in createClientCredentials. Use ${AUTH_DOMAIN} environment variable`);
21
21
  }
22
- const store = createTokenStore();
22
+ const store = createTokenStore({ debug });
23
23
  const queue = new PQueue({ concurrency: 1, timeout: 20 * 1000 });
24
24
  const isTokenExpired = (token) => {
25
25
  const { access_token } = token;
@@ -1,8 +1,12 @@
1
1
  export interface ClientCredentialsResponse {
2
2
  access_token: string;
3
3
  }
4
- export declare const createTokenStore: () => {
4
+ type TokenStoreOptions = {
5
+ debug?: boolean;
6
+ };
7
+ export declare const createTokenStore: ({ debug }?: TokenStoreOptions) => {
5
8
  saveToken: (token: ClientCredentialsResponse) => ClientCredentialsResponse;
6
9
  getToken: () => ClientCredentialsResponse | null;
7
10
  };
11
+ export {};
8
12
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/auth/client_credentials/store.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB;uBAMD,yBAAyB;;CASpD,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/auth/client_credentials/store.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAe,iBAAiB;uBAMjC,yBAAyB;;CASpD,CAAC"}
@@ -1,11 +1,11 @@
1
- export const createTokenStore = () => {
1
+ export const createTokenStore = ({ debug } = {}) => {
2
2
  let _stored_token;
3
3
  const getToken = () => {
4
4
  return _stored_token;
5
5
  };
6
6
  const saveToken = (token) => {
7
7
  _stored_token = token;
8
- console.log(`[SDK] Token stored successfully`);
8
+ debug && console.log(`[SDK] Token stored successfully`);
9
9
  return _stored_token;
10
10
  };
11
11
  return {
@@ -19,7 +19,7 @@ export const fetcher_axios = (params = {}) => {
19
19
  });
20
20
  instance.interceptors.request.use(async (req) => {
21
21
  const auth_data = params.auth && (await params.auth.hook());
22
- req.headers = auth_data?.headers;
22
+ req.headers.set(auth_data?.headers || {});
23
23
  return req;
24
24
  });
25
25
  // Add base interceptor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/sdk-base",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "author": "Marc Pomar <marc@faable.com>",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",