namirasoft-account
Advanced tools
Comparing version 1.2.1 to 1.2.2
export declare class NamirasoftAccountBaseHeader { | ||
protected getX(): string; | ||
protected getX(name: string): string; | ||
} |
@@ -5,4 +5,4 @@ "use strict"; | ||
class NamirasoftAccountBaseHeader { | ||
getX() { | ||
return `x-namirasoft-account-`; | ||
getX(name) { | ||
return `x-namirasoft-account-${name}`; | ||
} | ||
@@ -9,0 +9,0 @@ } |
import { NamirasoftAccountBaseHeader } from "./NamirasoftAccountBaseHeader"; | ||
export declare class NamirasoftAccountReqHeader extends NamirasoftAccountBaseHeader { | ||
JWT(): string; | ||
INFO(): string; | ||
TOKEN(): string; | ||
} |
@@ -6,10 +6,7 @@ "use strict"; | ||
class NamirasoftAccountReqHeader extends NamirasoftAccountBaseHeader_1.NamirasoftAccountBaseHeader { | ||
JWT() { | ||
return this.getX() + `jwt`; | ||
TOKEN() { | ||
return this.getX(`token`); | ||
} | ||
INFO() { | ||
return this.getX() + `info`; | ||
} | ||
} | ||
exports.NamirasoftAccountReqHeader = NamirasoftAccountReqHeader; | ||
//# sourceMappingURL=NamirasoftAccountReqHeader.js.map |
import { NamirasoftAccountBaseHeader } from "./NamirasoftAccountBaseHeader"; | ||
export declare class NamirasoftAccountResHeader extends NamirasoftAccountBaseHeader { | ||
USER_TYPE(): string; | ||
USER_VALUE(): string; | ||
IP_INFO(): string; | ||
USER(): string; | ||
} |
@@ -6,13 +6,7 @@ "use strict"; | ||
class NamirasoftAccountResHeader extends NamirasoftAccountBaseHeader_1.NamirasoftAccountBaseHeader { | ||
USER_TYPE() { | ||
return this.getX() + `user-name`; | ||
USER() { | ||
return this.getX(`user`); | ||
} | ||
USER_VALUE() { | ||
return this.getX() + `user-value`; | ||
} | ||
IP_INFO() { | ||
return this.getX() + `ip-info`; | ||
} | ||
} | ||
exports.NamirasoftAccountResHeader = NamirasoftAccountResHeader; | ||
//# sourceMappingURL=NamirasoftAccountResHeader.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
static onBeforeRequest_SetToken(manager, config) { | ||
let header = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.JWT(); | ||
let header = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.TOKEN(); | ||
let token = manager.getValue(); | ||
@@ -18,9 +18,5 @@ if (token) | ||
if (token) { | ||
let header_type = NamirasoftAccountHeader_1.NamirasoftAccountHeader.res.USER_TYPE(); | ||
let header_value = NamirasoftAccountHeader_1.NamirasoftAccountHeader.res.USER_VALUE(); | ||
let user_type = response.headers[header_type]; | ||
let user_value = atob(response.headers[header_value]); | ||
if (user_value == "namirasoft-account") | ||
manager.setUser(JSON.parse(user_value)); | ||
manager.setCustomUser(user_type, JSON.parse(user_value)); | ||
let header_user = NamirasoftAccountHeader_1.NamirasoftAccountHeader.res.USER(); | ||
let user_value = atob(response.headers[header_user]); | ||
manager.setUser(JSON.parse(user_value)); | ||
} | ||
@@ -27,0 +23,0 @@ } |
@@ -18,4 +18,2 @@ import { IStorage } from "namirasoft-core"; | ||
setUser(user: User | null): void; | ||
getCustomUser<U>(type: string): U; | ||
setCustomUser<U>(type: string, user: U): void; | ||
getValue(): string | undefined; | ||
@@ -22,0 +20,0 @@ getUserData<D = any>(getter: (user: User) => D, onNull: D): D; |
@@ -11,7 +11,7 @@ "use strict"; | ||
getText() { | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.JWT(); | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.TOKEN(); | ||
return this.storage.get(name, ""); | ||
} | ||
setText(text, isTheSameUser) { | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.JWT(); | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.TOKEN(); | ||
this.storage.set(name, text); | ||
@@ -32,3 +32,3 @@ if (!isTheSameUser) | ||
del() { | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.JWT(); | ||
let name = NamirasoftAccountHeader_1.NamirasoftAccountHeader.req.TOKEN(); | ||
this.storage.del(name); | ||
@@ -53,9 +53,2 @@ } | ||
} | ||
getCustomUser(type) { | ||
let ans = this.storage.get(type + "-user", ""); | ||
return JSON.parse(ans); | ||
} | ||
setCustomUser(type, user) { | ||
this.storage.set(type + "-user", JSON.stringify(user)); | ||
} | ||
getValue() { | ||
@@ -62,0 +55,0 @@ var _a; |
{ | ||
"name": "namirasoft-account", | ||
"description": "Namira Software Corporation Account NPM Package", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "./dist/index.js", | ||
@@ -11,5 +11,5 @@ "types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"namirasoft-core": "^1.2.0", | ||
"namirasoft-core": "^1.2.4", | ||
"namirasoft-site": "^1.2.1" | ||
} | ||
} | ||
} |
export class NamirasoftAccountBaseHeader | ||
{ | ||
protected getX() | ||
protected getX(name: string) | ||
{ | ||
return `x-namirasoft-account-`; | ||
return `x-namirasoft-account-${name}`; | ||
} | ||
} |
@@ -5,10 +5,6 @@ import { NamirasoftAccountBaseHeader } from "./NamirasoftAccountBaseHeader"; | ||
{ | ||
JWT() | ||
TOKEN() | ||
{ | ||
return this.getX() + `jwt`; | ||
return this.getX(`token`); | ||
} | ||
INFO() | ||
{ | ||
return this.getX() + `info`; | ||
} | ||
} |
@@ -5,14 +5,6 @@ import { NamirasoftAccountBaseHeader } from "./NamirasoftAccountBaseHeader"; | ||
{ | ||
USER_TYPE() | ||
USER() | ||
{ | ||
return this.getX() + `user-name`; | ||
return this.getX(`user`); | ||
} | ||
USER_VALUE() | ||
{ | ||
return this.getX() + `user-value`; | ||
} | ||
IP_INFO() | ||
{ | ||
return this.getX() + `ip-info`; | ||
} | ||
} |
@@ -11,3 +11,3 @@ import { NSBaseServer } from "namirasoft-site"; | ||
{ | ||
let header = NamirasoftAccountHeader.req.JWT(); | ||
let header = NamirasoftAccountHeader.req.TOKEN(); | ||
let token = manager.getValue(); | ||
@@ -23,9 +23,5 @@ if (token) | ||
{ | ||
let header_type = NamirasoftAccountHeader.res.USER_TYPE(); | ||
let header_value = NamirasoftAccountHeader.res.USER_VALUE(); | ||
let user_type = response.headers[header_type]; | ||
let user_value = atob(response.headers[header_value]); | ||
if (user_value == "namirasoft-account") | ||
manager.setUser(JSON.parse(user_value) as User); | ||
manager.setCustomUser(user_type, JSON.parse(user_value)); | ||
let header_user = NamirasoftAccountHeader.res.USER(); | ||
let user_value = atob(response.headers[header_user]); | ||
manager.setUser(JSON.parse(user_value) as User); | ||
} | ||
@@ -32,0 +28,0 @@ } |
@@ -19,3 +19,3 @@ import { IStorage } from "namirasoft-core"; | ||
{ | ||
let name: string = NamirasoftAccountHeader.req.JWT(); | ||
let name: string = NamirasoftAccountHeader.req.TOKEN(); | ||
return this.storage.get(name, ""); | ||
@@ -25,3 +25,3 @@ } | ||
{ | ||
let name: string = NamirasoftAccountHeader.req.JWT(); | ||
let name: string = NamirasoftAccountHeader.req.TOKEN(); | ||
this.storage.set(name, text); | ||
@@ -45,3 +45,3 @@ if (!isTheSameUser) | ||
{ | ||
let name: string = NamirasoftAccountHeader.req.JWT(); | ||
let name: string = NamirasoftAccountHeader.req.TOKEN(); | ||
this.storage.del(name); | ||
@@ -70,11 +70,2 @@ } | ||
} | ||
getCustomUser<U>(type: string): U | ||
{ | ||
let ans = this.storage.get(type + "-user", ""); | ||
return JSON.parse(ans) as U; | ||
} | ||
setCustomUser<U>(type: string, user: U) | ||
{ | ||
this.storage.set(type + "-user", JSON.stringify(user)); | ||
} | ||
getValue() | ||
@@ -81,0 +72,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82981
1591
Updatednamirasoft-core@^1.2.4