@futpib/parser 1.0.0 → 1.0.2
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/build/allSettledStream.js +32 -14
- package/build/allSettledStream.test.js +32 -0
- package/build/androidPackage.d.ts +39 -0
- package/build/androidPackageParser.d.ts +17 -0
- package/build/androidPackageParser.js +183 -0
- package/build/{apkParser.test.js → androidPackageParser.test.js} +7 -7
- package/build/androidPackageUnparser.d.ts +4 -0
- package/build/androidPackageUnparser.js +90 -0
- package/build/androidPackageUnparser.test.js +26 -0
- package/build/arbitrarilySlicedAsyncInterable.d.ts +3 -1
- package/build/arbitrarilySlicedAsyncInterable.js +3 -3
- package/build/arbitraryFileSystemEntry.js +1 -1
- package/build/arbitraryZip.d.ts +1 -1
- package/build/arbitraryZip.js +13 -19
- package/build/arbitraryZipPermissions.d.ts +1 -8
- package/build/arbitraryZipPermissions.js +1 -16
- package/build/arbitraryZipStream.d.ts +1 -1
- package/build/arbitraryZipStream.js +3 -3
- package/build/arrayParser.d.ts +1 -1
- package/build/arrayParser.js +2 -2
- package/build/arrayParser.test.js +4 -4
- package/build/arrayUnparser.d.ts +2 -0
- package/build/arrayUnparser.js +8 -0
- package/build/backsmali.d.ts +1 -0
- package/build/backsmali.js +22 -0
- package/build/bsonParser.js +6 -2
- package/build/bsonParser.test.js +2 -2
- package/build/{parserInvariant.d.ts → customInvariant.d.ts} +1 -1
- package/build/{parserInvariant.js → customInvariant.js} +1 -1
- package/build/dalvikBytecodeParser/formatParsers.d.ts +97 -0
- package/build/dalvikBytecodeParser/formatParsers.js +169 -0
- package/build/dalvikBytecodeParser.d.ts +107 -0
- package/build/dalvikBytecodeParser.js +836 -0
- package/build/dalvikExecutable.d.ts +158 -0
- package/build/dalvikExecutable.js +20 -0
- package/build/dalvikExecutableParser/stringSyntaxParser.d.ts +4 -0
- package/build/dalvikExecutableParser/stringSyntaxParser.js +76 -0
- package/build/dalvikExecutableParser/typeParsers.d.ts +10 -0
- package/build/dalvikExecutableParser/typeParsers.js +34 -0
- package/build/dalvikExecutableParser/typedNumbers.d.ts +90 -0
- package/build/dalvikExecutableParser/typedNumbers.js +19 -0
- package/build/dalvikExecutableParser.d.ts +5 -0
- package/build/dalvikExecutableParser.js +1439 -0
- package/build/dalvikExecutableParser.test.js +70 -0
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +298 -0
- package/build/debugLogInputParser.d.ts +4 -0
- package/build/debugLogInputParser.js +16 -0
- package/build/debugLogParser.d.ts +1 -1
- package/build/debugLogParser.js +15 -4
- package/build/disjunctionParser.d.ts +2 -1
- package/build/disjunctionParser.js +4 -2
- package/build/elementParser.d.ts +2 -2
- package/build/elementParser.js +1 -1
- package/build/elementTerminatedArrayParser.d.ts +3 -0
- package/build/elementTerminatedArrayParser.js +18 -0
- package/build/elementTerminatedArrayParser.test.js +52 -0
- package/build/elementTerminatedSequenceArrayParser.d.ts +3 -0
- package/build/elementTerminatedSequenceArrayParser.js +32 -0
- package/build/elementTerminatedSequenceArrayParser.test.js +34 -0
- package/build/elementTerminatedSequenceParser.d.ts +3 -0
- package/build/elementTerminatedSequenceParser.js +27 -0
- package/build/elementTerminatedSequenceParser.test.js +34 -0
- package/build/endOfInputParser.d.ts +2 -2
- package/build/exactElementParser.d.ts +1 -1
- package/build/exactElementParser.js +10 -5
- package/build/exactSequenceParser.d.ts +2 -1
- package/build/exactSequenceParser.js +12 -2
- package/build/fetchCid.d.ts +1 -0
- package/build/fetchCid.js +107 -0
- package/build/fixedLengthSequenceParser.d.ts +1 -0
- package/build/fixedLengthSequenceParser.js +18 -1
- package/build/fixedLengthSequenceParser.test.js +41 -0
- package/build/hasExecutable.d.ts +1 -0
- package/build/hasExecutable.js +8 -0
- package/build/highResolutionTimer.d.ts +16 -0
- package/build/highResolutionTimer.js +42 -0
- package/build/index.d.ts +5 -2
- package/build/index.js +3 -0
- package/build/inputReader.d.ts +14 -3
- package/build/inputReader.js +43 -6
- package/build/inputReader.test.js +172 -7
- package/build/inputReaderState.d.ts +10 -0
- package/build/inputReaderState.js +16 -0
- package/build/inspect.d.ts +1 -0
- package/build/inspect.js +7 -0
- package/build/javaKeyStoreParser.d.ts +2 -0
- package/build/javaKeyStoreParser.js +67 -0
- package/build/javaKeyStoreParser.test.d.ts +1 -0
- package/build/javaKeyStoreParser.test.js +16 -0
- package/build/jsonParser.d.ts +2 -0
- package/build/jsonParser.js +13 -15
- package/build/jsonParser.test.js +2 -2
- package/build/leb128Parser.d.ts +7 -0
- package/build/leb128Parser.js +82 -0
- package/build/leb128Parser.test.d.ts +1 -0
- package/build/leb128Parser.test.js +107 -0
- package/build/listParser.d.ts +1 -1
- package/build/listParser.js +5 -5
- package/build/lookaheadParser.d.ts +2 -0
- package/build/lookaheadParser.js +14 -0
- package/build/{negativeLookahead.d.ts → negativeLookaheadParser.d.ts} +1 -1
- package/build/negativeLookaheadParser.js +24 -0
- package/build/negativeLookaheadParser.test.d.ts +1 -0
- package/build/negativeLookaheadParser.test.js +30 -0
- package/build/nonEmptyArrayParser.d.ts +2 -0
- package/build/nonEmptyArrayParser.js +32 -0
- package/build/nonEmptyArrayParser.test.d.ts +1 -0
- package/build/nonEmptyArrayParser.test.js +16 -0
- package/build/optionalParser.d.ts +1 -1
- package/build/optionalParser.js +2 -2
- package/build/parser.d.ts +13 -4
- package/build/parser.js +67 -32
- package/build/parser.test.js +94 -27
- package/build/parserAccessorParser.d.ts +1 -1
- package/build/parserAccessorParser.js +9 -1
- package/build/parserConsumedSequenceParser.d.ts +2 -0
- package/build/parserConsumedSequenceParser.js +22 -0
- package/build/parserContext.d.ts +20 -6
- package/build/parserContext.js +70 -40
- package/build/parserContext.test.js +34 -7
- package/build/parserCreatorCompose.d.ts +4 -3
- package/build/parserCreatorCompose.js +9 -3
- package/build/parserError.d.ts +6 -0
- package/build/parserError.js +6 -6
- package/build/parserImplementationInvariant.d.ts +1 -1
- package/build/parserImplementationInvariant.js +2 -2
- package/build/parserInputCompanion.d.ts +35 -0
- package/build/parserInputCompanion.js +68 -0
- package/build/promiseCompose.d.ts +1 -1
- package/build/promiseCompose.js +12 -1
- package/build/promiseSettled.d.ts +1 -0
- package/build/promiseSettled.js +4 -0
- package/build/quantifierParser.d.ts +2 -0
- package/build/quantifierParser.js +17 -0
- package/build/separatedArrayParser.d.ts +2 -0
- package/build/separatedArrayParser.js +39 -0
- package/build/separatedArrayParser.test.d.ts +1 -0
- package/build/separatedArrayParser.test.js +21 -0
- package/build/sequenceBuffer.d.ts +13 -3
- package/build/sequenceBuffer.js +60 -8
- package/build/sequenceBuffer.test.js +59 -2
- package/build/sequenceTerminatedSequenceParser.d.ts +5 -0
- package/build/sequenceTerminatedSequenceParser.js +32 -0
- package/build/sequenceTerminatedSequenceParser.test.d.ts +1 -0
- package/build/sequenceTerminatedSequenceParser.test.js +37 -0
- package/build/sequenceUnparser.d.ts +2 -0
- package/build/sequenceUnparser.js +6 -0
- package/build/skipParser.d.ts +1 -1
- package/build/skipParser.js +4 -2
- package/build/skipToParser.d.ts +2 -0
- package/build/skipToParser.js +11 -0
- package/build/sliceBoundedParser.d.ts +2 -2
- package/build/sliceBoundedParser.js +8 -3
- package/build/sliceBoundedParser.test.js +37 -3
- package/build/smali.d.ts +1 -0
- package/build/smali.js +17 -0
- package/build/smaliParser.d.ts +12 -0
- package/build/smaliParser.js +656 -0
- package/build/smaliParser.test.d.ts +1 -0
- package/build/smaliParser.test.js +115 -0
- package/build/terminatedArrayParser.d.ts +4 -2
- package/build/terminatedArrayParser.js +82 -5
- package/build/terminatedArrayParser.test.d.ts +1 -0
- package/build/terminatedArrayParser.test.js +131 -0
- package/build/toAsyncIterable.d.ts +1 -0
- package/build/toAsyncIterable.js +7 -0
- package/build/toAsyncIterator.d.ts +1 -0
- package/build/toAsyncIterator.js +33 -0
- package/build/tupleParser.d.ts +4 -0
- package/build/tupleParser.js +1 -5
- package/build/uint8Array.d.ts +1 -0
- package/build/uint8Array.js +7 -0
- package/build/unionParser.d.ts +2 -1
- package/build/unionParser.js +27 -12
- package/build/unionParser.test.d.ts +1 -0
- package/build/unionParser.test.js +60 -0
- package/build/unparser.d.ts +8 -0
- package/build/unparser.js +104 -0
- package/build/unparser.test.d.ts +1 -0
- package/build/unparser.test.js +150 -0
- package/build/unparserContext.d.ts +31 -0
- package/build/unparserContext.js +74 -0
- package/build/unparserError.d.ts +9 -0
- package/build/unparserError.js +9 -0
- package/build/unparserImplementationInvariant.d.ts +2 -0
- package/build/unparserImplementationInvariant.js +5 -0
- package/build/unparserOutputCompanion.d.ts +15 -0
- package/build/unparserOutputCompanion.js +13 -0
- package/build/zip.d.ts +9 -17
- package/build/zipParser.d.ts +20 -12
- package/build/zipParser.js +83 -71
- package/build/zipParser.test.js +2 -7
- package/build/zipUnparser.d.ts +8 -0
- package/build/zipUnparser.js +200 -0
- package/build/zipUnparser.test.d.ts +1 -0
- package/build/zipUnparser.test.js +80 -0
- package/package.json +26 -8
- package/src/allSettledStream.test.ts +40 -0
- package/src/allSettledStream.ts +47 -15
- package/src/androidPackage.ts +48 -0
- package/src/{apkParser.test.ts → androidPackageParser.test.ts} +7 -8
- package/src/androidPackageParser.test.ts.md +271 -0
- package/src/androidPackageParser.test.ts.snap +0 -0
- package/src/androidPackageParser.ts +440 -0
- package/src/androidPackageUnparser.test.ts +36 -0
- package/src/androidPackageUnparser.ts +120 -0
- package/src/arbitrarilySlicedAsyncInterable.ts +7 -2
- package/src/arbitraryFileSystemEntry.ts +2 -4
- package/src/arbitraryZip.ts +20 -27
- package/src/arbitraryZipPermissions.ts +0 -25
- package/src/arbitraryZipStream.ts +4 -4
- package/src/arrayParser.test.ts +4 -4
- package/src/arrayParser.ts +3 -2
- package/src/arrayUnparser.ts +13 -0
- package/src/backsmali.ts +30 -0
- package/src/bsonParser.test.ts +2 -2
- package/src/bsonParser.ts +16 -5
- package/src/{parserInvariant.ts → customInvariant.ts} +2 -2
- package/src/dalvikBytecodeParser/formatParsers.ts +421 -0
- package/src/dalvikBytecodeParser.ts +2074 -0
- package/src/dalvikExecutable.ts +220 -0
- package/src/dalvikExecutableParser/stringSyntaxParser.ts +145 -0
- package/src/dalvikExecutableParser/typeParsers.ts +65 -0
- package/src/dalvikExecutableParser/typedNumbers.ts +57 -0
- package/src/dalvikExecutableParser.test.ts +89 -0
- package/src/dalvikExecutableParser.test.ts.md +634 -0
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +2768 -0
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +346 -0
- package/src/debugLogInputParser.ts +28 -0
- package/src/debugLogParser.ts +20 -4
- package/src/disjunctionParser.ts +10 -5
- package/src/elementParser.ts +3 -3
- package/src/elementTerminatedArrayParser.test.ts +99 -0
- package/src/elementTerminatedArrayParser.ts +31 -0
- package/src/elementTerminatedSequenceArrayParser.test.ts +54 -0
- package/src/elementTerminatedSequenceArrayParser.ts +52 -0
- package/src/elementTerminatedSequenceParser.test.ts +54 -0
- package/src/elementTerminatedSequenceParser.ts +43 -0
- package/src/endOfInputParser.ts +4 -4
- package/src/exactElementParser.ts +18 -12
- package/src/exactSequenceParser.ts +24 -3
- package/src/fetchCid.ts +125 -0
- package/src/fixedLengthSequenceParser.test.ts +77 -0
- package/src/fixedLengthSequenceParser.ts +28 -1
- package/src/hasExecutable.ts +11 -0
- package/src/highResolutionTimer.ts +49 -0
- package/src/index.ts +15 -2
- package/src/inputReader.test.ts +216 -7
- package/src/inputReader.ts +80 -5
- package/src/inputReaderState.ts +33 -0
- package/src/inspect.ts +9 -0
- package/src/javaKeyStore.ts +0 -0
- package/src/javaKeyStoreParser.test.ts +22 -0
- package/src/javaKeyStoreParser.test.ts.md +103 -0
- package/src/javaKeyStoreParser.test.ts.snap +0 -0
- package/src/javaKeyStoreParser.ts +136 -0
- package/src/jsonParser.test.ts +2 -2
- package/src/jsonParser.ts +23 -34
- package/src/leb128Parser.test.ts +171 -0
- package/src/leb128Parser.ts +125 -0
- package/src/listParser.ts +6 -6
- package/src/lookaheadParser.ts +19 -0
- package/src/negativeLookaheadParser.test.ts +53 -0
- package/src/negativeLookaheadParser.ts +36 -0
- package/src/nonEmptyArrayParser.test.ts +20 -0
- package/src/nonEmptyArrayParser.ts +44 -0
- package/src/optionalParser.ts +4 -3
- package/src/parser.test.ts +148 -27
- package/src/parser.test.ts.md +21 -21
- package/src/parser.test.ts.snap +0 -0
- package/src/parser.ts +153 -49
- package/src/parserAccessorParser.ts +12 -2
- package/src/parserConsumedSequenceParser.ts +29 -0
- package/src/parserContext.test.ts +38 -7
- package/src/parserContext.ts +127 -51
- package/src/parserCreatorCompose.ts +25 -7
- package/src/parserError.ts +9 -6
- package/src/parserImplementationInvariant.ts +2 -2
- package/src/parserInputCompanion.ts +102 -0
- package/src/promiseCompose.ts +17 -3
- package/src/promiseSettled.ts +6 -0
- package/src/quantifierParser.ts +25 -0
- package/src/separatedArrayParser.test.ts +34 -0
- package/src/separatedArrayParser.ts +55 -0
- package/src/sequenceBuffer.test.ts +72 -2
- package/src/sequenceBuffer.ts +93 -7
- package/src/sequenceTerminatedSequenceParser.test.ts +60 -0
- package/src/sequenceTerminatedSequenceParser.ts +62 -0
- package/src/sequenceUnparser.ts +9 -0
- package/src/skipParser.ts +7 -5
- package/src/skipToParser.ts +16 -0
- package/src/sliceBoundedParser.test.ts +45 -3
- package/src/sliceBoundedParser.ts +21 -3
- package/src/smali.ts +24 -0
- package/src/smaliParser.test.ts +132 -0
- package/src/smaliParser.test.ts.md +2320 -0
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +1166 -0
- package/src/terminatedArrayParser.test.ts +258 -0
- package/src/terminatedArrayParser.ts +111 -6
- package/src/toAsyncIterable.ts +7 -0
- package/src/toAsyncIterator.ts +48 -0
- package/src/tupleParser.ts +8 -5
- package/src/uint8Array.ts +10 -0
- package/src/unionParser.test.ts +79 -0
- package/src/unionParser.ts +44 -16
- package/src/unparser.test.ts +221 -0
- package/src/unparser.ts +209 -0
- package/src/unparserContext.ts +127 -0
- package/src/unparserError.ts +12 -0
- package/src/unparserImplementationInvariant.ts +6 -0
- package/src/unparserOutputCompanion.ts +24 -0
- package/src/zip.ts +10 -22
- package/src/zipParser.test.ts +2 -8
- package/src/zipParser.ts +223 -146
- package/src/zipUnparser.test.ts +119 -0
- package/src/zipUnparser.ts +300 -0
- package/build/apk.d.ts +0 -13
- package/build/apkParser.d.ts +0 -3
- package/build/apkParser.js +0 -135
- package/build/arbitraryDosDate.d.ts +0 -2
- package/build/arbitraryDosDate.js +0 -8
- package/build/arbitraryZipEntry.d.ts +0 -3
- package/build/arbitraryZipEntry.js +0 -26
- package/build/createDisjunctionParser.d.ts +0 -2
- package/build/createDisjunctionParser.js +0 -47
- package/build/createExactParser.d.ts +0 -2
- package/build/createExactParser.js +0 -12
- package/build/createSequentialUnionParser.d.ts +0 -2
- package/build/createSequentialUnionParser.js +0 -69
- package/build/fixedLengthChunkParser.d.ts +0 -2
- package/build/fixedLengthChunkParser.js +0 -12
- package/build/fixedLengthParser.d.ts +0 -2
- package/build/fixedLengthParser.js +0 -12
- package/build/inputChunkBuffer.d.ts +0 -15
- package/build/inputChunkBuffer.js +0 -40
- package/build/inputChunkBuffer.test.js +0 -34
- package/build/inputCompanion.d.ts +0 -18
- package/build/inputCompanion.js +0 -28
- package/build/invariantDefined.d.ts +0 -1
- package/build/invariantDefined.js +0 -5
- package/build/invariantIdentity.d.ts +0 -3
- package/build/invariantIdentity.js +0 -5
- package/build/jsonParser2.d.ts +0 -3
- package/build/jsonParser2.js +0 -52
- package/build/jsonParser2.test.js +0 -22
- package/build/negativeLookahead.js +0 -20
- package/build/parserCompose.d.ts +0 -3
- package/build/parserCompose.js +0 -7
- package/build/parserImplementationInvariantInvariant.d.ts +0 -3
- package/build/parserImplementationInvariantInvariant.js +0 -15
- package/build/promiseFish.d.ts +0 -1
- package/build/promiseFish.js +0 -3
- package/build/sequenceParser.d.ts +0 -3
- package/build/sequenceParser.js +0 -10
- package/build/terminatedSequenceParser.d.ts +0 -2
- package/build/terminatedSequenceParser.js +0 -24
- package/build/zipEntry.d.ts +0 -28
- package/build/zipFile.d.ts +0 -32
- package/build/zipFileEntry.d.ts +0 -6
- package/src/apk.ts +0 -16
- package/src/apkParser.test.ts.md +0 -268
- package/src/apkParser.test.ts.snap +0 -0
- package/src/apkParser.ts +0 -327
- package/src/inputCompanion.ts +0 -43
- package/src/invariantDefined.ts +0 -6
- package/src/invariantIdentity.ts +0 -8
- package/src/negativeLookahead.ts +0 -26
- /package/build/{apk.js → androidPackage.js} +0 -0
- /package/build/{apkParser.test.d.ts → androidPackageParser.test.d.ts} +0 -0
- /package/build/{arbitraryDosPermissions.d.ts → androidPackageUnparser.test.d.ts} +0 -0
- /package/build/{arbitraryDosPermissions.js → dalvikExecutableParser.test.d.ts} +0 -0
- /package/build/{inputChunkBuffer.test.d.ts → dalvikExecutableParserAgainstSmaliParser.test.d.ts} +0 -0
- /package/build/{jsonParser2.test.d.ts → elementTerminatedArrayParser.test.d.ts} +0 -0
- /package/build/{parserParsingInvariant.d.ts → elementTerminatedSequenceArrayParser.test.d.ts} +0 -0
- /package/build/{parserParsingInvariant.js → elementTerminatedSequenceParser.test.d.ts} +0 -0
- /package/build/{zipEntry.js → fixedLengthSequenceParser.test.d.ts} +0 -0
- /package/build/{zipFile.js → javaKeyStore.d.ts} +0 -0
- /package/build/{zipFileEntry.js → javaKeyStore.js} +0 -0
package/src/arbitraryZip.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as fc from 'fast-check';
|
|
2
|
-
import { Zip, ZipDirectoryEntry, ZipEntry, ZipFileEntry } from './zip.js';
|
|
3
|
-
import { arbitraryDosDateTime } from './arbitraryDosDateTime.js';
|
|
4
|
-
import { createArbitraryZipPermissions } from './arbitraryZipPermissions.js';
|
|
5
2
|
import invariant from 'invariant';
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
type Zip,
|
|
5
|
+
type ZipDirectoryEntry,
|
|
6
|
+
type ZipFileEntry,
|
|
7
|
+
type ZipEntry,
|
|
8
|
+
type ZipEntryAttributes,
|
|
9
|
+
} from './zip.js';
|
|
10
|
+
import { arbitraryDosDateTime } from './arbitraryDosDateTime.js';
|
|
8
11
|
|
|
9
12
|
const arbitraryPath = fc.string({ minLength: 1 }).filter(path => {
|
|
10
13
|
const pathSegments = path.split('/');
|
|
@@ -26,7 +29,10 @@ const createArbitraryZipEntry = (platform: 'unix' | 'dos') => fc.oneof<[
|
|
|
26
29
|
path: arbitraryPath,
|
|
27
30
|
date: arbitraryDosDateTime,
|
|
28
31
|
comment: fc.string(),
|
|
29
|
-
|
|
32
|
+
hostSystem: fc.constant(platform),
|
|
33
|
+
attributes: fc.record<ZipEntryAttributes>({
|
|
34
|
+
directory: fc.constant(false),
|
|
35
|
+
}),
|
|
30
36
|
compression: fc.oneof(
|
|
31
37
|
fc.constant('store' as const),
|
|
32
38
|
fc.constant('deflate' as const),
|
|
@@ -40,13 +46,6 @@ const createArbitraryZipEntry = (platform: 'unix' | 'dos') => fc.oneof<[
|
|
|
40
46
|
return false;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
if (
|
|
44
|
-
zipFileEntry.permissions.type === 'dos'
|
|
45
|
-
&& zipFileEntry.permissions.dosPermissions & DOS_DIRECTORY_FLAG
|
|
46
|
-
) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
49
|
return true;
|
|
51
50
|
}),
|
|
52
51
|
fc.record<ZipDirectoryEntry>({
|
|
@@ -54,16 +53,10 @@ const createArbitraryZipEntry = (platform: 'unix' | 'dos') => fc.oneof<[
|
|
|
54
53
|
path: arbitraryPath,
|
|
55
54
|
date: arbitraryDosDateTime,
|
|
56
55
|
comment: fc.string(),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
&& !(zipDirectoryEntry.permissions.dosPermissions & DOS_DIRECTORY_FLAG)
|
|
62
|
-
) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return true;
|
|
56
|
+
hostSystem: fc.constant(platform),
|
|
57
|
+
attributes: fc.record<ZipEntryAttributes>({
|
|
58
|
+
directory: fc.constant(false),
|
|
59
|
+
}),
|
|
67
60
|
}),
|
|
68
61
|
);
|
|
69
62
|
|
|
@@ -106,10 +99,10 @@ const createArbitraryZipEntries = (platform: 'unix' | 'dos') => (
|
|
|
106
99
|
path: directoryPath,
|
|
107
100
|
date: entry.date,
|
|
108
101
|
comment: '',
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
102
|
+
hostSystem: platform,
|
|
103
|
+
attributes: {
|
|
104
|
+
directory: true,
|
|
105
|
+
},
|
|
113
106
|
});
|
|
114
107
|
|
|
115
108
|
seenDirectoryPaths.add(directoryPath);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as fc from 'fast-check';
|
|
2
|
-
import { ZipDosPermissions, ZipUnixPermissions } from './zip.js';
|
|
3
|
-
|
|
4
|
-
const arbitraryZipUnixPermissions = fc.record<ZipUnixPermissions>({
|
|
5
|
-
type: fc.constant('unix'),
|
|
6
|
-
unixPermissions: (
|
|
7
|
-
fc.nat({ max: 0b0000000111111111 })
|
|
8
|
-
.filter((unixPermissions) => unixPermissions > 0)
|
|
9
|
-
),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const arbitraryZipDosPermissions = fc.record<ZipDosPermissions>({
|
|
13
|
-
type: fc.constant('dos'),
|
|
14
|
-
dosPermissions: (
|
|
15
|
-
fc.nat({ max: 0b00111111 })
|
|
16
|
-
),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const createArbitraryZipPermissions = (type: 'unix' | 'dos') => {
|
|
20
|
-
if (type === 'unix') {
|
|
21
|
-
return arbitraryZipUnixPermissions;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return arbitraryZipDosPermissions;
|
|
25
|
-
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import JSZip from 'jszip';
|
|
2
|
-
import { ZipEntry } from './zip.js';
|
|
2
|
+
import { type ZipEntry } from './zip.js';
|
|
3
3
|
import { arbitraryZip } from './arbitraryZip.js';
|
|
4
4
|
|
|
5
5
|
function addZipEntryToZip(zip: JSZip, zipEntry: ZipEntry) {
|
|
6
6
|
const options = {
|
|
7
7
|
comment: zipEntry.comment,
|
|
8
8
|
date: zipEntry.date,
|
|
9
|
-
unixPermissions: zipEntry.permissions.type === 'unix' ? zipEntry.permissions.unixPermissions : undefined,
|
|
10
|
-
dosPermissions: zipEntry.permissions.type === 'dos' ? zipEntry.permissions.dosPermissions : undefined,
|
|
9
|
+
// unixPermissions: zipEntry.permissions.type === 'unix' ? zipEntry.permissions.unixPermissions : undefined,
|
|
10
|
+
// dosPermissions: zipEntry.permissions.type === 'dos' ? zipEntry.permissions.dosPermissions : undefined,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
if (zipEntry.type === 'file') {
|
|
@@ -35,7 +35,7 @@ export const arbitraryZipStream = arbitraryZip.map(zip => {
|
|
|
35
35
|
const zipInternalStream = jsZip.generateInternalStream({
|
|
36
36
|
type: 'uint8array',
|
|
37
37
|
comment: zip.comment,
|
|
38
|
-
platform: zip.entries.at(0)?.
|
|
38
|
+
platform: zip.entries.at(0)?.hostSystem.toUpperCase() as any,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
const zipStream = new ReadableStream<Uint8Array>({
|
package/src/arrayParser.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import { createArrayParser } from './arrayParser.js';
|
|
3
|
-
import { Parser,
|
|
4
|
-
import {
|
|
3
|
+
import { type Parser, runParserWithRemainingInput } from './parser.js';
|
|
4
|
+
import { stringParserInputCompanion } from './parserInputCompanion.js';
|
|
5
5
|
|
|
6
6
|
test('does not loop forever with a child parser that does not consume anything', async t => {
|
|
7
7
|
const parser: Parser<undefined[], string> = createArrayParser(async () => undefined);
|
|
8
|
-
const
|
|
8
|
+
const { output } = await runParserWithRemainingInput(parser, 'foo', stringParserInputCompanion);
|
|
9
9
|
|
|
10
|
-
t.deepEqual(
|
|
10
|
+
t.deepEqual(output, []);
|
|
11
11
|
});
|
package/src/arrayParser.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getParserName, Parser, setParserName } from
|
|
2
|
-
import { ParserParsingFailedError } from
|
|
1
|
+
import { getParserName, type Parser, setParserName } from './parser.js';
|
|
2
|
+
import { ParserParsingFailedError } from './parserError.js';
|
|
3
3
|
|
|
4
4
|
export const createArrayParser = <ElementOutput, Sequence>(
|
|
5
5
|
elementParser: Parser<ElementOutput, Sequence>,
|
|
@@ -15,6 +15,7 @@ export const createArrayParser = <ElementOutput, Sequence>(
|
|
|
15
15
|
if (elementParserContext.position === initialPosition) {
|
|
16
16
|
return elements;
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
elements.push(element);
|
|
19
20
|
elementParserContext.unlookahead();
|
|
20
21
|
} catch (error) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Unparser } from "./unparser.js";
|
|
2
|
+
|
|
3
|
+
export const createArrayUnparser = <ElementInput, Sequence>(
|
|
4
|
+
elementUnparser: Unparser<ElementInput, Sequence>,
|
|
5
|
+
): Unparser<ElementInput[], Sequence> => {
|
|
6
|
+
const arrayUnparser: Unparser<ElementInput[], Sequence> = async function * (input, unparserContext) {
|
|
7
|
+
for (const element of input) {
|
|
8
|
+
yield * elementUnparser(element, unparserContext);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return arrayUnparser;
|
|
13
|
+
}
|
package/src/backsmali.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import { temporaryDirectory, temporaryFile } from 'tempy';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
export async function baksmaliClass(dexStream: AsyncIterable<Uint8Array>, smaliFilePath: string) {
|
|
7
|
+
const inputFilePath = temporaryFile();
|
|
8
|
+
const outputDirectoryPath = temporaryDirectory();
|
|
9
|
+
|
|
10
|
+
await fs.writeFile(inputFilePath, dexStream);
|
|
11
|
+
|
|
12
|
+
await execa('baksmali', [
|
|
13
|
+
'disassemble',
|
|
14
|
+
'--classes', 'L' + smaliFilePath + ';',
|
|
15
|
+
'--output', outputDirectoryPath,
|
|
16
|
+
inputFilePath,
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
await fs.unlink(inputFilePath);
|
|
20
|
+
|
|
21
|
+
const smaliFilePath_ = path.join(outputDirectoryPath, smaliFilePath + '.smali');
|
|
22
|
+
|
|
23
|
+
const smali = await fs.readFile(smaliFilePath_, 'utf8');
|
|
24
|
+
|
|
25
|
+
await fs.rm(outputDirectoryPath, {
|
|
26
|
+
recursive: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return smali;
|
|
30
|
+
}
|
package/src/bsonParser.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BSON } from 'bson';
|
|
|
3
3
|
import { bsonDocumentParser } from './bsonParser.js';
|
|
4
4
|
import { arbitrarilySlicedAsyncIterator } from './arbitrarilySlicedAsyncInterator.js';
|
|
5
5
|
import { runParser } from './parser.js';
|
|
6
|
-
import {
|
|
6
|
+
import { uint8ArrayParserInputCompanion } from './parserInputCompanion.js';
|
|
7
7
|
|
|
8
8
|
testProp(
|
|
9
9
|
'bson',
|
|
@@ -27,7 +27,7 @@ testProp(
|
|
|
27
27
|
async (t, [ bsonUint8Array, bsonUint8ArrayChunkIterator ]) => {
|
|
28
28
|
const expected = BSON.deserialize(bsonUint8Array);
|
|
29
29
|
|
|
30
|
-
const actual = await runParser(bsonDocumentParser, bsonUint8ArrayChunkIterator,
|
|
30
|
+
const actual = await runParser(bsonDocumentParser, bsonUint8ArrayChunkIterator, uint8ArrayParserInputCompanion);
|
|
31
31
|
|
|
32
32
|
t.deepEqual(actual, expected);
|
|
33
33
|
},
|
package/src/bsonParser.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type JsonObject, type JsonValue } from 'type-fest';
|
|
2
2
|
import { getParserName, setParserName, type Parser } from './parser.js';
|
|
3
|
-
import { invariantDefined } from './invariantDefined.js';
|
|
4
3
|
import { createFixedLengthSequenceParser } from './fixedLengthSequenceParser.js';
|
|
5
4
|
import { promiseCompose } from './promiseCompose.js';
|
|
6
5
|
import { createTupleParser } from './tupleParser.js';
|
|
@@ -30,13 +29,21 @@ const cstringParser: Parser<string, Uint8Array> = promiseCompose(
|
|
|
30
29
|
)(),
|
|
31
30
|
nullByteParser,
|
|
32
31
|
),
|
|
33
|
-
([sequence]) => Buffer.from(sequence).toString('utf8'),
|
|
32
|
+
([ sequence ]) => Buffer.from(sequence).toString('utf8'),
|
|
34
33
|
);
|
|
35
34
|
|
|
36
35
|
const doubleParser: Parser<number, Uint8Array> = promiseCompose(buffer8Parser, buffer => buffer.readDoubleLE(0));
|
|
36
|
+
|
|
37
|
+
setParserName(doubleParser, 'doubleParser');
|
|
38
|
+
|
|
37
39
|
const int32Parser: Parser<number, Uint8Array> = promiseCompose(buffer4Parser, buffer => buffer.readInt32LE(0));
|
|
40
|
+
|
|
41
|
+
setParserName(int32Parser, 'int32Parser');
|
|
42
|
+
|
|
38
43
|
const uint32Parser: Parser<number, Uint8Array> = promiseCompose(buffer4Parser, buffer => buffer.readUInt32LE(0));
|
|
39
44
|
|
|
45
|
+
setParserName(uint32Parser, 'uint32Parser');
|
|
46
|
+
|
|
40
47
|
const createFixedLengthStringParser = (length: number): Parser<string, Uint8Array> => promiseCompose(
|
|
41
48
|
createFixedLengthBufferParser(length),
|
|
42
49
|
buffer => buffer.toString('utf8'),
|
|
@@ -47,7 +54,7 @@ const createFixedLengthNullTerminatedStringParser = (lengthWihoutNullTerminator:
|
|
|
47
54
|
createFixedLengthStringParser(lengthWihoutNullTerminator),
|
|
48
55
|
nullByteParser,
|
|
49
56
|
]),
|
|
50
|
-
([string]) => string,
|
|
57
|
+
([ string ]) => string,
|
|
51
58
|
);
|
|
52
59
|
|
|
53
60
|
const bsonStringParser: Parser<string, Uint8Array> = async parserContext => {
|
|
@@ -56,6 +63,8 @@ const bsonStringParser: Parser<string, Uint8Array> = async parserContext => {
|
|
|
56
63
|
return createFixedLengthNullTerminatedStringParser(stringSize - 1)(parserContext);
|
|
57
64
|
};
|
|
58
65
|
|
|
66
|
+
setParserName(bsonStringParser, 'bsonStringParser');
|
|
67
|
+
|
|
59
68
|
const bsonArrayParser = promiseCompose(
|
|
60
69
|
createTupleParser([
|
|
61
70
|
createSkipParser(4),
|
|
@@ -64,8 +73,10 @@ const bsonArrayParser = promiseCompose(
|
|
|
64
73
|
([ _, elements ]) => elements.map(([ _, value ]) => value),
|
|
65
74
|
);
|
|
66
75
|
|
|
76
|
+
setParserName(bsonArrayParser, 'bsonArrayParser');
|
|
77
|
+
|
|
67
78
|
const bsonBooleanParser: Parser<boolean, Uint8Array> = async parserContext => {
|
|
68
|
-
const booleanValue =
|
|
79
|
+
const booleanValue = await parserContext.read(0);
|
|
69
80
|
|
|
70
81
|
return booleanValue === 1;
|
|
71
82
|
};
|
|
@@ -119,7 +130,7 @@ const bsonElementListParser: Parser<Array<[ string, JsonValue ]>, Uint8Array> =
|
|
|
119
130
|
bsonElementParser,
|
|
120
131
|
nullByteParser,
|
|
121
132
|
),
|
|
122
|
-
([elements]) => elements,
|
|
133
|
+
([ elements ]) => elements,
|
|
123
134
|
);
|
|
124
135
|
|
|
125
136
|
export const bsonDocumentParser: Parser<JsonObject, Uint8Array> = promiseCompose(
|
|
@@ -4,11 +4,11 @@ export type Falsy = '' | 0 | false | undefined;
|
|
|
4
4
|
|
|
5
5
|
export type ValueOrAccessor<T> = T | (() => T);
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function customInvariant<T>(
|
|
8
8
|
ErrorConstructor: Constructor<Error, [message: string]> | ((message: string) => Error),
|
|
9
9
|
value: T,
|
|
10
10
|
formatOrFormatLines: ValueOrAccessor<string | string[]>,
|
|
11
|
-
...formatArguments:
|
|
11
|
+
...formatArguments: (unknown | (() => unknown))[]
|
|
12
12
|
): Exclude<T, Falsy> {
|
|
13
13
|
if (value) {
|
|
14
14
|
return value as any;
|