diff --git a/lib/index.d.ts b/lib/index.d.ts index 8c7f896..a95ba9a 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -6,7 +6,7 @@ export type CreateOptions = { globOptions?: GlobOptions; ordering?: string; pattern?: string; - transform?: (filePath: string) => string; + transform?: (filePath: string) => NodeJS.ReadWriteStream | void; unpack?: string; unpackDir?: string; }; diff --git a/test/index.test-d.ts b/test/index.test-d.ts index 9642dd5..504d05b 100644 --- a/test/index.test-d.ts +++ b/test/index.test-d.ts @@ -1,5 +1,6 @@ import * as asar from '..'; import * as fs from 'fs'; +import * as crypto from 'crypto' import { expectType } from 'tsd'; await asar.createPackage('bin', 'tmp/foo.asar'); @@ -8,7 +9,11 @@ await asar.createPackageWithOptions('bin', 'tmp/foo.asar', { globOptions: { debug: true, }, - transform: (filePath: string) => filePath.replace('/', ':'), + transform: (filePath: string) => { + if (process.env.TRANSFORM_ASAR) { + return crypto.createCipheriv('aes-256-cbc', crypto.randomBytes(32), crypto.randomBytes(16)).setAutoPadding(true).setEncoding('base64') + } + } }); await asar.createPackageFromFiles('bin', 'tmp/foo.asar', ['bin/asar.js']); const stat = fs.statSync('bin/asar.js');