Skip to content

Commit

Permalink
chore: release v3.1.0 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mok authored Apr 6, 2022
1 parent 9695e47 commit 037ca01
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 41 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bankid",
"authentication"
],
"version": "3.0.0",
"version": "3.1.0",
"main": "lib/bankid.js",
"repository": {
"type": "git",
Expand All @@ -24,11 +24,11 @@
"url": "https://github.com/anyfin/bankid/issues"
},
"dependencies": {
"axios": "^0.21.1"
"axios": "^0.26.1"
},
"devDependencies": {
"@types/node": "^14.14.22",
"typescript": "^4.1.3",
"@types/node": "^14.18.12",
"typescript": "4.6.3",
"prettier": "^2.2.1"
},
"peerDependencies": {
Expand Down
42 changes: 26 additions & 16 deletions src/bankid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as fs from "fs";
import * as https from "https";
import * as path from "path";

import axios, { AxiosError, AxiosInstance } from "axios";
import type { AxiosInstance } from "axios";
import axios from "axios";

//
// Type definitions for /auth
Expand Down Expand Up @@ -35,6 +36,7 @@ interface AuthOptionalRequirements {

export interface SignRequest extends AuthRequest {
userVisibleData: string;
userVisibleDataFormat?: "simpleMarkdownV1";
userNonVisibleData?: string;
}

Expand Down Expand Up @@ -200,7 +202,7 @@ export class BankIdClient {

if (this.options.production) {
if (!options?.pfx || !options?.passphrase) {
throw Error(
throw new Error(
"BankId requires the pfx and passphrase in production mode",
);
}
Expand Down Expand Up @@ -235,15 +237,23 @@ export class BankIdClient {

authenticate(parameters: AuthRequest): Promise<AuthResponse> {
if (!parameters.endUserIp) {
throw Error("Missing required argument endUserIp.");
throw new Error("Missing required argument endUserIp.");
}

return this._call<AuthRequest, AuthResponse>(BankIdMethod.auth, parameters);
}

sign(parameters: SignRequest): Promise<SignResponse> {
if (!parameters.endUserIp || !parameters.userVisibleData) {
throw Error("Missing required arguments: endUserIp, userVisibleData.");
throw new Error(
"Missing required arguments: endUserIp, userVisibleData.",
);
}
if (
parameters.userVisibleDataFormat != null &&
parameters.userVisibleDataFormat !== "simpleMarkdownV1"
) {
throw new Error("userVisibleDataFormat can only be simpleMarkdownV1.");
}

parameters = {
Expand Down Expand Up @@ -318,18 +328,18 @@ export class BankIdClient {
.then(response => {
resolve(response.data);
})
.catch((error: AxiosError) => {
let thrownError;

if (error.response) {
thrownError = new BankIdError(
error.response.data.errorCode,
error.response.data.details,
);
} else if (error.request) {
thrownError = new RequestError(error.request);
} else {
thrownError = error;
.catch((error: unknown) => {
let thrownError = error;

if (axios.isAxiosError(error)) {
if (error.response) {
thrownError = new BankIdError(
error.response.data.errorCode,
error.response.data.details,
);
} else if (error.request) {
thrownError = new RequestError(error.request);
}
}

reject(thrownError);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"strict": true,
"target": "ES2018"
},
"include": ["src/**/*"],
"include": ["src"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
40 changes: 20 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
# yarn lockfile v1


"@types/node@^14.14.22":
version "14.14.22"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
"@types/node@^14.18.12":
version "14.18.12"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24"
integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==

axios@^0.21.1:
version "0.21.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
axios@^0.26.1:
version "0.26.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
dependencies:
follow-redirects "^1.14.0"
follow-redirects "^1.14.8"

follow-redirects@^1.14.0:
version "1.14.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
follow-redirects@^1.14.8:
version "1.14.9"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==

prettier@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
version "2.6.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==

typescript@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
typescript@4.6.3:
version "4.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==

0 comments on commit 037ca01

Please sign in to comment.