@flink-app/bankid-plugin 0.12.1-alpha.24 → 0.12.1-alpha.25

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.
@@ -51,7 +51,7 @@ function getAuthStatus(ctx, options) {
51
51
  case 1:
52
52
  session = _c.sent();
53
53
  if (!session) {
54
- throw new Error("BankId session not found");
54
+ throw (0, flink_1.notFound)("BankId session not found");
55
55
  }
56
56
  if (!(session.status === "complete")) return [3 /*break*/, 5];
57
57
  if (!!session.user) return [3 /*break*/, 3];
@@ -59,7 +59,7 @@ function getAuthStatus(ctx, options) {
59
59
  return [4 /*yield*/, ctx.repos.bankIdSessionRepo.failSession(orderRef, "USER_DATA_MISSING")];
60
60
  case 2:
61
61
  _c.sent();
62
- throw new Error("User data is missing");
62
+ throw (0, flink_1.internalServerError)("Session is completed but user data is missing");
63
63
  case 3: return [4 /*yield*/, pluginOptions.onAuthSuccess(session.user, (_a = session.device) === null || _a === void 0 ? void 0 : _a.ipAddress, session.payload)];
64
64
  case 4:
65
65
  authCallbackRes = _c.sent();
@@ -44,28 +44,18 @@ exports.Route = {
44
44
  method: flink_1.HttpMethod.get,
45
45
  };
46
46
  var GetBankIdAuth = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
- var orderRef, authStatus, error_1;
47
+ var orderRef, authStatus;
48
48
  var ctx = _b.ctx, req = _b.req;
49
49
  return __generator(this, function (_c) {
50
50
  switch (_c.label) {
51
51
  case 0:
52
52
  orderRef = req.params.orderRef;
53
- _c.label = 1;
54
- case 1:
55
- _c.trys.push([1, 3, , 4]);
56
53
  return [4 /*yield*/, (0, getAuthStatus_1.getAuthStatus)(ctx, { orderRef: orderRef })];
57
- case 2:
54
+ case 1:
58
55
  authStatus = _c.sent();
59
56
  return [2 /*return*/, {
60
57
  data: authStatus,
61
58
  }];
62
- case 3:
63
- error_1 = _c.sent();
64
- if (error_1.message === "BankId session not found") {
65
- return [2 /*return*/, (0, flink_1.notFound)("BankId session not found")];
66
- }
67
- return [2 /*return*/, (0, flink_1.internalServerError)(error_1.message || "Failed to get auth status")];
68
- case 4: return [2 /*return*/];
69
59
  }
70
60
  });
71
61
  }); };
@@ -44,28 +44,18 @@ exports.Route = {
44
44
  method: flink_1.HttpMethod.get,
45
45
  };
46
46
  var GetBankIdSign = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
- var orderRef, signStatus, error_1;
47
+ var orderRef, signStatus;
48
48
  var ctx = _b.ctx, req = _b.req;
49
49
  return __generator(this, function (_c) {
50
50
  switch (_c.label) {
51
51
  case 0:
52
52
  orderRef = req.params.orderRef;
53
- _c.label = 1;
54
- case 1:
55
- _c.trys.push([1, 3, , 4]);
56
53
  return [4 /*yield*/, (0, getSignStatus_1.getSignStatus)(ctx, { orderRef: orderRef })];
57
- case 2:
54
+ case 1:
58
55
  signStatus = _c.sent();
59
56
  return [2 /*return*/, {
60
57
  data: signStatus,
61
58
  }];
62
- case 3:
63
- error_1 = _c.sent();
64
- if (error_1.message === "BankId session not found") {
65
- return [2 /*return*/, (0, flink_1.notFound)("BankId session not found")];
66
- }
67
- return [2 /*return*/, (0, flink_1.internalServerError)(error_1.message || "Failed to get sign status")];
68
- case 4: return [2 /*return*/];
69
59
  }
70
60
  });
71
61
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/bankid-plugin",
3
- "version": "0.12.1-alpha.24",
3
+ "version": "0.12.1-alpha.25",
4
4
  "description": "Flink plugin for Swedish BankID authentication and document signing",
5
5
  "scripts": {
6
6
  "test": "node --preserve-symlinks -r ts-node/register -- node_modules/jasmine/bin/jasmine --config=./spec/support/jasmine.json",
@@ -32,5 +32,5 @@
32
32
  "tsc-watch": "^4.2.9",
33
33
  "typescript": "5.4.5"
34
34
  },
35
- "gitHead": "7acc954a5cfd65c1cba7707d633c18025cc80dcd"
35
+ "gitHead": "44a1bf5bb2b2c7d18e4cecc06da626700639f82a"
36
36
  }
