@triveria/wallet 0.0.274 → 0.0.277

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.
package/auth.js CHANGED
@@ -12,15 +12,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RequestToken = void 0;
15
+ exports.RequestToken = RequestToken;
16
16
  const axios_1 = __importDefault(require("axios"));
17
+ const node_localstorage_1 = require("node-localstorage");
18
+ const jwt_decode_1 = require("jwt-decode");
17
19
  function RequestToken(tokenUrl, audience, clientId, clientSecret) {
18
20
  return __awaiter(this, void 0, void 0, function* () {
21
+ let storage;
22
+ // Check whether we are in browser (window not undefined) or not and use the according storage
23
+ if (typeof window !== "undefined") {
24
+ storage = localStorage;
25
+ }
26
+ else {
27
+ storage = new node_localstorage_1.LocalStorage('./.data');
28
+ }
29
+ const token = storage.getItem("token");
30
+ if (token !== null) {
31
+ const decoded = (0, jwt_decode_1.jwtDecode)(token);
32
+ if (decoded.exp !== undefined && decoded.exp > Date.now() / 1000) {
33
+ return token;
34
+ }
35
+ }
19
36
  const body = `{"client_id":"${clientId}","client_secret":"${clientSecret}","audience":"${audience}","grant_type":"client_credentials"}`, headers = { 'content-type': 'application/json' };
20
37
  const { data: { access_token } } = yield axios_1.default.post(`${tokenUrl}`, body, {
21
38
  headers,
22
39
  });
40
+ storage.setItem("token", access_token);
23
41
  return access_token;
24
42
  });
25
43
  }
26
- exports.RequestToken = RequestToken;
package/base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Triveria Wallet API
3
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
3
+ * Triveria Wallet API
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0.0
6
6
  *
package/base.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable */
4
4
  /**
5
5
  * Triveria Wallet API
6
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
6
+ * Triveria Wallet API
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0.0
9
9
  *
package/common.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Triveria Wallet API
3
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
3
+ * Triveria Wallet API
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0.0
6
6
  *
@@ -25,4 +25,4 @@ export declare const setOAuthToObject: (object: any, name: string, scopes: strin
25
25
  export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
26
26
  export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
27
27
  export declare const toPathString: (url: URL) => string;
28
- export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
28
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
package/common.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable */
4
4
  /**
5
5
  * Triveria Wallet API
6
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
6
+ * Triveria Wallet API
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0.0
9
9
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Triveria Wallet API
3
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
3
+ * Triveria Wallet API
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0.0
6
6
  *
package/configuration.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /* tslint:disable */
3
3
  /**
4
4
  * Triveria Wallet API
5
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
5
+ * Triveria Wallet API
6
6
  *
7
7
  * The version of the OpenAPI document: 1.0.0
8
8
  *
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Triveria Wallet API
3
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
3
+ * Triveria Wallet API
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0.0
6
6
  *
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable */
4
4
  /**
5
5
  * Triveria Wallet API
6
- * Triveria Wallet API allows to manage credentials inside a specific wallet and interactions between wallets as specified by the OIDC4VC specification.
6
+ * Triveria Wallet API
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0.0
9
9
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@triveria/wallet",
3
3
  "private": false,
4
- "version": "0.0.274",
4
+ "version": "0.0.277",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -13,10 +13,14 @@
13
13
  "author": "",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
- "axios": "^1.6.5"
16
+ "axios": "^1.6.5",
17
+ "jwt-decode": "^4.0.0",
18
+ "node-localstorage": "^3.0.5",
19
+ "ts-localstorage": "^3.1.0"
17
20
  },
18
21
  "devDependencies": {
19
22
  "@types/node": "^20.10.6",
23
+ "@types/node-localstorage": "^1.3.3",
20
24
  "typedoc": "^0.25.7",
21
25
  "typedoc-plugin-markdown": "^3.17.1",
22
26
  "typescript": "^5.3.3"