@flink-app/bankid-plugin 1.0.0 → 2.0.0-alpha.101

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,376 @@
1
1
  # @flink-app/bankid-plugin
2
2
 
3
+ ## 2.0.0-alpha.101
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b11f2f8]
8
+ - @flink-app/flink@2.0.0-alpha.101
9
+
10
+ ## 2.0.0-alpha.100
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [6e8166a]
15
+ - @flink-app/flink@2.0.0-alpha.100
16
+
17
+ ## 2.0.0-alpha.99
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [ed9cd2c]
22
+ - @flink-app/flink@2.0.0-alpha.99
23
+
24
+ ## 2.0.0-alpha.98
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [2f4a132]
29
+ - @flink-app/flink@2.0.0-alpha.98
30
+
31
+ ## 2.0.0-alpha.97
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [eed6bc1]
36
+ - @flink-app/flink@2.0.0-alpha.97
37
+
38
+ ## 2.0.0-alpha.96
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies
43
+ - @flink-app/flink@2.0.0-alpha.96
44
+
45
+ ## 2.0.0-alpha.95
46
+
47
+ ### Patch Changes
48
+
49
+ - @flink-app/flink@2.0.0-alpha.95
50
+
51
+ ## 2.0.0-alpha.94
52
+
53
+ ### Patch Changes
54
+
55
+ - @flink-app/flink@2.0.0-alpha.94
56
+
57
+ ## 2.0.0-alpha.93
58
+
59
+ ### Patch Changes
60
+
61
+ - @flink-app/flink@2.0.0-alpha.93
62
+
63
+ ## 2.0.0-alpha.92
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [8d23d56]
68
+ - @flink-app/flink@2.0.0-alpha.92
69
+
70
+ ## 2.0.0-alpha.91
71
+
72
+ ### Patch Changes
73
+
74
+ - @flink-app/flink@2.0.0-alpha.91
75
+
76
+ ## 2.0.0-alpha.90
77
+
78
+ ### Patch Changes
79
+
80
+ - Updated dependencies [0d84b5f]
81
+ - @flink-app/flink@2.0.0-alpha.90
82
+
83
+ ## 2.0.0-alpha.89
84
+
85
+ ### Patch Changes
86
+
87
+ - @flink-app/flink@2.0.0-alpha.89
88
+
89
+ ## 2.0.0-alpha.88
90
+
91
+ ### Patch Changes
92
+
93
+ - @flink-app/flink@2.0.0-alpha.88
94
+
95
+ ## 2.0.0-alpha.87
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies
100
+ - @flink-app/flink@2.0.0-alpha.87
101
+
102
+ ## 2.0.0-alpha.86
103
+
104
+ ### Patch Changes
105
+
106
+ - @flink-app/flink@2.0.0-alpha.86
107
+
108
+ ## 2.0.0-alpha.85
109
+
110
+ ### Patch Changes
111
+
112
+ - @flink-app/flink@2.0.0-alpha.85
113
+
114
+ ## 2.0.0-alpha.84
115
+
116
+ ### Patch Changes
117
+
118
+ - @flink-app/flink@2.0.0-alpha.84
119
+
120
+ ## 2.0.0-alpha.83
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies
125
+ - @flink-app/flink@2.0.0-alpha.83
126
+
127
+ ## 2.0.0-alpha.82
128
+
129
+ ### Patch Changes
130
+
131
+ - @flink-app/flink@2.0.0-alpha.82
132
+
133
+ ## 2.0.0-alpha.81
134
+
135
+ ### Patch Changes
136
+
137
+ - Pass ctx to onAuthSuccess and onSignSuccess callbacks, matching the OIDC plugin pattern. Callbacks now receive a params object as first argument and the Flink context (TCtx) as second argument. Plugin factory is now generic: `bankIdPlugin<TCtx>()`.
138
+ - @flink-app/flink@2.0.0-alpha.81
139
+
140
+ ## 2.0.0-alpha.80
141
+
142
+ ### Patch Changes
143
+
144
+ - @flink-app/flink@2.0.0-alpha.80
145
+
146
+ ## 2.0.0-alpha.79
147
+
148
+ ### Patch Changes
149
+
150
+ - @flink-app/flink@2.0.0-alpha.79
151
+
152
+ ## 2.0.0-alpha.78
153
+
154
+ ### Patch Changes
155
+
156
+ - @flink-app/flink@2.0.0-alpha.78
157
+
158
+ ## 2.0.0-alpha.77
159
+
160
+ ### Patch Changes
161
+
162
+ - @flink-app/flink@2.0.0-alpha.77
163
+
164
+ ## 2.0.0-alpha.76
165
+
166
+ ### Patch Changes
167
+
168
+ - @flink-app/flink@2.0.0-alpha.76
169
+
170
+ ## 2.0.0-alpha.75
171
+
172
+ ### Patch Changes
173
+
174
+ - @flink-app/flink@2.0.0-alpha.75
175
+
176
+ ## 2.0.0-alpha.74
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies
181
+ - Updated dependencies
182
+ - @flink-app/flink@2.0.0-alpha.74
183
+
184
+ ## 2.0.0-alpha.73
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies
189
+ - @flink-app/flink@2.0.0-alpha.73
190
+
191
+ ## 2.0.0-alpha.72
192
+
193
+ ### Patch Changes
194
+
195
+ - Updated dependencies
196
+ - @flink-app/flink@2.0.0-alpha.72
197
+
198
+ ## 2.0.0-alpha.71
199
+
200
+ ### Patch Changes
201
+
202
+ - @flink-app/flink@2.0.0-alpha.71
203
+
204
+ ## 2.0.0-alpha.70
205
+
206
+ ### Patch Changes
207
+
208
+ - @flink-app/flink@2.0.0-alpha.70
209
+
210
+ ## 2.0.0-alpha.69
211
+
212
+ ### Patch Changes
213
+
214
+ - @flink-app/flink@2.0.0-alpha.69
215
+
216
+ ## 2.0.0-alpha.68
217
+
218
+ ### Patch Changes
219
+
220
+ - @flink-app/flink@2.0.0-alpha.68
221
+
222
+ ## 2.0.0-alpha.67
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies [418cb54]
227
+ - Updated dependencies [70d574c]
228
+ - @flink-app/flink@2.0.0-alpha.67
229
+
230
+ ## 2.0.0-alpha.66
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [5593d26]
235
+ - @flink-app/flink@2.0.0-alpha.66
236
+
237
+ ## 2.0.0-alpha.65
238
+
239
+ ### Patch Changes
240
+
241
+ - @flink-app/flink@2.0.0-alpha.65
242
+
243
+ ## 2.0.0-alpha.64
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [95b99ee]
248
+ - @flink-app/flink@2.0.0-alpha.64
249
+
250
+ ## 2.0.0-alpha.63
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [810df2c]
255
+ - Updated dependencies [8dd0752]
256
+ - @flink-app/flink@2.0.0-alpha.63
257
+
258
+ ## 2.0.0-alpha.62
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies
263
+ - @flink-app/flink@2.0.0-alpha.62
264
+
265
+ ## 2.0.0-alpha.61
266
+
267
+ ### Patch Changes
268
+
269
+ - @flink-app/flink@2.0.0-alpha.61
270
+
271
+ ## 2.0.0-alpha.60
272
+
273
+ ### Patch Changes
274
+
275
+ - @flink-app/flink@2.0.0-alpha.60
276
+
277
+ ## 2.0.0-alpha.59
278
+
279
+ ### Patch Changes
280
+
281
+ - Updated dependencies [dbc2119]
282
+ - @flink-app/flink@2.0.0-alpha.59
283
+
284
+ ## 2.0.0-alpha.58
285
+
286
+ ### Patch Changes
287
+
288
+ - Updated dependencies
289
+ - @flink-app/flink@2.0.0-alpha.58
290
+
291
+ ## 2.0.0-alpha.57
292
+
293
+ ### Patch Changes
294
+
295
+ - Updated dependencies [ef7f495]
296
+ - Updated dependencies [2d53aa4]
297
+ - Updated dependencies [b3cc5d1]
298
+ - Updated dependencies [d377fac]
299
+ - Updated dependencies [4ad44c0]
300
+ - Updated dependencies [90f80c7]
301
+ - Updated dependencies [f0887e7]
302
+ - Updated dependencies [68c46d3]
303
+ - Updated dependencies [4ad44c0]
304
+ - Updated dependencies
305
+ - @flink-app/flink@2.0.0-alpha.57
306
+
307
+ ## 2.0.0-alpha.56
308
+
309
+ ### Patch Changes
310
+
311
+ - Zod 3.x compat
312
+ - Updated dependencies
313
+ - Updated dependencies [0203256]
314
+ - @flink-app/flink@2.0.0-alpha.56
315
+
316
+ ## 2.0.0-alpha.55
317
+
318
+ ### Patch Changes
319
+
320
+ - Updated dependencies [3267206]
321
+ - Updated dependencies [497b7c2]
322
+ - Updated dependencies [3267206]
323
+ - @flink-app/flink@2.0.0-alpha.55
324
+
325
+ ## 2.0.0-alpha.53
326
+
327
+ ### Patch Changes
328
+
329
+ - Updated dependencies [669c806]
330
+ - @flink-app/flink@2.0.0-alpha.53
331
+
332
+ ## 2.0.0-alpha.52
333
+
334
+ ### Patch Changes
335
+
336
+ - Updated dependencies [fe9f8f2]
337
+ - @flink-app/flink@2.0.0-alpha.52
338
+
339
+ ## 2.0.0-alpha.51
340
+
341
+ ### Patch Changes
342
+
343
+ - fix: add peerDependencies to all plugins and adapters
344
+
345
+ **Breaking Change Prevention:**
346
+
347
+ - Added "@flink-app/flink": ">=2.0.0-alpha.0" as peerDependency to all plugins
348
+ - Fixed oidc-plugin peerDependencies from "workspace:\*" to proper version ranges
349
+ - Fixed oauth-plugin to include @flink-app/flink peerDependency
350
+
351
+ **JWT Auth Plugin Interface Fix:**
352
+
353
+ - Removed redundant createToken declaration from JwtAuthPlugin interface
354
+ - The method is already inherited from FlinkAuthPlugin, this fixes TypeScript type checking issues
355
+
356
+ **Why this matters:**
357
+
358
+ - Ensures only one version of @flink-app/flink exists in node_modules
359
+ - Prevents type conflicts when TypeScript resolves interfaces across packages
360
+ - Follows standard plugin architecture best practices (same pattern as React, Webpack, etc.)
361
+ - Package managers now warn if incompatible versions are installed
362
+ - @flink-app/flink@2.0.0-alpha.51
363
+
364
+ ## 2.0.0-alpha.50
365
+
366
+ ## 2.0.0-alpha.49
367
+
368
+ ### Patch Changes
369
+
370
+ - Typescript include fix
371
+
372
+ ## 2.0.0-alpha.48
373
+
3
374
  ## 1.0.0