@@ -1,4 +1,4 @@
1
- import { log } from "@flink-app/flink";
1
+ import { internalServerError, log, notFound } from "@flink-app/flink";
2
2
  import { BankIdInternalCtx } from "../BankIdInternalContext";
3
3
 
4
4
  export interface AuthStatusOptions {
@@ -23,7 +23,7 @@ export async function getAuthStatus(ctx: BankIdInternalCtx, options: AuthStatusO
23
23
  const session = await ctx.repos.bankIdSessionRepo.getSession(orderRef, "auth");
24
24
 
25
25
  if (!session) {
26
- throw new Error("BankId session not found");
26
+ throw notFound("BankId session not found");
27
27
  }
28
28
 
29
29
  // Session is completed, create tokens
@@ -32,7 +32,7 @@ export async function getAuthStatus(ctx: BankIdInternalCtx, options: AuthStatusO
32
32
  if (!session.user) {
33
33
  log.error(`Auth session ${orderRef} marked complete but user data is missing`);
34
34
  await ctx.repos.bankIdSessionRepo.failSession(orderRef, "USER_DATA_MISSING");
35
- throw new Error("User data is missing");
35
+ throw internalServerError("Session is completed but user data is missing");
36
36
  }
37
37
 
38
38
  // Invoke host app callback which will (probably) do the following:
@@ -65,4 +65,4 @@ export async function getAuthStatus(ctx: BankIdInternalCtx, options: AuthStatusO
65
65
  hintCode: session.hintCode || undefined,
66
66
  qr: session.qr?.qr,
67
67
  };
68
- }
68
+ }
@@ -1,7 +1,7 @@
1
- import { Handler, HttpMethod, RouteProps, internalServerError, notFound } from "@flink-app/flink";
1
+ import { Handler, HttpMethod, RouteProps } from "@flink-app/flink";
2
2
  import { BankIdInternalCtx } from "../BankIdInternalContext";
3
- import AuthStatusRes from "../schemas/AuthStatusRes";
4
3
  import { getAuthStatus } from "../functions/getAuthStatus";
4
+ import AuthStatusRes from "../schemas/AuthStatusRes";
5
5
 
6
6
  export const Route: RouteProps = {
7
7
  path: "/bankid/auth/:orderRef",
@@ -11,18 +11,11 @@ export const Route: RouteProps = {
11
11
  const GetBankIdAuth: Handler<BankIdInternalCtx, any, AuthStatusRes, { orderRef: string }> = async ({ ctx, req }) => {
12
12
  const { orderRef } = req.params;
13
13
 
14
- try {
15
- const authStatus = await getAuthStatus(ctx, { orderRef });
14
+ const authStatus = await getAuthStatus(ctx, { orderRef });
16
15
 
17
- return {
18
- data: authStatus,
19
- };
20
- } catch (error: any) {
21
- if (error.message === "BankId session not found") {
22
- return notFound("BankId session not found");
23
- }
24
- return internalServerError(error.message || "Failed to get auth status");
25
- }
16
+ return {
17
+ data: authStatus,
18
+ };
26
19
  };
27
20
 
28
21
  export default GetBankIdAuth;
@@ -1,7 +1,7 @@
1
- import { Handler, HttpMethod, RouteProps, internalServerError, notFound } from "@flink-app/flink";
1
+ import { Handler, HttpMethod, RouteProps } from "@flink-app/flink";
2
2
  import { BankIdInternalCtx } from "../BankIdInternalContext";
3
- import SignStatusRes from "../schemas/SignStatusRes";
4
3
  import { getSignStatus } from "../functions/getSignStatus";
4
+ import SignStatusRes from "../schemas/SignStatusRes";
5
5
 
6
6
  export const Route: RouteProps = {
7
7
  path: "/bankid/sign/:orderRef",
@@ -11,18 +11,11 @@ export const Route: RouteProps = {
11
11
  const GetBankIdSign: Handler<BankIdInternalCtx, any, SignStatusRes, { orderRef: string }> = async ({ ctx, req }) => {
12
12
  const { orderRef } = req.params;
13
13
 
14
- try {
15
- const signStatus = await getSignStatus(ctx, { orderRef });
14
+ const signStatus = await getSignStatus(ctx, { orderRef });
16
15
 
17
- return {
18
- data: signStatus,
19
- };
20
- } catch (error: any) {
21
- if (error.message === "BankId session not found") {
22
- return notFound("BankId session not found");
23
- }
24
- return internalServerError(error.message || "Failed to get sign status");
25
- }
16
+ return {
17
+ data: signStatus,
18
+ };
26
19
  };
27
20
 
28
21
  export default GetBankIdSign;