docpouch-client 1.1.4 → 1.2.0
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/coverage/lcov-report/index.html +20 -20
- package/coverage/lcov.info +410 -234
- package/dist/index.d.ts +118 -0
- package/dist/index.js +266 -0
- package/package.json +1 -1
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">56.74% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>446/
|
|
28
|
+
<span class='fraction'>446/786</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">42.16% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>234/
|
|
35
|
+
<span class='fraction'>234/555</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">74.59% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>91/
|
|
42
|
+
<span class='fraction'>91/122</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">59.25% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>432/
|
|
49
|
+
<span class='fraction'>432/729</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -79,18 +79,18 @@
|
|
|
79
79
|
</tr>
|
|
80
80
|
</thead>
|
|
81
81
|
<tbody><tr>
|
|
82
|
-
<td class="file
|
|
83
|
-
<td data-value="
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width:
|
|
82
|
+
<td class="file low" data-value="src"><a href="src/index.html">src</a></td>
|
|
83
|
+
<td data-value="43.13" class="pic low">
|
|
84
|
+
<div class="chart"><div class="cover-fill" style="width: 43%"></div><div class="cover-empty" style="width: 57%"></div></div>
|
|
85
85
|
</td>
|
|
86
|
-
<td data-value="
|
|
87
|
-
<td data-value="
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="
|
|
90
|
-
<td data-value="
|
|
91
|
-
<td data-value="
|
|
92
|
-
<td data-value="
|
|
93
|
-
<td data-value="
|
|
86
|
+
<td data-value="43.13" class="pct low">43.13%</td>
|
|
87
|
+
<td data-value="466" class="abs low">201/466</td>
|
|
88
|
+
<td data-value="33.9" class="pct low">33.9%</td>
|
|
89
|
+
<td data-value="348" class="abs low">118/348</td>
|
|
90
|
+
<td data-value="66.66" class="pct medium">66.66%</td>
|
|
91
|
+
<td data-value="72" class="abs medium">48/72</td>
|
|
92
|
+
<td data-value="43.4" class="pct low">43.4%</td>
|
|
93
|
+
<td data-value="447" class="abs low">194/447</td>
|
|
94
94
|
</tr>
|
|
95
95
|
|
|
96
96
|
<tr>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
117
117
|
Code coverage generated by
|
|
118
118
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
119
|
-
at 2026-
|
|
119
|
+
at 2026-07-05T08:03:42.223Z
|
|
120
120
|
</div>
|
|
121
121
|
<script src="prettify.js"></script>
|
|
122
122
|
<script>
|
package/coverage/lcov.info
CHANGED
|
@@ -36,34 +36,43 @@ FN:702,(anonymous_32)
|
|
|
36
36
|
FN:709,(anonymous_33)
|
|
37
37
|
FN:716,(anonymous_34)
|
|
38
38
|
FN:726,(anonymous_35)
|
|
39
|
-
FN:
|
|
40
|
-
FN:
|
|
41
|
-
FN:
|
|
42
|
-
FN:
|
|
43
|
-
FN:
|
|
44
|
-
FN:
|
|
45
|
-
FN:
|
|
46
|
-
FN:
|
|
47
|
-
FN:
|
|
48
|
-
FN:
|
|
49
|
-
FN:
|
|
50
|
-
FN:
|
|
51
|
-
FN:
|
|
52
|
-
FN:
|
|
53
|
-
FN:
|
|
54
|
-
FN:
|
|
55
|
-
FN:
|
|
56
|
-
FN:
|
|
57
|
-
FN:
|
|
58
|
-
FN:
|
|
59
|
-
FN:
|
|
60
|
-
FN:
|
|
61
|
-
FN:
|
|
62
|
-
FN:
|
|
63
|
-
FN:
|
|
64
|
-
FN:
|
|
65
|
-
FN:
|
|
66
|
-
|
|
39
|
+
FN:812,(anonymous_36)
|
|
40
|
+
FN:823,(anonymous_37)
|
|
41
|
+
FN:835,(anonymous_38)
|
|
42
|
+
FN:846,(anonymous_39)
|
|
43
|
+
FN:855,(anonymous_40)
|
|
44
|
+
FN:857,(anonymous_41)
|
|
45
|
+
FN:862,(anonymous_42)
|
|
46
|
+
FN:867,(anonymous_43)
|
|
47
|
+
FN:872,(anonymous_44)
|
|
48
|
+
FN:883,(anonymous_45)
|
|
49
|
+
FN:917,(anonymous_46)
|
|
50
|
+
FN:931,(anonymous_47)
|
|
51
|
+
FN:961,(anonymous_48)
|
|
52
|
+
FN:967,(anonymous_49)
|
|
53
|
+
FN:1009,(anonymous_50)
|
|
54
|
+
FN:1014,(anonymous_51)
|
|
55
|
+
FN:1023,(anonymous_52)
|
|
56
|
+
FN:1034,(anonymous_53)
|
|
57
|
+
FN:1046,(anonymous_54)
|
|
58
|
+
FN:1052,(anonymous_55)
|
|
59
|
+
FN:1083,(anonymous_56)
|
|
60
|
+
FN:1087,(anonymous_57)
|
|
61
|
+
FN:1090,(anonymous_58)
|
|
62
|
+
FN:1100,(anonymous_59)
|
|
63
|
+
FN:1103,(anonymous_60)
|
|
64
|
+
FN:1111,(anonymous_61)
|
|
65
|
+
FN:1118,(anonymous_62)
|
|
66
|
+
FN:1140,(anonymous_63)
|
|
67
|
+
FN:1162,(anonymous_64)
|
|
68
|
+
FN:1195,(anonymous_65)
|
|
69
|
+
FN:1254,(anonymous_66)
|
|
70
|
+
FN:1309,(anonymous_67)
|
|
71
|
+
FN:1325,(anonymous_68)
|
|
72
|
+
FN:1337,(anonymous_69)
|
|
73
|
+
FN:1361,(anonymous_70)
|
|
74
|
+
FN:1396,(anonymous_71)
|
|
75
|
+
FNF:72
|
|
67
76
|
FNH:48
|
|
68
77
|
FNDA:69,(anonymous_0)
|
|
69
78
|
FNDA:7,(anonymous_1)
|
|
@@ -128,6 +137,15 @@ FNDA:3,(anonymous_59)
|
|
|
128
137
|
FNDA:96,(anonymous_60)
|
|
129
138
|
FNDA:0,(anonymous_61)
|
|
130
139
|
FNDA:2,(anonymous_62)
|
|
140
|
+
FNDA:0,(anonymous_63)
|
|
141
|
+
FNDA:0,(anonymous_64)
|
|
142
|
+
FNDA:0,(anonymous_65)
|
|
143
|
+
FNDA:0,(anonymous_66)
|
|
144
|
+
FNDA:0,(anonymous_67)
|
|
145
|
+
FNDA:0,(anonymous_68)
|
|
146
|
+
FNDA:0,(anonymous_69)
|
|
147
|
+
FNDA:0,(anonymous_70)
|
|
148
|
+
FNDA:0,(anonymous_71)
|
|
131
149
|
DA:45,69
|
|
132
150
|
DA:52,69
|
|
133
151
|
DA:53,69
|
|
@@ -345,57 +363,56 @@ DA:717,1
|
|
|
345
363
|
DA:728,0
|
|
346
364
|
DA:732,0
|
|
347
365
|
DA:733,0
|
|
348
|
-
DA:737,0
|
|
349
366
|
DA:738,0
|
|
350
|
-
DA:
|
|
367
|
+
DA:739,0
|
|
368
|
+
DA:742,0
|
|
351
369
|
DA:743,0
|
|
352
|
-
DA:744,0
|
|
353
370
|
DA:746,0
|
|
354
|
-
DA:
|
|
355
|
-
DA:
|
|
356
|
-
DA:
|
|
357
|
-
DA:
|
|
371
|
+
DA:748,0
|
|
372
|
+
DA:749,0
|
|
373
|
+
DA:751,0
|
|
374
|
+
DA:755,0
|
|
358
375
|
DA:757,0
|
|
359
376
|
DA:758,0
|
|
360
|
-
DA:
|
|
361
|
-
DA:
|
|
362
|
-
DA:
|
|
363
|
-
DA:
|
|
364
|
-
DA:
|
|
365
|
-
DA:
|
|
366
|
-
DA:
|
|
367
|
-
DA:
|
|
377
|
+
DA:761,0
|
|
378
|
+
DA:762,0
|
|
379
|
+
DA:763,0
|
|
380
|
+
DA:764,0
|
|
381
|
+
DA:765,0
|
|
382
|
+
DA:771,0
|
|
383
|
+
DA:774,0
|
|
384
|
+
DA:775,0
|
|
368
385
|
DA:777,0
|
|
369
386
|
DA:778,0
|
|
370
|
-
DA:
|
|
371
|
-
DA:
|
|
387
|
+
DA:781,0
|
|
388
|
+
DA:782,0
|
|
389
|
+
DA:783,0
|
|
372
390
|
DA:784,0
|
|
373
391
|
DA:785,0
|
|
374
|
-
DA:
|
|
392
|
+
DA:789,0
|
|
393
|
+
DA:790,0
|
|
375
394
|
DA:792,0
|
|
376
|
-
DA:
|
|
377
|
-
DA:
|
|
378
|
-
DA:
|
|
379
|
-
DA:
|
|
380
|
-
DA:
|
|
381
|
-
DA:
|
|
382
|
-
DA:
|
|
383
|
-
DA:853,0
|
|
384
|
-
DA:854,0
|
|
395
|
+
DA:797,0
|
|
396
|
+
DA:798,0
|
|
397
|
+
DA:800,0
|
|
398
|
+
DA:813,10
|
|
399
|
+
DA:824,3
|
|
400
|
+
DA:836,1
|
|
401
|
+
DA:847,2
|
|
385
402
|
DA:857,69
|
|
386
|
-
DA:858,
|
|
387
|
-
DA:859,
|
|
403
|
+
DA:858,0
|
|
404
|
+
DA:859,0
|
|
388
405
|
DA:862,69
|
|
389
406
|
DA:863,5
|
|
390
407
|
DA:864,5
|
|
391
408
|
DA:867,69
|
|
392
|
-
DA:868,
|
|
393
|
-
DA:869,
|
|
394
|
-
DA:
|
|
395
|
-
DA:
|
|
409
|
+
DA:868,5
|
|
410
|
+
DA:869,5
|
|
411
|
+
DA:872,69
|
|
412
|
+
DA:873,0
|
|
413
|
+
DA:874,0
|
|
414
|
+
DA:884,5
|
|
396
415
|
DA:885,5
|
|
397
|
-
DA:886,0
|
|
398
|
-
DA:887,0
|
|
399
416
|
DA:890,5
|
|
400
417
|
DA:891,0
|
|
401
418
|
DA:892,0
|
|
@@ -403,94 +420,180 @@ DA:895,5
|
|
|
403
420
|
DA:896,0
|
|
404
421
|
DA:897,0
|
|
405
422
|
DA:900,5
|
|
406
|
-
DA:
|
|
407
|
-
DA:
|
|
408
|
-
DA:
|
|
409
|
-
DA:
|
|
410
|
-
DA:
|
|
411
|
-
DA:
|
|
412
|
-
DA:914,
|
|
413
|
-
DA:
|
|
414
|
-
DA:
|
|
415
|
-
DA:
|
|
416
|
-
DA:
|
|
417
|
-
DA:
|
|
418
|
-
DA:
|
|
419
|
-
DA:927,
|
|
420
|
-
DA:928,
|
|
421
|
-
DA:
|
|
423
|
+
DA:901,0
|
|
424
|
+
DA:902,0
|
|
425
|
+
DA:905,5
|
|
426
|
+
DA:907,5
|
|
427
|
+
DA:908,5
|
|
428
|
+
DA:911,5
|
|
429
|
+
DA:914,5
|
|
430
|
+
DA:917,5
|
|
431
|
+
DA:918,2
|
|
432
|
+
DA:919,1
|
|
433
|
+
DA:920,1
|
|
434
|
+
DA:921,1
|
|
435
|
+
DA:922,1
|
|
436
|
+
DA:927,5
|
|
437
|
+
DA:928,5
|
|
438
|
+
DA:931,5
|
|
422
439
|
DA:932,0
|
|
423
440
|
DA:933,0
|
|
424
441
|
DA:934,0
|
|
425
|
-
DA:
|
|
442
|
+
DA:937,0
|
|
443
|
+
DA:938,0
|
|
444
|
+
DA:939,0
|
|
426
445
|
DA:940,0
|
|
427
|
-
DA:
|
|
428
|
-
DA:
|
|
429
|
-
DA:
|
|
430
|
-
DA:
|
|
431
|
-
DA:
|
|
432
|
-
DA:966,59
|
|
433
|
-
DA:967,99
|
|
434
|
-
DA:968,0
|
|
446
|
+
DA:945,0
|
|
447
|
+
DA:946,0
|
|
448
|
+
DA:962,99
|
|
449
|
+
DA:966,99
|
|
450
|
+
DA:967,0
|
|
435
451
|
DA:970,99
|
|
436
|
-
DA:
|
|
437
|
-
DA:
|
|
438
|
-
DA:
|
|
439
|
-
DA:
|
|
440
|
-
DA:
|
|
452
|
+
DA:971,59
|
|
453
|
+
DA:972,99
|
|
454
|
+
DA:973,0
|
|
455
|
+
DA:975,99
|
|
456
|
+
DA:981,99
|
|
457
|
+
DA:982,99
|
|
441
458
|
DA:988,99
|
|
442
|
-
DA:
|
|
443
|
-
DA:
|
|
444
|
-
DA:
|
|
445
|
-
DA:
|
|
446
|
-
DA:
|
|
447
|
-
DA:
|
|
448
|
-
DA:
|
|
449
|
-
DA:
|
|
459
|
+
DA:989,99
|
|
460
|
+
DA:992,99
|
|
461
|
+
DA:993,99
|
|
462
|
+
DA:995,98
|
|
463
|
+
DA:996,14
|
|
464
|
+
DA:997,7
|
|
465
|
+
DA:999,14
|
|
466
|
+
DA:1002,84
|
|
467
|
+
DA:1004,83
|
|
450
468
|
DA:1010,1
|
|
451
469
|
DA:1011,1
|
|
452
|
-
DA:1012,1
|
|
453
|
-
DA:1013,1
|
|
454
|
-
DA:1014,1
|
|
455
470
|
DA:1015,1
|
|
456
|
-
DA:
|
|
457
|
-
DA:
|
|
458
|
-
DA:
|
|
459
|
-
DA:
|
|
460
|
-
DA:
|
|
471
|
+
DA:1016,1
|
|
472
|
+
DA:1017,1
|
|
473
|
+
DA:1018,1
|
|
474
|
+
DA:1019,1
|
|
475
|
+
DA:1020,1
|
|
461
476
|
DA:1024,2
|
|
462
477
|
DA:1025,2
|
|
463
478
|
DA:1026,2
|
|
464
|
-
DA:
|
|
465
|
-
DA:
|
|
466
|
-
DA:
|
|
467
|
-
DA:
|
|
468
|
-
DA:
|
|
479
|
+
DA:1027,2
|
|
480
|
+
DA:1028,2
|
|
481
|
+
DA:1029,2
|
|
482
|
+
DA:1030,2
|
|
483
|
+
DA:1031,2
|
|
484
|
+
DA:1035,1
|
|
485
|
+
DA:1036,0
|
|
486
|
+
DA:1042,0
|
|
487
|
+
DA:1047,2
|
|
469
488
|
DA:1048,0
|
|
470
|
-
DA:
|
|
471
|
-
DA:
|
|
472
|
-
DA:
|
|
473
|
-
DA:
|
|
474
|
-
DA:1063,0
|
|
475
|
-
DA:1064,0
|
|
476
|
-
DA:1066,0
|
|
489
|
+
DA:1053,0
|
|
490
|
+
DA:1054,0
|
|
491
|
+
DA:1055,0
|
|
492
|
+
DA:1061,0
|
|
477
493
|
DA:1067,0
|
|
478
|
-
DA:
|
|
479
|
-
DA:
|
|
480
|
-
DA:
|
|
481
|
-
DA:
|
|
482
|
-
DA:
|
|
494
|
+
DA:1068,0
|
|
495
|
+
DA:1069,0
|
|
496
|
+
DA:1071,0
|
|
497
|
+
DA:1072,0
|
|
498
|
+
DA:1080,0
|
|
499
|
+
DA:1084,3
|
|
500
|
+
DA:1085,3
|
|
483
501
|
DA:1086,3
|
|
484
|
-
DA:1087,
|
|
485
|
-
DA:
|
|
486
|
-
DA:
|
|
487
|
-
DA:
|
|
488
|
-
DA:
|
|
489
|
-
DA:
|
|
490
|
-
DA:
|
|
491
|
-
DA:
|
|
492
|
-
DA:
|
|
493
|
-
|
|
502
|
+
DA:1087,192
|
|
503
|
+
DA:1091,3
|
|
504
|
+
DA:1092,3
|
|
505
|
+
DA:1093,3
|
|
506
|
+
DA:1094,3
|
|
507
|
+
DA:1101,3
|
|
508
|
+
DA:1102,3
|
|
509
|
+
DA:1103,96
|
|
510
|
+
DA:1112,0
|
|
511
|
+
DA:1119,2
|
|
512
|
+
DA:1120,0
|
|
513
|
+
DA:1141,0
|
|
514
|
+
DA:1142,0
|
|
515
|
+
DA:1143,0
|
|
516
|
+
DA:1146,0
|
|
517
|
+
DA:1147,0
|
|
518
|
+
DA:1148,0
|
|
519
|
+
DA:1150,0
|
|
520
|
+
DA:1163,0
|
|
521
|
+
DA:1164,0
|
|
522
|
+
DA:1166,0
|
|
523
|
+
DA:1199,0
|
|
524
|
+
DA:1200,0
|
|
525
|
+
DA:1202,0
|
|
526
|
+
DA:1206,0
|
|
527
|
+
DA:1210,0
|
|
528
|
+
DA:1220,0
|
|
529
|
+
DA:1221,0
|
|
530
|
+
DA:1222,0
|
|
531
|
+
DA:1223,0
|
|
532
|
+
DA:1229,0
|
|
533
|
+
DA:1230,0
|
|
534
|
+
DA:1231,0
|
|
535
|
+
DA:1233,0
|
|
536
|
+
DA:1234,0
|
|
537
|
+
DA:1236,0
|
|
538
|
+
DA:1256,0
|
|
539
|
+
DA:1257,0
|
|
540
|
+
DA:1258,0
|
|
541
|
+
DA:1259,0
|
|
542
|
+
DA:1260,0
|
|
543
|
+
DA:1261,0
|
|
544
|
+
DA:1265,0
|
|
545
|
+
DA:1266,0
|
|
546
|
+
DA:1267,0
|
|
547
|
+
DA:1268,0
|
|
548
|
+
DA:1269,0
|
|
549
|
+
DA:1270,0
|
|
550
|
+
DA:1271,0
|
|
551
|
+
DA:1275,0
|
|
552
|
+
DA:1279,0
|
|
553
|
+
DA:1280,0
|
|
554
|
+
DA:1281,0
|
|
555
|
+
DA:1282,0
|
|
556
|
+
DA:1283,0
|
|
557
|
+
DA:1288,0
|
|
558
|
+
DA:1289,0
|
|
559
|
+
DA:1290,0
|
|
560
|
+
DA:1291,0
|
|
561
|
+
DA:1292,0
|
|
562
|
+
DA:1293,0
|
|
563
|
+
DA:1297,0
|
|
564
|
+
DA:1310,0
|
|
565
|
+
DA:1311,0
|
|
566
|
+
DA:1312,0
|
|
567
|
+
DA:1313,0
|
|
568
|
+
DA:1314,0
|
|
569
|
+
DA:1316,0
|
|
570
|
+
DA:1326,0
|
|
571
|
+
DA:1327,0
|
|
572
|
+
DA:1338,0
|
|
573
|
+
DA:1339,0
|
|
574
|
+
DA:1340,0
|
|
575
|
+
DA:1341,0
|
|
576
|
+
DA:1342,0
|
|
577
|
+
DA:1343,0
|
|
578
|
+
DA:1344,0
|
|
579
|
+
DA:1345,0
|
|
580
|
+
DA:1362,0
|
|
581
|
+
DA:1363,0
|
|
582
|
+
DA:1364,0
|
|
583
|
+
DA:1366,0
|
|
584
|
+
DA:1367,0
|
|
585
|
+
DA:1370,0
|
|
586
|
+
DA:1373,0
|
|
587
|
+
DA:1374,0
|
|
588
|
+
DA:1382,0
|
|
589
|
+
DA:1383,0
|
|
590
|
+
DA:1385,0
|
|
591
|
+
DA:1386,0
|
|
592
|
+
DA:1397,0
|
|
593
|
+
DA:1398,0
|
|
594
|
+
DA:1399,0
|
|
595
|
+
DA:1402,0
|
|
596
|
+
LF:447
|
|
494
597
|
LH:194
|
|
495
598
|
BRDA:89,0,0,64
|
|
496
599
|
BRDA:92,1,0,69
|
|
@@ -668,106 +771,179 @@ BRDA:728,81,0,0
|
|
|
668
771
|
BRDA:728,81,1,0
|
|
669
772
|
BRDA:732,82,0,0
|
|
670
773
|
BRDA:732,82,1,0
|
|
671
|
-
BRDA:
|
|
672
|
-
BRDA:
|
|
774
|
+
BRDA:739,83,0,0
|
|
775
|
+
BRDA:739,83,1,0
|
|
673
776
|
BRDA:743,84,0,0
|
|
674
777
|
BRDA:743,84,1,0
|
|
675
|
-
BRDA:
|
|
676
|
-
BRDA:
|
|
677
|
-
BRDA:
|
|
678
|
-
BRDA:
|
|
679
|
-
BRDA:
|
|
680
|
-
BRDA:
|
|
681
|
-
BRDA:
|
|
682
|
-
BRDA:
|
|
683
|
-
BRDA:
|
|
684
|
-
BRDA:
|
|
685
|
-
BRDA:
|
|
686
|
-
BRDA:
|
|
687
|
-
BRDA:
|
|
688
|
-
BRDA:
|
|
689
|
-
BRDA:
|
|
690
|
-
BRDA:
|
|
691
|
-
BRDA:
|
|
692
|
-
BRDA:
|
|
693
|
-
BRDA:
|
|
694
|
-
BRDA:
|
|
695
|
-
BRDA:
|
|
696
|
-
BRDA:
|
|
697
|
-
BRDA:
|
|
698
|
-
BRDA:
|
|
699
|
-
BRDA:
|
|
700
|
-
BRDA:
|
|
701
|
-
BRDA:
|
|
702
|
-
BRDA:
|
|
703
|
-
BRDA:
|
|
704
|
-
BRDA:
|
|
705
|
-
BRDA:
|
|
706
|
-
BRDA:
|
|
707
|
-
BRDA:
|
|
708
|
-
BRDA:
|
|
709
|
-
BRDA:
|
|
710
|
-
BRDA:
|
|
711
|
-
BRDA:
|
|
712
|
-
BRDA:
|
|
713
|
-
BRDA:
|
|
714
|
-
BRDA:
|
|
715
|
-
BRDA:
|
|
716
|
-
BRDA:
|
|
717
|
-
BRDA:
|
|
718
|
-
BRDA:
|
|
719
|
-
BRDA:
|
|
720
|
-
BRDA:
|
|
721
|
-
BRDA:
|
|
722
|
-
BRDA:
|
|
723
|
-
BRDA:
|
|
724
|
-
BRDA:
|
|
725
|
-
BRDA:
|
|
726
|
-
BRDA:
|
|
727
|
-
BRDA:
|
|
728
|
-
BRDA:
|
|
729
|
-
BRDA:
|
|
730
|
-
BRDA:
|
|
731
|
-
BRDA:
|
|
732
|
-
BRDA:
|
|
733
|
-
BRDA:
|
|
734
|
-
BRDA:
|
|
735
|
-
BRDA:
|
|
736
|
-
BRDA:
|
|
737
|
-
BRDA:
|
|
738
|
-
BRDA:
|
|
739
|
-
BRDA:
|
|
740
|
-
BRDA:
|
|
741
|
-
BRDA:
|
|
742
|
-
BRDA:
|
|
743
|
-
BRDA:
|
|
744
|
-
BRDA:
|
|
745
|
-
BRDA:
|
|
746
|
-
BRDA:
|
|
747
|
-
BRDA:
|
|
748
|
-
BRDA:
|
|
749
|
-
BRDA:
|
|
750
|
-
BRDA:
|
|
751
|
-
BRDA:
|
|
752
|
-
BRDA:
|
|
753
|
-
BRDA:
|
|
754
|
-
BRDA:
|
|
755
|
-
BRDA:
|
|
756
|
-
BRDA:
|
|
757
|
-
BRDA:
|
|
758
|
-
BRDA:
|
|
759
|
-
BRDA:
|
|
760
|
-
BRDA:
|
|
761
|
-
BRDA:
|
|
762
|
-
BRDA:
|
|
763
|
-
BRDA:
|
|
764
|
-
BRDA:
|
|
765
|
-
BRDA:
|
|
766
|
-
BRDA:
|
|
767
|
-
BRDA:
|
|
768
|
-
BRDA:
|
|
769
|
-
BRDA:
|
|
770
|
-
|
|
778
|
+
BRDA:746,85,0,0
|
|
779
|
+
BRDA:746,85,1,0
|
|
780
|
+
BRDA:748,86,0,0
|
|
781
|
+
BRDA:748,86,1,0
|
|
782
|
+
BRDA:748,87,0,0
|
|
783
|
+
BRDA:748,87,1,0
|
|
784
|
+
BRDA:755,88,0,0
|
|
785
|
+
BRDA:755,88,1,0
|
|
786
|
+
BRDA:755,89,0,0
|
|
787
|
+
BRDA:755,89,1,0
|
|
788
|
+
BRDA:757,90,0,0
|
|
789
|
+
BRDA:757,90,1,0
|
|
790
|
+
BRDA:757,91,0,0
|
|
791
|
+
BRDA:757,91,1,0
|
|
792
|
+
BRDA:764,92,0,0
|
|
793
|
+
BRDA:764,92,1,0
|
|
794
|
+
BRDA:771,93,0,0
|
|
795
|
+
BRDA:771,93,1,0
|
|
796
|
+
BRDA:774,94,0,0
|
|
797
|
+
BRDA:774,94,1,0
|
|
798
|
+
BRDA:775,95,0,0
|
|
799
|
+
BRDA:775,95,1,0
|
|
800
|
+
BRDA:777,96,0,0
|
|
801
|
+
BRDA:777,96,1,0
|
|
802
|
+
BRDA:777,97,0,0
|
|
803
|
+
BRDA:777,97,1,0
|
|
804
|
+
BRDA:784,98,0,0
|
|
805
|
+
BRDA:784,98,1,0
|
|
806
|
+
BRDA:789,99,0,0
|
|
807
|
+
BRDA:789,99,1,0
|
|
808
|
+
BRDA:789,100,0,0
|
|
809
|
+
BRDA:789,100,1,0
|
|
810
|
+
BRDA:797,101,0,0
|
|
811
|
+
BRDA:797,101,1,0
|
|
812
|
+
BRDA:797,102,0,0
|
|
813
|
+
BRDA:797,102,1,0
|
|
814
|
+
BRDA:884,103,0,0
|
|
815
|
+
BRDA:884,103,1,5
|
|
816
|
+
BRDA:890,104,0,0
|
|
817
|
+
BRDA:890,104,1,5
|
|
818
|
+
BRDA:895,105,0,0
|
|
819
|
+
BRDA:895,105,1,5
|
|
820
|
+
BRDA:900,106,0,0
|
|
821
|
+
BRDA:900,106,1,5
|
|
822
|
+
BRDA:918,107,0,1
|
|
823
|
+
BRDA:918,107,1,1
|
|
824
|
+
BRDA:921,108,0,1
|
|
825
|
+
BRDA:921,108,1,0
|
|
826
|
+
BRDA:932,109,0,0
|
|
827
|
+
BRDA:932,109,1,0
|
|
828
|
+
BRDA:937,110,0,0
|
|
829
|
+
BRDA:937,110,1,0
|
|
830
|
+
BRDA:961,111,0,45
|
|
831
|
+
BRDA:966,112,0,99
|
|
832
|
+
BRDA:966,112,1,84
|
|
833
|
+
BRDA:966,113,0,0
|
|
834
|
+
BRDA:966,113,1,84
|
|
835
|
+
BRDA:970,114,0,59
|
|
836
|
+
BRDA:970,114,1,40
|
|
837
|
+
BRDA:970,115,0,99
|
|
838
|
+
BRDA:970,115,1,61
|
|
839
|
+
BRDA:972,116,0,0
|
|
840
|
+
BRDA:972,116,1,99
|
|
841
|
+
BRDA:978,117,0,71
|
|
842
|
+
BRDA:978,117,1,28
|
|
843
|
+
BRDA:981,118,0,99
|
|
844
|
+
BRDA:981,118,1,0
|
|
845
|
+
BRDA:982,119,0,1
|
|
846
|
+
BRDA:982,119,1,98
|
|
847
|
+
BRDA:989,120,0,2
|
|
848
|
+
BRDA:989,120,1,97
|
|
849
|
+
BRDA:989,121,0,99
|
|
850
|
+
BRDA:989,121,1,2
|
|
851
|
+
BRDA:995,122,0,14
|
|
852
|
+
BRDA:995,122,1,84
|
|
853
|
+
BRDA:996,123,0,7
|
|
854
|
+
BRDA:996,123,1,7
|
|
855
|
+
BRDA:996,124,0,14
|
|
856
|
+
BRDA:996,124,1,7
|
|
857
|
+
BRDA:1002,125,0,1
|
|
858
|
+
BRDA:1002,125,1,83
|
|
859
|
+
BRDA:1017,126,0,1
|
|
860
|
+
BRDA:1017,126,1,0
|
|
861
|
+
BRDA:1018,127,0,1
|
|
862
|
+
BRDA:1018,127,1,0
|
|
863
|
+
BRDA:1030,128,0,0
|
|
864
|
+
BRDA:1030,128,1,2
|
|
865
|
+
BRDA:1035,129,0,0
|
|
866
|
+
BRDA:1035,129,1,1
|
|
867
|
+
BRDA:1035,130,0,1
|
|
868
|
+
BRDA:1035,130,1,1
|
|
869
|
+
BRDA:1047,131,0,0
|
|
870
|
+
BRDA:1047,131,1,2
|
|
871
|
+
BRDA:1047,132,0,2
|
|
872
|
+
BRDA:1047,132,1,2
|
|
873
|
+
BRDA:1053,133,0,0
|
|
874
|
+
BRDA:1053,133,1,0
|
|
875
|
+
BRDA:1067,134,0,0
|
|
876
|
+
BRDA:1067,134,1,0
|
|
877
|
+
BRDA:1119,135,0,0
|
|
878
|
+
BRDA:1119,135,1,2
|
|
879
|
+
BRDA:1143,136,0,0
|
|
880
|
+
BRDA:1143,136,1,0
|
|
881
|
+
BRDA:1146,137,0,0
|
|
882
|
+
BRDA:1146,137,1,0
|
|
883
|
+
BRDA:1147,138,0,0
|
|
884
|
+
BRDA:1147,138,1,0
|
|
885
|
+
BRDA:1199,139,0,0
|
|
886
|
+
BRDA:1199,139,1,0
|
|
887
|
+
BRDA:1202,140,0,0
|
|
888
|
+
BRDA:1202,140,1,0
|
|
889
|
+
BRDA:1202,141,0,0
|
|
890
|
+
BRDA:1202,141,1,0
|
|
891
|
+
BRDA:1206,142,0,0
|
|
892
|
+
BRDA:1206,142,1,0
|
|
893
|
+
BRDA:1220,143,0,0
|
|
894
|
+
BRDA:1220,143,1,0
|
|
895
|
+
BRDA:1230,144,0,0
|
|
896
|
+
BRDA:1230,144,1,0
|
|
897
|
+
BRDA:1230,145,0,0
|
|
898
|
+
BRDA:1230,145,1,0
|
|
899
|
+
BRDA:1233,146,0,0
|
|
900
|
+
BRDA:1233,146,1,0
|
|
901
|
+
BRDA:1233,147,0,0
|
|
902
|
+
BRDA:1233,147,1,0
|
|
903
|
+
BRDA:1233,147,2,0
|
|
904
|
+
BRDA:1256,148,0,0
|
|
905
|
+
BRDA:1256,148,1,0
|
|
906
|
+
BRDA:1267,149,0,0
|
|
907
|
+
BRDA:1267,149,1,0
|
|
908
|
+
BRDA:1269,150,0,0
|
|
909
|
+
BRDA:1269,150,1,0
|
|
910
|
+
BRDA:1279,151,0,0
|
|
911
|
+
BRDA:1279,151,1,0
|
|
912
|
+
BRDA:1281,152,0,0
|
|
913
|
+
BRDA:1281,152,1,0
|
|
914
|
+
BRDA:1288,153,0,0
|
|
915
|
+
BRDA:1288,153,1,0
|
|
916
|
+
BRDA:1288,154,0,0
|
|
917
|
+
BRDA:1288,154,1,0
|
|
918
|
+
BRDA:1290,155,0,0
|
|
919
|
+
BRDA:1290,155,1,0
|
|
920
|
+
BRDA:1313,156,0,0
|
|
921
|
+
BRDA:1313,156,1,0
|
|
922
|
+
BRDA:1326,157,0,0
|
|
923
|
+
BRDA:1326,157,1,0
|
|
924
|
+
BRDA:1326,158,0,0
|
|
925
|
+
BRDA:1326,158,1,0
|
|
926
|
+
BRDA:1338,159,0,0
|
|
927
|
+
BRDA:1338,159,1,0
|
|
928
|
+
BRDA:1338,160,0,0
|
|
929
|
+
BRDA:1338,160,1,0
|
|
930
|
+
BRDA:1363,161,0,0
|
|
931
|
+
BRDA:1363,161,1,0
|
|
932
|
+
BRDA:1366,162,0,0
|
|
933
|
+
BRDA:1366,162,1,0
|
|
934
|
+
BRDA:1366,163,0,0
|
|
935
|
+
BRDA:1366,163,1,0
|
|
936
|
+
BRDA:1367,164,0,0
|
|
937
|
+
BRDA:1367,164,1,0
|
|
938
|
+
BRDA:1382,165,0,0
|
|
939
|
+
BRDA:1382,165,1,0
|
|
940
|
+
BRDA:1397,166,0,0
|
|
941
|
+
BRDA:1397,166,1,0
|
|
942
|
+
BRDA:1399,167,0,0
|
|
943
|
+
BRDA:1399,167,1,0
|
|
944
|
+
BRDA:1399,168,0,0
|
|
945
|
+
BRDA:1399,168,1,0
|
|
946
|
+
BRF:348
|
|
771
947
|
BRH:118
|
|
772
948
|
end_of_record
|
|
773
949
|
TN:
|
package/dist/index.d.ts
CHANGED
|
@@ -364,6 +364,120 @@ export default class docPouchClient {
|
|
|
364
364
|
* Emit an event
|
|
365
365
|
*/
|
|
366
366
|
private emit;
|
|
367
|
+
/**
|
|
368
|
+
* Fetches the OIDC client configuration from the server's
|
|
369
|
+
* `/api/oidc-client-config` endpoint. This is the first step in any
|
|
370
|
+
* OIDC flow: call this method to discover whether OIDC is configured
|
|
371
|
+
* and, if so, obtain the issuer, clientId, redirectUri, etc.
|
|
372
|
+
*
|
|
373
|
+
* The returned object matches the {@link I_OidcClientConfig} shape which
|
|
374
|
+
* can be passed directly to {@link setOidcConfig} or
|
|
375
|
+
* {@link loginWithOidc}.
|
|
376
|
+
*
|
|
377
|
+
* @returns {Promise<I_OidcClientConfig | null>} The client config if
|
|
378
|
+
* OIDC is configured, or null if the server reports OIDC is not
|
|
379
|
+
* available.
|
|
380
|
+
*/
|
|
381
|
+
fetchOidcClientConfig(): Promise<I_OidcClientConfig | null>;
|
|
382
|
+
/**
|
|
383
|
+
* Fetches the currently authenticated user's profile from the
|
|
384
|
+
* `/users/whoami` endpoint. Works with both JWT and OIDC
|
|
385
|
+
* authentication — the correct token is sent automatically.
|
|
386
|
+
*
|
|
387
|
+
* @returns {Promise<I_UserEntry | null>} The user profile, or null
|
|
388
|
+
* if the request fails or the user is not authenticated.
|
|
389
|
+
*/
|
|
390
|
+
getCurrentUser(): Promise<I_UserEntry | null>;
|
|
391
|
+
/**
|
|
392
|
+
* Ensures an OIDC client is registered with the DocPouch server
|
|
393
|
+
* (dynamic client registration). If a `clientId` is found in
|
|
394
|
+
* localStorage under `docpouch_oidc_client_id`, it attempts to
|
|
395
|
+
* update the existing registration. If that fails (or no stored ID
|
|
396
|
+
* exists), a new client is registered via
|
|
397
|
+
* {@link registerOidcClient}.
|
|
398
|
+
*
|
|
399
|
+
* This method manages the `docpouch_oidc_client_id` localStorage
|
|
400
|
+
* key automatically. Call it before {@link loginWithOidc} when
|
|
401
|
+
* acting as a third-party relying party (i.e. not the built-in
|
|
402
|
+
* admin UI).
|
|
403
|
+
*
|
|
404
|
+
* @param {string} redirectUri - The URI the IdP should redirect to
|
|
405
|
+
* after login.
|
|
406
|
+
* @param {string} [registrationToken] - Initial access token for
|
|
407
|
+
* the `/oidc/reg` endpoint. If omitted the current auth token is
|
|
408
|
+
* used.
|
|
409
|
+
* @param {object} [options] - Additional options.
|
|
410
|
+
* @param {string} [options.clientName] - Display name for the
|
|
411
|
+
* client registration (default `'DocPouch Client'`).
|
|
412
|
+
* @param {string} [options.postLogoutRedirectUri] - If provided,
|
|
413
|
+
* also registers this URI as a post-logout redirect.
|
|
414
|
+
* @returns {Promise<string>} The resolved clientId.
|
|
415
|
+
*/
|
|
416
|
+
ensureOidcClient(redirectUri: string, registrationToken?: string, options?: {
|
|
417
|
+
clientName?: string;
|
|
418
|
+
postLogoutRedirectUri?: string;
|
|
419
|
+
}): Promise<string>;
|
|
420
|
+
/**
|
|
421
|
+
* Attempts to restore an existing authentication session (JWT or
|
|
422
|
+
* OIDC) from browser storage. This is the recommended entry point
|
|
423
|
+
* on page load:
|
|
424
|
+
*
|
|
425
|
+
* 1. If an OIDC logout redirect was just completed, clears local
|
|
426
|
+
* state and returns `{method: 'none'}`.
|
|
427
|
+
* 2. If the URL contains `code` and `state` params, exchanges them
|
|
428
|
+
* for OIDC tokens via {@link handleOidcCallback}.
|
|
429
|
+
* 3. If a persisted OIDC session exists, restores it.
|
|
430
|
+
* 4. Falls back to a JWT token in localStorage.
|
|
431
|
+
*
|
|
432
|
+
* @returns {Promise<I_AuthState>} The authentication state after
|
|
433
|
+
* attempting restoration.
|
|
434
|
+
*/
|
|
435
|
+
initAuth(): Promise<I_AuthState>;
|
|
436
|
+
/**
|
|
437
|
+
* Clears all local authentication state — JWT token, OIDC tokens,
|
|
438
|
+
* persisted sessions, and localStorage keys managed by this library.
|
|
439
|
+
* Disconnects the WebSocket if connected.
|
|
440
|
+
*
|
|
441
|
+
* This does NOT redirect to an OIDC end-session endpoint. For a
|
|
442
|
+
* full RP-initiated logout use {@link logout} or
|
|
443
|
+
* {@link logoutOidc}.
|
|
444
|
+
*/
|
|
445
|
+
clearAuth(): void;
|
|
446
|
+
/**
|
|
447
|
+
* Persists the current authentication method to localStorage so it
|
|
448
|
+
* can be restored after a page reload.
|
|
449
|
+
*
|
|
450
|
+
* @param {'jwt' | 'oidc'} method - The auth method to persist.
|
|
451
|
+
*/
|
|
452
|
+
persistAuthMethod(method: 'jwt' | 'oidc'): void;
|
|
453
|
+
/**
|
|
454
|
+
* Removes all localStorage keys managed by docpouch-client:
|
|
455
|
+
* `authToken`, `authMethod`, `docpouch_oidc_session`,
|
|
456
|
+
* `docpouch_oidc_client_id`, `docpouch_registration_token`,
|
|
457
|
+
* `isAdmin`, and `postLogoutRedirectUri`.
|
|
458
|
+
*/
|
|
459
|
+
clearPersistedAuthState(): void;
|
|
460
|
+
/**
|
|
461
|
+
* Convenience method to fetch the OIDC client config from the server
|
|
462
|
+
* and immediately initiate the OIDC login redirect. This combines
|
|
463
|
+
* {@link fetchOidcClientConfig} and {@link loginWithOidc} into a
|
|
464
|
+
* single call.
|
|
465
|
+
*
|
|
466
|
+
* @param {string} [registrationToken] - Optional initial access
|
|
467
|
+
* token for dynamic client registration. If provided and no
|
|
468
|
+
* client config is available from the server, the method attempts
|
|
469
|
+
* dynamic registration via {@link ensureOidcClient}.
|
|
470
|
+
* @returns {Promise<void>}
|
|
471
|
+
*/
|
|
472
|
+
startOidcLogin(registrationToken?: string): Promise<void>;
|
|
473
|
+
/**
|
|
474
|
+
* Derives the OIDC issuer URL from the client's baseUrl. By
|
|
475
|
+
* convention the DocPouch OIDC provider is mounted at
|
|
476
|
+
* `${baseUrl}/oidc`.
|
|
477
|
+
*
|
|
478
|
+
* @returns {string} The issuer URL.
|
|
479
|
+
*/
|
|
480
|
+
getOidcIssuer(): string;
|
|
367
481
|
}
|
|
368
482
|
export interface I_UserEntry extends I_UserCreation {
|
|
369
483
|
_id: string;
|
|
@@ -416,6 +530,10 @@ export interface I_OidcConfig {
|
|
|
416
530
|
clientSecret?: string;
|
|
417
531
|
postLogoutRedirectUri?: string;
|
|
418
532
|
}
|
|
533
|
+
export interface I_OidcClientConfig extends I_OidcConfig {
|
|
534
|
+
configured?: boolean;
|
|
535
|
+
apiBaseUrl?: string;
|
|
536
|
+
}
|
|
419
537
|
export interface I_OidcTokenResponse {
|
|
420
538
|
accessToken: string;
|
|
421
539
|
refreshToken?: string;
|
package/dist/index.js
CHANGED
|
@@ -970,4 +970,270 @@ export default class docPouchClient {
|
|
|
970
970
|
this.events[event]();
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
+
// Convenience OIDC methods
|
|
974
|
+
/**
|
|
975
|
+
* Fetches the OIDC client configuration from the server's
|
|
976
|
+
* `/api/oidc-client-config` endpoint. This is the first step in any
|
|
977
|
+
* OIDC flow: call this method to discover whether OIDC is configured
|
|
978
|
+
* and, if so, obtain the issuer, clientId, redirectUri, etc.
|
|
979
|
+
*
|
|
980
|
+
* The returned object matches the {@link I_OidcClientConfig} shape which
|
|
981
|
+
* can be passed directly to {@link setOidcConfig} or
|
|
982
|
+
* {@link loginWithOidc}.
|
|
983
|
+
*
|
|
984
|
+
* @returns {Promise<I_OidcClientConfig | null>} The client config if
|
|
985
|
+
* OIDC is configured, or null if the server reports OIDC is not
|
|
986
|
+
* available.
|
|
987
|
+
*/
|
|
988
|
+
async fetchOidcClientConfig() {
|
|
989
|
+
try {
|
|
990
|
+
const data = await this.request('/api/oidc-client-config', 'GET', undefined, false);
|
|
991
|
+
if (!data)
|
|
992
|
+
return null;
|
|
993
|
+
// The server may or may not include `configured`. If it has an
|
|
994
|
+
// `issuer` field we consider it valid regardless.
|
|
995
|
+
if (data.configured === false)
|
|
996
|
+
return null;
|
|
997
|
+
if (!data.issuer)
|
|
998
|
+
return null;
|
|
999
|
+
return data;
|
|
1000
|
+
}
|
|
1001
|
+
catch {
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Fetches the currently authenticated user's profile from the
|
|
1007
|
+
* `/users/whoami` endpoint. Works with both JWT and OIDC
|
|
1008
|
+
* authentication — the correct token is sent automatically.
|
|
1009
|
+
*
|
|
1010
|
+
* @returns {Promise<I_UserEntry | null>} The user profile, or null
|
|
1011
|
+
* if the request fails or the user is not authenticated.
|
|
1012
|
+
*/
|
|
1013
|
+
async getCurrentUser() {
|
|
1014
|
+
try {
|
|
1015
|
+
return await this.request('/users/whoami', 'GET');
|
|
1016
|
+
}
|
|
1017
|
+
catch {
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Ensures an OIDC client is registered with the DocPouch server
|
|
1023
|
+
* (dynamic client registration). If a `clientId` is found in
|
|
1024
|
+
* localStorage under `docpouch_oidc_client_id`, it attempts to
|
|
1025
|
+
* update the existing registration. If that fails (or no stored ID
|
|
1026
|
+
* exists), a new client is registered via
|
|
1027
|
+
* {@link registerOidcClient}.
|
|
1028
|
+
*
|
|
1029
|
+
* This method manages the `docpouch_oidc_client_id` localStorage
|
|
1030
|
+
* key automatically. Call it before {@link loginWithOidc} when
|
|
1031
|
+
* acting as a third-party relying party (i.e. not the built-in
|
|
1032
|
+
* admin UI).
|
|
1033
|
+
*
|
|
1034
|
+
* @param {string} redirectUri - The URI the IdP should redirect to
|
|
1035
|
+
* after login.
|
|
1036
|
+
* @param {string} [registrationToken] - Initial access token for
|
|
1037
|
+
* the `/oidc/reg` endpoint. If omitted the current auth token is
|
|
1038
|
+
* used.
|
|
1039
|
+
* @param {object} [options] - Additional options.
|
|
1040
|
+
* @param {string} [options.clientName] - Display name for the
|
|
1041
|
+
* client registration (default `'DocPouch Client'`).
|
|
1042
|
+
* @param {string} [options.postLogoutRedirectUri] - If provided,
|
|
1043
|
+
* also registers this URI as a post-logout redirect.
|
|
1044
|
+
* @returns {Promise<string>} The resolved clientId.
|
|
1045
|
+
*/
|
|
1046
|
+
async ensureOidcClient(redirectUri, registrationToken, options) {
|
|
1047
|
+
const clientName = options?.clientName || 'DocPouch Client';
|
|
1048
|
+
const postLogoutRedirectUri = options?.postLogoutRedirectUri;
|
|
1049
|
+
const storedClientId = typeof window !== 'undefined' && window.localStorage
|
|
1050
|
+
? localStorage.getItem('docpouch_oidc_client_id')
|
|
1051
|
+
: null;
|
|
1052
|
+
const postLogoutUris = postLogoutRedirectUri
|
|
1053
|
+
? [redirectUri, postLogoutRedirectUri]
|
|
1054
|
+
: [redirectUri];
|
|
1055
|
+
const payload = {
|
|
1056
|
+
client_name: clientName,
|
|
1057
|
+
redirect_uris: [redirectUri],
|
|
1058
|
+
post_logout_redirect_uris: postLogoutUris,
|
|
1059
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
1060
|
+
response_types: ['code'],
|
|
1061
|
+
token_endpoint_auth_method: 'none',
|
|
1062
|
+
application_type: 'web',
|
|
1063
|
+
};
|
|
1064
|
+
if (storedClientId) {
|
|
1065
|
+
try {
|
|
1066
|
+
await this.updateOidcClient(storedClientId, payload, registrationToken);
|
|
1067
|
+
return storedClientId;
|
|
1068
|
+
}
|
|
1069
|
+
catch {
|
|
1070
|
+
// Update failed, will re-register below
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
const response = await this.registerOidcClient(payload, registrationToken);
|
|
1074
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
1075
|
+
localStorage.setItem('docpouch_oidc_client_id', response.client_id);
|
|
1076
|
+
}
|
|
1077
|
+
if (response.registration_access_token && typeof window !== 'undefined' && window.localStorage) {
|
|
1078
|
+
localStorage.setItem('docpouch_registration_token', response.registration_access_token);
|
|
1079
|
+
}
|
|
1080
|
+
return response.client_id;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Attempts to restore an existing authentication session (JWT or
|
|
1084
|
+
* OIDC) from browser storage. This is the recommended entry point
|
|
1085
|
+
* on page load:
|
|
1086
|
+
*
|
|
1087
|
+
* 1. If an OIDC logout redirect was just completed, clears local
|
|
1088
|
+
* state and returns `{method: 'none'}`.
|
|
1089
|
+
* 2. If the URL contains `code` and `state` params, exchanges them
|
|
1090
|
+
* for OIDC tokens via {@link handleOidcCallback}.
|
|
1091
|
+
* 3. If a persisted OIDC session exists, restores it.
|
|
1092
|
+
* 4. Falls back to a JWT token in localStorage.
|
|
1093
|
+
*
|
|
1094
|
+
* @returns {Promise<I_AuthState>} The authentication state after
|
|
1095
|
+
* attempting restoration.
|
|
1096
|
+
*/
|
|
1097
|
+
async initAuth() {
|
|
1098
|
+
// 1. Check for logout redirect
|
|
1099
|
+
if (this.wasJustLoggedOut()) {
|
|
1100
|
+
this.authToken = null;
|
|
1101
|
+
this.clearOidcTokens();
|
|
1102
|
+
this.authMethod = 'none';
|
|
1103
|
+
this.clearPersistedAuthState();
|
|
1104
|
+
return { method: 'none', token: null, isAdmin: false, userName: '' };
|
|
1105
|
+
}
|
|
1106
|
+
// 2. Try OIDC callback (code/state in URL)
|
|
1107
|
+
try {
|
|
1108
|
+
const handled = await this.handleOidcCallback();
|
|
1109
|
+
if (handled) {
|
|
1110
|
+
const token = this.getToken();
|
|
1111
|
+
if (token) {
|
|
1112
|
+
this.persistAuthMethod('oidc');
|
|
1113
|
+
return { method: 'oidc', token, isAdmin: false, userName: '' };
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
catch (e) {
|
|
1118
|
+
console.error('OIDC callback error:', e);
|
|
1119
|
+
}
|
|
1120
|
+
// 3. Try OIDC session restore
|
|
1121
|
+
if (this.restoreOidcSession()) {
|
|
1122
|
+
const token = this.getToken();
|
|
1123
|
+
if (token) {
|
|
1124
|
+
this.persistAuthMethod('oidc');
|
|
1125
|
+
return { method: 'oidc', token, isAdmin: false, userName: '' };
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
// 4. Fallback to JWT token
|
|
1129
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
1130
|
+
const storedToken = localStorage.getItem('authToken');
|
|
1131
|
+
if (storedToken) {
|
|
1132
|
+
this.authToken = storedToken;
|
|
1133
|
+
this.authMethod = 'jwt';
|
|
1134
|
+
return { method: 'jwt', token: storedToken, isAdmin: false, userName: '' };
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return { method: 'none', token: null, isAdmin: false, userName: '' };
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Clears all local authentication state — JWT token, OIDC tokens,
|
|
1141
|
+
* persisted sessions, and localStorage keys managed by this library.
|
|
1142
|
+
* Disconnects the WebSocket if connected.
|
|
1143
|
+
*
|
|
1144
|
+
* This does NOT redirect to an OIDC end-session endpoint. For a
|
|
1145
|
+
* full RP-initiated logout use {@link logout} or
|
|
1146
|
+
* {@link logoutOidc}.
|
|
1147
|
+
*/
|
|
1148
|
+
clearAuth() {
|
|
1149
|
+
this.authToken = null;
|
|
1150
|
+
this.clearOidcTokens();
|
|
1151
|
+
this.authMethod = 'none';
|
|
1152
|
+
if (this.socket.connected) {
|
|
1153
|
+
this.socket.disconnect();
|
|
1154
|
+
}
|
|
1155
|
+
this.clearPersistedAuthState();
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Persists the current authentication method to localStorage so it
|
|
1159
|
+
* can be restored after a page reload.
|
|
1160
|
+
*
|
|
1161
|
+
* @param {'jwt' | 'oidc'} method - The auth method to persist.
|
|
1162
|
+
*/
|
|
1163
|
+
persistAuthMethod(method) {
|
|
1164
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
1165
|
+
localStorage.setItem('authMethod', method);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Removes all localStorage keys managed by docpouch-client:
|
|
1170
|
+
* `authToken`, `authMethod`, `docpouch_oidc_session`,
|
|
1171
|
+
* `docpouch_oidc_client_id`, `docpouch_registration_token`,
|
|
1172
|
+
* `isAdmin`, and `postLogoutRedirectUri`.
|
|
1173
|
+
*/
|
|
1174
|
+
clearPersistedAuthState() {
|
|
1175
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
1176
|
+
localStorage.removeItem('authToken');
|
|
1177
|
+
localStorage.removeItem('authMethod');
|
|
1178
|
+
localStorage.removeItem('docpouch_oidc_session');
|
|
1179
|
+
localStorage.removeItem('docpouch_oidc_client_id');
|
|
1180
|
+
localStorage.removeItem('docpouch_registration_token');
|
|
1181
|
+
localStorage.removeItem('isAdmin');
|
|
1182
|
+
localStorage.removeItem('postLogoutRedirectUri');
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Convenience method to fetch the OIDC client config from the server
|
|
1187
|
+
* and immediately initiate the OIDC login redirect. This combines
|
|
1188
|
+
* {@link fetchOidcClientConfig} and {@link loginWithOidc} into a
|
|
1189
|
+
* single call.
|
|
1190
|
+
*
|
|
1191
|
+
* @param {string} [registrationToken] - Optional initial access
|
|
1192
|
+
* token for dynamic client registration. If provided and no
|
|
1193
|
+
* client config is available from the server, the method attempts
|
|
1194
|
+
* dynamic registration via {@link ensureOidcClient}.
|
|
1195
|
+
* @returns {Promise<void>}
|
|
1196
|
+
*/
|
|
1197
|
+
async startOidcLogin(registrationToken) {
|
|
1198
|
+
let config = this.oidcConfig;
|
|
1199
|
+
if (!config) {
|
|
1200
|
+
config = await this.fetchOidcClientConfig();
|
|
1201
|
+
}
|
|
1202
|
+
if (!config && registrationToken) {
|
|
1203
|
+
const redirectUri = typeof window !== 'undefined'
|
|
1204
|
+
? window.location.origin + window.location.pathname
|
|
1205
|
+
: '';
|
|
1206
|
+
const clientId = await this.ensureOidcClient(redirectUri, registrationToken, {
|
|
1207
|
+
postLogoutRedirectUri: redirectUri,
|
|
1208
|
+
});
|
|
1209
|
+
const issuer = this.getOidcIssuer();
|
|
1210
|
+
config = {
|
|
1211
|
+
issuer,
|
|
1212
|
+
clientId,
|
|
1213
|
+
redirectUri,
|
|
1214
|
+
postLogoutRedirectUri: redirectUri,
|
|
1215
|
+
scope: 'openid profile email offline_access',
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
if (!config) {
|
|
1219
|
+
throw new Error('OIDC is not configured on this server');
|
|
1220
|
+
}
|
|
1221
|
+
this.setOidcConfig(config);
|
|
1222
|
+
await this.loginWithOidc(config);
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Derives the OIDC issuer URL from the client's baseUrl. By
|
|
1226
|
+
* convention the DocPouch OIDC provider is mounted at
|
|
1227
|
+
* `${baseUrl}/oidc`.
|
|
1228
|
+
*
|
|
1229
|
+
* @returns {string} The issuer URL.
|
|
1230
|
+
*/
|
|
1231
|
+
getOidcIssuer() {
|
|
1232
|
+
const trimmedBaseUrl = this.baseUrl.endsWith('/') ? this.baseUrl.slice(0, -1) : this.baseUrl;
|
|
1233
|
+
const hasExplicitPort = /:\d+(?=\/|$)/.test(trimmedBaseUrl);
|
|
1234
|
+
const normalizedBaseUrl = !hasExplicitPort && this.port
|
|
1235
|
+
? `${trimmedBaseUrl}:${this.port}`
|
|
1236
|
+
: trimmedBaseUrl;
|
|
1237
|
+
return `${normalizedBaseUrl}/oidc`;
|
|
1238
|
+
}
|
|
973
1239
|
}
|