4
375
 
5
376
  ### Minor Changes
@@ -1,3 +1,3 @@
1
1
  import { FlinkPlugin } from "@flink-app/flink";
2
2
  import { BankIdPluginOptions } from "./BankIdPluginOptions";
3
- export declare function bankIdPlugin(options: BankIdPluginOptions): FlinkPlugin;
3
+ export declare function bankIdPlugin<TCtx = any>(options: BankIdPluginOptions<TCtx>): FlinkPlugin;
@@ -14,7 +14,7 @@ export interface AuthSuccessCallbackResponse {
14
14
  user: any;
15
15
  token: string;
16
16
  }
17
- export interface BankIdPluginOptions {
17
+ export interface BankIdPluginOptions<TCtx = any> {
18
18
  /**
19
19
  * BankID PFX certificate in base64 format
20
20
  */
@@ -46,22 +46,27 @@ export interface BankIdPluginOptions {
46
46
  * Callback invoked when BankID auth is successful.
47
47
  * Callback must return an object containing user information and
48
48
  * token. This will be relayed in the collect response to client.
49
- * @param userData
50
- * @param ip
51
- * @param payload
52
- * @returns
49
+ *
50
+ * @param params - Auth result data (user, ip, payload)
51
+ * @param ctx - Flink context with access to repos and plugins
52
+ * @returns User object and JWT token
53
53
  */
54
- onAuthSuccess: (userData: BankIdUserData, ip?: string, payload?: Record<string, any>) => Promise<AuthSuccessCallbackResponse>;
54
+ onAuthSuccess: (params: {
55
+ user: BankIdUserData;
56
+ ip?: string;
57
+ payload?: Record<string, any>;
58
+ }, ctx: TCtx) => Promise<AuthSuccessCallbackResponse>;
55
59
  /**
56
60
  * Callback invoked when BankID sign is successful.
57
- * Callback must return an object containing user information and
58
- * signature data. This will be relayed in the collect response to client.
59
- * @param userData
60
- * @param signature
61
- * @param payload
62
- * @returns
61
+ *
62
+ * @param params - Sign result data (user, signature, payload)
63
+ * @param ctx - Flink context with access to repos and plugins
63
64
  */
64
- onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature, payload?: Record<string, any>) => Promise<void>;
65
+ onSignSuccess?: (params: {
66
+ user: BankIdUserData;
67
+ signature: BankIdSignature;
68
+ payload?: Record<string, any>;
69
+ }, ctx: TCtx) => Promise<void>;
65
70
  /**
66
71
  * For how long to keep sessions in database.
67
72
  * This has nothing to do with how long the user is logged in, only
@@ -60,7 +60,7 @@ function getAuthStatus(ctx, options) {
60
60
  case 2:
61
61
  _c.sent();
62
62
  throw (0, flink_1.internalServerError)("Session is completed but 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, session.payload)];
63
+ case 3: return [4 /*yield*/, pluginOptions.onAuthSuccess({ user: session.user, ip: (_a = session.device) === null || _a === void 0 ? void 0 : _a.ipAddress, payload: session.payload }, ctx)];
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, session.payload)];
76
+ return [4 /*yield*/, pluginOptions.onSignSuccess({ user: session.user, signature: session.signature, payload: session.payload }, ctx)];
77
77
  case 6:
