@secrecy/lib 1.0.0-dev.24 → 1.0.0-dev.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.
Files changed (156) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/__tests__/client/client.test.ts +81 -0
  3. package/__tests__/client/folder.test.ts +302 -0
  4. package/__tests__/client/mail.test.ts +476 -0
  5. package/__tests__/client/timing.test.ts +35 -0
  6. package/__tests__/client/utils.ts +41 -0
  7. package/__tests__/client/vFile.test.ts +207 -0
  8. package/__tests__/index.test.ts +171 -0
  9. package/commitlint.config.cjs +3 -0
  10. package/{lib/zeus → dist}/index.d.ts +729 -915
  11. package/dist/index.js +255 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index.mjs +255 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/docs/assets/css/main.css +2660 -0
  16. package/docs/assets/images/icons.png +0 -0
  17. package/docs/assets/images/icons@2x.png +0 -0
  18. package/docs/assets/images/widgets.png +0 -0
  19. package/docs/assets/images/widgets@2x.png +0 -0
  20. package/docs/assets/js/main.js +248 -0
  21. package/docs/assets/js/search.js +1 -0
  22. package/docs/classes/baseclient.baseclient-1.html +1165 -0
  23. package/docs/classes/client.secrecyclient.html +2527 -0
  24. package/docs/enums/index.sodium.base64_variants.html +205 -0
  25. package/docs/index.html +198 -0
  26. package/docs/interfaces/client_types.draftmail.html +335 -0
  27. package/docs/interfaces/client_types.filecontentbase.html +231 -0
  28. package/docs/interfaces/client_types.filecontentcloud.html +244 -0
  29. package/docs/interfaces/client_types.filecontentreceivedmail.html +244 -0
  30. package/docs/interfaces/client_types.filecontentsentmail.html +230 -0
  31. package/docs/interfaces/client_types.receivedmail.html +363 -0
  32. package/docs/interfaces/client_types.sentmail.html +335 -0
  33. package/docs/interfaces/crypto.keypair.html +202 -0
  34. package/docs/interfaces/index.sodium.cryptobox.html +185 -0
  35. package/docs/interfaces/index.sodium.cryptokx.html +185 -0
  36. package/docs/interfaces/index.sodium.keypair.html +199 -0
  37. package/docs/interfaces/index.sodium.messagetag.html +185 -0
  38. package/docs/interfaces/index.sodium.secretbox.html +185 -0
  39. package/docs/interfaces/index.sodium.stateaddress.html +171 -0
  40. package/docs/interfaces/index.sodium.stringcryptobox.html +185 -0
  41. package/docs/interfaces/index.sodium.stringcryptokx.html +185 -0
  42. package/docs/interfaces/index.sodium.stringkeypair.html +199 -0
  43. package/docs/interfaces/index.sodium.stringmessagetag.html +185 -0
  44. package/docs/interfaces/index.sodium.stringsecretbox.html +185 -0
  45. package/docs/interfaces/utils_store_buddy.storebuddy.html +333 -0
  46. package/docs/modules/baseclient.html +929 -0
  47. package/docs/modules/cache.html +185 -0
  48. package/docs/modules/client.html +207 -0
  49. package/docs/modules/client_convert_file.html +216 -0
  50. package/docs/modules/client_convert_folder.html +303 -0
  51. package/docs/modules/client_convert_vfile.html +216 -0
  52. package/docs/modules/client_helpers.html +311 -0
  53. package/docs/modules/client_storage.html +167 -0
  54. package/docs/modules/client_types.html +1227 -0
  55. package/docs/modules/client_types_file.html +233 -0
  56. package/docs/modules/client_types_filesonusersonapplications.html +168 -0
  57. package/docs/modules/client_types_folder.html +383 -0
  58. package/docs/modules/client_types_inputs.html +263 -0
  59. package/docs/modules/client_types_mail.html +181 -0
  60. package/docs/modules/client_types_queries.html +199 -0
  61. package/docs/modules/client_types_userappsettings.html +163 -0
  62. package/docs/modules/client_types_vfile.html +364 -0
  63. package/docs/modules/crypto.html +366 -0
  64. package/docs/modules/crypto_file.html +344 -0
  65. package/docs/modules/index.html +779 -0
  66. package/docs/modules/index.sodium.html +6039 -0
  67. package/docs/modules/minify.html +183 -0
  68. package/docs/modules/minify_lz4.html +279 -0
  69. package/docs/modules/popuptools.html +259 -0
  70. package/docs/modules/sodium.html +167 -0
  71. package/docs/modules/utils.html +219 -0
  72. package/docs/modules/utils_store_buddy.html +208 -0
  73. package/docs/modules/utils_time.html +330 -0
  74. package/docs/modules/worker_md5.html +156 -0
  75. package/docs/modules/worker_sodium.html +231 -0
  76. package/docs/modules/worker_workercodes.html +157 -0
  77. package/docs/modules.html +235 -0
  78. package/index.html +21 -0
  79. package/jest.config.ts +27 -0
  80. package/jest.setup.ts +6 -0
  81. package/package.json +29 -37
  82. package/release.config.cjs +15 -0
  83. package/tsup.config.ts +23 -0
  84. package/lib/BaseClient.d.ts +0 -274
  85. package/lib/BaseClient.js +0 -2227
  86. package/lib/PopupTools.d.ts +0 -17
  87. package/lib/PopupTools.js +0 -213
  88. package/lib/ZeusThunder.d.ts +0 -2
  89. package/lib/ZeusThunder.js +0 -113
  90. package/lib/cache.d.ts +0 -7
  91. package/lib/cache.js +0 -5
  92. package/lib/client/admin/index.d.ts +0 -11
  93. package/lib/client/admin/index.js +0 -198
  94. package/lib/client/convert/file.d.ts +0 -5
  95. package/lib/client/convert/file.js +0 -39
  96. package/lib/client/convert/folder.d.ts +0 -8
  97. package/lib/client/convert/folder.js +0 -264
  98. package/lib/client/convert/mail.d.ts +0 -3
  99. package/lib/client/convert/mail.js +0 -46
  100. package/lib/client/convert/vFile.d.ts +0 -5
  101. package/lib/client/convert/vFile.js +0 -164
  102. package/lib/client/helpers.d.ts +0 -23
  103. package/lib/client/helpers.js +0 -114
  104. package/lib/client/index.d.ts +0 -172
  105. package/lib/client/index.js +0 -6171
  106. package/lib/client/storage.d.ts +0 -7
  107. package/lib/client/storage.js +0 -12
  108. package/lib/client/types/File.d.ts +0 -21
  109. package/lib/client/types/File.js +0 -3
  110. package/lib/client/types/FilesOnUsersOnApplications.d.ts +0 -9
  111. package/lib/client/types/FilesOnUsersOnApplications.js +0 -3
  112. package/lib/client/types/Folder.d.ts +0 -68
  113. package/lib/client/types/Folder.js +0 -7
  114. package/lib/client/types/Inputs.d.ts +0 -21
  115. package/lib/client/types/Inputs.js +0 -3
  116. package/lib/client/types/UserAppNotifications.d.ts +0 -6
  117. package/lib/client/types/UserAppNotifications.js +0 -3
  118. package/lib/client/types/UserAppSettings.d.ts +0 -7
  119. package/lib/client/types/UserAppSettings.js +0 -3
  120. package/lib/client/types/VFile.d.ts +0 -62
  121. package/lib/client/types/VFile.js +0 -4
  122. package/lib/client/types/index.d.ts +0 -154
  123. package/lib/client/types/index.js +0 -10
  124. package/lib/client/types/queries.d.ts +0 -535
  125. package/lib/client/types/queries.js +0 -192
  126. package/lib/crypto/file.d.ts +0 -14
  127. package/lib/crypto/file.js +0 -291
  128. package/lib/crypto/index.d.ts +0 -12
  129. package/lib/crypto/index.js +0 -37
  130. package/lib/error.d.ts +0 -30
  131. package/lib/error.js +0 -3
  132. package/lib/index.d.ts +0 -13
  133. package/lib/index.js +0 -42
  134. package/lib/minify/index.d.ts +0 -2
  135. package/lib/minify/index.js +0 -28
  136. package/lib/minify/lz4.d.ts +0 -5
  137. package/lib/minify/lz4.js +0 -633
  138. package/lib/sodium.d.ts +0 -3
  139. package/lib/sodium.js +0 -28
  140. package/lib/utils/store-buddy.d.ts +0 -14
  141. package/lib/utils/store-buddy.js +0 -69
  142. package/lib/utils/time.d.ts +0 -10
  143. package/lib/utils/time.js +0 -22
  144. package/lib/utils.d.ts +0 -4
  145. package/lib/utils.js +0 -188
  146. package/lib/worker/__mock__/sodium.worker.d.ts +0 -19
  147. package/lib/worker/__mock__/sodium.worker.js +0 -46
  148. package/lib/worker/md5.d.ts +0 -1
  149. package/lib/worker/md5.js +0 -43
  150. package/lib/worker/sodium.d.ts +0 -3
  151. package/lib/worker/sodium.js +0 -155
  152. package/lib/worker/workerCodes.d.ts +0 -2
  153. package/lib/worker/workerCodes.js +0 -3
  154. package/lib/zeus/const.d.ts +0 -2
  155. package/lib/zeus/const.js +0 -2267
  156. package/lib/zeus/index.js +0 -549
