@stryke/crypto 0.5.13 → 0.5.21

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 (57) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/README.md +31 -25
  3. package/dist/{base-64.d.ts → base-64-B1YDs-zl.d.cts} +8 -4
  4. package/dist/base-64-B1YDs-zl.d.cts.map +1 -0
  5. package/dist/base-64-Bh0chPX9.cjs +1 -0
  6. package/dist/base-64-D3iUgxLe.d.mts +40 -0
  7. package/dist/base-64-D3iUgxLe.d.mts.map +1 -0
  8. package/dist/base-64-n6I9tGzK.mjs +2 -0
  9. package/dist/base-64-n6I9tGzK.mjs.map +1 -0
  10. package/dist/base-64.cjs +1 -79
  11. package/dist/base-64.d.cts +2 -0
  12. package/dist/base-64.d.mts +2 -0
  13. package/dist/base-64.mjs +1 -1
  14. package/dist/encryption-CchoDEon.mjs +2 -0
  15. package/dist/encryption-CchoDEon.mjs.map +1 -0
  16. package/dist/{encryption.d.ts → encryption-Dw19bezD.d.cts} +11 -7
  17. package/dist/encryption-Dw19bezD.d.cts.map +1 -0
  18. package/dist/encryption-HwrvWUAF.cjs +1 -0
  19. package/dist/encryption-yC-pEQ14.d.mts +82 -0
  20. package/dist/encryption-yC-pEQ14.d.mts.map +1 -0
  21. package/dist/encryption.cjs +1 -60
  22. package/dist/encryption.d.cts +2 -0
  23. package/dist/encryption.d.mts +2 -0
  24. package/dist/encryption.mjs +1 -1
  25. package/dist/encryption.node-BLOlwsYV.mjs +2 -0
  26. package/dist/encryption.node-BLOlwsYV.mjs.map +1 -0
  27. package/dist/{encryption.node.d.ts → encryption.node-CyYXMEWi.d.cts} +11 -5
  28. package/dist/encryption.node-CyYXMEWi.d.cts.map +1 -0
  29. package/dist/encryption.node-DCO-i6QP.cjs +1 -0
  30. package/dist/encryption.node-pNNijU1t.d.mts +42 -0
  31. package/dist/encryption.node-pNNijU1t.d.mts.map +1 -0
  32. package/dist/encryption.node.cjs +1 -34
  33. package/dist/encryption.node.d.cts +2 -0
  34. package/dist/encryption.node.d.mts +2 -0
  35. package/dist/encryption.node.mjs +1 -1
  36. package/dist/{hex.d.ts → hex-BaOs3VLq.d.cts} +6 -2
  37. package/dist/hex-BaOs3VLq.d.cts.map +1 -0
  38. package/dist/hex-C1p5VuEv.mjs +2 -0
  39. package/dist/hex-C1p5VuEv.mjs.map +1 -0
  40. package/dist/hex-CDXtL048.cjs +1 -0
  41. package/dist/hex-eot11JTh.d.mts +18 -0
  42. package/dist/hex-eot11JTh.d.mts.map +1 -0
  43. package/dist/hex.cjs +1 -47
  44. package/dist/hex.d.cts +2 -0
  45. package/dist/hex.d.mts +2 -0
  46. package/dist/hex.mjs +1 -1
  47. package/dist/index.cjs +1 -38
  48. package/dist/index.d.cts +4 -0
  49. package/dist/index.d.mts +4 -0
  50. package/dist/index.mjs +1 -1
  51. package/dist/neutral.cjs +1 -38
  52. package/dist/neutral.d.cts +4 -0
  53. package/dist/neutral.d.mts +4 -0
  54. package/dist/neutral.mjs +1 -1
  55. package/package.json +24 -125
  56. package/dist/index.d.ts +0 -3
  57. package/dist/neutral.d.ts +0 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,225 @@