78
78
  // Invoke host app callback
79
79
  _b.sent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/bankid-plugin",
3
- "version": "1.0.0",
3
+ "version": "2.0.0-alpha.101",
4
4
  "description": "Flink plugin for Swedish BankID authentication and document signing",
5
5
  "author": "joel@frost.se",
6
6
  "license": "MIT",
@@ -20,9 +20,12 @@
20
20
  "@types/node": "22.13.10",
21
21
  "ts-node": "^10.9.2",
22
22
  "tsc-watch": "^4.2.9",
23
- "@flink-app/flink": "1.0.0"
23
+ "@flink-app/flink": "2.0.0-alpha.101"
24
24
  },
25
25
  "gitHead": "4243e3b3cd6d4e1ca001a61baa8436bf2bbe4113",
26
+ "peerDependencies": {
27
+ "@flink-app/flink": ">=2.0.0-alpha.101"
28
+ },
26
29
  "scripts": {
27
30
  "test": "jasmine-ts --config=./spec/support/jasmine.json",
28
31
  "test:watch": "nodemon --ext ts --exec 'jasmine-ts --config=./spec/support/jasmine.json'",
@@ -13,7 +13,7 @@ import { getAuthStatus } from "./functions/getAuthStatus";
13
13
  import { getSignStatus } from "./functions/getSignStatus";
14
14
  import { cancelSession } from "./functions/cancelSession";
15
15
 
16
- export function bankIdPlugin(options: BankIdPluginOptions): FlinkPlugin {
16
+ export function bankIdPlugin<TCtx = any>(options: BankIdPluginOptions<TCtx>): FlinkPlugin {
17
17
  if (!options.pfxBase64) {
18
18
  throw new Error("BankID Plugin: pfxBase64 is required");
19
19
  }
@@ -18,7 +18,7 @@ export interface AuthSuccessCallbackResponse {
18
18
  token: string;
19
19
  }
20
20
 
21
- export interface BankIdPluginOptions {
21
+ export interface BankIdPluginOptions<TCtx = any> {
22
22
  /**
23
23
  * BankID PFX certificate in base64 format
24
24
  */
@@ -55,23 +55,34 @@ export interface BankIdPluginOptions {
55
55
  * Callback invoked when BankID auth is successful.
56
56
  * Callback must return an object containing user information and
57
57
  * token. This will be relayed in the collect response to client.
58
- * @param userData
59
- * @param ip
60
- * @param payload
61
- * @returns
58
+ *
59
+ * @param params - Auth result data (user, ip, payload)
60
+ * @param ctx - Flink context with access to repos and plugins
61
+ * @returns User object and JWT token
62
62
  */
63
- onAuthSuccess: (userData: BankIdUserData, ip?: string, payload?: Record<string, any>) => Promise<AuthSuccessCallbackResponse>;
63
+ onAuthSuccess: (
64
+ params: {
65
+ user: BankIdUserData;
66
+ ip?: string;
67
+ payload?: Record<string, any>;
68
+ },
69
+ ctx: TCtx
70
+ ) => Promise<AuthSuccessCallbackResponse>;
64
71
 
65
72
  /**
66
73
  * Callback invoked when BankID sign is successful.
67
- * Callback must return an object containing user information and
68
- * signature data. This will be relayed in the collect response to client.
69
- * @param userData
70
- * @param signature
71
- * @param payload
72
- * @returns
74
+ *
75
+ * @param params - Sign result data (user, signature, payload)
76
+ * @param ctx - Flink context with access to repos and plugins
73
77
  */
74
- onSignSuccess?: (userData: BankIdUserData, signature: BankIdSignature, payload?: Record<string, any>) => Promise<void>;
78
+ onSignSuccess?: (
79
+ params: {
80
+ user: BankIdUserData;
81
+ signature: BankIdSignature;
82
+ payload?: Record<string, any>;
83
+ },
84
+ ctx: TCtx
85
+ ) => Promise<void>;
75
86
 
76
87
  /**
77
88
  * For how long to keep sessions in database.
@@ -40,7 +40,10 @@ 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, session.payload);
43
+ const authCallbackRes = await pluginOptions.onAuthSuccess(
44
+ { user: session.user, ip: session.device?.ipAddress, payload: session.payload },
45
+ ctx
46
+ );
44
47
 
45
48
  return {
46
49
  status: "complete",
@@ -48,7 +48,10 @@ 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, session.payload);
51
+ await pluginOptions.onSignSuccess(
52
+ { user: session.user, signature: session.signature, payload: session.payload },
53
+ ctx
54
+ );
52
55
 
53
56
  return {
54
57
  status: "complete",