@@ -0,0 +1,156 @@
1
+ <!doctype html>
2
+ <html class="default no-js">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>worker/md5 | @secrecy/lib</title>
7
+ <meta name="description" content="Documentation for @secrecy/lib">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ <link rel="stylesheet" href="../assets/css/main.css">
10
+ <script async src="../assets/js/search.js" id="search-script"></script>
11
+ </head>
12
+ <body>
13
+ <header>
14
+ <div class="tsd-page-toolbar">
15
+ <div class="container">
16
+ <div class="table-wrap">
17
+ <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
18
+ <div class="field">
19
+ <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
20
+ <input id="tsd-search-field" type="text" />
21
+ </div>
22
+ <ul class="results">
23
+ <li class="state loading">Preparing search index...</li>
24
+ <li class="state failure">The search index is not available</li>
25
+ </ul>
26
+ <a href="../index.html" class="title">@secrecy/lib</a>
27
+ </div>
28
+ <div class="table-cell" id="tsd-widgets">
29
+ <div id="tsd-filter">
30
+ <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
31
+ <div class="tsd-filter-group">
32
+ <div class="tsd-select" id="tsd-filter-visibility">
33
+ <span class="tsd-select-label">All</span>
34
+ <ul class="tsd-select-list">
35
+ <li data-value="public">Public</li>
36
+ <li data-value="protected">Public/Protected</li>
37
+ <li data-value="private" class="selected">All</li>
38
+ </ul>
39
+ </div>
40
+ <input type="checkbox" id="tsd-filter-inherited" checked />
41
+ <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
42
+ <input type="checkbox" id="tsd-filter-externals" checked />
43
+ <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
44
+ </div>
45
+ </div>
46
+ <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div class="tsd-page-title">
52
+ <div class="container">
53
+ <ul class="tsd-breadcrumb">
54
+ <li>
55
+ <a href="../modules.html">@secrecy/lib</a>
56
+ </li>
57
+ <li>
58
+ <a href="worker_md5.html">worker/md5</a>
59
+ </li>
60
+ </ul>
61
+ <h1>Module worker/md5</h1>
62
+ </div>
63
+ </div>
64
+ </header>
65
+ <div class="container container-main">
66
+ <div class="row">
67
+ <div class="col-8 col-content">
68
+ <section class="tsd-panel-group tsd-index-group">
69
+ <h2>Index</h2>
70
+ <section class="tsd-panel tsd-index-panel">
71
+ <div class="tsd-index-content">
72
+ <section class="tsd-index-section ">
73
+ <h3>Functions</h3>
74
+ <ul class="tsd-index-list">
75
+ <li class="tsd-kind-function tsd-parent-kind-module"><a href="worker_md5.html#md5" class="tsd-kind-icon">md5</a></li>
76
+ </ul>
77
+ </section>
78
+ </div>
79
+ </section>
80
+ </section>
81
+ <section class="tsd-panel-group tsd-member-group ">
82
+ <h2>Functions</h2>
83
+ <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
84
+ <a name="md5" class="tsd-anchor"></a>
85
+ <h3>md5</h3>
86
+ <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
87
+ <li class="tsd-signature tsd-kind-icon">md5<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></li>
88
+ </ul>
89
+ <ul class="tsd-descriptions">
90
+ <li class="tsd-description">
91
+ <aside class="tsd-sources">
92
+ <ul>
93
+ <li>Defined in src/worker/md5.ts:3</li>
94
+ </ul>
95
+ </aside>
96
+ <h4 class="tsd-parameters-title">Parameters</h4>
97
+ <ul class="tsd-parameters">
98
+ <li>
99
+ <h5>data: <span class="tsd-signature-type">Uint8Array</span></h5>
100
+ </li>
101
+ </ul>
102
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></h4>
103
+ </li>
104
+ </ul>
105
+ </section>
106
+ </section>
107
+ </div>
108
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
109
+ <nav class="tsd-navigation primary">
110
+ <ul>
111
+ <li class=" ">
112
+ <a href="../modules.html">Modules</a>
113
+ </li>
114
+ <li class="current tsd-kind-module">
115
+ <a href="worker_md5.html">worker/md5</a>
116
+ </li>
117
+ </ul>
118
+ </nav>
119
+ <nav class="tsd-navigation secondary menu-sticky">
120
+ <ul class="before-current">
121
+ <li class=" tsd-kind-function tsd-parent-kind-module">
122
+ <a href="worker_md5.html#md5" class="tsd-kind-icon">md5</a>
123
+ </li>
124
+ </ul>
125
+ </nav>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ <footer class="with-border-bottom">
130
+ <div class="container">
131
+ <h2>Legend</h2>
132
+ <div class="tsd-legend-group">
133
+ <ul class="tsd-legend">
134
+ <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
135
+ <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
136
+ <li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
137
+ <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
138
+ <li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li>
139
+ </ul>
140
+ <ul class="tsd-legend">
141
+ <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
142
+ <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
143
+ </ul>
144
+ <ul class="tsd-legend">
145
+ <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
146
+ </ul>
147
+ </div>
148
+ </div>
149
+ </footer>
150
+ <div class="container tsd-generator">
151
+ <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
152
+ </div>
153
+ <div class="overlay"></div>
154
+ <script src="../assets/js/main.js"></script>
155
+ </body>
156
+ </html>
@@ -0,0 +1,231 @@
1
+ <!doctype html>
2
+ <html class="default no-js">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>worker/sodium | @secrecy/lib</title>
7
+ <meta name="description" content="Documentation for @secrecy/lib">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ <link rel="stylesheet" href="../assets/css/main.css">
10
+ <script async src="../assets/js/search.js" id="search-script"></script>
11
+ </head>
12
+ <body>
13
+ <header>
14
+ <div class="tsd-page-toolbar">
15
+ <div class="container">
16
+ <div class="table-wrap">
17
+ <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
18
+ <div class="field">
19
+ <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
20
+ <input id="tsd-search-field" type="text" />
21
+ </div>
22
+ <ul class="results">
23
+ <li class="state loading">Preparing search index...</li>
24
+ <li class="state failure">The search index is not available</li>
25
+ </ul>
26
+ <a href="../index.html" class="title">@secrecy/lib</a>
27
+ </div>
28
+ <div class="table-cell" id="tsd-widgets">
29
+ <div id="tsd-filter">
30
+ <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
31
+ <div class="tsd-filter-group">
32
+ <div class="tsd-select" id="tsd-filter-visibility">
33
+ <span class="tsd-select-label">All</span>
34
+ <ul class="tsd-select-list">
35
+ <li data-value="public">Public</li>
36
+ <li data-value="protected">Public/Protected</li>
37
+ <li data-value="private" class="selected">All</li>
38
+ </ul>
39
+ </div>
40
+ <input type="checkbox" id="tsd-filter-inherited" checked />
41
+ <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
42
+ <input type="checkbox" id="tsd-filter-externals" checked />
43
+ <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
44
+ </div>
45
+ </div>
46
+ <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div class="tsd-page-title">
52
+ <div class="container">
53
+ <ul class="tsd-breadcrumb">
54
+ <li>
55
+ <a href="../modules.html">@secrecy/lib</a>
56
+ </li>
57
+ <li>
58
+ <a href="worker_sodium.html">worker/sodium</a>
59
+ </li>
60
+ </ul>
61
+ <h1>Module worker/sodium</h1>
62
+ </div>
63
+ </div>
64
+ </header>
65
+ <div class="container container-main">
66
+ <div class="row">
67
+ <div class="col-8 col-content">
68
+ <section class="tsd-panel-group tsd-index-group">
69
+ <h2>Index</h2>
70
+ <section class="tsd-panel tsd-index-panel">
71
+ <div class="tsd-index-content">
72
+ <section class="tsd-index-section ">
73
+ <h3>Functions</h3>
74
+ <ul class="tsd-index-list">
75
+ <li class="tsd-kind-function tsd-parent-kind-module"><a href="worker_sodium.html#decrypt" class="tsd-kind-icon">decrypt</a></li>
76
+ <li class="tsd-kind-function tsd-parent-kind-module"><a href="worker_sodium.html#encrypt" class="tsd-kind-icon">encrypt</a></li>
77
+ </ul>
78
+ </section>
79
+ </div>
80
+ </section>
81
+ </section>
82
+ <section class="tsd-panel-group tsd-member-group ">
83
+ <h2>Functions</h2>
84
+ <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
85
+ <a name="decrypt" class="tsd-anchor"></a>
86
+ <h3>decrypt</h3>
87
+ <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
88
+ <li class="tsd-signature tsd-kind-icon">decrypt<span class="tsd-signature-symbol">(</span>key<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, dataToDecrypt<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, progress<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">&gt;</span></li>
89
+ </ul>
90
+ <ul class="tsd-descriptions">
91
+ <li class="tsd-description">
92
+ <aside class="tsd-sources">
93
+ <ul>
94
+ <li>Defined in src/worker/sodium.ts:145</li>
95
+ </ul>
96
+ </aside>
97
+ <h4 class="tsd-parameters-title">Parameters</h4>
98
+ <ul class="tsd-parameters">
99
+ <li>
100
+ <h5>key: <span class="tsd-signature-type">Uint8Array</span></h5>
101
+ </li>
102
+ <li>
103
+ <h5>dataToDecrypt: <span class="tsd-signature-type">Uint8Array</span></h5>
104
+ </li>
105
+ <li>
106
+ <h5><span class="tsd-flag ts-flagOptional">Optional</span> progress: <span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h5>
107
+ <ul class="tsd-parameters">
108
+ <li class="tsd-parameter-signature">
109
+ <ul class="tsd-signatures tsd-kind-type-literal">
110
+ <li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
111
+ </ul>
112
+ <ul class="tsd-descriptions">
113
+ <li class="tsd-description">
114
+ <h4 class="tsd-parameters-title">Parameters</h4>
115
+ <ul class="tsd-parameters">
116
+ <li>
117
+ <h5>progress: <a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a></h5>
118
+ </li>
119
+ </ul>
120
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
121
+ </li>
122
+ </ul>
123
+ </li>
124
+ </ul>
125
+ </li>
126
+ </ul>
127
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">&gt;</span></h4>
128
+ </li>
129
+ </ul>
130
+ </section>
131
+ <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
132
+ <a name="encrypt" class="tsd-anchor"></a>
133
+ <h3>encrypt</h3>
134
+ <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
135
+ <li class="tsd-signature tsd-kind-icon">encrypt<span class="tsd-signature-symbol">(</span>key<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, dataToEncrypt<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, progress<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="crypto_file.html#EncryptedFile" class="tsd-signature-type" data-tsd-kind="Type alias">EncryptedFile</a><span class="tsd-signature-symbol">&gt;</span></li>
136
+ </ul>
137
+ <ul class="tsd-descriptions">
138
+ <li class="tsd-description">
139
+ <aside class="tsd-sources">
140
+ <ul>
141
+ <li>Defined in src/worker/sodium.ts:98</li>
142
+ </ul>
143
+ </aside>
144
+ <h4 class="tsd-parameters-title">Parameters</h4>
145
+ <ul class="tsd-parameters">
146
+ <li>
147
+ <h5>key: <span class="tsd-signature-type">Uint8Array</span></h5>
148
+ </li>
149
+ <li>
150
+ <h5>dataToEncrypt: <span class="tsd-signature-type">Uint8Array</span></h5>
151
+ </li>
152
+ <li>
153
+ <h5><span class="tsd-flag ts-flagOptional">Optional</span> progress: <span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h5>
154
+ <ul class="tsd-parameters">
155
+ <li class="tsd-parameter-signature">
156
+ <ul class="tsd-signatures tsd-kind-type-literal">
157
+ <li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>progress<span class="tsd-signature-symbol">: </span><a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
158
+ </ul>
159
+ <ul class="tsd-descriptions">
160
+ <li class="tsd-description">
161
+ <h4 class="tsd-parameters-title">Parameters</h4>
162
+ <ul class="tsd-parameters">
163
+ <li>
164
+ <h5>progress: <a href="crypto_file.html#Progress" class="tsd-signature-type" data-tsd-kind="Type alias">Progress</a></h5>
165
+ </li>
166
+ </ul>
167
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
168
+ </li>
169
+ </ul>
170
+ </li>
171
+ </ul>
172
+ </li>
173
+ </ul>
174
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="crypto_file.html#EncryptedFile" class="tsd-signature-type" data-tsd-kind="Type alias">EncryptedFile</a><span class="tsd-signature-symbol">&gt;</span></h4>
175
+ </li>
176
+ </ul>
177
+ </section>
178
+ </section>
179
+ </div>
180
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
181
+ <nav class="tsd-navigation primary">
182
+ <ul>
183
+ <li class=" ">
184
+ <a href="../modules.html">Modules</a>
185
+ </li>
186
+ <li class="current tsd-kind-module">
187
+ <a href="worker_sodium.html">worker/sodium</a>
188
+ </li>
189
+ </ul>
190
+ </nav>
191
+ <nav class="tsd-navigation secondary menu-sticky">
192
+ <ul class="before-current">
193
+ <li class=" tsd-kind-function tsd-parent-kind-module">
194
+ <a href="worker_sodium.html#decrypt" class="tsd-kind-icon">decrypt</a>
195
+ </li>
196
+ <li class=" tsd-kind-function tsd-parent-kind-module">
197
+ <a href="worker_sodium.html#encrypt" class="tsd-kind-icon">encrypt</a>
198
+ </li>
199
+ </ul>
200
+ </nav>
201
+ </div>
202
+ </div>
203
+ </div>
204
+ <footer class="with-border-bottom">
205
+ <div class="container">
206
+ <h2>Legend</h2>
207
+ <div class="tsd-legend-group">
208
+ <ul class="tsd-legend">
209
+ <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
210
+ <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
211
+ <li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
212
+ <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
213
+ <li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li>
214
+ </ul>
215
+ <ul class="tsd-legend">
216
+ <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
217
+ <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
218
+ </ul>
219
+ <ul class="tsd-legend">
220
+ <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
221
+ </ul>
222
+ </div>
223
+ </div>
224
+ </footer>
225
+ <div class="container tsd-generator">
226
+ <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
227
+ </div>
228
+ <div class="overlay"></div>
229
+ <script src="../assets/js/main.js"></script>
230
+ </body>
231
+ </html>
@@ -0,0 +1,157 @@
1
+ <!doctype html>
2
+ <html class="default no-js">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>worker/workerCodes | @secrecy/lib</title>
7
+ <meta name="description" content="Documentation for @secrecy/lib">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ <link rel="stylesheet" href="../assets/css/main.css">
10
+ <script async src="../assets/js/search.js" id="search-script"></script>
11
+ </head>
12
+ <body>
13
+ <header>
14
+ <div class="tsd-page-toolbar">
15
+ <div class="container">
16
+ <div class="table-wrap">
17
+ <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
18
+ <div class="field">
19
+ <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
20
+ <input id="tsd-search-field" type="text" />
21
+ </div>
22
+ <ul class="results">
23
+ <li class="state loading">Preparing search index...</li>
24
+ <li class="state failure">The search index is not available</li>
25
+ </ul>
26
+ <a href="../index.html" class="title">@secrecy/lib</a>
27
+ </div>
28
+ <div class="table-cell" id="tsd-widgets">
29
+ <div id="tsd-filter">
30
+ <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
31
+ <div class="tsd-filter-group">
32
+ <div class="tsd-select" id="tsd-filter-visibility">
33
+ <span class="tsd-select-label">All</span>
34
+ <ul class="tsd-select-list">
35
+ <li data-value="public">Public</li>
36
+ <li data-value="protected">Public/Protected</li>
37
+ <li data-value="private" class="selected">All</li>
38
+ </ul>
39
+ </div>
40
+ <input type="checkbox" id="tsd-filter-inherited" checked />
41
+ <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
42
+ <input type="checkbox" id="tsd-filter-externals" checked />
43
+ <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
44
+ </div>
45
+ </div>
46
+ <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div class="tsd-page-title">
52
+ <div class="container">
53
+ <ul class="tsd-breadcrumb">
54
+ <li>
55
+ <a href="../modules.html">@secrecy/lib</a>
56
+ </li>
57
+ <li>
58
+ <a href="worker_workerCodes.html">worker/workerCodes</a>
59
+ </li>
60
+ </ul>
61
+ <h1>Module worker/workerCodes</h1>
62
+ </div>
63
+ </div>
64
+ </header>
65
+ <div class="container container-main">
66
+ <div class="row">
67
+ <div class="col-8 col-content">
68
+ <section class="tsd-panel-group tsd-index-group">
69
+ <h2>Index</h2>
70
+ <section class="tsd-panel tsd-index-panel">
71
+ <div class="tsd-index-content">
72
+ <section class="tsd-index-section ">
73
+ <h3>Variables</h3>
74
+ <ul class="tsd-index-list">
75
+ <li class="tsd-kind-variable tsd-parent-kind-module"><a href="worker_workerCodes.html#workerMd5Script" class="tsd-kind-icon">worker<wbr>Md5<wbr>Script</a></li>
76
+ <li class="tsd-kind-variable tsd-parent-kind-module"><a href="worker_workerCodes.html#workerSodiumScript" class="tsd-kind-icon">worker<wbr>Sodium<wbr>Script</a></li>
77
+ </ul>
78
+ </section>
79
+ </div>
80
+ </section>
81
+ </section>
82
+ <section class="tsd-panel-group tsd-member-group ">
83
+ <h2>Variables</h2>
84
+ <section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
85
+ <a name="workerMd5Script" class="tsd-anchor"></a>
86
+ <h3><span class="tsd-flag ts-flagConst">Const</span> worker<wbr>Md5<wbr>Script</h3>
87
+ <div class="tsd-signature tsd-kind-icon">worker<wbr>Md5<wbr>Script<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;importScripts(&#x27;https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js&#x27;);\n\nfunction* chunks(arr, n) {\n for (let i &#x3D; 0; i &lt; arr.length; i +&#x3D; n) {\n yield arr.slice(i, i + n);\n }\n}\n\nconst CHUNK_SIZE &#x3D; 8192;\n\nfunction md5(data) {\n const spark &#x3D; new SparkMD5.ArrayBuffer();\n for (const chunk of chunks(data, CHUNK_SIZE)) {\n spark.append(chunk);\n }\n return spark.end();\n}\n\n\nself.onmessage &#x3D; ({ data }) &#x3D;&gt; {\n switch (data.event) {\n case \&quot;md5\&quot;: {\n postMessage({\n event: \&quot;md5-result\&quot;,\n data: md5(data.data)\n });\n break;\n }\n }\n}&quot;</span><span class="tsd-signature-symbol"> = ...</span></div>
88
+ <aside class="tsd-sources">
89
+ <ul>
90
+ <li>Defined in src/worker/workerCodes.ts:215</li>
91
+ </ul>
92
+ </aside>
93
+ </section>
94
+ <section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
95
+ <a name="workerSodiumScript" class="tsd-anchor"></a>
96
+ <h3><span class="tsd-flag ts-flagConst">Const</span> worker<wbr>Sodium<wbr>Script</h3>
97
+ <div class="tsd-signature tsd-kind-icon">worker<wbr>Sodium<wbr>Script<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;let sodium;\n\nself.sodium &#x3D; {\n onload: (sod) &#x3D;&gt; {\n sodium &#x3D; sod\n postMessage({ event: \&quot;ready\&quot; })\n }\n};\n\nimportScripts(&#x27;https://cdn.jsdelivr.net/gh/jedisct1/libsodium.js@master/dist/browsers/sodium.js&#x27;);\nimportScripts(&#x27;https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js&#x27;);\n\nfunction* chunks(arr, n) {\n for (let i &#x3D; 0; i &lt; arr.length; i +&#x3D; n) {\n yield arr.slice(i, i + n);\n }\n}\n\nfunction assert(c, message) {\n if (!c) {\n throw new Error(message);\n }\n}\n\nfunction encrypt(key) {\n let destroyed &#x3D; false;\n const {\n state,\n header\n } &#x3D; sodium.crypto_secretstream_xchacha20poly1305_init_push(key);\n\n const encrypt &#x3D; (tag, plaintext) &#x3D;&gt; {\n assert(destroyed &#x3D;&#x3D;&#x3D; false, \&quot;state already destroyed\&quot;);\n\n return sodium.crypto_secretstream_xchacha20poly1305_push(\n state,\n plaintext,\n null,\n tag\n );\n };\n\n function destroy() {\n assert(destroyed &#x3D;&#x3D;&#x3D; false, \&quot;state already destroyed\&quot;);\n destroyed &#x3D; true;\n }\n\n return {\n encrypt,\n destroy,\n header\n };\n}\n\nfunction decrypt(header, key) {\n assert(\n header.byteLength &gt;&#x3D;\n sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES,\n \&quot;header must be at least HEADERBYTES (\&quot; + sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES + \&quot;) long\&quot;\n );\n assert(\n key.byteLength &gt;&#x3D; sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES,\n \&quot;key must be at least KEYBYTES (\&quot; + sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES + \&quot;) long\&quot;\n );\n\n let destroyed &#x3D; false;\n const state &#x3D; sodium.crypto_secretstream_xchacha20poly1305_init_pull(\n header,\n key\n );\n\n const decrypt &#x3D; ciphertext &#x3D;&gt; {\n assert(destroyed &#x3D;&#x3D;&#x3D; false, \&quot;state already destroyed\&quot;);\n\n return sodium.crypto_secretstream_xchacha20poly1305_pull(state, ciphertext);\n };\n\n function destroy() {\n assert(destroyed &#x3D;&#x3D;&#x3D; false, \&quot;state already destroyed\&quot;);\n destroyed &#x3D; true;\n }\n\n return {\n decrypt,\n destroy\n };\n}\n\nconst CHUNK_SIZE &#x3D; 8192;\n\nasync function encryptSecretstream(key, data, progress) {\n const { encrypt: crypt, destroy, header } &#x3D; encrypt(key);\n const cryptedChunk &#x3D;\n CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;\n const max &#x3D;\n Math.ceil(data.byteLength / CHUNK_SIZE) * cryptedChunk + header.byteLength;\n\n progress?.({\n percent: 0,\n total: max,\n current: 0\n });\n const final &#x3D; new Uint8Array(max);\n const sparkEncrypted &#x3D; new SparkMD5.ArrayBuffer();\n const spark &#x3D; new SparkMD5.ArrayBuffer();\n\n final.set(header);\n sparkEncrypted.append(header);\n let total &#x3D; header.byteLength;\n progress?.({\n percent: total / max,\n total: max,\n current: total\n });\n\n for (const chunk of chunks(data, CHUNK_SIZE)) {\n spark.append(chunk);\n const tag &#x3D;\n chunk.length &lt; CHUNK_SIZE\n ? sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL\n : sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE;\n const crypted &#x3D; crypt(tag, chunk);\n sparkEncrypted.append(crypted);\n final.set(crypted, total);\n total +&#x3D; crypted.byteLength;\n progress?.({\n percent: total / max,\n total: max,\n current: total\n });\n }\n\n destroy();\n progress?.({\n percent: 1,\n total,\n current: total\n });\n return {\n data: final.slice(0, total),\n md5Encrypted: sparkEncrypted.end(),\n md5: spark.end()\n };\n}\n\nasync function decryptSecretstream(key, data, progress) {\n const header &#x3D; data.slice(\n 0,\n sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES\n );\n data &#x3D; data.slice(sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);\n\n const { decrypt: decryptt, destroy } &#x3D; decrypt(header, key);\n const chunkSize &#x3D;\n CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;\n const max &#x3D; Math.ceil(data.byteLength / chunkSize) * CHUNK_SIZE;\n\n progress?.({\n percent: 0,\n total: max,\n current: 0\n });\n const final &#x3D; new Uint8Array(max);\n let total &#x3D; 0;\n\n for (const chunk of chunks(data, chunkSize)) {\n const tmp &#x3D; decryptt(chunk);\n final.set(tmp.message, total);\n total +&#x3D; tmp.message.byteLength;\n progress?.({\n percent: total / max,\n total: max,\n current: total\n });\n }\n\n destroy();\n progress?.({\n percent: 1,\n total,\n current: total\n });\n return final.slice(0, total);\n}\n\nself.onmessage &#x3D; async ({ data }) &#x3D;&gt; {\n switch (data.event) {\n case \&quot;encrypt\&quot;: {\n postMessage({ event: \&quot;working\&quot; })\n postMessage({\n event: \&quot;encrypt-result\&quot;,\n data: await encryptSecretstream(data.key, data.data, progress &#x3D;&gt; postMessage({\n event: \&quot;encrypt-progress\&quot;,\n data: progress\n }))\n });\n postMessage({ event: \&quot;ready\&quot; })\n break;\n }\n case \&quot;decrypt\&quot;: {\n postMessage({ event: \&quot;working\&quot; })\n postMessage({\n event: \&quot;decrypt-result\&quot;,\n data: await decryptSecretstream(data.key, data.data, progress &#x3D;&gt; postMessage({\n event: \&quot;decrypt-progress\&quot;,\n data: progress\n }))\n });\n postMessage({ event: \&quot;ready\&quot; })\n break;\n }\n }\n}&quot;</span><span class="tsd-signature-symbol"> = ...</span></div>
98
+ <aside class="tsd-sources">
99
+ <ul>
100
+ <li>Defined in src/worker/workerCodes.ts:1</li>
101
+ </ul>
102
+ </aside>
103
+ </section>
104
+ </section>
105
+ </div>
106
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
107
+ <nav class="tsd-navigation primary">
108
+ <ul>
109
+ <li class=" ">
110
+ <a href="../modules.html">Modules</a>
111
+ </li>
112
+ <li class="current tsd-kind-module">
113
+ <a href="worker_workerCodes.html">worker/worker<wbr>Codes</a>
114
+ </li>
115
+ </ul>
116
+ </nav>
117
+ <nav class="tsd-navigation secondary menu-sticky">
118
+ <ul class="before-current">
119
+ <li class=" tsd-kind-variable tsd-parent-kind-module">
120
+ <a href="worker_workerCodes.html#workerMd5Script" class="tsd-kind-icon">worker<wbr>Md5<wbr>Script</a>
121
+ </li>
122
+ <li class=" tsd-kind-variable tsd-parent-kind-module">
123
+ <a href="worker_workerCodes.html#workerSodiumScript" class="tsd-kind-icon">worker<wbr>Sodium<wbr>Script</a>
124
+ </li>
125
+ </ul>
126
+ </nav>
127
+ </div>
128
+ </div>
129
+ </div>
130
+ <footer class="with-border-bottom">
131
+ <div class="container">
132
+ <h2>Legend</h2>
133
+ <div class="tsd-legend-group">
134
+ <ul class="tsd-legend">
135
+ <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
136
+ <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
137
+ <li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
138
+ <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
139
+ <li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li>
140
+ </ul>
141
+ <ul class="tsd-legend">
142
+ <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
143
+ <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
144
+ </ul>
145
+ <ul class="tsd-legend">
146
+ <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
147
+ </ul>
148
+ </div>
149
+ </div>
150
+ </footer>
151
+ <div class="container tsd-generator">
152
+ <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
153
+ </div>
154
+ <div class="overlay"></div>
155
+ <script src="../assets/js/main.js"></script>
156
+ </body>
157
+ </html>