@bicycle-codes/crypto-stream
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -37,14 +37,15 @@ /** | ||
/** | ||
* Given a desired plaintext byte range specified by `offset` and `length`, and the | ||
* total size of the encrypted stream in `totalEncryptedLength`, provides a mechanism to | ||
* decrypt that range. | ||
* Given a desired plaintext byte range specified by `offset` and `length`, | ||
* and the total size of the encrypted stream in `totalEncryptedLength`, | ||
* provides a mechanism to decrypt that range. | ||
* | ||
* To decrypt an arbitrary plaintext range, the client will need to supply multiple | ||
* (currently always two) ranges of encrypted data. `decryptStreamRange` returns a promise | ||
* that resolves to an object containing `ranges`, which is an array of { offset, length } | ||
* entries specifying the needed encrypted byte ranges, and `encrypt`, a callback function. | ||
* (currently always two) ranges of encrypted data. `decryptStreamRange` | ||
* returns a promise that resolves to an object containing `ranges`, which is | ||
* an array of { offset, length } entries specifying the needed encrypted byte | ||
* ranges, and `encrypt`, a callback function. | ||
* | ||
* Once the client has gathered an array `streams` of encrypted ReadableStreams, one for | ||
* each of these ranges, it should call `encrypt(streams)`. This will then return the final | ||
* plaintext ReadableStream. | ||
* Once the client has gathered an array `streams` of encrypted ReadableStreams, | ||
* one for each of these ranges, it should call `encrypt(streams)`. This will | ||
* then return the final plaintext ReadableStream. | ||
* | ||
@@ -57,3 +58,3 @@ * secretKey: CryptoKey containing secret key of size KEY_LENGTH | ||
*/ | ||
export declare function decryptStreamRange(secretKey: any, offset: any, length: any, totalEncryptedLength: any, rs?: number): { | ||
export declare function decryptStreamRange(secretKey: CryptoKey, offset: number, length: number, totalEncryptedLength: number, rs?: number): { | ||
ranges: { | ||
@@ -63,4 +64,4 @@ offset: number; | ||
}[]; | ||
decrypt: (streams: any) => ReadableStream<any>; | ||
decrypt: (streams: ReadableStream[]) => ReadableStream; | ||
}; | ||
//# sourceMappingURL=ece.d.ts.map |
@@ -79,14 +79,15 @@ /** | ||
/** | ||
* Given a desired plaintext byte range specified by `offset` and `length`, and the | ||
* total size of the encrypted stream in `totalEncryptedLength`, provides a mechanism to | ||
* decrypt that range. | ||
* Given a desired plaintext byte range specified by `offset` and `length`, | ||
* and the total size of the encrypted stream in `totalEncryptedLength`, | ||
* provides a mechanism to decrypt that range. | ||
* | ||
* To decrypt an arbitrary plaintext range, the client will need to supply multiple | ||
* (currently always two) ranges of encrypted data. `decryptStreamRange` returns a promise | ||
* that resolves to an object containing `ranges`, which is an array of { offset, length } | ||
* entries specifying the needed encrypted byte ranges, and `encrypt`, a callback function. | ||
* (currently always two) ranges of encrypted data. `decryptStreamRange` | ||
* returns a promise that resolves to an object containing `ranges`, which is | ||
* an array of { offset, length } entries specifying the needed encrypted byte | ||
* ranges, and `encrypt`, a callback function. | ||
* | ||
* Once the client has gathered an array `streams` of encrypted ReadableStreams, one for | ||
* each of these ranges, it should call `encrypt(streams)`. This will then return the final | ||
* plaintext ReadableStream. | ||
* Once the client has gathered an array `streams` of encrypted ReadableStreams, | ||
* one for each of these ranges, it should call `encrypt(streams)`. This will | ||
* then return the final plaintext ReadableStream. | ||
* | ||
@@ -101,3 +102,3 @@ * secretKey: CryptoKey containing secret key of size KEY_LENGTH | ||
if (!Number.isInteger(rs)) { | ||
throw new TypeError('rs'); | ||
throw new TypeError('Missing record size (rs)'); | ||
} | ||
@@ -104,0 +105,0 @@ // Chunk metadata, tag and delimiter |
@@ -36,3 +36,3 @@ export { encryptedSize, plaintextSize } from './ece.js'; | ||
}[]; | ||
decrypt: any; | ||
decrypt: (streams: ReadableStream[]) => ReadableStream; | ||
}>; | ||
@@ -39,0 +39,0 @@ encryptMeta(meta: Uint8Array): Promise<Uint8Array>; |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "dist/index.js", | ||
@@ -8,0 +8,0 @@ "files": [ |
@@ -201,7 +201,12 @@ # crypto stream | ||
```ts | ||
decryptStreamRange ( | ||
function decryptStreamRange ( | ||
secretKey:CryptoKey, | ||
offset:number, | ||
length:number, | ||
totalEncryptedLength:number | ||
):Promise<{ ranges:{ offset:number, length:number }[], decrypt }> | ||
totalEncryptedLength:number, | ||
rs:number = RECORD_SIZE | ||
):{ | ||
ranges:{ offset:number, length:number }[], | ||
decrypt:(streams:ReadableStream[])=>ReadableStream | ||
} | ||
``` | ||
@@ -208,0 +213,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109151
1927
284