@opengovsg/myinfo-gov-client
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -28,6 +30,6 @@ function __() { this.constructor = d; } | ||
if (err instanceof Error) { | ||
_this.message = message + ": " + err.message; | ||
_this.message = "".concat(message, ": ").concat(err.message); | ||
} | ||
else if (err) { | ||
_this.message = message + ": " + JSON.stringify(err); | ||
_this.message = "".concat(message, ": ").concat(JSON.stringify(err)); | ||
} | ||
@@ -34,0 +36,0 @@ Error.captureStackTrace(_this, _this.constructor); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -155,3 +155,3 @@ "use strict"; | ||
}); | ||
return "" + this.baseAPIUrl + Endpoint.Authorise + "?" + queryParams; | ||
return "".concat(this.baseAPIUrl).concat(Endpoint.Authorise, "?").concat(queryParams); | ||
}; | ||
@@ -184,3 +184,3 @@ /** | ||
uinFin = this.extractUinFin(accessToken); | ||
url = "" + this.baseAPIUrl + Endpoint.Person + "/" + uinFin + "/"; | ||
url = "".concat(this.baseAPIUrl).concat(Endpoint.Person, "/").concat(uinFin, "/"); | ||
params = { | ||
@@ -194,3 +194,3 @@ client_id: this.clientId, | ||
'Cache-Control': 'no-cache', | ||
Authorization: paramsAuthHeader + ",Bearer " + accessToken, | ||
Authorization: "".concat(paramsAuthHeader, ",Bearer ").concat(accessToken), | ||
}; | ||
@@ -244,3 +244,3 @@ _a.label = 1; | ||
try { | ||
decoded = jsonwebtoken_1.verify(accessToken, this.myInfoPublicKey, { | ||
decoded = (0, jsonwebtoken_1.verify)(accessToken, this.myInfoPublicKey, { | ||
algorithms: ['RS256'], | ||
@@ -253,3 +253,3 @@ }); | ||
if (typeof decoded === 'object' && | ||
util_1.hasProp(decoded, 'sub') && | ||
(0, util_1.hasProp)(decoded, 'sub') && | ||
typeof decoded.sub === 'string') { | ||
@@ -275,3 +275,3 @@ return decoded.sub; | ||
case 0: | ||
postUrl = "" + this.baseAPIUrl + Endpoint.Token; | ||
postUrl = "".concat(this.baseAPIUrl).concat(Endpoint.Token); | ||
postParams = { | ||
@@ -294,3 +294,3 @@ grant_type: 'authorization_code', | ||
// eslint-disable-next-line camelcase | ||
.post(postUrl, util_1.objToSearchParams(postParams), { headers: headers })]; | ||
.post(postUrl, (0, util_1.objToSearchParams)(postParams), { headers: headers })]; | ||
case 2: | ||
@@ -324,6 +324,5 @@ response = _b.sent(); | ||
var nonce = crypto_1.default.randomBytes(32).toString('base64'); | ||
var authParams = util_1.sortObjKeys(__assign(__assign({}, urlParams), { signature_method: 'RS256', nonce: nonce, | ||
timestamp: timestamp, app_id: this.clientId })); | ||
var authParams = (0, util_1.sortObjKeys)(__assign(__assign({}, urlParams), { signature_method: 'RS256', nonce: nonce, timestamp: timestamp, app_id: this.clientId })); | ||
var paramString = qs_1.default.stringify(authParams, { encode: false }); | ||
var baseString = method.toUpperCase() + "&" + url + "&" + paramString; | ||
var baseString = "".concat(method.toUpperCase(), "&").concat(url, "&").concat(paramString); | ||
var signature = crypto_1.default | ||
@@ -333,3 +332,3 @@ .createSign('RSA-SHA256') | ||
.sign(this.clientPrivateKey, 'base64'); | ||
return "PKI_SIGN timestamp=\"" + timestamp + "\",nonce=\"" + nonce + "\",app_id=\"" + this.clientId + "\",signature_method=\"RS256\",signature=\"" + signature + "\""; | ||
return "PKI_SIGN timestamp=\"".concat(timestamp, "\",nonce=\"").concat(nonce, "\",app_id=\"").concat(this.clientId, "\",signature_method=\"RS256\",signature=\"").concat(signature, "\""); | ||
}; | ||
@@ -368,3 +367,3 @@ /** | ||
try { | ||
decoded = jsonwebtoken_1.verify(jwt, this.myInfoPublicKey, { | ||
decoded = (0, jsonwebtoken_1.verify)(jwt, this.myInfoPublicKey, { | ||
algorithms: ['RS256'], | ||
@@ -379,3 +378,3 @@ }); | ||
} | ||
return [2 /*return*/, decoded]; | ||
return [2 /*return*/, decoded]; // assumes JwtPayload *is* of shape IPerson - could add more checks here | ||
} | ||
@@ -382,0 +381,0 @@ }); |
@@ -10,3 +10,3 @@ export declare enum MyInfoSource { | ||
} | ||
declare type SourceProp<T> = { | ||
declare type SourceProp<T extends MyInfoSource> = { | ||
source: T; | ||
@@ -16,4 +16,4 @@ }; | ||
export declare type MyInfoNotApplicable = SourceProp<MyInfoSource.NotApplicable>; | ||
export declare type MyInfoApplicable<S> = { | ||
lastupdated: string; | ||
export declare type MyInfoApplicable<S extends MyInfoSource> = { | ||
lastupdated?: string; | ||
classification: MyInfoDataClassification.Confidential; | ||
@@ -24,6 +24,6 @@ } & SourceProp<S>; | ||
}; | ||
export declare type MyInfoUnavailableField<S> = MyInfoApplicable<S> & UnavailableProp<true>; | ||
export declare type MyInfoAvailableMetadata<S> = MyInfoApplicable<S> & Partial<UnavailableProp<undefined>>; | ||
export declare type MyInfoField<T, S = MyInfoSourceDefault> = MyInfoUnavailableField<S> | (T & MyInfoAvailableMetadata<S>); | ||
declare type ValueType<T> = { | ||
export declare type MyInfoUnavailableField<S extends MyInfoSource> = MyInfoApplicable<S> & UnavailableProp<true>; | ||
export declare type MyInfoAvailableMetadata<S extends MyInfoSource> = MyInfoApplicable<S> & Partial<UnavailableProp<undefined>>; | ||
export declare type MyInfoField<T, S extends MyInfoSource = MyInfoSourceDefault> = MyInfoUnavailableField<S> | (T & MyInfoAvailableMetadata<S>); | ||
declare type ValueType<T extends string | number | boolean> = { | ||
value: T; | ||
@@ -30,0 +30,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
{ | ||
"name": "@opengovsg/myinfo-gov-client", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "A lightweight client to easily call the MyInfo Person v3.2 endpoint for the Singapore government. Tested with NodeJS version >=12.", | ||
@@ -35,38 +35,39 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"axios": "^0.27.2", | ||
"jsonwebtoken": "^8.5.1", | ||
"node-jose": "^2.0.0", | ||
"qs": "^6.9.6" | ||
"node-jose": "^2.1.1", | ||
"qs": "^6.11.0" | ||
}, | ||
"devDependencies": { | ||
"@opengovsg/eslint-config-opengovsg": "^1.0.5", | ||
"@opengovsg/mockpass": "^2.6.10", | ||
"@types/express": "^4.17.11", | ||
"@types/jest": "^26.0.20", | ||
"@types/jsonwebtoken": "^8.5.0", | ||
"@types/node": "^14.11.10", | ||
"@types/node-jose": "^1.1.5", | ||
"@types/qs": "^6.9.5", | ||
"@typescript-eslint/eslint-plugin": "^4.4.1", | ||
"@typescript-eslint/parser": "^4.4.1", | ||
"concurrently": "^5.3.0", | ||
"@opengovsg/eslint-config-opengovsg": "^1.0.7", | ||
"@opengovsg/mockpass": "^2.9.2", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "^28.1.6", | ||
"@types/jsonwebtoken": "^8.5.8", | ||
"@types/node": "^18.6.1", | ||
"@types/node-jose": "^1.1.10", | ||
"@types/qs": "^6.9.7", | ||
"@typescript-eslint/eslint-plugin": "^5.31.0", | ||
"@typescript-eslint/parser": "^5.31.0", | ||
"concurrently": "^7.3.0", | ||
"env-cmd": "^10.1.0", | ||
"eslint": "^7.11.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"express": "^4.17.1", | ||
"husky": "^5.1.3", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"prettier": "^2.2.1", | ||
"testcafe": "^1.10.1", | ||
"ts-jest": "^26.5.0", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.5" | ||
"eslint": "^8.20.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-n": "^15.2.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-standard": "^4.1.0", | ||
"express": "^4.18.1", | ||
"husky": "^8.0.1", | ||
"jest": "^28.1.3", | ||
"lint-staged": "^13.0.3", | ||
"prettier": "^2.7.1", | ||
"testcafe": "^1.20.0", | ||
"ts-jest": "^28.0.7", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
79697
1621
0
30
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
- Removedaxios@0.21.4(transitive)
Updatedaxios@^0.27.2
Updatednode-jose@^2.1.1
Updatedqs@^6.11.0