New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@expo/fingerprint

Package Overview
Dependencies
Maintainers
25
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/fingerprint - npm Package Compare versions

Comparing version 0.0.1-canary-20240305-e60019e to 0.0.1-canary-20240308-6715875

build/utils/Predicates.d.ts

39

build/Fingerprint.types.d.ts

@@ -8,2 +8,7 @@ /// <reference types="node" />

hash: string | null;
/**
* Debug info from the hashing process. Differs based on source type. Designed to be consumed by humans
* as opposed to programmatically.
*/
debugInfo?: DebugInfo;
};

@@ -59,2 +64,6 @@ export interface Fingerprint {

silent?: boolean;
/**
* Whether to include verbose debug info in source output. Useful for debugging.
*/
debug?: boolean;
}

@@ -93,5 +102,33 @@ export interface NormalizedOptions extends Options {

export type HashSource = HashSourceFile | HashSourceDir | HashSourceContents;
export interface HashResult {
export interface DebugInfoFile {
path: string;
hash: string;
}
export interface DebugInfoDir {
path: string;
hash: string;
children: (DebugInfoFile | DebugInfoDir | undefined)[];
}
export interface DebugInfoContents {
hash: string;
}
export type DebugInfo = DebugInfoFile | DebugInfoDir | DebugInfoContents;
export interface HashResultFile {
type: 'file';
id: string;
hex: string;
debugInfo?: DebugInfoFile;
}
export interface HashResultDir {
type: 'dir';
id: string;
hex: string;
debugInfo?: DebugInfoDir;
}
export interface HashResultContents {
type: 'contents';
id: string;
hex: string;
debugInfo?: DebugInfoContents;
}
export type HashResult = HashResultFile | HashResultDir | HashResultContents;

8

build/hash/Hash.d.ts
import pLimit from 'p-limit';
import type { Fingerprint, FingerprintSource, HashResult, HashSource, HashSourceContents, NormalizedOptions } from '../Fingerprint.types';
import type { Fingerprint, FingerprintSource, HashResultContents, HashResultDir, HashResultFile, HashSource, HashSourceContents, NormalizedOptions } from '../Fingerprint.types';
/**

@@ -15,3 +15,3 @@ * Create a `Fingerprint` from `HashSources` array

*/
export declare function createFileHashResultsAsync(filePath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions): Promise<HashResult | null>;
export declare function createFileHashResultsAsync(filePath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions): Promise<HashResultFile | null>;
/**

@@ -21,7 +21,7 @@ * Create `HashResult` for a dir.

*/
export declare function createDirHashResultsAsync(dirPath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions, depth?: number): Promise<HashResult | null>;
export declare function createDirHashResultsAsync(dirPath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions, depth?: number): Promise<HashResultDir | null>;
/**
* Create `HashResult` for a `HashSourceContents`
*/
export declare function createContentsHashResultsAsync(source: HashSourceContents, options: NormalizedOptions): Promise<HashResult>;
export declare function createContentsHashResultsAsync(source: HashSourceContents, options: NormalizedOptions): Promise<HashResultContents>;
/**

@@ -28,0 +28,0 @@ * Create id from given source

@@ -13,2 +13,3 @@ "use strict";

const Path_1 = require("../utils/Path");
const Predicates_1 = require("../utils/Predicates");
const Profile_1 = require("../utils/Profile");

@@ -54,3 +55,7 @@ /**

}
return { ...source, hash: result?.hex ?? null };
return {
...source,
hash: result?.hex ?? null,
...(options.debug ? { debugInfo: result?.debugInfo } : undefined),
};
}

@@ -94,3 +99,8 @@ exports.createFingerprintSourceAsync = createFingerprintSourceAsync;

const hex = hasher.digest('hex');
resolve({ id: filePath, hex });
resolve({
type: 'file',
id: filePath,
hex,
...(options.debug ? { debugInfo: { path: filePath, hash: hex } } : undefined),
});
resolved = true;

@@ -118,24 +128,30 @@ }

const dirents = (await promises_1.default.readdir(path_1.default.join(projectRoot, dirPath), { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
const promises = [];
for (const dirent of dirents) {
const results = (await Promise.all(dirents.map(async (dirent) => {
if (dirent.isDirectory()) {
const filePath = path_1.default.join(dirPath, dirent.name);
promises.push(createDirHashResultsAsync(filePath, limiter, projectRoot, options, depth + 1));
return await createDirHashResultsAsync(filePath, limiter, projectRoot, options, depth + 1);
}
else if (dirent.isFile()) {
const filePath = path_1.default.join(dirPath, dirent.name);
promises.push(createFileHashResultsAsync(filePath, limiter, projectRoot, options));
return await createFileHashResultsAsync(filePath, limiter, projectRoot, options);
}
}
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
const results = (await Promise.all(promises)).filter((result) => result != null);
return null;
}))).filter(Predicates_1.nonNullish);
if (results.length === 0) {
return null;
}
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
const children = [];
for (const result of results) {
hasher.update(result.id);
hasher.update(result.hex);
children.push(result.debugInfo);
}
const hex = hasher.digest('hex');
return { id: dirPath, hex };
return {
type: 'dir',
id: dirPath,
hex,
...(options.debug ? { debugInfo: { path: dirPath, children, hash: hex } } : undefined),
};
}

@@ -148,3 +164,8 @@ exports.createDirHashResultsAsync = createDirHashResultsAsync;

const hex = (0, crypto_1.createHash)(options.hashAlgorithm).update(source.contents).digest('hex');
return { id: source.id, hex };
return {
type: 'contents',
id: source.id,
hex,
...(options.debug ? { debugInfo: { hash: hex } } : undefined),
};
}

@@ -151,0 +172,0 @@ exports.createContentsHashResultsAsync = createContentsHashResultsAsync;

{
"name": "@expo/fingerprint",
"version": "0.0.1-canary-20240305-e60019e",
"version": "0.0.1-canary-20240308-6715875",
"description": "A library to generate a fingerprint from a React Native project",

@@ -55,7 +55,7 @@ "main": "build/index.js",

"@types/find-up": "^4.0.0",
"expo-module-scripts": "0.0.1-canary-20240305-e60019e",
"expo-module-scripts": "0.0.1-canary-20240308-6715875",
"glob": "^7.1.7",
"temp-dir": "^2.0.0"
},
"gitHead": "e60019e11a6d46e330b57b18c64468a58d589875"
"gitHead": "67158757cf78be8094fe6b7461e8523157f1f615"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc