Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bankid

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bankid - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

5

lib/bankid.d.ts

@@ -7,2 +7,5 @@ /// <reference types="node" />

requirement?: AuthOptionalRequirements;
userVisibleData?: string;
userVisibleDataFormat?: "simpleMarkdownV1";
userNonVisibleData?: string;
}

@@ -24,4 +27,2 @@ export interface AuthResponse {

userVisibleData: string;
userVisibleDataFormat?: "simpleMarkdownV1";
userNonVisibleData?: string;
}

@@ -28,0 +29,0 @@ export interface SignResponse extends AuthResponse {

@@ -99,2 +99,15 @@ "use strict";

}
if (parameters.userVisibleDataFormat != null &&
parameters.userVisibleDataFormat !== "simpleMarkdownV1") {
throw new Error("userVisibleDataFormat can only be simpleMarkdownV1.");
}
parameters = {
...parameters,
userVisibleData: parameters.userVisibleData
? Buffer.from(parameters.userVisibleData).toString("base64")
: undefined,
userNonVisibleData: parameters.userNonVisibleData
? Buffer.from(parameters.userNonVisibleData).toString("base64")
: undefined,
};
return __classPrivateFieldGet(this, _BankIdClient_instances, "m", _BankIdClient_call).call(this, BankIdMethod.auth, parameters);

@@ -101,0 +114,0 @@ }

10

package.json

@@ -9,3 +9,3 @@ {

],
"version": "3.1.2",
"version": "3.1.3",
"main": "lib/bankid.js",

@@ -28,11 +28,11 @@ "repository": {

"dependencies": {
"axios": "^0.26.1"
"axios": "^1.6.4"
},
"devDependencies": {
"@types/node": "^14.18.12",
"prettier": "^2.2.1",
"@types/node": "^20.11.10",
"prettier": "^3.2.4",
"typescript": "5.x"
},
"peerDependencies": {
"@types/node": "^14.14.22"
"@types/node": ">=14,<21"
},

@@ -39,0 +39,0 @@ "peerDependenciesMeta": {

@@ -26,2 +26,3 @@ # bankid

endUserIp: "127.0.0.1",
userVisibleData: "Authentication request for my service",
})

@@ -33,9 +34,11 @@ .then(res => console.log(res.completionData))

As outlined in the [relying party guidelines](https://www.bankid.com/assets/bankid/rp/bankid-relying-party-guidelines-v3.5.pdf),
there' four main methods (arguments marked with `*` are required)
there are four main methods (arguments marked with `*` are required)
- `authenticate({endUserIp*, personalNumber, requirement})`
- `sign({endUserIp*, personalNumber, requirement, userVisibleData*, userNonVisibleData})`
- `authenticate({endUserIp*, personalNumber, requirement, userVisibleData, userVisibleDataFormat, userNonVisibleData})`
- `sign({endUserIp*, personalNumber, requirement, userVisibleData*, userVisibleDataFormat, userNonVisibleData})`
- `collect({orderRef*})`
- `cancel({orderRef*})`
Note that `userVisibleData` will be base64-encoded before sent to the BankID API.
Additionally, `bankid` provides convenience methods to combine auth / sign with periodic collection of the status until the process either failed or succeeded (as shown in the example code above):

@@ -42,0 +45,0 @@

@@ -13,5 +13,5 @@ {

"devDependencies": {
"@types/node": "^14.14.22",
"@types/node": "^20.11.10",
"typescript": "5.x"
}
}

@@ -8,2 +8,3 @@ import { BankIdClient } from "bankid";

const personalNumber = process.argv[3];
const errors = [];

@@ -21,14 +22,17 @@ if (!ip || !personalNumber) {

console.log("starting to test authenticate");
try {
console.log("starting to test /auth");
const authRequest = await client.authenticate({
endUserIp: ip,
personalNumber: personalNumber,
userVisibleData:
"### This is a test\n\nThis test has some *simpleMarkdownV1*",
userVisibleDataFormat: "simpleMarkdownV1",
});
console.log(authRequest);
await client._awaitPendingCollect(authRequest.orderRef);
console.log("auth request successful");
console.log("authenticate successful");
} catch (e) {
console.log(e);
console.log("authenticate failed");
errors.push(e);
}

@@ -38,5 +42,4 @@

console.log("starting to test sign");
try {
console.log("starting to test /sign");
const signRequest = await client.sign({

@@ -46,9 +49,10 @@ endUserIp: ip,

userVisibleData: "this is a test",
userVisibleDataFormat: "simpleMarkdownV1",
});
console.log(signRequest);
await client.awaitPendingCollect(signRequest.orderRef);
console.log("sign request successful");
console.log("sign successful");
} catch (e) {
console.log(e);
console.log("sign failed");
errors.push(e);
}

@@ -58,4 +62,3 @@

console.log("starting to test /auth and /collect");
console.log("starting to test authenticateAndCollect");
await client

@@ -65,10 +68,13 @@ .authenticateAndCollect({

personalNumber: personalNumber,
userVisibleData: "this is a test of authenticateAndCollect",
})
.then(() => console.log("authenticateAndCollect successful"))
.catch(console.log);
.catch(e => {
console.log("authenticateAndCollect failed");
errors.push(e);
});
await delay(DELAY_BETWEEN_REQUETS);
console.log("starting to test /sign and /collect");
console.log("starting to test signAndCollect");
await client

@@ -83,9 +89,11 @@ .signAndCollect({

})
.catch(console.log);
.catch(e => {
console.log("signAndCollect failed");
errors.push(e);
});
await delay(DELAY_BETWEEN_REQUETS);
console.log("starting to test sign and cancel");
try {
console.log("starting to test /sign and /cancel");
const response = await client.sign({

@@ -95,14 +103,28 @@ endUserIp: ip,

userVisibleData:
"this is a cancellation test - please DO NOT fill in your verification code",
"this is a cancellation test - please DO NOT fill in your verification code or cancel the sign from your device",
});
await cancelOrderIn(client, response.orderRef, 5000);
console.log("sign and cancel successful");
} catch (e) {
console.log(e);
console.log("sign and cancel failed");
errors.push(e);
}
return errors;
}
main()
.then(() => console.log("✅ All tests completed successfully"))
.catch(err => console.log(err));
.then(errors => {
const failedTests = errors.length;
if (failedTests === 0) {
console.log("✅ All tests completed successfully");
} else {
console.error(`❌ ${failedTests} test(s) failed`);
}
})
.catch(error => {
console.error(`❌ test(s) crashed`);
console.error(error);
});

@@ -109,0 +131,0 @@ function delay(ms: number) {

@@ -10,6 +10,6 @@ {

"skipLibCheck": true,
"target": "ES2018"
"target": "ES2018",
},
"include": ["src/manualTests.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
"exclude": ["node_modules", "**/*.spec.ts"],
}

@@ -10,6 +10,6 @@ {

"strict": true,
"target": "ES2018"
"target": "ES2018",
},
"include": ["src"],
"exclude": ["node_modules", "**/*.spec.ts"]
"exclude": ["node_modules", "**/*.spec.ts"],
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc