docpouch-client 1.0.5 → 1.1.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/README.md CHANGED
@@ -166,28 +166,18 @@ const newDocument = await client.createDocument({
166
166
  public: false
167
167
  });
168
168
 
169
- // Update a document
170
- await client.updateDocument('document-id', {
171
- _id: 'document-id',
172
- owner: 'user-id',
173
- title: 'Updated Mission Statement',
169
+ // Create an anonymous document
170
+ const anonymousDocument = await client.createDocument({
171
+ title: 'Anonymous Feedback',
174
172
  type: 17,
175
173
  subType: 11,
176
- content: '{"msg": "Our updated mission..."}',
174
+ content: '{"msg": "This is anonymous feedback"}',
177
175
  shareWithGroup: false,
178
176
  shareWithDepartment: false,
179
- public: false
177
+ public: false,
178
+ anonymous: true // Document will be owned by admin user
180
179
  });
181
-
182
- // Delete a document
183
- await client.removeDocument('document-id');
184
-
185
- // List all documents
186
- const allDocuments = await client.listDocuments();
187
-
188
- // Fetch documents by query
189
- const documents = await client.fetchDocuments({type: 17, subType: 11});
190
- ```
180
+ ```
191
181
 
192
182
  ### Data Structure Management
193
183
 
@@ -502,6 +492,7 @@ Authentication failures (HTTP 401/403) automatically clear the stored JWT token.
502
492
  shareWithGroup: boolean;
503
493
  shareWithDepartment: boolean;
504
494
  public: boolean;
495
+ anonymous?: boolean; // If true, document will be owned by admin user
505
496
  }
506
497
  ```
507
498
 
@@ -518,6 +509,7 @@ Authentication failures (HTTP 401/403) automatically clear the stored JWT token.
518
509
  shareWithGroup: boolean;
519
510
  shareWithDepartment: boolean;
520
511
  public: boolean;
512
+ anonymous?: boolean; // If true, document will be owned by admin user (owner field will be overridden)
521
513
  }
522
514
  ```
523
515
 
@@ -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-05-31T08:16:09.168Z
119
+ at 2026-05-31T17:49:07.278Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -35,34 +35,34 @@ FN:654,(anonymous_31)
35
35
  FN:679,(anonymous_32)
36
36
  FN:686,(anonymous_33)
37
37
  FN:693,(anonymous_34)
38
- FN:700,(anonymous_35)
39
- FN:715,(anonymous_36)
40
- FN:726,(anonymous_37)
41
- FN:738,(anonymous_38)
42
- FN:749,(anonymous_39)
43
- FN:758,(anonymous_40)
44
- FN:760,(anonymous_41)
45
- FN:765,(anonymous_42)
46
- FN:770,(anonymous_43)
47
- FN:775,(anonymous_44)
48
- FN:786,(anonymous_45)
49
- FN:820,(anonymous_46)
50
- FN:834,(anonymous_47)
51
- FN:864,(anonymous_48)
52
- FN:870,(anonymous_49)
53
- FN:903,(anonymous_50)
54
- FN:908,(anonymous_51)
55
- FN:917,(anonymous_52)
56
- FN:928,(anonymous_53)
57
- FN:940,(anonymous_54)
58
- FN:946,(anonymous_55)
59
- FN:977,(anonymous_56)
60
- FN:981,(anonymous_57)
61
- FN:984,(anonymous_58)
62
- FN:994,(anonymous_59)
63
- FN:997,(anonymous_60)
64
- FN:1006,(anonymous_61)
65
- FN:1030,(anonymous_62)
38
+ FN:703,(anonymous_35)
39
+ FN:731,(anonymous_36)
40
+ FN:742,(anonymous_37)
41
+ FN:754,(anonymous_38)
42
+ FN:765,(anonymous_39)
43
+ FN:774,(anonymous_40)
44
+ FN:776,(anonymous_41)
45
+ FN:781,(anonymous_42)
46
+ FN:786,(anonymous_43)
47
+ FN:791,(anonymous_44)
48
+ FN:802,(anonymous_45)
49
+ FN:836,(anonymous_46)
50
+ FN:850,(anonymous_47)
51
+ FN:880,(anonymous_48)
52
+ FN:886,(anonymous_49)
53
+ FN:919,(anonymous_50)
54
+ FN:924,(anonymous_51)
55
+ FN:933,(anonymous_52)
56
+ FN:944,(anonymous_53)
57
+ FN:956,(anonymous_54)
58
+ FN:962,(anonymous_55)
59
+ FN:993,(anonymous_56)
60
+ FN:997,(anonymous_57)
61
+ FN:1000,(anonymous_58)
62
+ FN:1010,(anonymous_59)
63
+ FN:1013,(anonymous_60)
64
+ FN:1021,(anonymous_61)
65
+ FN:1028,(anonymous_62)
66
66
  FNF:63
67
67
  FNH:48
68
68
  FNDA:64,(anonymous_0)
@@ -100,7 +100,7 @@ FNDA:1,(anonymous_31)
100
100
  FNDA:1,(anonymous_32)
101
101
  FNDA:0,(anonymous_33)
102
102
  FNDA:1,(anonymous_34)
103
- FNDA:2,(anonymous_35)
103
+ FNDA:0,(anonymous_35)
104
104
  FNDA:5,(anonymous_36)
105
105
  FNDA:3,(anonymous_37)
106
106
  FNDA:1,(anonymous_38)
@@ -127,7 +127,7 @@ FNDA:3,(anonymous_58)
127
127
  FNDA:3,(anonymous_59)
128
128
  FNDA:96,(anonymous_60)
129
129
  FNDA:0,(anonymous_61)
130
- FNDA:0,(anonymous_62)
130
+ FNDA:2,(anonymous_62)
131
131
  DA:33,64
132
132
  DA:40,64
133
133
  DA:41,64
@@ -345,127 +345,127 @@ DA:672,1
345
345
  DA:680,1
346
346
  DA:687,0
347
347
  DA:694,1
348
- DA:701,2
349
- DA:702,0
350
- DA:716,5
351
- DA:727,3
352
- DA:739,1
353
- DA:750,2
354
- DA:760,64
355
- DA:761,0
356
- DA:762,0
357
- DA:765,64
358
- DA:766,5
359
- DA:767,5
360
- DA:770,64
361
- DA:771,5
362
- DA:772,5
363
- DA:775,64
364
- DA:776,0
348
+ DA:705,0
349
+ DA:706,0
350
+ DA:707,0
351
+ DA:711,0
352
+ DA:712,0
353
+ DA:715,0
354
+ DA:716,0
355
+ DA:719,0
356
+ DA:732,5
357
+ DA:743,3
358
+ DA:755,1
359
+ DA:766,2
360
+ DA:776,64
365
361
  DA:777,0
362
+ DA:778,0
363
+ DA:781,64
364
+ DA:782,5
365
+ DA:783,5
366
+ DA:786,64
366
367
  DA:787,5
367
368
  DA:788,5
368
- DA:793,5
369
- DA:794,0
370
- DA:795,0
371
- DA:798,5
372
- DA:799,0
373
- DA:800,0
369
+ DA:791,64
370
+ DA:792,0
371
+ DA:793,0
374
372
  DA:803,5
375
- DA:804,0
376
- DA:805,0
377
- DA:808,5
378
- DA:810,5
379
- DA:811,5
373
+ DA:804,5
374
+ DA:809,5
375
+ DA:810,0
376
+ DA:811,0
380
377
  DA:814,5
381
- DA:817,5
382
- DA:820,5
383
- DA:821,2
384
- DA:822,1
385
- DA:823,1
386
- DA:824,1
387
- DA:825,1
378
+ DA:815,0
379
+ DA:816,0
380
+ DA:819,5
381
+ DA:820,0
382
+ DA:821,0
383
+ DA:824,5
384
+ DA:826,5
385
+ DA:827,5
388
386
  DA:830,5
389
- DA:831,5
390
- DA:834,5
391
- DA:835,0
392
- DA:836,0
393
- DA:837,0
394
- DA:840,0
395
- DA:841,0
396
- DA:842,0
397
- DA:843,0
398
- DA:848,0
399
- DA:849,0
400
- DA:865,94
401
- DA:869,94
402
- DA:870,0
403
- DA:873,94
404
- DA:874,54
405
- DA:875,94
406
- DA:876,0
407
- DA:878,94
408
- DA:884,94
387
+ DA:833,5
388
+ DA:836,5
389
+ DA:837,2
390
+ DA:838,1
391
+ DA:839,1
392
+ DA:840,1
393
+ DA:841,1
394
+ DA:846,5
395
+ DA:847,5
396
+ DA:850,5
397
+ DA:851,0
398
+ DA:852,0
399
+ DA:853,0
400
+ DA:856,0
401
+ DA:857,0
402
+ DA:858,0
403
+ DA:859,0
404
+ DA:864,0
405
+ DA:865,0
406
+ DA:881,94
409
407
  DA:885,94
410
- DA:886,94
411
- DA:887,94
412
- DA:889,93
413
- DA:890,14
414
- DA:891,7
415
- DA:893,14
416
- DA:896,79
417
- DA:898,78
418
- DA:904,1
419
- DA:905,1
420
- DA:909,1
421
- DA:910,1
422
- DA:911,1
423
- DA:912,1
424
- DA:913,1
425
- DA:914,1
426
- DA:918,2
427
- DA:919,2
428
- DA:920,2
429
- DA:921,2
430
- DA:922,2
431
- DA:923,2
432
- DA:924,2
433
- DA:925,2
408
+ DA:886,0
409
+ DA:889,94
410
+ DA:890,54
411
+ DA:891,94
412
+ DA:892,0
413
+ DA:894,94
414
+ DA:900,94
415
+ DA:901,94
416
+ DA:902,94
417
+ DA:903,94
418
+ DA:905,93
419
+ DA:906,14
420
+ DA:907,7
421
+ DA:909,14
422
+ DA:912,79
423
+ DA:914,78
424
+ DA:920,1
425
+ DA:921,1
426
+ DA:925,1
427
+ DA:926,1
428
+ DA:927,1
429
+ DA:928,1
434
430
  DA:929,1
435
- DA:930,0
436
- DA:936,0
431
+ DA:930,1
432
+ DA:934,2
433
+ DA:935,2
434
+ DA:936,2
435
+ DA:937,2
436
+ DA:938,2
437
+ DA:939,2
438
+ DA:940,2
437
439
  DA:941,2
438
- DA:942,0
439
- DA:947,0
440
- DA:948,0
441
- DA:949,0
442
- DA:955,0
443
- DA:961,0
444
- DA:962,0
440
+ DA:945,1
441
+ DA:946,0
442
+ DA:952,0
443
+ DA:957,2
444
+ DA:958,0
445
445
  DA:963,0
446
+ DA:964,0
446
447
  DA:965,0
447
- DA:966,0
448
- DA:974,0
449
- DA:978,3
450
- DA:979,3
451
- DA:980,3
452
- DA:981,192
453
- DA:985,3
454
- DA:986,3
455
- DA:987,3
456
- DA:988,3
448
+ DA:971,0
449
+ DA:977,0
450
+ DA:978,0
451
+ DA:979,0
452
+ DA:981,0
453
+ DA:982,0
454
+ DA:990,0
455
+ DA:994,3
457
456
  DA:995,3
458
457
  DA:996,3
459
- DA:997,96
460
- DA:1008,0
461
- DA:1009,0
462
- DA:1010,0
463
- DA:1014,0
464
- DA:1015,0
465
- DA:1018,0
466
- DA:1019,0
458
+ DA:997,192
459
+ DA:1001,3
460
+ DA:1002,3
461
+ DA:1003,3
462
+ DA:1004,3
463
+ DA:1011,3
464
+ DA:1012,3
465
+ DA:1013,96
467
466
  DA:1022,0
468
- DA:1031,0
467
+ DA:1029,2
468
+ DA:1030,0
469
469
  LF:338
470
470
  LH:191
471
471
  BRDA:71,0,0,63
@@ -632,73 +632,73 @@ BRDA:668,76,0,1
632
632
  BRDA:668,76,1,0
633
633
  BRDA:671,77,0,1
634
634
  BRDA:671,77,1,0
635
- BRDA:701,78,0,0
636
- BRDA:701,78,1,2
637
- BRDA:787,79,0,0
638
- BRDA:787,79,1,5
639
- BRDA:793,80,0,0
640
- BRDA:793,80,1,5
641
- BRDA:798,81,0,0
642
- BRDA:798,81,1,5
643
- BRDA:803,82,0,0
644
- BRDA:803,82,1,5
645
- BRDA:821,83,0,1
646
- BRDA:821,83,1,1
647
- BRDA:824,84,0,1
648
- BRDA:824,84,1,0
649
- BRDA:835,85,0,0
650
- BRDA:835,85,1,0
651
- BRDA:840,86,0,0
635
+ BRDA:706,78,0,0
636
+ BRDA:706,78,1,0
637
+ BRDA:715,79,0,0
638
+ BRDA:715,79,1,0
639
+ BRDA:715,80,0,0
640
+ BRDA:715,80,1,0
641
+ BRDA:803,81,0,0
642
+ BRDA:803,81,1,5
643
+ BRDA:809,82,0,0
644
+ BRDA:809,82,1,5
645
+ BRDA:814,83,0,0
646
+ BRDA:814,83,1,5
647
+ BRDA:819,84,0,0
648
+ BRDA:819,84,1,5
649
+ BRDA:837,85,0,1
650
+ BRDA:837,85,1,1
651
+ BRDA:840,86,0,1
652
652
  BRDA:840,86,1,0
653
- BRDA:864,87,0,45
654
- BRDA:869,88,0,94
655
- BRDA:869,88,1,84
656
- BRDA:869,89,0,0
657
- BRDA:869,89,1,84
658
- BRDA:873,90,0,54
659
- BRDA:873,90,1,40
660
- BRDA:873,91,0,94
661
- BRDA:873,91,1,56
662
- BRDA:875,92,0,0
663
- BRDA:875,92,1,94
664
- BRDA:881,93,0,66
665
- BRDA:881,93,1,28
666
- BRDA:884,94,0,94
667
- BRDA:884,94,1,0
668
- BRDA:885,95,0,0
669
- BRDA:885,95,1,94
670
- BRDA:889,96,0,14
671
- BRDA:889,96,1,79
672
- BRDA:890,97,0,7
673
- BRDA:890,97,1,7
674
- BRDA:890,98,0,14
675
- BRDA:890,98,1,7
676
- BRDA:896,99,0,1
677
- BRDA:896,99,1,78
678
- BRDA:911,100,0,1
679
- BRDA:911,100,1,0
653
+ BRDA:851,87,0,0
654
+ BRDA:851,87,1,0
655
+ BRDA:856,88,0,0
656
+ BRDA:856,88,1,0
657
+ BRDA:880,89,0,45
658
+ BRDA:885,90,0,94
659
+ BRDA:885,90,1,84
660
+ BRDA:885,91,0,0
661
+ BRDA:885,91,1,84
662
+ BRDA:889,92,0,54
663
+ BRDA:889,92,1,40
664
+ BRDA:889,93,0,94
665
+ BRDA:889,93,1,56
666
+ BRDA:891,94,0,0
667
+ BRDA:891,94,1,94
668
+ BRDA:897,95,0,66
669
+ BRDA:897,95,1,28
670
+ BRDA:900,96,0,94
671
+ BRDA:900,96,1,0
672
+ BRDA:901,97,0,0
673
+ BRDA:901,97,1,94
674
+ BRDA:905,98,0,14
675
+ BRDA:905,98,1,79
676
+ BRDA:906,99,0,7
677
+ BRDA:906,99,1,7
678
+ BRDA:906,100,0,14
679
+ BRDA:906,100,1,7
680
680
  BRDA:912,101,0,1
681
- BRDA:912,101,1,0
682
- BRDA:924,102,0,0
683
- BRDA:924,102,1,2
684
- BRDA:929,103,0,0
685
- BRDA:929,103,1,1
686
- BRDA:929,104,0,1
687
- BRDA:929,104,1,1
688
- BRDA:941,105,0,0
689
- BRDA:941,105,1,2
690
- BRDA:941,106,0,2
691
- BRDA:941,106,1,2
692
- BRDA:947,107,0,0
693
- BRDA:947,107,1,0
694
- BRDA:961,108,0,0
695
- BRDA:961,108,1,0
696
- BRDA:1009,109,0,0
697
- BRDA:1009,109,1,0
698
- BRDA:1018,110,0,0
699
- BRDA:1018,110,1,0
700
- BRDA:1018,111,0,0
701
- BRDA:1018,111,1,0
681
+ BRDA:912,101,1,78
682
+ BRDA:927,102,0,1
683
+ BRDA:927,102,1,0
684
+ BRDA:928,103,0,1
685
+ BRDA:928,103,1,0
686
+ BRDA:940,104,0,0
687
+ BRDA:940,104,1,2
688
+ BRDA:945,105,0,0
689
+ BRDA:945,105,1,1
690
+ BRDA:945,106,0,1
691
+ BRDA:945,106,1,1
692
+ BRDA:957,107,0,0
693
+ BRDA:957,107,1,2
694
+ BRDA:957,108,0,2
695
+ BRDA:957,108,1,2
696
+ BRDA:963,109,0,0
697
+ BRDA:963,109,1,0
698
+ BRDA:977,110,0,0
699
+ BRDA:977,110,1,0
700
+ BRDA:1029,111,0,0
701
+ BRDA:1029,111,1,2
702
702
  BRF:231
703
703
  BRH:113
704
704
  end_of_record
package/dist/index.d.ts CHANGED
@@ -264,9 +264,12 @@ export default class docPouchClient {
264
264
  */
265
265
  onJwtLogout(callback: () => void): void;
266
266
  /**
267
- * Emit an event
267
+ * Check if user was just logged out (after redirect from /end_session)
268
+ * Checks URL for logout indicator or checks localStorage
269
+ *
270
+ * @returns {boolean} True if user was just logged out
268
271
  */
269
- private emit;
272
+ wasJustLoggedOut(): boolean;
270
273
  /**
271
274
  * Registers a new OIDC client with the server (dynamic client registration).
272
275
  *
@@ -333,19 +336,16 @@ export default class docPouchClient {
333
336
  private generateCodeVerifier;
334
337
  private generateCodeChallenge;
335
338
  private generateState;
336
- /**
337
- * Check if user was just logged out (after redirect from /end_session)
338
- * Checks URL for logout indicator or checks localStorage
339
- *
340
- * @returns {boolean} True if user was just logged out
341
- */
342
- wasJustLoggedOut(): boolean;
343
339
  /**
344
340
  * Get post_logout_redirect_uri after OIDC logout
345
341
  *
346
342
  * @returns {string | null} The post logout redirect URI or null if not set
347
343
  */
348
344
  getPostLogoutRedirectUri(): string | null;
345
+ /**
346
+ * Emit an event
347
+ */
348
+ private emit;
349
349
  }
350
350
  export interface I_UserEntry extends I_UserCreation {
351
351
  _id: string;
@@ -456,6 +456,7 @@ export interface I_DocumentCreation {
456
456
  shareWithGroup: boolean;
457
457
  shareWithDepartment: boolean;
458
458
  public: boolean;
459
+ anonymous?: boolean;
459
460
  }
460
461
  export interface I_DocumentCreationOwned extends I_DocumentCreation {
461
462
  owner: string;
package/dist/index.js CHANGED
@@ -606,12 +606,25 @@ export default class docPouchClient {
606
606
  this.events['jwt-logout'] = callback;
607
607
  }
608
608
  /**
609
- * Emit an event
609
+ * Check if user was just logged out (after redirect from /end_session)
610
+ * Checks URL for logout indicator or checks localStorage
611
+ *
612
+ * @returns {boolean} True if user was just logged out
610
613
  */
611
- emit(event) {
612
- if (this.events[event]) {
613
- this.events[event]();
614
+ wasJustLoggedOut() {
615
+ // Check URL query parameter
616
+ const urlParams = new URLSearchParams(window.location.search);
617
+ if (urlParams.get('logout') === 'true') {
618
+ return true;
614
619
  }
620
+ // Check localStorage flag
621
+ const lastAuthMethod = localStorage.getItem('lastAuthMethod');
622
+ const currentAuthMethod = localStorage.getItem('authMethod');
623
+ // If last was OIDC/JWT but current is none, was logged out
624
+ if (lastAuthMethod && currentAuthMethod === null) {
625
+ return true;
626
+ }
627
+ return false;
615
628
  }
616
629
  // OIDC Dynamic Client Registration Methods
617
630
  /**
@@ -868,27 +881,6 @@ export default class docPouchClient {
868
881
  crypto.getRandomValues(array);
869
882
  return Array.from(array, byte => byte.toString(16).padStart(2, '0')).join('');
870
883
  }
871
- /**
872
- * Check if user was just logged out (after redirect from /end_session)
873
- * Checks URL for logout indicator or checks localStorage
874
- *
875
- * @returns {boolean} True if user was just logged out
876
- */
877
- wasJustLoggedOut() {
878
- // Check URL query parameter
879
- const urlParams = new URLSearchParams(window.location.search);
880
- if (urlParams.get('logout') === 'true') {
881
- return true;
882
- }
883
- // Check localStorage flag
884
- const lastAuthMethod = localStorage.getItem('lastAuthMethod');
885
- const currentAuthMethod = localStorage.getItem('authMethod');
886
- // If last was OIDC/JWT but current is none, was logged out
887
- if (lastAuthMethod && currentAuthMethod === null) {
888
- return true;
889
- }
890
- return false;
891
- }
892
884
  /**
893
885
  * Get post_logout_redirect_uri after OIDC logout
894
886
  *
@@ -897,4 +889,12 @@ export default class docPouchClient {
897
889
  getPostLogoutRedirectUri() {
898
890
  return localStorage.getItem('postLogoutRedirectUri');
899
891
  }
892
+ /**
893
+ * Emit an event
894
+ */
895
+ emit(event) {
896
+ if (this.events[event]) {
897
+ this.events[event]();
898
+ }
899
+ }
900
900
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docpouch-client",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {