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

@fluidframework/common-utils

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluidframework/common-utils - npm Package Compare versions

Comparing version 0.25.0 to 0.26.0-11161

2

.eslintrc.js

@@ -11,3 +11,3 @@ /*!

"parserOptions": {
"project": [ "./tsconfig.json", "./test/tsconfig.json" ]
"project": [ "./tsconfig.json", "./test/tsconfig.json", "./testJest/tsconfig.json" ]
},

@@ -14,0 +14,0 @@ "rules": {

@@ -7,5 +7,14 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export declare function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>): void;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -12,0 +21,0 @@ * @param file - The contents of the file in a buffer

@@ -7,7 +7,21 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("./assert");
const bufferBrowser_1 = require("./bufferBrowser");
let insecureContextHashFn;
/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
function setInsecureContextHashFn(hashFn) {
insecureContextHashFn = hashFn;
}
exports.setInsecureContextHashFn = setInsecureContextHashFn;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -18,2 +32,7 @@ * @param file - The contents of the file in a buffer

async function hashFile(file) {
// Use the function override if provided
if (insecureContextHashFn !== undefined) {
assert_1.assert(crypto.subtle === undefined);
return insecureContextHashFn(file);
}
const hash = await crypto.subtle.digest("SHA-1", file);

@@ -20,0 +39,0 @@ const hashArray = new Uint8Array(hash);

@@ -7,5 +7,14 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export declare function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>): void;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -12,0 +21,0 @@ * @param file - The contents of the file in a buffer

@@ -13,5 +13,17 @@ "use strict";

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
function setInsecureContextHashFn(hashFn) {
return;
}
exports.setInsecureContextHashFn = setInsecureContextHashFn;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -18,0 +30,0 @@ * @param file - The contents of the file in a buffer

@@ -8,3 +8,3 @@ /*!

export declare const pkgName = "@fluidframework/common-utils";
export declare const pkgVersion = "0.25.0";
export declare const pkgVersion = "0.26.0-11161";
//# sourceMappingURL=packageVersion.d.ts.map

@@ -10,3 +10,3 @@ "use strict";

exports.pkgName = "@fluidframework/common-utils";
exports.pkgVersion = "0.25.0";
exports.pkgVersion = "0.26.0-11161";
//# sourceMappingURL=packageVersion.js.map

@@ -7,5 +7,14 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export declare function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>): void;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -12,0 +21,0 @@ * @param file - The contents of the file in a buffer

@@ -5,7 +5,20 @@ /*!

*/
import { assert } from "./assert";
import { IsoBuffer } from "./bufferBrowser";
let insecureContextHashFn;
/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export function setInsecureContextHashFn(hashFn) {
insecureContextHashFn = hashFn;
}
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -16,2 +29,7 @@ * @param file - The contents of the file in a buffer

export async function hashFile(file) {
// Use the function override if provided
if (insecureContextHashFn !== undefined) {
assert(crypto.subtle === undefined);
return insecureContextHashFn(file);
}
const hash = await crypto.subtle.digest("SHA-1", file);

@@ -18,0 +36,0 @@ const hashArray = new Uint8Array(hash);

@@ -7,5 +7,14 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export declare function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>): void;
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -12,0 +21,0 @@ * @param file - The contents of the file in a buffer

@@ -8,5 +8,16 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export function setInsecureContextHashFn(hashFn) {
return;
}
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -13,0 +24,0 @@ * @param file - The contents of the file in a buffer

@@ -8,3 +8,3 @@ /*!

export declare const pkgName = "@fluidframework/common-utils";
export declare const pkgVersion = "0.25.0";
export declare const pkgVersion = "0.26.0-11161";
//# sourceMappingURL=packageVersion.d.ts.map

@@ -8,3 +8,3 @@ /*!

export const pkgName = "@fluidframework/common-utils";
export const pkgVersion = "0.25.0";
export const pkgVersion = "0.26.0-11161";
//# sourceMappingURL=packageVersion.js.map
{
"name": "@fluidframework/common-utils",
"version": "0.25.0",
"version": "0.26.0-11161",
"description": "Collection of utility functions for Fluid",
"homepage": "https://fluidframework.com",
"repository": "microsoft/FluidFramework",
"repository": "https://github.com/microsoft/FluidFramework",
"license": "MIT",
"author": "Microsoft",
"sideEffects": "false",
"sideEffects": false,
"main": "dist/index.js",

@@ -32,4 +32,4 @@ "module": "lib/index.js",

"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
"eslint": "eslint --format stylish src test",
"eslint:fix": "eslint --ext=ts,tsx --format stylish src test --fix",
"eslint": "eslint --format stylish src test testJest",
"eslint:fix": "eslint --format stylish src test testJest --fix",
"lint": "npm run eslint",

@@ -79,3 +79,3 @@ "lint:fix": "npm run eslint:fix",

"@fluidframework/build-common": "^0.19.2",
"@fluidframework/eslint-config-fluid": "^0.20.0",
"@fluidframework/eslint-config-fluid": "^0.21.0",
"@microsoft/api-extractor": "^7.7.2",

@@ -82,0 +82,0 @@ "@types/assert": "^1.5.1",

@@ -6,8 +6,23 @@ /*!

import { assert } from "./assert";
import { IsoBuffer } from "./bufferBrowser";
let insecureContextHashFn: ((f: IsoBuffer) => Promise<string>) | undefined;
/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>) {
insecureContextHashFn = hashFn;
}
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -18,2 +33,8 @@ * @param file - The contents of the file in a buffer

export async function hashFile(file: IsoBuffer): Promise<string> {
// Use the function override if provided
if (insecureContextHashFn !== undefined) {
assert(crypto.subtle === undefined);
return insecureContextHashFn(file);
}
const hash = await crypto.subtle.digest("SHA-1", file);

@@ -20,0 +41,0 @@ const hashArray = new Uint8Array(hash);

@@ -11,5 +11,17 @@ /*!

/**
* Set a hashing function to be called in place of hashFile's internal
* implementation when running under insecure contexts. Not needed
* when running under Node. The internal algorithm should match that the
* one used internally by hashFile.
* @param hashFn - The function that should be used in place of hashFile
*/
export function setInsecureContextHashFn(hashFn: (f: IsoBuffer) => Promise<string>) {
return;
}
/**
* Hash a file. Consistent within a session, but should not be persisted and
* is not consistent with git.
* Must be called under secure context for browsers
* If called under an insecure context for a browser, an override function
* needs to be set using setInsecureContextHashFn
*

@@ -16,0 +28,0 @@ * @param file - The contents of the file in a buffer

@@ -9,2 +9,2 @@ /*!

export const pkgName = "@fluidframework/common-utils";
export const pkgVersion = "0.25.0";
export const pkgVersion = "0.26.0-11161";

@@ -18,2 +18,2 @@ {

]
}
}

@@ -6,3 +6,5 @@ /*!

// eslint-disable-next-line import/no-internal-modules
import * as BufferNode from "../src/bufferNode";
// eslint-disable-next-line import/no-internal-modules
import * as BufferBrowser from "../src/bufferBrowser";

@@ -19,8 +21,8 @@

"\ud800", // single utf-16 surrogate without pair
"\u2962\u0000\uffff\uaaaa" // garbage
"\u2962\u0000\uffff\uaaaa", // garbage
];
for (let i = 0; i < testArray.length; i++) {
const nodeBuffer = BufferNode.IsoBuffer.from(testArray[i]);
const browserBuffer = BufferBrowser.IsoBuffer.from(testArray[i]);
for (const item of testArray) {
const nodeBuffer = BufferNode.IsoBuffer.from(item);
const browserBuffer = BufferBrowser.IsoBuffer.from(item);

@@ -30,6 +32,8 @@ expect(nodeBuffer.toString()).toEqual(browserBuffer.toString());

const nodeBuffer = BufferNode.IsoBuffer.from(testArray[1]);
const browserBuffer = BufferBrowser.IsoBuffer.from(testArray[1]);
expect(nodeBuffer.toString("utf8")).toEqual(browserBuffer.toString("utf8"));
expect(nodeBuffer.toString("utf-8")).toEqual(browserBuffer.toString("utf-8"));
{
const nodeBuffer = BufferNode.IsoBuffer.from(testArray[1]);
const browserBuffer = BufferBrowser.IsoBuffer.from(testArray[1]);
expect(nodeBuffer.toString("utf8")).toEqual(browserBuffer.toString("utf8"));
expect(nodeBuffer.toString("utf-8")).toEqual(browserBuffer.toString("utf-8"));
}
});

@@ -47,8 +51,8 @@

"5q+U54m55biB", // ๆฏ”็‰นๅธ
"8J+YgvCfkoHwn4+84oCN4pmC77iP8J+SgfCfj7zigI3wn5KB4oCN4pmC" // ๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚
"8J+YgvCfkoHwn4+84oCN4pmC77iP8J+SgfCfj7zigI3wn5KB4oCN4pmC", // ๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚
];
for (let i = 0; i < testArray.length; i++) {
const nodeBuffer = BufferNode.IsoBuffer.from(testArray[i], "base64");
const browserBuffer = BufferBrowser.IsoBuffer.from(testArray[i], "base64");
for (const item of testArray) {
const nodeBuffer = BufferNode.IsoBuffer.from(item, "base64");
const browserBuffer = BufferBrowser.IsoBuffer.from(item, "base64");

@@ -67,4 +71,4 @@ expect(nodeBuffer.toString("base64")).toEqual(browserBuffer.toString("base64"));

for (let i = 0; i < testArray.length; i++) {
const encoded = new TextEncoder().encode(testArray[i]).buffer;
for (const item of testArray) {
const encoded = new TextEncoder().encode(item).buffer;
const nodeBuffer = BufferNode.IsoBuffer.from(encoded);

@@ -82,3 +86,3 @@ const browserBuffer = BufferBrowser.IsoBuffer.from(encoded);

"ๆฏ”็‰นๅธ", // non-ascii range
"๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚" // surrogate pairs with glyph modifiers
"๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚", // surrogate pairs with glyph modifiers
];

@@ -90,3 +94,3 @@

"5q+U54m55biB", // ๆฏ”็‰นๅธ
"8J+YgvCfkoHwn4+84oCN4pmC77iP8J+SgfCfj7zigI3wn5KB4oCN4pmC" // ๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚
"8J+YgvCfkoHwn4+84oCN4pmC77iP8J+SgfCfj7zigI3wn5KB4oCN4pmC", // ๐Ÿ˜‚๐Ÿ’๐Ÿผโ€โ™‚๏ธ๐Ÿ’๐Ÿผโ€๐Ÿ’โ€โ™‚
];

@@ -93,0 +97,0 @@

@@ -9,2 +9,3 @@ /*!

import http from "http";
// eslint-disable-next-line import/no-internal-modules
import * as HashNode from "../src/hashFileNode";

@@ -35,6 +36,6 @@

return page.evaluate(async (file) => {
return page.evaluate(async (f) => {
// Pass the string conversion into evaluate and re-encode it here because
// Uint8Array is not directly jsonable
const fileUint8 = Uint8Array.from(new window.TextEncoder().encode(file));
const fileUint8 = Uint8Array.from(new window.TextEncoder().encode(f));

@@ -45,7 +46,7 @@ // This is copied from hashFileBrowser's hashFile - puppeteer has issues

const hashArray = new Uint8Array(hash);
const hashHex = Array.prototype.map.call(hashArray, function(byte) {
const hashHex = Array.prototype.map.call(hashArray, function(byte: number) {
return byte.toString(16).padStart(2, "0");
}).join("");
return hashHex;
}, hashBuffer.toString());
}, hashBuffer.toString()) as Promise<string>;
}

@@ -68,3 +69,3 @@

server?.close();
})
});

@@ -71,0 +72,0 @@ // Expected hashes are from git hash-object file...

@@ -10,3 +10,6 @@ {

]
}
}
},
"include": [
"./**/*"
]
}

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

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

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

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

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