@thefirstspine/auth 2.1.2 → 2.2.0
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/lib/auth.service.d.ts +1 -0
- package/lib/auth.service.d.ts.map +1 -1
- package/lib/auth.service.js +25 -8
- package/lib/auth.service.js.map +1 -1
- package/lib/me-response.interface.d.ts +5 -0
- package/lib/me-response.interface.d.ts.map +1 -0
- package/lib/me-response.interface.js +3 -0
- package/lib/me-response.interface.js.map +1 -0
- package/package.json +11 -11
package/lib/auth.service.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":"AAMA,qBAAa,WAAW;IAEtB,OAAO,CAAC,iBAAiB,CAAmC;IAK5D,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAkC;IAMpE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAC,IAAI,CAAC;IAsCpC,oBAAoB,IAAI,MAAM;CAItC;;AAED,wBAAiC"}
|
package/lib/auth.service.js
CHANGED
|
@@ -15,18 +15,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.AuthService = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
class AuthService {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.cachedMeResponses = {};
|
|
20
|
+
}
|
|
18
21
|
me(jwt) {
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (this.cachedMeResponses[jwt] != undefined && (new Date()).getTime() < this.cachedMeResponses[jwt].expires) {
|
|
24
|
+
return this.cachedMeResponses[jwt].user_id;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const response = yield axios_1.default.get(this.getAuthNetServiceUrl() + '/api/v2/me', {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${jwt}`,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const jsonResponse = response.data;
|
|
33
|
+
if (!jsonResponse.user_id) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
this.cachedMeResponses[jwt] = {
|
|
37
|
+
expires: (new Date()).getTime() + (60 * 1000),
|
|
38
|
+
user_id: jsonResponse.user_id,
|
|
39
|
+
};
|
|
40
|
+
return jsonResponse.user_id;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.log({ errorFromAxios: e });
|
|
27
44
|
return null;
|
|
28
45
|
}
|
|
29
|
-
return
|
|
46
|
+
return null;
|
|
30
47
|
});
|
|
31
48
|
}
|
|
32
49
|
getAuthNetServiceUrl() {
|
package/lib/auth.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAM1B,MAAa,WAAW;IAAxB;QAEU,sBAAiB,GAAgC,EAAE,CAAC;IAqD9D,CAAC;IA1CO,EAAE,CAAC,GAAW;;YAElB,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC7G,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,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AA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"me-response.interface.js","sourceRoot":"","sources":["../src/me-response.interface.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thefirstspine/auth",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Javascript & Typescript dependency to help developers to use the auth net service.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"axios": "^1.
|
|
8
|
+
"axios": "^1.7.4"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@types/jest": "^29.5.
|
|
12
|
-
"@types/node": "^
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
14
|
-
"@typescript-eslint/parser": "^6.
|
|
15
|
-
"eslint": "^8.
|
|
11
|
+
"@types/jest": "^29.5.12",
|
|
12
|
+
"@types/node": "^22.4.1",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
14
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
15
|
+
"eslint": "^8.56.0",
|
|
16
16
|
"jest": "^29.7.0",
|
|
17
|
-
"rimraf": "^
|
|
18
|
-
"ts-jest": "^29.
|
|
19
|
-
"ts-node": "^10.9.
|
|
20
|
-
"typescript": "^5.
|
|
17
|
+
"rimraf": "^6.0.1",
|
|
18
|
+
"ts-jest": "^29.2.4",
|
|
19
|
+
"ts-node": "^10.9.2",
|
|
20
|
+
"typescript": "^5.5.4"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "rimraf ./lib && tsc -b",
|