@triveria/wallet 0.0.284 → 0.0.285
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/api.d.ts +1 -1
- package/api.js +1 -1
- package/auth.js +0 -18
- package/base.d.ts +1 -1
- package/base.js +1 -1
- package/common.d.ts +1 -1
- package/common.js +1 -1
- package/configuration.d.ts +1 -1
- package/configuration.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/api.d.ts
CHANGED
package/api.js
CHANGED
package/auth.js
CHANGED
|
@@ -14,30 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
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");
|
|
19
17
|
function RequestToken(tokenUrl, audience, clientId, clientSecret) {
|
|
20
18
|
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
|
-
}
|
|
36
19
|
const body = `{"client_id":"${clientId}","client_secret":"${clientSecret}","audience":"${audience}","grant_type":"client_credentials"}`, headers = { 'content-type': 'application/json' };
|
|
37
20
|
const { data: { access_token } } = yield axios_1.default.post(`${tokenUrl}`, body, {
|
|
38
21
|
headers,
|
|
39
22
|
});
|
|
40
|
-
storage.setItem("token", access_token);
|
|
41
23
|
return access_token;
|
|
42
24
|
});
|
|
43
25
|
}
|
package/base.d.ts
CHANGED
package/base.js
CHANGED
package/common.d.ts
CHANGED
package/common.js
CHANGED
package/configuration.d.ts
CHANGED
package/configuration.js
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED