Skip to content

Commit

Permalink
Run pre-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
dmattia committed Dec 6, 2023
1 parent 718b54b commit fbbd721
Show file tree
Hide file tree
Showing 35 changed files with 45 additions and 108 deletions.
6 changes: 6 additions & 0 deletions src/@types/conflux/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ declare module '@transcend-io/conflux' {
// TypeScript isn't aware of TransformStream
/** Conflux Zip Writer class */
export class Writer extends TransformStream {
/**
* Constructor
*/
constructor();

/** Write stream to filename in zip */
Expand All @@ -16,6 +19,9 @@ declare module '@transcend-io/conflux' {
stream(): ReadableStream;
}): void;

/**
* Closes the stream
*/
close(): void;
}
}
10 changes: 10 additions & 0 deletions src/@types/crypto-browserify/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ declare module 'crypto-browserify' {

/**
* Create cipher iv
* @param algorithm - Cipher algorithm
* @param key - Cipher key
* @param iv - Cipher iv
* @param options - Cipher options
* @returns Cipher
*/
export function createCipheriv(
algorithm: CipherGCMTypes,
Expand All @@ -21,6 +26,11 @@ declare module 'crypto-browserify' {

/**
* Create decipher iv
* @param algorithm - Cipher algorithm
* @param key - Cipher key
* @param iv - Cipher iv
* @param options - Cipher options
* @returns Decipher iv
*/
export function createDecipheriv(
algorithm: CipherGCMTypes,
Expand Down
3 changes: 3 additions & 0 deletions src/@types/streamsaver/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
declare module 'streamsaver' {
/**
* Create a write stream
* @param filename - Filename
* @param size - Size
* @returns WritableStream
*/
export function createWriteStream(
filename: string,
Expand Down
6 changes: 5 additions & 1 deletion src/@types/typedarray-to-buffer/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** typedarray-to-buffer types */
/**
* typedarray-to-buffer types
* @param arr - Typed array
* @returns Buffer
*/
declare module 'typedarray-to-buffer' {
function toBuffer(arr: NodeJS.TypedArray): Buffer;

Expand Down
38 changes: 13 additions & 25 deletions src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const resolver = document.createElementNS(

/**
* Retrieve and decrypt files (batch job)
*
* @param resources - Resources
* @returns Penumbra files
*/
Expand Down Expand Up @@ -95,25 +94,24 @@ async function getJob(...resources: RemoteResource[]): Promise<PenumbraFile[]> {
*
* // Buffer all responses & read them as text
* await Promise.all((await penumbra.get(resources)).map(({ stream }) =>
* new Response(stream).text()
* new Response(stream).text()
* ));
*
* // Buffer a response & read as text
* await new Response((await penumbra.get(resource))[0].stream).text();
*
* // Example call with an included resource
* await penumbra.get({
* url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/NYT.txt.enc',
* filePrefix: 'NYT',
* mimetype: 'text/plain',
* decryptionOptions: {
* key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
* iv: '6lNU+2vxJw6SFgse',
* authTag: 'gadZhS1QozjEmfmHLblzbg==',
* },
* url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/NYT.txt.enc',
* filePrefix: 'NYT',
* mimetype: 'text/plain',
* decryptionOptions: {
* key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
* iv: '6lNU+2vxJw6SFgse',
* authTag: 'gadZhS1QozjEmfmHLblzbg==',
* },
* });
* ```
*
* @param resources - Resources to fetch
* @returns Penumbra files
*/
Expand All @@ -130,7 +128,6 @@ const MAX_ALLOWED_SIZE_MAIN_THREAD = 32 * 1024 * 1024; // 32 MiB

/**
* Save a zip containing files retrieved by Penumbra
*
* @param options - ZipOptions
* @returns PenumbraZipWriter class instance
*/
Expand All @@ -140,7 +137,6 @@ function saveZip(options?: ZipOptions): PenumbraZipWriter {

/**
* Save files retrieved by Penumbra
*
* @param files - Files to save
* @param fileName - The name of the file to save to
* @param controller - Controller
Expand Down Expand Up @@ -197,7 +193,6 @@ function save(

/**
* Load files retrieved by Penumbra into memory as a Blob
*
* @param files - Files to load
* @param type - Mimetype
* @returns A blob of the data
Expand Down Expand Up @@ -267,7 +262,6 @@ const trackJobCompletion = (
* ```ts
* penumbra.getDecryptionInfo(file: PenumbraEncryptedFile): Promise<PenumbraDecryptionInfo>
* ```
*
* @param file - File to get info for
* @returns Decryption info
*/
Expand All @@ -284,7 +278,6 @@ export function getDecryptionInfo(

/**
* Encrypt files (batch job)
*
* @param options - Options
* @param files - Files to operate on
* @returns Encrypted files
Expand Down Expand Up @@ -334,7 +327,6 @@ async function encryptJob(
* PenumbraWorkerAPI.encrypt calls require('./encrypt').encrypt()
* from the worker thread and starts reading the input stream from
* [remoteWritableStream.writable]
*
* @param thread - Thread
*/
(thread) => {
Expand Down Expand Up @@ -408,11 +400,10 @@ async function encryptJob(
* file = penumbra.encrypt(null, {stream: new Uint8Array(size), size});
* let data = [];
* file.then(async ([encrypted]) => {
* console.log('encryption started');
* data.push(new Uint8Array(await new Response(encrypted.stream).arrayBuffer()));
* console.log('encryption started');
* data.push(new Uint8Array(await new Response(encrypted.stream).arrayBuffer()));
* });
* ```
*
* @param options - Options
* @param files - Files
* @returns Encrypted files
Expand All @@ -428,7 +419,6 @@ export function encrypt(

/**
* Decrypt files encrypted by penumbra.encrypt() (batch job)
*
* @param options - Options
* @param files - Files
* @returns Penumbra files
Expand Down Expand Up @@ -539,11 +529,10 @@ async function decryptJob(
* file = penumbra.encrypt(null, {stream: new Uint8Array(size), size});
* let data = [];
* file.then(async ([encrypted]) => {
* console.log('encryption started');
* data.push(new Uint8Array(await new Response(encrypted.stream).arrayBuffer()));
* console.log('encryption started');
* data.push(new Uint8Array(await new Response(encrypted.stream).arrayBuffer()));
* });
* ```
*
* @param options - Options
* @param files - Files
* @returns Files
Expand All @@ -559,7 +548,6 @@ export function decrypt(

/**
* Get file text (if content is viewable) or URI (if content is not viewable)
*
* @param files - A list of files to get the text of
* @returns A list with the text itself or a URI encoding the file if applicable
*/
Expand Down
3 changes: 0 additions & 3 deletions src/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { emitJobCompletion, emitProgress, toBuff } from './utils';

/**
* Decrypts a readable stream
*
* @param stream - A readable stream of encrypted data
* @param decipher - The crypto module's decipher
* @param contentLength - The content length of the file, in bytes
Expand Down Expand Up @@ -71,7 +70,6 @@ export function decryptStream(
return new ReadableStream({
/**
* Controller
*
* @param controller - Controller
*/
start(controller) {
Expand Down Expand Up @@ -112,7 +110,6 @@ export function decryptStream(

/**
* Decrypts a file and returns a ReadableStream
*
* @param options - Options
* @param file - The remote resource to download
* @param size - Size
Expand Down
4 changes: 0 additions & 4 deletions src/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { logger } from './logger';

/**
* Encrypts a readable stream
*
* @param jobID - Job ID
* @param rs - A readable stream of encrypted data
* @param cipher - The crypto module's cipher
Expand Down Expand Up @@ -72,7 +71,6 @@ export function encryptStream(
return new ReadableStream({
/**
* Controller
*
* @param controller - Controller
*/
start(controller) {
Expand Down Expand Up @@ -116,7 +114,6 @@ export function encryptStream(

/**
* Encrypt a buffer
*
* @returns Buffer
*/
export function encryptBuffer(): ArrayBuffer {
Expand All @@ -130,7 +127,6 @@ const IV_RANDOMNESS = 12;

/**
* Encrypts a file and returns a ReadableStream
*
* @param options - Options
* @param file - The remote resource to download
* @param size - Size
Expand Down
2 changes: 0 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class PenumbraError extends Error {

/**
* Extend new Error
*
* @param error - Error
* @param id - ID
*/
Expand All @@ -39,7 +38,6 @@ export class PenumbraError extends Error {

/**
* Error name
*
* @returns Name
*/
get [Symbol.toStringTag](): string {
Expand Down
1 change: 0 additions & 1 deletion src/fetchAndDecrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import emitError from './utils/emitError';

/**
* Fetches a remote file from a URL, deciphers it (if encrypted), and returns a ReadableStream
*
* @param resource - The remote resource to download
* @returns A readable stream of the deciphered file
*/
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Penumbra
* Fetch and decrypt files in the browser using whatwg streams and web workers.
*
* @module penumbra
* @author Transcend Inc. <https://transcend.io>
* @license Apache-2.0
Expand Down
4 changes: 2 additions & 2 deletions src/mock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-function,require-await */
/* eslint-disable require-await */

// local
import { PenumbraAPI } from './types';
Expand Down Expand Up @@ -41,4 +41,4 @@ const MOCK_API: PenumbraAPI = {

export default MOCK_API;

/* eslint-enable @typescript-eslint/no-empty-function,require-await */
/* eslint-enable require-await */
6 changes: 1 addition & 5 deletions src/resource-hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ export type CleanupResourceHints = () => void;

/**
* No-op function generator
*
* @returns Function
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function

const nooper = (): CleanupResourceHints => (): void => {};

/**
* A helper function that creates a set resource hints
*
* @param urls - The urls to add the resource hint to
* @param rel - Type of link rel that is being being hinted
* @param fetch - Request resource as a cross-origin fetch
Expand Down Expand Up @@ -55,7 +53,6 @@ export function createResourceHintHelper(
* Initialize and open connections to origins that
* will soon be requested to speed up connection setup.
* This should speed up HTTP/2 connections, but not HTTP/1.1.
*
* @param resources - Origins of the files to pre-connect to
* @returns A function removing the links that were appended to the DOM
*/
Expand All @@ -67,7 +64,6 @@ export function preconnect(...resources: RemoteResource[]): () => void {

/**
* Connect to and start loading URLs before they are needed.
*
* @param resources - Resources to load
* @returns A function that removes the link tags that were appended to the DOM
*/
Expand Down
1 change: 0 additions & 1 deletion src/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ test.skip('penumbra.saveZip({ saveBuffer: true }) - getBuffer(), getSize() and a
const writer = penumbra.saveZip({
/**
* onProgress handler
*
* @param event - Event
*/
onProgress(event) {
Expand Down
1 change: 0 additions & 1 deletion src/tests/helpers/hash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Get the cryptographic hash of an ArrayBuffer
*
* @param algorithm - Cryptographic hash digest algorithm
* @param ab - ArrayBuffer to digest
* @returns Hexadecimal hash digest string
Expand Down
5 changes: 2 additions & 3 deletions src/tests/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
*
* ## Test Utility Functions
* Global test utility functions
*
*## Test Utility Functions
*Global test utility functions
* @module test/utility
*/

Expand Down
1 change: 0 additions & 1 deletion src/tests/helpers/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface TimeoutManager {

/**
* Set and manage a timeout
*
* @param callback - Timeout callback
* @param delay - Time in seconds to wait before calling the callback
* @returns Timeout cancellation helper
Expand Down
Loading

0 comments on commit fbbd721

Please sign in to comment.