builder-util-runtime
Advanced tools
Comparing version 0.0.0-semantic-release to 1.0.0
@@ -1,2 +0,3 @@ | ||
export declare const BLOCK_MAP_FILE_NAME = "blockMap.yml"; | ||
export declare const BLOCK_MAP_FILE_NAME = "_blockMap.yml"; | ||
export declare const SIGNATURE_HEADER_SIZE: number; | ||
export interface BlockMap { | ||
@@ -11,4 +12,5 @@ blockSize: number; | ||
name: string; | ||
offset: number; | ||
size: number; | ||
blocks: Array<string>; | ||
} |
@@ -6,3 +6,4 @@ "use strict"; | ||
}); | ||
const BLOCK_MAP_FILE_NAME = exports.BLOCK_MAP_FILE_NAME = "blockMap.yml"; | ||
const BLOCK_MAP_FILE_NAME = exports.BLOCK_MAP_FILE_NAME = "_blockMap.yml"; | ||
const SIGNATURE_HEADER_SIZE = exports.SIGNATURE_HEADER_SIZE = 12 /* signature + 2 bytes version + 4 bytes CRC */ + 20; | ||
//# sourceMappingURL=blockMapApi.js.map |
@@ -56,9 +56,13 @@ /// <reference types="node" /> | ||
export declare class DigestTransform extends Transform { | ||
private readonly expected; | ||
readonly expected: string; | ||
private readonly algorithm; | ||
private readonly encoding; | ||
private readonly digester; | ||
constructor(expected: string, algorithm: string, encoding: "hex" | "base64" | "latin1"); | ||
private _actual; | ||
readonly actual: string; | ||
isValidateOnEnd: boolean; | ||
constructor(expected: string, algorithm?: string, encoding?: "hex" | "base64" | "latin1"); | ||
_transform(chunk: any, encoding: string, callback: any): void; | ||
_flush(callback: any): void; | ||
validate(): null; | ||
} | ||
@@ -65,0 +69,0 @@ export declare function safeGetHeader(response: any, headerKey: string): any; |
@@ -202,3 +202,6 @@ "use strict"; | ||
class DigestTransform extends (_stream || _load_stream()).Transform { | ||
constructor(expected, algorithm, encoding) { | ||
constructor(expected) { | ||
let algorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "sha512"; | ||
let encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "base64"; | ||
super(); | ||
@@ -208,4 +211,8 @@ this.expected = expected; | ||
this.encoding = encoding; | ||
this.isValidateOnEnd = true; | ||
this.digester = (0, (_crypto || _load_crypto()).createHash)(algorithm); | ||
} | ||
get actual() { | ||
return this._actual; | ||
} | ||
_transform(chunk, encoding, callback) { | ||
@@ -216,5 +223,22 @@ this.digester.update(chunk); | ||
_flush(callback) { | ||
const hash = this.digester.digest(this.encoding); | ||
callback(hash === this.expected ? null : new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${hash}`)); | ||
this._actual = this.digester.digest(this.encoding); | ||
if (this.isValidateOnEnd) { | ||
try { | ||
this.validate(); | ||
} catch (e) { | ||
callback(e); | ||
return; | ||
} | ||
} | ||
callback(null); | ||
} | ||
validate() { | ||
if (this._actual == null) { | ||
throw new Error("Not finished yet"); | ||
} | ||
if (this._actual !== this.expected) { | ||
throw new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`); | ||
} | ||
return null; | ||
} | ||
} | ||
@@ -221,0 +245,0 @@ exports.DigestTransform = DigestTransform; |
@@ -11,2 +11,5 @@ export interface VersionInfo { | ||
sha512: string; | ||
headerSize?: number; | ||
blockMapSize?: number; | ||
blockMapData?: string; | ||
} | ||
@@ -13,0 +16,0 @@ export interface UpdateInfo extends VersionInfo { |
{ | ||
"name": "builder-util-runtime", | ||
"version": "0.0.0-semantic-release", | ||
"version": "1.0.0", | ||
"main": "out/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Vladimir Krivosheev", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
160753
1763
0