@fgv/ts-web-extras 5.1.0-17 → 5.1.0-19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/{edc66e6a37414a0b69e52d768684c18c9d5825e3.tar.log → 42a7a953924ae898114e7b6231a2408228d92433.tar.log} +8 -2
- package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +19 -17
- package/.rush/temp/operation/build/all.log +19 -17
- package/.rush/temp/operation/build/log-chunks.jsonl +19 -17
- package/.rush/temp/operation/build/state.json +1 -1
- package/dist/packlets/crypto-utils/browserCryptoProvider.js +176 -18
- package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/dist/test/unit/browserCryptoProvider.wrapBytes.test.js +221 -0
- package/dist/test/unit/browserCryptoProvider.wrapBytes.test.js.map +1 -0
- package/dist/ts-web-extras.d.ts +46 -6
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.exportPublicKeyJwk.md +24 -0
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKeyPair.md +25 -0
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.importPublicKeyJwk.md +25 -0
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.md +67 -0
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.unwrapBytes.md +27 -0
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.wrapBytes.md +28 -0
- package/docs/classes/BrowserCryptoProvider.exportPublicKeyJwk.md +24 -0
- package/docs/classes/BrowserCryptoProvider.generateKeyPair.md +25 -0
- package/docs/classes/BrowserCryptoProvider.importPublicKeyJwk.md +25 -0
- package/docs/classes/BrowserCryptoProvider.md +67 -0
- package/docs/classes/BrowserCryptoProvider.unwrapBytes.md +27 -0
- package/docs/classes/BrowserCryptoProvider.wrapBytes.md +28 -0
- package/etc/ts-web-extras.api.md +10 -5
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +46 -5
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.js +175 -17
- package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/lib/test/unit/browserCryptoProvider.wrapBytes.test.d.ts +2 -0
- package/lib/test/unit/browserCryptoProvider.wrapBytes.test.d.ts.map +1 -0
- package/lib/test/unit/browserCryptoProvider.wrapBytes.test.js +223 -0
- package/lib/test/unit/browserCryptoProvider.wrapBytes.test.js.map +1 -0
- package/package.json +14 -14
- package/rush-logs/ts-web-extras.build.cache.log +1 -1
- package/rush-logs/ts-web-extras.build.log +19 -17
- package/src/packlets/crypto-utils/browserCryptoProvider.ts +244 -23
- package/src/test/unit/browserCryptoProvider.wrapBytes.test.ts +325 -0
- package/temp/build/typescript/ts_8nwakTlr.json +1 -1
- package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +692 -29
- package/temp/coverage/crypto-utils/browserHashProvider.ts.html +1 -1
- package/temp/coverage/crypto-utils/index.html +9 -9
- package/temp/coverage/file-tree/directoryHandleStore.ts.html +1 -1
- package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +1 -1
- package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +1 -1
- package/temp/coverage/file-tree/httpTreeAccessors.ts.html +1 -1
- package/temp/coverage/file-tree/index.html +1 -1
- package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +1 -1
- package/temp/coverage/helpers/fileTreeHelpers.ts.html +1 -1
- package/temp/coverage/helpers/index.html +1 -1
- package/temp/coverage/index.html +10 -10
- package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +692 -29
- package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +1 -1
- package/temp/coverage/lcov-report/crypto-utils/index.html +9 -9
- package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +1 -1
- package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +1 -1
- package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +1 -1
- package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +1 -1
- package/temp/coverage/lcov-report/file-tree/index.html +1 -1
- package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +1 -1
- package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +1 -1
- package/temp/coverage/lcov-report/helpers/index.html +1 -1
- package/temp/coverage/lcov-report/index.html +10 -10
- package/temp/coverage/lcov-report/url-utils/index.html +1 -1
- package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +1 -1
- package/temp/coverage/lcov.info +294 -23
- package/temp/coverage/url-utils/index.html +1 -1
- package/temp/coverage/url-utils/urlParams.ts.html +1 -1
- package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
- package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +1 -1
- package/temp/ts-web-extras.api.json +465 -4
- package/temp/ts-web-extras.api.md +10 -5
|
@@ -160,5 +160,72 @@ Encodes binary data to base64 string.
|
|
|
160
160
|
|
|
161
161
|
Decodes base64 string to binary data.
|
|
162
162
|
|
|
163
|
+
</td></tr>
|
|
164
|
+
<tr><td>
|
|
165
|
+
|
|
166
|
+
[generateKeyPair(algorithm, extractable)](./BrowserCryptoProvider.generateKeyPair.md)
|
|
167
|
+
|
|
168
|
+
</td><td>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
</td><td>
|
|
173
|
+
|
|
174
|
+
Generates a new asymmetric keypair via Web Crypto.
|
|
175
|
+
|
|
176
|
+
</td></tr>
|
|
177
|
+
<tr><td>
|
|
178
|
+
|
|
179
|
+
[exportPublicKeyJwk(publicKey)](./BrowserCryptoProvider.exportPublicKeyJwk.md)
|
|
180
|
+
|
|
181
|
+
</td><td>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
</td><td>
|
|
186
|
+
|
|
187
|
+
Exports a public `CryptoKey` as a JSON Web Key.
|
|
188
|
+
|
|
189
|
+
</td></tr>
|
|
190
|
+
<tr><td>
|
|
191
|
+
|
|
192
|
+
[importPublicKeyJwk(jwk, algorithm)](./BrowserCryptoProvider.importPublicKeyJwk.md)
|
|
193
|
+
|
|
194
|
+
</td><td>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
</td><td>
|
|
199
|
+
|
|
200
|
+
Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
201
|
+
|
|
202
|
+
</td></tr>
|
|
203
|
+
<tr><td>
|
|
204
|
+
|
|
205
|
+
[wrapBytes(plaintext, recipientPublicKey, options)](./BrowserCryptoProvider.wrapBytes.md)
|
|
206
|
+
|
|
207
|
+
</td><td>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
</td><td>
|
|
212
|
+
|
|
213
|
+
Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
214
|
+
ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256).
|
|
215
|
+
|
|
216
|
+
</td></tr>
|
|
217
|
+
<tr><td>
|
|
218
|
+
|
|
219
|
+
[unwrapBytes(wrapped, recipientPrivateKey, options)](./BrowserCryptoProvider.unwrapBytes.md)
|
|
220
|
+
|
|
221
|
+
</td><td>
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
</td><td>
|
|
226
|
+
|
|
227
|
+
Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
228
|
+
key.
|
|
229
|
+
|
|
163
230
|
</td></tr>
|
|
164
231
|
</tbody></table>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[Home](../../README.md) > [CryptoUtils](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > unwrapBytes
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.unwrapBytes() method
|
|
4
|
+
|
|
5
|
+
Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
6
|
+
key. See CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes.
|
|
7
|
+
|
|
8
|
+
**Signature:**
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
unwrapBytes(wrapped: IWrappedBytes, recipientPrivateKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<Uint8Array<ArrayBufferLike>>>;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Parameters:**
|
|
15
|
+
|
|
16
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<tr><td>wrapped</td><td>IWrappedBytes</td><td>The wrapped payload.</td></tr>
|
|
19
|
+
<tr><td>recipientPrivateKey</td><td>CryptoKey</td><td>The recipient's ECDH P-256 private `CryptoKey`.</td></tr>
|
|
20
|
+
<tr><td>options</td><td>IWrapBytesOptions</td><td>HKDF salt and info matching the wrap call.</td></tr>
|
|
21
|
+
</tbody></table>
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
Promise<Result<Uint8Array<ArrayBufferLike>>>
|
|
26
|
+
|
|
27
|
+
`Success` with the original `plaintext`, or `Failure` with an error.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[Home](../../README.md) > [CryptoUtils](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > wrapBytes
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.wrapBytes() method
|
|
4
|
+
|
|
5
|
+
Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
6
|
+
ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See
|
|
7
|
+
CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<IWrappedBytes>>;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Parameters:**
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
<tr><td>plaintext</td><td>Uint8Array</td><td>The bytes to wrap.</td></tr>
|
|
20
|
+
<tr><td>recipientPublicKey</td><td>CryptoKey</td><td>The recipient's ECDH P-256 public `CryptoKey`.</td></tr>
|
|
21
|
+
<tr><td>options</td><td>IWrapBytesOptions</td><td>HKDF salt and info; see CryptoUtils.IWrapBytesOptions | IWrapBytesOptions.</td></tr>
|
|
22
|
+
</tbody></table>
|
|
23
|
+
|
|
24
|
+
**Returns:**
|
|
25
|
+
|
|
26
|
+
Promise<Result<IWrappedBytes>>
|
|
27
|
+
|
|
28
|
+
`Success` with the wrapped payload, or `Failure` with an error.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[Home](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > exportPublicKeyJwk
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.exportPublicKeyJwk() method
|
|
4
|
+
|
|
5
|
+
Exports a public `CryptoKey` as a JSON Web Key.
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
|
|
15
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr><td>publicKey</td><td>CryptoKey</td><td>Extractable public key to export.</td></tr>
|
|
18
|
+
</tbody></table>
|
|
19
|
+
|
|
20
|
+
**Returns:**
|
|
21
|
+
|
|
22
|
+
Promise<Result<JsonWebKey>>
|
|
23
|
+
|
|
24
|
+
`Success` with the JWK, or `Failure` if not a public key or if export fails.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[Home](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > generateKeyPair
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.generateKeyPair() method
|
|
4
|
+
|
|
5
|
+
Generates a new asymmetric keypair via Web Crypto.
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
generateKeyPair(algorithm: KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
|
|
15
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr><td>algorithm</td><td>KeyPairAlgorithm</td><td>The algorithm to use.</td></tr>
|
|
18
|
+
<tr><td>extractable</td><td>boolean</td><td>Whether the resulting keys may be exported.</td></tr>
|
|
19
|
+
</tbody></table>
|
|
20
|
+
|
|
21
|
+
**Returns:**
|
|
22
|
+
|
|
23
|
+
Promise<Result<CryptoKeyPair>>
|
|
24
|
+
|
|
25
|
+
`Success` with the generated `CryptoKeyPair`, or `Failure` with an error.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[Home](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > importPublicKeyJwk
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.importPublicKeyJwk() method
|
|
4
|
+
|
|
5
|
+
Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
|
|
15
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr><td>jwk</td><td>JsonWebKey</td><td>The JSON Web Key produced by a prior export.</td></tr>
|
|
18
|
+
<tr><td>algorithm</td><td>KeyPairAlgorithm</td><td>The algorithm the key was generated for.</td></tr>
|
|
19
|
+
</tbody></table>
|
|
20
|
+
|
|
21
|
+
**Returns:**
|
|
22
|
+
|
|
23
|
+
Promise<Result<CryptoKey>>
|
|
24
|
+
|
|
25
|
+
`Success` with the imported public `CryptoKey`, or `Failure` with an error.
|
|
@@ -160,5 +160,72 @@ Encodes binary data to base64 string.
|
|
|
160
160
|
|
|
161
161
|
Decodes base64 string to binary data.
|
|
162
162
|
|
|
163
|
+
</td></tr>
|
|
164
|
+
<tr><td>
|
|
165
|
+
|
|
166
|
+
[generateKeyPair(algorithm, extractable)](./BrowserCryptoProvider.generateKeyPair.md)
|
|
167
|
+
|
|
168
|
+
</td><td>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
</td><td>
|
|
173
|
+
|
|
174
|
+
Generates a new asymmetric keypair via Web Crypto.
|
|
175
|
+
|
|
176
|
+
</td></tr>
|
|
177
|
+
<tr><td>
|
|
178
|
+
|
|
179
|
+
[exportPublicKeyJwk(publicKey)](./BrowserCryptoProvider.exportPublicKeyJwk.md)
|
|
180
|
+
|
|
181
|
+
</td><td>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
</td><td>
|
|
186
|
+
|
|
187
|
+
Exports a public `CryptoKey` as a JSON Web Key.
|
|
188
|
+
|
|
189
|
+
</td></tr>
|
|
190
|
+
<tr><td>
|
|
191
|
+
|
|
192
|
+
[importPublicKeyJwk(jwk, algorithm)](./BrowserCryptoProvider.importPublicKeyJwk.md)
|
|
193
|
+
|
|
194
|
+
</td><td>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
</td><td>
|
|
199
|
+
|
|
200
|
+
Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
201
|
+
|
|
202
|
+
</td></tr>
|
|
203
|
+
<tr><td>
|
|
204
|
+
|
|
205
|
+
[wrapBytes(plaintext, recipientPublicKey, options)](./BrowserCryptoProvider.wrapBytes.md)
|
|
206
|
+
|
|
207
|
+
</td><td>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
</td><td>
|
|
212
|
+
|
|
213
|
+
Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
214
|
+
ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256).
|
|
215
|
+
|
|
216
|
+
</td></tr>
|
|
217
|
+
<tr><td>
|
|
218
|
+
|
|
219
|
+
[unwrapBytes(wrapped, recipientPrivateKey, options)](./BrowserCryptoProvider.unwrapBytes.md)
|
|
220
|
+
|
|
221
|
+
</td><td>
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
</td><td>
|
|
226
|
+
|
|
227
|
+
Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
228
|
+
key.
|
|
229
|
+
|
|
163
230
|
</td></tr>
|
|
164
231
|
</tbody></table>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[Home](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > unwrapBytes
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.unwrapBytes() method
|
|
4
|
+
|
|
5
|
+
Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
6
|
+
key. See CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes.
|
|
7
|
+
|
|
8
|
+
**Signature:**
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
unwrapBytes(wrapped: IWrappedBytes, recipientPrivateKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<Uint8Array<ArrayBufferLike>>>;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Parameters:**
|
|
15
|
+
|
|
16
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<tr><td>wrapped</td><td>IWrappedBytes</td><td>The wrapped payload.</td></tr>
|
|
19
|
+
<tr><td>recipientPrivateKey</td><td>CryptoKey</td><td>The recipient's ECDH P-256 private `CryptoKey`.</td></tr>
|
|
20
|
+
<tr><td>options</td><td>IWrapBytesOptions</td><td>HKDF salt and info matching the wrap call.</td></tr>
|
|
21
|
+
</tbody></table>
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
Promise<Result<Uint8Array<ArrayBufferLike>>>
|
|
26
|
+
|
|
27
|
+
`Success` with the original `plaintext`, or `Failure` with an error.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[Home](../README.md) > [BrowserCryptoProvider](./BrowserCryptoProvider.md) > wrapBytes
|
|
2
|
+
|
|
3
|
+
## BrowserCryptoProvider.wrapBytes() method
|
|
4
|
+
|
|
5
|
+
Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
6
|
+
ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See
|
|
7
|
+
CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<IWrappedBytes>>;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Parameters:**
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
<tr><td>plaintext</td><td>Uint8Array</td><td>The bytes to wrap.</td></tr>
|
|
20
|
+
<tr><td>recipientPublicKey</td><td>CryptoKey</td><td>The recipient's ECDH P-256 public `CryptoKey`.</td></tr>
|
|
21
|
+
<tr><td>options</td><td>IWrapBytesOptions</td><td>HKDF salt and info; see CryptoUtils.IWrapBytesOptions | IWrapBytesOptions.</td></tr>
|
|
22
|
+
</tbody></table>
|
|
23
|
+
|
|
24
|
+
**Returns:**
|
|
25
|
+
|
|
26
|
+
Promise<Result<IWrappedBytes>>
|
|
27
|
+
|
|
28
|
+
`Success` with the wrapped payload, or `Failure` with an error.
|
package/etc/ts-web-extras.api.md
CHANGED
|
@@ -10,21 +10,26 @@ import { FileTree } from '@fgv/ts-json-base';
|
|
|
10
10
|
import { Logging } from '@fgv/ts-utils';
|
|
11
11
|
import { Result } from '@fgv/ts-utils';
|
|
12
12
|
|
|
13
|
-
// Warning: (ae-forgotten-export) The symbol "ICryptoProvider" needs to be exported by the entry point index.d.ts
|
|
14
|
-
//
|
|
15
13
|
// @public
|
|
16
|
-
class BrowserCryptoProvider implements ICryptoProvider {
|
|
14
|
+
class BrowserCryptoProvider implements CryptoUtils_2.ICryptoProvider {
|
|
17
15
|
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
|
18
16
|
constructor(cryptoApi?: Crypto);
|
|
19
17
|
decrypt(encryptedData: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array): Promise<Result<string>>;
|
|
20
18
|
deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
encrypt(plaintext: string, key: Uint8Array): Promise<Result<CryptoUtils_2.IEncryptionResult>>;
|
|
20
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
23
21
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
24
22
|
generateKey(): Promise<Result<Uint8Array>>;
|
|
23
|
+
generateKeyPair(algorithm: CryptoUtils_2.KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
25
24
|
generateRandomBytes(length: number): Result<Uint8Array>;
|
|
25
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: CryptoUtils_2.KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
26
26
|
sha256(data: string): Promise<Result<string>>;
|
|
27
27
|
toBase64(data: Uint8Array): string;
|
|
28
|
+
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
|
29
|
+
unwrapBytes(wrapped: CryptoUtils_2.IWrappedBytes, recipientPrivateKey: CryptoKey, options: CryptoUtils_2.IWrapBytesOptions): Promise<Result<Uint8Array>>;
|
|
30
|
+
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
|
31
|
+
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
|
32
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: CryptoUtils_2.IWrapBytesOptions): Promise<Result<CryptoUtils_2.IWrappedBytes>>;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
// @public
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
2
|
import { CryptoUtils } from '@fgv/ts-extras';
|
|
3
|
-
type ICryptoProvider = CryptoUtils.ICryptoProvider;
|
|
4
|
-
type IEncryptionResult = CryptoUtils.IEncryptionResult;
|
|
5
3
|
/**
|
|
6
4
|
* Browser implementation of `ICryptoProvider` using the Web Crypto API.
|
|
7
5
|
* Uses AES-256-GCM for authenticated encryption.
|
|
@@ -11,7 +9,7 @@ type IEncryptionResult = CryptoUtils.IEncryptionResult;
|
|
|
11
9
|
*
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
|
-
export declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
12
|
+
export declare class BrowserCryptoProvider implements CryptoUtils.ICryptoProvider {
|
|
15
13
|
private readonly _crypto;
|
|
16
14
|
/**
|
|
17
15
|
* Creates a new {@link CryptoUtils.BrowserCryptoProvider | BrowserCryptoProvider}.
|
|
@@ -24,7 +22,7 @@ export declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
24
22
|
* @param key - 32-byte encryption key
|
|
25
23
|
* @returns `Success` with encryption result, or `Failure` with an error.
|
|
26
24
|
*/
|
|
27
|
-
encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>>;
|
|
25
|
+
encrypt(plaintext: string, key: Uint8Array): Promise<Result<CryptoUtils.IEncryptionResult>>;
|
|
28
26
|
/**
|
|
29
27
|
* Decrypts ciphertext using AES-256-GCM.
|
|
30
28
|
* @param encryptedData - Encrypted bytes
|
|
@@ -71,6 +69,50 @@ export declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
71
69
|
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
72
70
|
*/
|
|
73
71
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
72
|
+
/**
|
|
73
|
+
* Generates a new asymmetric keypair via Web Crypto.
|
|
74
|
+
* @param algorithm - The algorithm to use.
|
|
75
|
+
* @param extractable - Whether the resulting keys may be exported.
|
|
76
|
+
* @returns `Success` with the generated `CryptoKeyPair`, or `Failure` with an error.
|
|
77
|
+
*/
|
|
78
|
+
generateKeyPair(algorithm: CryptoUtils.KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
79
|
+
/**
|
|
80
|
+
* Exports a public `CryptoKey` as a JSON Web Key.
|
|
81
|
+
* @remarks
|
|
82
|
+
* Rejects non-public keys at runtime. WebCrypto's `exportKey('jwk', ...)`
|
|
83
|
+
* does not enforce public-vs-private; without this guard a caller that
|
|
84
|
+
* passed an extractable private key would receive its private fields
|
|
85
|
+
* (`d`, `p`, `q`, ...) as JWK, defeating the method's name.
|
|
86
|
+
* @param publicKey - Extractable public key to export.
|
|
87
|
+
* @returns `Success` with the JWK, or `Failure` if not a public key or if export fails.
|
|
88
|
+
*/
|
|
89
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
90
|
+
/**
|
|
91
|
+
* Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
92
|
+
* @param jwk - The JSON Web Key produced by a prior export.
|
|
93
|
+
* @param algorithm - The algorithm the key was generated for.
|
|
94
|
+
* @returns `Success` with the imported public `CryptoKey`, or `Failure` with an error.
|
|
95
|
+
*/
|
|
96
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: CryptoUtils.KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
97
|
+
/**
|
|
98
|
+
* Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
99
|
+
* ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See
|
|
100
|
+
* {@link CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes}.
|
|
101
|
+
* @param plaintext - The bytes to wrap.
|
|
102
|
+
* @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.
|
|
103
|
+
* @param options - HKDF salt and info; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.
|
|
104
|
+
* @returns `Success` with the wrapped payload, or `Failure` with an error.
|
|
105
|
+
*/
|
|
106
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: CryptoUtils.IWrapBytesOptions): Promise<Result<CryptoUtils.IWrappedBytes>>;
|
|
107
|
+
/**
|
|
108
|
+
* Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
109
|
+
* key. See {@link CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes}.
|
|
110
|
+
* @param wrapped - The wrapped payload.
|
|
111
|
+
* @param recipientPrivateKey - The recipient's ECDH P-256 private `CryptoKey`.
|
|
112
|
+
* @param options - HKDF salt and info matching the wrap call.
|
|
113
|
+
* @returns `Success` with the original `plaintext`, or `Failure` with an error.
|
|
114
|
+
*/
|
|
115
|
+
unwrapBytes(wrapped: CryptoUtils.IWrappedBytes, recipientPrivateKey: CryptoKey, options: CryptoUtils.IWrapBytesOptions): Promise<Result<Uint8Array>>;
|
|
74
116
|
}
|
|
75
117
|
/**
|
|
76
118
|
* Creates a {@link CryptoUtils.BrowserCryptoProvider | BrowserCryptoProvider} if Web
|
|
@@ -79,5 +121,4 @@ export declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
79
121
|
* @public
|
|
80
122
|
*/
|
|
81
123
|
export declare function createBrowserCryptoProvider(): Result<BrowserCryptoProvider>;
|
|
82
|
-
export {};
|
|
83
124
|
//# sourceMappingURL=browserCryptoProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserCryptoProvider.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/browserCryptoProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browserCryptoProvider.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/browserCryptoProvider.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAoD,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkC7C;;;;;;;;GAQG;AACH,qBAAa,qBAAsB,YAAW,WAAW,CAAC,eAAe;IACvE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAGjC;;;OAGG;gBACgB,SAAS,CAAC,EAAE,MAAM;IAYrC;;;;;OAKG;IACU,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAmDxG;;;;;;;OAOG;IACU,OAAO,CAClB,aAAa,EAAE,UAAU,EACzB,GAAG,EAAE,UAAU,EACf,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAgD1B;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAWvD;;;;;;OAMG;IACU,SAAS,CACpB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAqC9B;;;;OAIG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAoB1D;;;;OAIG;IACI,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAY9D;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IASzC;;;;OAIG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAiBrD;;;;;OAKG;IACU,eAAe,CAC1B,SAAS,EAAE,WAAW,CAAC,gBAAgB,EACvC,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAQjC;;;;;;;;;OASG;IACU,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAQlF;;;;;OAKG;IACU,kBAAkB,CAC7B,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,WAAW,CAAC,gBAAgB,GACtC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAS7B;;;;;;;;OAQG;IACU,SAAS,CACpB,SAAS,EAAE,UAAU,EACrB,kBAAkB,EAAE,SAAS,EAC7B,OAAO,EAAE,WAAW,CAAC,iBAAiB,GACrC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAoC7C;;;;;;;OAOG;IACU,WAAW,CACtB,OAAO,EAAE,WAAW,CAAC,aAAa,EAClC,mBAAmB,EAAE,SAAS,EAC9B,OAAO,EAAE,WAAW,CAAC,iBAAiB,GACrC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;CAuD/B;AA+BD;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAE3E"}
|