@thefirstspine/auth 2.2.7 → 3.1.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 +9 -0
- package/lib/auth.service.d.ts.map +1 -1
- package/lib/auth.service.js +13 -4
- package/lib/auth.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/lib/me-response.interface.d.ts +0 -5
- package/lib/me-response.interface.d.ts.map +0 -1
- package/lib/me-response.interface.js +0 -3
- package/lib/me-response.interface.js.map +0 -1
package/lib/auth.service.d.ts
CHANGED
|
@@ -2,8 +2,17 @@ export declare class AuthService {
|
|
|
2
2
|
private cachedMeResponses;
|
|
3
3
|
static readonly AUTH_URL_DEFAULT: string;
|
|
4
4
|
me(jwt: string): Promise<number | null>;
|
|
5
|
+
meFull(jwt: string): Promise<IPublicUser | null>;
|
|
5
6
|
getAuthNetServiceUrl(): string;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: AuthService;
|
|
8
9
|
export default _default;
|
|
10
|
+
export interface IPublicUser {
|
|
11
|
+
user_id: number;
|
|
12
|
+
is_guest: boolean;
|
|
13
|
+
email: string;
|
|
14
|
+
meta: {
|
|
15
|
+
[key: string]: string | number | boolean | null;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
9
18
|
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -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":"AAKA,qBAAa,WAAW;IAEtB,OAAO,CAAC,iBAAiB,CAGjB;IAKR,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAkC;IAMpE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAC,IAAI,CAAC;IAYrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAC,IAAI,CAAC;IAsC7C,oBAAoB,IAAI,MAAM;CAItC;;AAED,wBAAiC;AAKjC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC;CAC3D"}
|
package/lib/auth.service.js
CHANGED
|
@@ -19,12 +19,21 @@ class AuthService {
|
|
|
19
19
|
this.cachedMeResponses = {};
|
|
20
20
|
}
|
|
21
21
|
me(jwt) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const user = yield this.meFull(jwt);
|
|
24
|
+
if (user == null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return user.user_id;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
meFull(jwt) {
|
|
22
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
32
|
if (this.cachedMeResponses[jwt] != undefined && (new Date()).getTime() < this.cachedMeResponses[jwt].expires) {
|
|
24
|
-
return this.cachedMeResponses[jwt].
|
|
33
|
+
return this.cachedMeResponses[jwt].user;
|
|
25
34
|
}
|
|
26
35
|
try {
|
|
27
|
-
const response = yield axios_1.default.get(this.getAuthNetServiceUrl() + '/api/
|
|
36
|
+
const response = yield axios_1.default.get(this.getAuthNetServiceUrl() + '/api/v3/me', {
|
|
28
37
|
headers: {
|
|
29
38
|
Authorization: `Bearer ${jwt}`,
|
|
30
39
|
},
|
|
@@ -35,9 +44,9 @@ class AuthService {
|
|
|
35
44
|
}
|
|
36
45
|
this.cachedMeResponses[jwt] = {
|
|
37
46
|
expires: (new Date()).getTime() + (60 * 1000),
|
|
38
|
-
|
|
47
|
+
user: jsonResponse,
|
|
39
48
|
};
|
|
40
|
-
return
|
|
49
|
+
return this.cachedMeResponses[jwt].user;
|
|
41
50
|
}
|
|
42
51
|
catch (e) {
|
|
43
52
|
console.log({ errorFromAxios: e });
|
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;AAK1B,MAAa,WAAW;IAAxB;QAEU,sBAAiB,GAGpB,EAAE,CAAC;IAiEV,CAAC;IAtDO,EAAE,CAAC,GAAW;;YAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;KAAA;IAMK,MAAM,CAAC,GAAW;;YAEtB,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,CAAC,IAAI,CAAC;YAC1C,CAAC;YAGD,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,YAAY,EAAE;oBAC3E,OAAO,EAAE;wBACP,aAAa,EAAE,UAAU,GAAG,EAAE;qBAC/B;iBACF,CAAC,CAAC;gBAEH,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;gBACnC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;oBAC1B,OAAO,IAAI,CAAC;gBACd,CAAC;gBAGD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG;oBAC5B,OAAO,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;oBAC7C,IAAI,EAAE,YAAY;iBACnB,CAAC;gBAGF,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YAC1C,CAAC;YAAC,OAAM,CAAC,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAKM,oBAAoB;;QACzB,OAAO,CAAA,MAAA,MAAA,OAAO,CAAC,GAAG,0CAAE,QAAQ,0CAAE,MAAM,IAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACjG,CAAC;;AApEH,kCAsEC;AA5DiB,4BAAgB,GAAW,+BAA+B,AAA1C,CAA0C;AA8D5E,kBAAe,IAAI,WAAW,EAAE,CAAC"}
|
package/lib/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/auth.service.ts","../src/index.ts"
|
|
1
|
+
{"root":["../src/auth.service.ts","../src/index.ts"],"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thefirstspine/auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/jest": "^29.5.14",
|
|
12
|
-
"@types/node": "^22.15.
|
|
12
|
+
"@types/node": "^22.15.21",
|
|
13
13
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
14
14
|
"@typescript-eslint/parser": "^6.21.0",
|
|
15
15
|
"eslint": "^8.56.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"me-response.interface.d.ts","sourceRoot":"","sources":["../src/me-response.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"me-response.interface.js","sourceRoot":"","sources":["../src/me-response.interface.ts"],"names":[],"mappings":""}
|