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

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.
@@ -48,18 +48,20 @@ export interface BankIdPluginOptions {
48
48
  * token. This will be relayed in the collect response to client.
49
49
  * @param userData
50
50
  * @param ip
51
+ * @param payload
51
52
  * @returns
52
53
  */
53
- onAuthSuccess: (userData: BankIdUserData, ip?: string) => Promise<AuthSuccessCallbackResponse>;
54
+ onAuthSuccess: (userData: BankIdUserData, ip?: string, payload?: Record<string, any>) => Promise<AuthSuccessCallbackResponse>;
54
55
  /**
55
56
  * Callback invoked when BankID sign is successful.
56
57
  * Callback must return an object containing user information and
57
58
  * signature data. This will be relayed in the collect response to client.
58
59
  * @param userData
59
60
  * @param signature
61
+ * @param payload
60
62
  * @returns
61
63
  */
62
- onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature) => Promise<void>;
64
+ onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature, payload?: Record<string, any>) => Promise<void>;
63
65
  /**
64
66
  * For how long to keep sessions in database.
65
67
  * This has nothing to do with how long the user is logged in, only
@@ -1,6 +1,7 @@
1
1
  import { BankIdInternalCtx } from "../BankIdInternalContext";
2
2
  export interface AuthOptions {
3
3
  endUserIp?: string;
4
+ payload?: Record<string, any>;
4
5
  }
5
6
  export interface AuthResponse {
6
7
  orderRef: string;
@@ -87,6 +87,7 @@ function auth(ctx_1) {
87
87
  createdAt: new Date(),
88
88
  ip: clientIp,
89
89
  autoStartToken: authResponse.autoStartToken,
90
+ payload: options.payload,
90
91
  qr: {
91
92
  qrStartToken: authResponse.qrStartToken,
92
93
  qrStartSecret: authResponse.qrStartSecret,
@@ -60,7 +60,7 @@ function getAuthStatus(ctx, options) {
60
60
  case 2:
61
61
  _c.sent();
62
62
  throw new Error("User data is missing");
63
- case 3: return [4 /*yield*/, pluginOptions.onAuthSuccess(session.user, (_a = session.device) === null || _a === void 0 ? void 0 : _a.ipAddress)];
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();
66
66
  return [2 /*return*/, {
@@ -73,7 +73,7 @@ function getSignStatus(ctx, options) {
73
73
  throw new Error("Signature data is missing");
74
74
  case 5:
75
75
  // Invoke host app callback
76
- return [4 /*yield*/, pluginOptions.onSignSuccess(session.user, session.signature)];
76
+ return [4 /*yield*/, pluginOptions.onSignSuccess(session.user, session.signature, session.payload)];
77
77
  case 6:
78
78
  // Invoke host app callback
79
79
  _b.sent();
@@ -3,6 +3,7 @@ export interface SignOptions {
3
3
  userVisibleData: string;
4
4
  userNonVisibleData?: string;
5
5
  endUserIp?: string;
6
+ payload?: Record<string, any>;
6
7
  }
7
8
  export interface SignResponse {
8
9
  orderRef: string;
@@ -96,6 +96,7 @@ function sign(ctx, options) {
96
96
  createdAt: new Date(),
97
97
  ip: clientIp,
98
98
  autoStartToken: signResponse.autoStartToken,
99
+ payload: options.payload,
99
100
  qr: {
100
101
  qrStartToken: signResponse.qrStartToken,
101
102
  qrStartSecret: signResponse.qrStartSecret,
@@ -56,7 +56,10 @@ var PostBankIdAuth = function (_a) { return __awaiter(void 0, [_a], void 0, func
56
56
  return [4 /*yield*/, options.onGetEndUserIp(req)];
57
57
  case 2:
58
58
  clientIp = _c.sent();
59
- return [4 /*yield*/, (0, auth_1.auth)(ctx, { endUserIp: clientIp })];
59
+ return [4 /*yield*/, (0, auth_1.auth)(ctx, {
60
+ endUserIp: clientIp,
61
+ payload: req.body.payload
62
+ })];
60
63
  case 3:
61
64
  authResponse = _c.sent();
62
65
  return [2 /*return*/, {
@@ -1,2 +1,3 @@
1
1
  export default interface AuthInitiateReq {
2
+ payload?: Record<string, any>;
2
3
  }
@@ -22,6 +22,7 @@ export default interface BankIdSession {
22
22
  hintCode?: string | null;
23
23
  ip: string;
24
24
  autoStartToken: string;
25
+ payload?: Record<string, any>;
25
26
  qr?: {
26
27
  qrStartToken: string;
27
28
  qrStartSecret: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/bankid-plugin",
3
- "version": "0.12.1-alpha.23",
3
+ "version": "0.12.1-alpha.24",
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": "ab25ba2532fd79e5452390591c1899fbe3eae230"
35
+ "gitHead": "7acc954a5cfd65c1cba7707d633c18025cc80dcd"
36
36
  }
@@ -0,0 +1,5 @@
1
+ describe("BankID Plugin", () => {
2
+ it("should be testable", () => {
3
+ expect(true).toBe(true);
4
+ });
5
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "spec_dir": "spec",
3
+ "spec_files": ["**/*[sS]pec.ts"],
4
+ "helpers": ["helpers/**/*.ts"],
5
+ "stopSpecOnExpectationFailure": false,
6
+ "random": true
7
+ }
@@ -57,9 +57,10 @@ export interface BankIdPluginOptions {
57
57
  * token. This will be relayed in the collect response to client.
58
58
  * @param userData
59
59
  * @param ip
60
+ * @param payload
60
61
  * @returns
61
62
  */
62
- onAuthSuccess: (userData: BankIdUserData, ip?: string) => Promise<AuthSuccessCallbackResponse>;
63
+ onAuthSuccess: (userData: BankIdUserData, ip?: string, payload?: Record<string, any>) => Promise<AuthSuccessCallbackResponse>;
63
64
 
64
65
  /**
65
66
  * Callback invoked when BankID sign is successful.
@@ -67,9 +68,10 @@ export interface BankIdPluginOptions {
67
68
  * signature data. This will be relayed in the collect response to client.
68
69
  * @param userData
69
70
  * @param signature
71
+ * @param payload
70
72
  * @returns
71
73
  */
72
- onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature) => Promise<void>;
74
+ onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature, payload?: Record<string, any>) => Promise<void>;
73
75
 
74
76
  /**
75
77
  * For how long to keep sessions in database.
@@ -5,6 +5,7 @@ import { checkAndGenerateQr } from "../bankid-utils";
5
5
 
6
6
  export interface AuthOptions {
7
7
  endUserIp?: string;
8
+ payload?: Record<string, any>;
8
9
  }
9
10
 
10
11
  export interface AuthResponse {
@@ -55,6 +56,7 @@ export async function auth(ctx: BankIdInternalCtx, options: AuthOptions = {}): P
55
56
  createdAt: new Date(),
56
57
  ip: clientIp,
57
58
  autoStartToken: authResponse.autoStartToken,
59
+ payload: options.payload,
58
60
  qr: {
59
61
  qrStartToken: authResponse.qrStartToken,
60
62
  qrStartSecret: authResponse.qrStartSecret,
@@ -40,7 +40,7 @@ export async function getAuthStatus(ctx: BankIdInternalCtx, options: AuthStatusO
40
40
  // - Create user if not found
41
41
  // - Create access token
42
42
  // If host app throws for example notFound error, this will be propagated as response here
43
- const authCallbackRes = await pluginOptions.onAuthSuccess(session.user, session.device?.ipAddress);
43
+ const authCallbackRes = await pluginOptions.onAuthSuccess(session.user, session.device?.ipAddress, session.payload);
44
44
 
45
45
  return {
46
46
  status: "complete",
@@ -48,7 +48,7 @@ export async function getSignStatus(ctx: BankIdInternalCtx, options: SignStatusO
48
48
  }
49
49
 
50
50
  // Invoke host app callback
51
- await pluginOptions.onSignSuccess(session.user, session.signature);
51
+ await pluginOptions.onSignSuccess(session.user, session.signature, session.payload);
52
52
 
53
53
  return {
54
54
  status: "complete",
@@ -7,6 +7,7 @@ export interface SignOptions {
7
7
  userVisibleData: string;
8
8
  userNonVisibleData?: string;
9
9
  endUserIp?: string;
10
+ payload?: Record<string, any>;
10
11
  }
11
12
 
12
13
  export interface SignResponse {
@@ -69,6 +70,7 @@ export async function sign(ctx: BankIdInternalCtx, options: SignOptions): Promis
69
70
  createdAt: new Date(),
70
71
  ip: clientIp,
71
72
  autoStartToken: signResponse.autoStartToken,
73
+ payload: options.payload,
72
74
  qr: {
73
75
  qrStartToken: signResponse.qrStartToken,
74
76
  qrStartSecret: signResponse.qrStartSecret,
@@ -15,7 +15,10 @@ const PostBankIdAuth: Handler<BankIdInternalCtx, AuthInitiateReq, AuthInitiateRe
15
15
  try {
16
16
  let clientIp = await options.onGetEndUserIp(req);
17
17
 
18
- const authResponse = await auth(ctx, { endUserIp: clientIp });
18
+ const authResponse = await auth(ctx, {
19
+ endUserIp: clientIp,
20
+ payload: req.body.payload
21
+ });
19
22
 
20
23
  return {
21
24
  data: authResponse,
@@ -1 +1,3 @@
1
- export default interface AuthInitiateReq {}
1
+ export default interface AuthInitiateReq {
2
+ payload?: Record<string, any>;
3
+ }
@@ -24,6 +24,7 @@ export default interface BankIdSession {
24
24
  hintCode?: string | null;
25
25
  ip: string;
26
26
  autoStartToken: string;
27
+ payload?: Record<string, any>;
27
28
  qr?: {
28
29
  qrStartToken: string;
29
30
  qrStartSecret: string;