1
+ ![Storm Software's logo banner](https://public.storm-cdn.com/storm-software/banner-1280x320-optimized.gif)
2
+
3
+ # Changelog for Stryke - Crypto
4
+
5
+ ## [0.5.20](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.20) (12/07/2025)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.4**
10
+ - Updated **convert** to **v0.6.19**
11
+
12
+ ## [0.5.19](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.19) (12/07/2025)
13
+
14
+ ### Miscellaneous
15
+
16
+ - **monorepo:** Format monorepo source files
17
+ ([9428936](https://github.com/storm-software/stryke/commit/9428936))
18
+
19
+ ### Updated Dependencies
20
+
21
+ - Updated **type-checks** to **v0.5.3**
22
+ - Updated **convert** to **v0.6.18**
23
+
24
+ ## [0.5.18](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.18) (12/06/2025)
25
+
26
+ ### Features
27
+
28
+ - **tools-nx:** Resolved issue inferring build command-line arguments for local
29
+ packages ([de00278](https://github.com/storm-software/stryke/commit/de00278))
30
+
31
+ ### Updated Dependencies
32
+
33
+ - Updated **type-checks** to **v0.5.2**
34
+ - Updated **convert** to **v0.6.17**
35
+
36
+ ## [0.5.17](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.17) (12/06/2025)
37
+
38
+ ### Updated Dependencies
39
+
40
+ - Updated **type-checks** to **v0.5.1**
41
+ - Updated **convert** to **v0.6.16**
42
+
43
+ ## [0.5.16](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.16) (12/05/2025)
44
+
45
+ ### Updated Dependencies
46
+
47
+ - Updated **type-checks** to **v0.5.0**
48
+ - Updated **convert** to **v0.6.15**
49
+
50
+ ## [0.5.15](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.15) (12/05/2025)
51
+
52
+ ### Features
53
+
54
+ - **monorepo:** Update repository to use `tsdown` to build/bundle packages
55
+ ([8ceb909](https://github.com/storm-software/stryke/commit/8ceb909))
56
+
57
+ ### Updated Dependencies
58
+
59
+ - Updated **type-checks** to **v0.4.5**
60
+ - Updated **convert** to **v0.6.14**
61
+
62
+ ## [0.5.14](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.14) (12/01/2025)
63
+
64
+ ### Updated Dependencies
65
+
66
+ - Updated **type-checks** to **v0.4.4**
67
+ - Updated **convert** to **v0.6.13**
68
+
69
+ ## [0.5.13](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.13) (11/30/2025)
70
+
71
+ ### Updated Dependencies
72
+
73
+ - Updated **type-checks** to **v0.4.3**
74
+ - Updated **convert** to **v0.6.12**
75
+
76
+ ## [0.5.12](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.12) (11/30/2025)
77
+
78
+ ### Updated Dependencies
79
+
80
+ - Updated **type-checks** to **v0.4.2**
81
+ - Updated **convert** to **v0.6.11**
82
+
83
+ ## [0.5.11](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.11) (11/30/2025)
84
+
85
+ ### Updated Dependencies
86
+
87
+ - Updated **type-checks** to **v0.4.1**
88
+ - Updated **convert** to **v0.6.10**
89
+
90
+ ## [0.5.10](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.10) (11/30/2025)
91
+
92
+ ### Updated Dependencies
93
+
94
+ - Updated **type-checks** to **v0.4.0**
95
+ - Updated **convert** to **v0.6.9**
96
+
97
+ ## [0.5.9](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.9) (11/24/2025)
98
+
99
+ ### Updated Dependencies
100
+
101
+ - Updated **type-checks** to **v0.3.18**
102
+ - Updated **convert** to **v0.6.8**
103
+
104
+ ## [0.5.8](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.8) (11/21/2025)
105
+
106
+ ### Updated Dependencies
107
+
108
+ - Updated **type-checks** to **v0.3.17**
109
+ - Updated **convert** to **v0.6.7**
110
+
111
+ ## [0.5.7](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.7) (11/21/2025)
112
+
113
+ ### Updated Dependencies
114
+
115
+ - Updated **type-checks** to **v0.3.16**
116
+ - Updated **convert** to **v0.6.6**
117
+
118
+ ## [0.5.6](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.6) (11/21/2025)
119
+
120
+ ### Updated Dependencies
121
+
122
+ - Updated **type-checks** to **v0.3.15**
123
+ - Updated **convert** to **v0.6.5**
124
+
125
+ ## [0.5.5](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.5) (11/21/2025)
126
+
127
+ ### Updated Dependencies
128
+
129
+ - Updated **type-checks** to **v0.3.14**
130
+ - Updated **convert** to **v0.6.4**
131
+
132
+ ## [0.5.4](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.4) (11/21/2025)
133
+
134
+ ### Updated Dependencies
135
+
136
+ - Updated **type-checks** to **v0.3.13**
137
+ - Updated **convert** to **v0.6.3**
138
+
139
+ ## [0.5.3](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.3) (11/16/2025)
140
+
141
+ ### Updated Dependencies
142
+
143
+ - Updated **type-checks** to **v0.3.12**
144
+ - Updated **convert** to **v0.6.2**
145
+
146
+ ## [0.5.2](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.2) (11/08/2025)
147
+
148
+ ### Updated Dependencies
149
+
150
+ - Updated **type-checks** to **v0.3.11**
151
+ - Updated **convert** to **v0.6.1**
152
+
153
+ ## [0.5.1](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.1) (2025-09-20)
154
+
155
+ ### Miscellaneous
156
+
157
+ - **monorepo:** Update workspace package links
158
+ ([6a19f93](https://github.com/storm-software/stryke/commit/6a19f93))
159
+
160
+ ## [0.5.0](https://github.com/storm-software/stryke/releases/tag/crypto%400.5.0) (2025-09-19)
161
+
162
+ ### Features
163
+
164
+ - **crypto:** Split package between `neutral` and `node` exports
165
+ ([cfd15b3](https://github.com/storm-software/stryke/commit/cfd15b3))
166
+
167
+ ### Miscellaneous
168
+
169
+ - **monorepo:** Update `storm-ops` workspace dependencies
170
+ ([23343cf](https://github.com/storm-software/stryke/commit/23343cf))
171
+
172
+ ### Updated Dependencies
173
+
174
+ - Updated convert to 0.6.0
175
+
176
+ ## [0.4.2](https://github.com/storm-software/stryke/releases/tag/crypto%400.4.2) (2025-09-16)
177
+
178
+ ### Miscellaneous
179
+
180
+ - **monorepo:** Format the package source files
181
+ ([180b674](https://github.com/storm-software/stryke/commit/180b674))
182
+
183
+ ## [0.4.1](https://github.com/storm-software/stryke/releases/tag/crypto%400.4.1) (2025-09-13)
184
+
185
+ ### Miscellaneous
186
+
187
+ - **monorepo:** Update workspace package links
188
+ ([ad0b548](https://github.com/storm-software/stryke/commit/ad0b548))
189
+
190
+ ## [0.4.0](https://github.com/storm-software/stryke/releases/tag/crypto%400.4.0) (2025-09-12)
191
+
192
+ ### Features
193
+
194
+ - **crypto:** Added neutral crypto utilites
195
+ ([3aca214](https://github.com/storm-software/stryke/commit/3aca214))
196
+
197
+ ### Updated Dependencies
198
+
199
+ - Updated convert to 0.5.0
200
+
201
+ ## [0.3.0](https://github.com/storm-software/stryke/releases/tag/crypto%400.3.0) (2025-09-11)
202
+
203
+ ### Features
204
+
205
+ - **crypto:** Added the `base-64` helpers module
206
+ ([36b6631](https://github.com/storm-software/stryke/commit/36b6631))
207
+
208
+ ## [0.2.0](https://github.com/storm-software/stryke/releases/tag/crypto%400.2.0) (2025-09-08)
209
+
210
+ ### Features
211
+
212
+ - **crypto:** Added the `sym` module for symmetric ChaCha20-Poly1305 encryption
213
+ ([39947e5](https://github.com/storm-software/stryke/commit/39947e5))
214
+
215
+ ### Miscellaneous
216
+
217
+ - **crypto:** Simplify utility function names
218
+ ([f4528da](https://github.com/storm-software/stryke/commit/f4528da))
219
+
220
+ ## [0.1.0](https://github.com/storm-software/stryke/releases/tag/crypto%400.1.0) (2025-09-07)
221
+
222
+ ### Features
223
+
224
+ - **crypto:** Initial check-in of encryption helpers package
225
+ ([f1b9895](https://github.com/storm-software/stryke/commit/f1b9895))
package/README.md CHANGED
@@ -3,7 +3,13 @@
3
3
  <!-- markdownlint-disable -->
4
4
 
5
5
 
6
- <div align="center"><img src="https://public.storm-cdn.com/storm-banner.gif" width="100%" alt="Storm Software" /></div>
6
+ <div align="center">
7
+ <picture>
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x640-dark-optimized.gif">
9
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x640-light-optimized.gif">
10
+ <img src="https://public.storm-cdn.com/storm-software/banner-1280x640-dark-optimized.gif" width="100%" alt="Storm Software" />
11
+ </picture>
12
+ </div>
7
13
  <br />
8
14
 
9
15
  <div align="center">
@@ -16,13 +22,13 @@
16
22
  </div>
17
23
 
18
24
  <br />
19
- This package is part of Storm Software's **🌩️ Stryke** monorepo. Stryke packages TypeScript utility packages with shared functionality common to many Storm Software applications.
25
+ This package is part of Storm Software's **💥 Stryke** monorepo. Stryke packages TypeScript utility packages with shared functionality common to many Storm Software applications.
20
26
 
21
27
  <br />
22
28
 
23
29
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
24
30
 
25
- [![Version](https://img.shields.io/badge/version-0.8.2-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
+ [![Version](https://img.shields.io/badge/version-0.5.18-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
32
 
27
33
  > [!IMPORTANT] Important
28
34
  > This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
@@ -46,24 +52,21 @@ encrypting and decrypting data.
46
52
 
47
53
  <!-- START doctoc -->
48
54
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
49
-
50
55
  ## Table of Contents
51
56
 
52
- - [Stryke - Encryption Helpers](#stryke---encryption-helpers)
53
- - [Table of Contents](#table-of-contents)
54
- - [Installing](#installing)
55
- - [Reduced Package Size](#reduced-package-size)
56
- - [Development](#development)
57
- - [Building](#building)
58
- - [Running unit tests](#running-unit-tests)
59
- - [Linting](#linting)
60
- - [Storm Workspaces](#storm-workspaces)
61
- - [Roadmap](#roadmap)
62
- - [Support](#support)
63
- - [License](#license)
64
- - [Changelog](#changelog)
65
- - [Contributing](#contributing)
66
- - [Contributors](#contributors)
57
+ - [Installing](#installing)
58
+ - [Reduced Package Size](#reduced-package-size)
59
+ - [Development](#development)
60
+ - [Building](#building)
61
+ - [Running unit tests](#running-unit-tests)
62
+ - [Linting](#linting)
63
+ - [Storm Workspaces](#storm-workspaces)
64
+ - [Roadmap](#roadmap)
65
+ - [Support](#support)
66
+ - [License](#license)
67
+ - [Changelog](#changelog)
68
+ - [Contributing](#contributing)
69
+ - [Contributors](#contributors)
67
70
 
68
71
  <!-- END doctoc -->
69
72
 
@@ -97,10 +100,10 @@ yarn add -D @stryke/http
97
100
 
98
101
  ## Reduced Package Size
99
102
 
100
- This project uses [tsup](https://tsup.egoist.dev/) to package the source code
101
- due to its ability to remove unused code and ship smaller javascript files
102
- thanks to code splitting. This helps to greatly reduce the size of the package
103
- and to make it easier to use in other projects.
103
+ This project uses [tsdown](https://tsdown.dev) to package the source code due to
104
+ its ability to remove unused code and ship smaller javascript files thanks to
105
+ code splitting. This helps to greatly reduce the size of the package and to make
106
+ it easier to use in other projects.
104
107
 
105
108
  ## Development
106
109
 
@@ -241,10 +244,13 @@ specification. Contributions of any kind welcome!
241
244
  <br />
242
245
 
243
246
  <hr />
244
- <br />
245
247
 
246
248
  <div align="center">
247
- <img src="https://public.storm-cdn.com/logo-banner.png" width="100%" alt="Storm Software" />
249
+ <picture>
250
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-dark-optimized.webp">
251
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-light-optimized.webp">
252
+ <img src="https://public.storm-cdn.com/storm-software/banner-1280x320-dark-optimized.webp" width="100%" alt="Storm Software" />
253
+ </picture>
248
254
  </div>
249
255
  <br />
250
256
 
@@ -1,3 +1,4 @@
1
+ //#region src/base-64.d.ts
1
2
  /**
2
3
  * Encodes a Uint8Array into a Base64 encoded Uint8Array.
3
4
  *
@@ -6,7 +7,7 @@
6
7
  * @param input - The input Uint8Array or string to encode.
7
8
  * @returns The Base64 encoded Uint8Array.
8
9
  */
9
- export declare function encodeBase64(input: Uint8Array | string): string;
10
+ declare function encodeBase64(input: Uint8Array | string): string;
10
11
  /**
11
12
  * Decodes a Base64 encoded Uint8Array into a Uint8Array.
12
13
  *
@@ -15,7 +16,7 @@ export declare function encodeBase64(input: Uint8Array | string): string;
15
16
  * @param input - The Base64 encoded Uint8Array or string to decode.
16
17
  * @returns The decoded Uint8Array.
17
18
  */
18
- export declare function decodeBase64(input: Uint8Array | string): Uint8Array;
19
+ declare function decodeBase64(input: Uint8Array | string): Uint8Array;
19
20
  /**
20
21
  * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.
21
22
  *
@@ -24,7 +25,7 @@ export declare function decodeBase64(input: Uint8Array | string): Uint8Array;
24
25
  * @param base64 - The Base64 encoded string to convert.
25
26
  * @returns The Base64url encoded string.
26
27
  */
27
- export declare function base64ToBase64url(base64: string): string;
28
+ declare function base64ToBase64url(base64: string): string;
28
29
  /**
29
30
  * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.
30
31
  *
@@ -33,4 +34,7 @@ export declare function base64ToBase64url(base64: string): string;
33
34
  * @param base64url - The Base64url encoded string to convert.
34
35
  * @returns The Base64 encoded string.
35
36
  */
36
- export declare function base64FromBase64url(base64url: string): string;
37
+ declare function base64FromBase64url(base64url: string): string;
38
+ //#endregion
39
+ export { encodeBase64 as i, base64ToBase64url as n, decodeBase64 as r, base64FromBase64url as t };
40
+ //# sourceMappingURL=base-64-B1YDs-zl.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-64-B1YDs-zl.d.cts","names":[],"sources":["../src/base-64.ts"],"sourcesContent":[],"mappings":";;AAoEA;AAmDA;AAkFA;AAYA;;;;iBAjJgB,YAAA,QAAoB;;;;;;;;;iBAmDpB,YAAA,QAAoB,sBAAsB;;;;;;;;;iBAkF1C,iBAAA;;;;;;;;;iBAYA,mBAAA"}
@@ -0,0 +1 @@
1
+ function e(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.byteLength;if(n<65535)return String.fromCharCode.apply(null,t);let r=``;for(let e=0;e<n;e++)r+=String.fromCharCode(t[e]);return r}const t=e=>e===void 0,n=typeof Buffer<`u`,r=n?Buffer.isBuffer.bind(Buffer):function(e){return!1},i=(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype),a=e=>{try{return typeof e==`string`}catch{return!1}};function o(e){return Uint8Array.from([...encodeURIComponent(e)].map(e=>e.codePointAt(0)))}function s(e){return o(atob(e))}const c=new TextEncoder;function l(e){return c.encode(e)}function u(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function d(t){return btoa(e(t))}const f=new TextDecoder;function p(e){return f.decode(e)}const m=new Uint8Array([65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47]),h=61,g=new Uint8Array([100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,62,100,100,100,63,52,53,54,55,56,57,58,59,60,61,100,100,100,100,100,100,100,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,100,100,100,100,100,100,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]);function _(e){a(e)&&(e=o(e));let t=e.length,n=new Uint8Array(Math.ceil(t/3)*4),r=Math.floor(t/3);for(let t=0;t<r;t++){let r=e[3*t+0]<<16|e[3*t+1]<<8|e[3*t+2];n[4*t+0]=m[r>>18&63],n[4*t+1]=m[r>>12&63],n[4*t+2]=m[r>>6&63],n[4*t+3]=m[r>>0&63]}let i=r;switch(t%3){case 1:{let t=e[3*i+0]<<16;n[4*i+0]=m[t>>18&63],n[4*i+1]=m[t>>12&63],n[4*i+2]=61,n[4*i+3]=61;break}case 2:{let t=e[3*i+0]<<16|e[3*i+1]<<8;n[4*i+0]=m[t>>18&63],n[4*i+1]=m[t>>12&63],n[4*i+2]=m[t>>6&63],n[4*i+3]=61;break}}return p(n)}function v(e){a(e)&&(e=o(e));let n=e.length;if(n%4!=0)throw Error(`invalid length`);let r=0;for(;r<2&&r<e.length&&e[e.length-1-r]===61;)r++;for(let n=0;n<e.length-r;n++)if(t(e[n])||t(g[e[n]])||g[e[n]]>=64)throw Error(`invalid data`);let i=Math.floor((n-r)/4),s=3*i+(3-r)%3,c=new Uint8Array(s);for(let t=0;t<i;t++){let n=g[e[4*t+0]]<<18|g[e[4*t+1]]<<12|g[e[4*t+2]]<<6|g[e[4*t+3]]<<0;c[3*t]=n>>16&255,c[3*t+1]=n>>8&255,c[3*t+2]=n>>0&255}let l=i;switch(s%3){case 1:{let t=g[e[4*l+0]]<<18|g[e[4*l+1]]<<12;c[3*l]=t>>16&255;break}case 2:{let t=g[e[4*l+0]]<<18|g[e[4*l+1]]<<12|g[e[4*l+2]]<<6;c[3*l]=t>>16&255,c[3*l+1]=t>>8&255;break}}return c}function y(e){return e.replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function b(e){return e.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat((4-e.length%4)%4)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}});
@@ -0,0 +1,40 @@
1
+ //#region src/base-64.d.ts
2
+ /**
3
+ * Encodes a Uint8Array into a Base64 encoded Uint8Array.
4
+ *
5
+ * @credit https://github.com/hi-ogawa/js-utils
6
+ *
7
+ * @param input - The input Uint8Array or string to encode.
8
+ * @returns The Base64 encoded Uint8Array.
9
+ */
10
+ declare function encodeBase64(input: Uint8Array | string): string;
11
+ /**
12
+ * Decodes a Base64 encoded Uint8Array into a Uint8Array.
13
+ *
14
+ * @credit https://github.com/hi-ogawa/js-utils
15
+ *
16
+ * @param input - The Base64 encoded Uint8Array or string to decode.
17
+ * @returns The decoded Uint8Array.
18
+ */
19
+ declare function decodeBase64(input: Uint8Array | string): Uint8Array;
20
+ /**
21
+ * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.
22
+ *
23
+ * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
24
+ *
25
+ * @param base64 - The Base64 encoded string to convert.
26
+ * @returns The Base64url encoded string.
27
+ */
28
+ declare function base64ToBase64url(base64: string): string;
29
+ /**
30
+ * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.
31
+ *
32
+ * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
33
+ *
34
+ * @param base64url - The Base64url encoded string to convert.
35
+ * @returns The Base64 encoded string.
36
+ */
37
+ declare function base64FromBase64url(base64url: string): string;
38
+ //#endregion
39
+ export { encodeBase64 as i, base64ToBase64url as n, decodeBase64 as r, base64FromBase64url as t };
40
+ //# sourceMappingURL=base-64-D3iUgxLe.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-64-D3iUgxLe.d.mts","names":[],"sources":["../src/base-64.ts"],"sourcesContent":[],"mappings":";;AAoEA;AAmDA;AAkFA;AAYA;;;;iBAjJgB,YAAA,QAAoB;;;;;;;;;iBAmDpB,YAAA,QAAoB,sBAAsB;;;;;;;;;iBAkF1C,iBAAA;;;;;;;;;iBAYA,mBAAA"}
@@ -0,0 +1,2 @@
1
+ function e(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.byteLength;if(n<65535)return String.fromCharCode.apply(null,t);let r=``;for(let e=0;e<n;e++)r+=String.fromCharCode(t[e]);return r}const t=e=>e===void 0;typeof Buffer<`u`&&Buffer.isBuffer.bind(Buffer),(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);const n=e=>{try{return typeof e==`string`}catch{return!1}};function r(e){return Uint8Array.from([...encodeURIComponent(e)].map(e=>e.codePointAt(0)))}function i(e){return r(atob(e))}const a=new TextEncoder;function o(e){return a.encode(e)}function s(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function c(t){return btoa(e(t))}const l=new TextDecoder;function u(e){return l.decode(e)}const d=new Uint8Array([65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47]),f=new Uint8Array([100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,62,100,100,100,63,52,53,54,55,56,57,58,59,60,61,100,100,100,100,100,100,100,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,100,100,100,100,100,100,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]);function p(e){n(e)&&(e=r(e));let t=e.length,i=new Uint8Array(Math.ceil(t/3)*4),a=Math.floor(t/3);for(let t=0;t<a;t++){let n=e[3*t+0]<<16|e[3*t+1]<<8|e[3*t+2];i[4*t+0]=d[n>>18&63],i[4*t+1]=d[n>>12&63],i[4*t+2]=d[n>>6&63],i[4*t+3]=d[n>>0&63]}let o=a;switch(t%3){case 1:{let t=e[3*o+0]<<16;i[4*o+0]=d[t>>18&63],i[4*o+1]=d[t>>12&63],i[4*o+2]=61,i[4*o+3]=61;break}case 2:{let t=e[3*o+0]<<16|e[3*o+1]<<8;i[4*o+0]=d[t>>18&63],i[4*o+1]=d[t>>12&63],i[4*o+2]=d[t>>6&63],i[4*o+3]=61;break}}return u(i)}function m(e){n(e)&&(e=r(e));let i=e.length;if(i%4!=0)throw Error(`invalid length`);let a=0;for(;a<2&&a<e.length&&e[e.length-1-a]===61;)a++;for(let n=0;n<e.length-a;n++)if(t(e[n])||t(f[e[n]])||f[e[n]]>=64)throw Error(`invalid data`);let o=Math.floor((i-a)/4),s=3*o+(3-a)%3,c=new Uint8Array(s);for(let t=0;t<o;t++){let n=f[e[4*t+0]]<<18|f[e[4*t+1]]<<12|f[e[4*t+2]]<<6|f[e[4*t+3]]<<0;c[3*t]=n>>16&255,c[3*t+1]=n>>8&255,c[3*t+2]=n>>0&255}let l=o;switch(s%3){case 1:{let t=f[e[4*l+0]]<<18|f[e[4*l+1]]<<12;c[3*l]=t>>16&255;break}case 2:{let t=f[e[4*l+0]]<<18|f[e[4*l+1]]<<12|f[e[4*l+2]]<<6;c[3*l]=t>>16&255,c[3*l+1]=t>>8&255;break}}return c}function h(e){return e.replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function g(e){return e.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat((4-e.length%4)%4)}export{u as a,o as c,p as i,i as l,h as n,c as o,m as r,s,g as t};
2
+ //# sourceMappingURL=base-64-n6I9tGzK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-64-n6I9tGzK.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer","i"],"sources":["../../convert/src/array-buffer-to-string.ts","../../type-checks/src/is-undefined.ts","../../type-checks/src/is-buffer.ts","../../type-checks/src/type-detect.ts","../../type-checks/src/is-string.ts","../../convert/src/string-to-uint8-array.ts","../../convert/src/string-to-utf8-array.ts","../../convert/src/uint8-array-to-stream.ts","../../convert/src/uint8-array-to-string.ts","../../convert/src/utf8-array-to-string.ts","../src/base-64.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert a string to Uint8Array\n *\n * @param text - The text to convert\n * @returns The converted Uint8Array\n */\nexport function stringToUint8Array(text: string): Uint8Array {\n return Uint8Array.from(\n [...encodeURIComponent(text)].map(letter => letter.codePointAt(0)!)\n );\n}\n\n/**\n * Convert a binary string to Uint8Array\n *\n * @param binary - The binary string to convert\n * @returns The converted Uint8Array\n */\nexport function binaryStringToUint8Array(binary: string): Uint8Array {\n const len = binary.length;\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = binary.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Convert a base64 string to a Uint8Array\n *\n * @param data - The base64 string to convert\n * @returns The converted Uint8Array\n */\nexport function base64StringToUint8Array(data: string): Uint8Array {\n return stringToUint8Array(atob(data));\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst encoder = new TextEncoder();\n\n/**\n * Convert a string to a utf-8 array\n *\n * @param input - The string to convert\n * @returns The converted utf-8 array\n */\nexport function stringToUtf8Array(input: string): Uint8Array {\n return encoder.encode(input);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert a Uint8Array to a ReadableStream\n *\n * @param data - The Uint8Array to convert\n * @returns The converted ReadableStream\n */\nexport function uint8ArrayToStream(\n data: Uint8Array\n): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(data);\n controller.close();\n }\n });\n}\n\n/**\n * Concatenate an array of Uint8Array chunks into a single Uint8Array\n *\n * @param chunks - Array of Uint8Array chunks to concatenate\n * @returns The concatenated Uint8Array\n */\nexport function concatUint8Array(chunks: Uint8Array[]): Uint8Array {\n let total = 0;\n for (const chunk of chunks) {\n total += chunk.length;\n }\n const result = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\n/**\n * Concatenate a ReadableStream of Uint8Array chunks into a single Uint8Array\n *\n * @param stream - The ReadableStream of Uint8Array chunks to concatenate\n * @returns A promise that resolves to the concatenated Uint8Array\n */\nexport async function concatUint8ArrayStream(\n stream: ReadableStream<Uint8Array>\n): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n await stream.pipeTo(\n new WritableStream({\n write(chunk) {\n chunks.push(chunk);\n }\n })\n );\n\n return concatUint8Array(chunks);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { arrayBufferToString } from \"./array-buffer-to-string\";\n\n/**\n * Convert a Uint8Array to a base64 string\n *\n * @param buffer - The Uint8Array to convert\n * @returns The converted base64 string\n */\nexport function uint8ArrayToString(buffer: Uint8Array): string {\n return btoa(arrayBufferToString(buffer));\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst decoder = new TextDecoder();\n\n/**\n * Convert a utf-8 array to string\n *\n * @param input - Utf-8 Array\n * @returns The converted string\n */\nexport function utf8ArrayToString(\n input: NodeJS.ArrayBufferView | ArrayBuffer\n): string {\n return decoder.decode(input);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { stringToUint8Array } from \"@stryke/convert/neutral\";\nimport { utf8ArrayToString } from \"@stryke/convert/utf8-array-to-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\n// map 6 bits [0, 64) into ascii byte (8 bits)\n// generated by\n// Array.from(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\", c => c.charCodeAt(0))\n// biome-ignore format:\nconst ENCODE_MAP = new Uint8Array([\n 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\n 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,\n 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47\n]);\n\n// \"=\".codePointAt(0)\nconst ENCODE_PAD = 61;\n\n// inverse of ENCODE_MAP\n// generated by\n// ENCODE_MAP.reduce((acc, v, i) => { acc[v] = i; return acc }, Array(255).fill(100))\n// biome-ignore format:\nconst DECODE_MAP = new Uint8Array([\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 62, 100, 100,\n 100, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 100, 100, 100, 100, 100, 100,\n 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 100, 100, 100, 100, 100, 100, 26, 27, 28, 29, 30, 31, 32,\n 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100\n]);\n\n/**\n * Encodes a Uint8Array into a Base64 encoded Uint8Array.\n *\n * @credit https://github.com/hi-ogawa/js-utils\n *\n * @param input - The input Uint8Array or string to encode.\n * @returns The Base64 encoded Uint8Array.\n */\nexport function encodeBase64(input: Uint8Array | string): string {\n if (isString(input)) {\n input = stringToUint8Array(input);\n }\n\n const xLen = input.length;\n const result = new Uint8Array(Math.ceil(xLen / 3) * 4);\n const chunkLen = Math.floor(xLen / 3);\n\n // encode complete chunks\n for (let i = 0; i < chunkLen; i++) {\n const chunk =\n (input[3 * i + 0]! << 16) | (input[3 * i + 1]! << 8) | input[3 * i + 2]!;\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_MAP[(chunk >> 6) & 0b111111]!;\n result[4 * i + 3] = ENCODE_MAP[(chunk >> 0) & 0b111111]!;\n }\n\n // encode partial chunk with padding\n const i = chunkLen;\n switch (xLen % 3) {\n case 1: {\n const chunk = input[3 * i + 0]! << 16;\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_PAD;\n result[4 * i + 3] = ENCODE_PAD;\n break;\n }\n case 2: {\n const chunk = (input[3 * i + 0]! << 16) | (input[3 * i + 1]! << 8);\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_MAP[(chunk >> 6) & 0b111111]!;\n result[4 * i + 3] = ENCODE_PAD;\n break;\n }\n }\n\n return utf8ArrayToString(result);\n}\n\n/**\n * Decodes a Base64 encoded Uint8Array into a Uint8Array.\n *\n * @credit https://github.com/hi-ogawa/js-utils\n *\n * @param input - The Base64 encoded Uint8Array or string to decode.\n * @returns The decoded Uint8Array.\n */\nexport function decodeBase64(input: Uint8Array | string): Uint8Array {\n if (isString(input)) {\n input = stringToUint8Array(input);\n }\n\n const yLen = input.length;\n\n // validate length\n if (yLen % 4 !== 0) {\n throw new Error(\"invalid length\");\n }\n\n // get padding length\n let padLen = 0;\n while (\n padLen < 2 &&\n padLen < input.length &&\n input[input.length - 1 - padLen] === ENCODE_PAD\n ) {\n padLen++;\n }\n\n // validate encoding\n for (let i = 0; i < input.length - padLen; i++) {\n if (\n isUndefined(input[i]) ||\n isUndefined(DECODE_MAP[input[i]!]) ||\n DECODE_MAP[input[i]!]! >= 64\n ) {\n throw new Error(\"invalid data\");\n }\n }\n\n // validate encoding\n const chunkLen = Math.floor((yLen - padLen) / 4);\n const xLen = 3 * chunkLen + ((3 - padLen) % 3);\n const result = new Uint8Array(xLen);\n\n // decode complete chunks\n for (let i = 0; i < chunkLen; i++) {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12) |\n (DECODE_MAP[input[4 * i + 2]!]! << 6) |\n (DECODE_MAP[input[4 * i + 3]!]! << 0);\n result[3 * i] = (chunk >> 16) & 0xff;\n result[3 * i + 1] = (chunk >> 8) & 0xff;\n result[3 * i + 2] = (chunk >> 0) & 0xff;\n }\n\n // decode partial chunk\n const i = chunkLen;\n switch (xLen % 3) {\n case 1: {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12);\n result[3 * i] = (chunk >> 16) & 0xff;\n break;\n }\n case 2: {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12) |\n (DECODE_MAP[input[4 * i + 2]!]! << 6);\n result[3 * i] = (chunk >> 16) & 0xff;\n result[3 * i + 1] = (chunk >> 8) & 0xff;\n break;\n }\n }\n\n return result;\n}\n\n/**\n * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C\n *\n * @param base64 - The Base64 encoded string to convert.\n * @returns The Base64url encoded string.\n */\nexport function base64ToBase64url(base64: string): string {\n return base64.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/g, \"\");\n}\n\n/**\n * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C\n *\n * @param base64url - The Base64url encoded string to convert.\n * @returns The Base64 encoded string.\n */\nexport function base64FromBase64url(base64url: string): string {\n return (\n base64url.replace(/-/g, \"+\").replace(/_/g, \"/\") +\n \"=\".repeat((4 - (base64url.length % 4)) % 4)\n );\n}\n"],"mappings":"AAwBA,SAAgB,EACd,EACQ,CACR,IAAM,EACJ,aAAkB,WACd,EACA,IAAI,WAAW,EAA0B,CACzC,EAAM,EAAM,WAClB,GAAI,EAAM,MACR,OAAO,OAAO,aAAa,MAAM,KAAM,EAA6B,CAEtE,IAAI,EAAS,GACb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,IACvB,GAAU,OAAO,aAAa,EAAM,GAAI,CAE1C,OAAO,ECrBT,MAAa,EAAe,GACnB,IAAU,IAAA,GCDW,OAAO,OAAW,KAM5C,OAAO,SAAS,KAAK,OAAO,ECJV,IAChB,OAAO,YAAe,UAG1B,OAAO,eAAe,EAAK,yBAA0B,CACnD,KAAM,CACJ,OAAO,MAET,aAAc,GACf,CAAC,CAPO,aAeR,OAAO,UAAU,CCnBpB,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO,KCEX,SAAg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,EAAI,KAAS,EACrC,EAAO,EAAI,GAAM,GAAS,GAAM,IAChC,EAAO,EAAI,EAAI,GAAM,GAAS,EAAK,IACnC,OAIJ,OAAO,EAWT,SAAgB,EAAkB,EAAwB,CACxD,OAAO,EAAO,QAAQ,MAAO,IAAI,CAAC,QAAQ,MAAO,IAAI,CAAC,QAAQ,OAAQ,GAAG,CAW3E,SAAgB,EAAoB,EAA2B,CAC7D,OACE,EAAU,QAAQ,KAAM,IAAI,CAAC,QAAQ,KAAM,IAAI,CAC/C,IAAI,QAAQ,EAAK,EAAU,OAAS,GAAM,EAAE"}
package/dist/base-64.cjs CHANGED
@@ -1,79 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.base64FromBase64url = base64FromBase64url;
7
- exports.base64ToBase64url = base64ToBase64url;
8
- exports.decodeBase64 = decodeBase64;
9
- exports.encodeBase64 = encodeBase64;
10
- var _neutral = require("@stryke/convert/neutral");
11
- var _utf8ArrayToString = require("@stryke/convert/utf8-array-to-string");
12
- var _isString = require("@stryke/type-checks/is-string");
13
- var _isUndefined = require("@stryke/type-checks/is-undefined");
14
- const a = new Uint8Array([65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47]),
15
- h = 61,
16
- s = new Uint8Array([100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 62, 100, 100, 100, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 100, 100, 100, 100, 100, 100, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 100, 100, 100, 100, 100, 100, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]);
17
- function encodeBase64(r) {
18
- (0, _isString.isString)(r) && (r = (0, _neutral.stringToUint8Array)(r));
19
- const f = r.length,
20
- n = new Uint8Array(Math.ceil(f / 3) * 4),
21
- l = Math.floor(f / 3);
22
- for (let e = 0; e < l; e++) {
23
- const c = r[3 * e + 0] << 16 | r[3 * e + 1] << 8 | r[3 * e + 2];
24
- n[4 * e + 0] = a[c >> 18 & 63], n[4 * e + 1] = a[c >> 12 & 63], n[4 * e + 2] = a[c >> 6 & 63], n[4 * e + 3] = a[c >> 0 & 63];
25
- }
26
- const t = l;
27
- switch (f % 3) {
28
- case 1:
29
- {
30
- const e = r[3 * t + 0] << 16;
31
- n[4 * t + 0] = a[e >> 18 & 63], n[4 * t + 1] = a[e >> 12 & 63], n[4 * t + 2] = h, n[4 * t + 3] = h;
32
- break;
33
- }
34
- case 2:
35
- {
36
- const e = r[3 * t + 0] << 16 | r[3 * t + 1] << 8;
37
- n[4 * t + 0] = a[e >> 18 & 63], n[4 * t + 1] = a[e >> 12 & 63], n[4 * t + 2] = a[e >> 6 & 63], n[4 * t + 3] = h;
38
- break;
39
- }
40
- }
41
- return (0, _utf8ArrayToString.utf8ArrayToString)(n);
42
- }
43
- function decodeBase64(r) {
44
- (0, _isString.isString)(r) && (r = (0, _neutral.stringToUint8Array)(r));
45
- const f = r.length;
46
- if (f % 4 !== 0) throw new Error("invalid length");
47
- let n = 0;
48
- for (; n < 2 && n < r.length && r[r.length - 1 - n] === h;) n++;
49
- for (let o = 0; o < r.length - n; o++) if ((0, _isUndefined.isUndefined)(r[o]) || (0, _isUndefined.isUndefined)(s[r[o]]) || s[r[o]] >= 64) throw new Error("invalid data");
50
- const l = Math.floor((f - n) / 4),
51
- t = 3 * l + (3 - n) % 3,
52
- e = new Uint8Array(t);
53
- for (let o = 0; o < l; o++) {
54
- const g = s[r[4 * o + 0]] << 18 | s[r[4 * o + 1]] << 12 | s[r[4 * o + 2]] << 6 | s[r[4 * o + 3]] << 0;
55
- e[3 * o] = g >> 16 & 255, e[3 * o + 1] = g >> 8 & 255, e[3 * o + 2] = g >> 0 & 255;
56
- }
57
- const c = l;
58
- switch (t % 3) {
59
- case 1:
60
- {
61
- const o = s[r[4 * c + 0]] << 18 | s[r[4 * c + 1]] << 12;
62
- e[3 * c] = o >> 16 & 255;
63
- break;
64
- }
65
- case 2:
66
- {
67
- const o = s[r[4 * c + 0]] << 18 | s[r[4 * c + 1]] << 12 | s[r[4 * c + 2]] << 6;
68
- e[3 * c] = o >> 16 & 255, e[3 * c + 1] = o >> 8 & 255;
69
- break;
70
- }
71
- }
72
- return e;
73
- }
74
- function base64ToBase64url(r) {
75
- return r.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
76
- }
77
- function base64FromBase64url(r) {
78
- return r.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - r.length % 4) % 4);
79
- }
1
+ const e=require(`./base-64-Bh0chPX9.cjs`);exports.base64FromBase64url=e.t,exports.base64ToBase64url=e.n,exports.decodeBase64=e.r,exports.encodeBase64=e.i;
@@ -0,0 +1,2 @@
1
+ import { i as encodeBase64, n as base64ToBase64url, r as decodeBase64, t as base64FromBase64url } from "./base-64-B1YDs-zl.cjs";
2
+ export { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 };
@@ -0,0 +1,2 @@
1
+ import { i as encodeBase64, n as base64ToBase64url, r as decodeBase64, t as base64FromBase64url } from "./base-64-D3iUgxLe.mjs";
2
+ export { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 };
package/dist/base-64.mjs CHANGED
@@ -1 +1 @@
1
- import{stringToUint8Array as i}from"@stryke/convert/neutral";import{utf8ArrayToString as x}from"@stryke/convert/utf8-array-to-string";import{isString as b}from"@stryke/type-checks/is-string";import{isUndefined as k}from"@stryke/type-checks/is-undefined";const a=new Uint8Array([65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47]),h=61,s=new Uint8Array([100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,62,100,100,100,63,52,53,54,55,56,57,58,59,60,61,100,100,100,100,100,100,100,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,100,100,100,100,100,100,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]);export function encodeBase64(r){b(r)&&(r=i(r));const f=r.length,n=new Uint8Array(Math.ceil(f/3)*4),l=Math.floor(f/3);for(let e=0;e<l;e++){const c=r[3*e+0]<<16|r[3*e+1]<<8|r[3*e+2];n[4*e+0]=a[c>>18&63],n[4*e+1]=a[c>>12&63],n[4*e+2]=a[c>>6&63],n[4*e+3]=a[c>>0&63]}const t=l;switch(f%3){case 1:{const e=r[3*t+0]<<16;n[4*t+0]=a[e>>18&63],n[4*t+1]=a[e>>12&63],n[4*t+2]=h,n[4*t+3]=h;break}case 2:{const e=r[3*t+0]<<16|r[3*t+1]<<8;n[4*t+0]=a[e>>18&63],n[4*t+1]=a[e>>12&63],n[4*t+2]=a[e>>6&63],n[4*t+3]=h;break}}return x(n)}export function decodeBase64(r){b(r)&&(r=i(r));const f=r.length;if(f%4!==0)throw new Error("invalid length");let n=0;for(;n<2&&n<r.length&&r[r.length-1-n]===h;)n++;for(let o=0;o<r.length-n;o++)if(k(r[o])||k(s[r[o]])||s[r[o]]>=64)throw new Error("invalid data");const l=Math.floor((f-n)/4),t=3*l+(3-n)%3,e=new Uint8Array(t);for(let o=0;o<l;o++){const g=s[r[4*o+0]]<<18|s[r[4*o+1]]<<12|s[r[4*o+2]]<<6|s[r[4*o+3]]<<0;e[3*o]=g>>16&255,e[3*o+1]=g>>8&255,e[3*o+2]=g>>0&255}const c=l;switch(t%3){case 1:{const o=s[r[4*c+0]]<<18|s[r[4*c+1]]<<12;e[3*c]=o>>16&255;break}case 2:{const o=s[r[4*c+0]]<<18|s[r[4*c+1]]<<12|s[r[4*c+2]]<<6;e[3*c]=o>>16&255,e[3*c+1]=o>>8&255;break}}return e}export function base64ToBase64url(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}export function base64FromBase64url(r){return r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4)}
1
+ import{i as e,n as t,r as n,t as r}from"./base-64-n6I9tGzK.mjs";export{r as base64FromBase64url,t as base64ToBase64url,n as decodeBase64,e as encodeBase64};
@@ -0,0 +1,2 @@
1
+ import{a as e,c as t,i as n,l as r,o as i,r as a,s as o}from"./base-64-n6I9tGzK.mjs";import{n as s,t as c}from"./hex-C1p5VuEv.mjs";async function l(){return crypto.subtle.generateKey({name:`AES-GCM`,length:256},!0,[`encrypt`,`decrypt`])}async function u(e){let t=await crypto.subtle.exportKey(`raw`,e);return n(new Uint8Array(t)).toString()}async function d(e){let t=a(e);return crypto.subtle.importKey(`raw`,t.buffer,`AES-GCM`,!0,[`encrypt`,`decrypt`])}async function f(e,r){let i=crypto.getRandomValues(new Uint8Array(24/2)),a=await crypto.subtle.encrypt({name:`AES-GCM`,iv:i},e,t(r));return s(i)+n(new Uint8Array(a))}async function p(t,n){return e(await crypto.subtle.decrypt({name:`AES-GCM`,iv:c(n.slice(0,24))},t,a(n.slice(24))))}async function m(e,t){let n=crypto.getRandomValues(new Uint8Array(16)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},e,t);return i(o([n,new Uint8Array(r)]))}async function h(e,t){let n=r(t);return crypto.subtle.decrypt({name:`AES-GCM`,iv:n.slice(0,16)},e,n.slice(16))}export{u as a,h as i,d as n,f as o,p as r,m as s,l as t};
2
+ //# sourceMappingURL=encryption-CchoDEon.mjs.map