Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zenfs/core

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenfs/core - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

dist/emulation/path.d.ts

4

dist/backends/AsyncMirror.js

@@ -14,3 +14,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { FileFlag, PreloadFile } from '../file.js';
import * as path from 'path';
import { join } from '../emulation/path.js';
import { Cred } from '../cred.js';

@@ -189,3 +189,3 @@ import { CreateBackend } from './backend.js';

for (const file of files) {
yield copyItem(path.join(p, file));
yield copyItem(join(p, file));
}

@@ -192,0 +192,0 @@ }), copyFile = (p, mode) => __awaiter(this, void 0, void 0, function* () {

@@ -10,3 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import * as path from 'path';
import { dirname, basename, join, resolve } from '../emulation/path.js';
import { ApiError, ErrorCode } from '../ApiError.js';

@@ -208,3 +208,3 @@ import { W_OK, R_OK } from '../emulation/constants.js';

try {
const tx = this.store.beginTransaction('readwrite'), oldParent = path.dirname(oldPath), oldName = path.basename(oldPath), newParent = path.dirname(newPath), newName = path.basename(newPath),
const tx = this.store.beginTransaction('readwrite'), oldParent = dirname(oldPath), oldName = basename(oldPath), newParent = dirname(newPath), newName = basename(newPath),
// Remove oldPath from parent's directory listing.

@@ -355,3 +355,3 @@ oldDirNode = yield this.findINode(tx, oldParent), oldDirList = yield this.getDirListing(tx, oldParent, oldDirNode);

// We use the _findInode helper because we actually need the INode id.
fileInodeId = yield this._findINode(tx, path.dirname(p), path.basename(p)), fileInode = yield this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);
fileInodeId = yield this._findINode(tx, dirname(p), basename(p)), fileInode = yield this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);
try {

@@ -399,3 +399,3 @@ // Sync data.

return __awaiter(this, void 0, void 0, function* () {
const currentPath = path.posix.join(parent, filename);
const currentPath = join(parent, filename);
if (visited.has(currentPath)) {

@@ -431,3 +431,3 @@ throw new ApiError(ErrorCode.EIO, 'Infinite loop detected while finding inode', currentPath);

else {
throw ApiError.ENOENT(path.resolve(parent, filename));
throw ApiError.ENOENT(resolve(parent, filename));
}

@@ -449,3 +449,3 @@ }

else {
throw ApiError.ENOENT(path.resolve(parent, filename));
throw ApiError.ENOENT(resolve(parent, filename));
}

@@ -462,3 +462,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const id = yield this._findINode(tx, path.dirname(p), path.basename(p), visited);
const id = yield this._findINode(tx, dirname(p), basename(p), visited);
return this.getINode(tx, p, id);

@@ -542,3 +542,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
const parentDir = path.dirname(p), fname = path.basename(p), parentNode = yield this.findINode(tx, parentDir), dirListing = yield this.getDirListing(tx, parentDir, parentNode), currTime = new Date().getTime();
const parentDir = dirname(p), fname = basename(p), parentNode = yield this.findINode(tx, parentDir), dirListing = yield this.getDirListing(tx, parentDir, parentNode), currTime = new Date().getTime();
//Check that the creater has correct access

@@ -594,3 +594,3 @@ if (!parentNode.toStats().hasAccess(W_OK, cred)) {

}
const tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), parentNode = yield this.findINode(tx, parent), parentListing = yield this.getDirListing(tx, parent, parentNode), fileName = path.basename(p);
const tx = this.store.beginTransaction('readwrite'), parent = dirname(p), parentNode = yield this.findINode(tx, parent), parentListing = yield this.getDirListing(tx, parent, parentNode), fileName = basename(p);
if (!parentListing[fileName]) {

@@ -597,0 +597,0 @@ throw ApiError.ENOENT(p);

@@ -12,3 +12,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { BaseFileSystem } from '../filesystem.js';
import * as path from 'path';
import { relative, join } from '../emulation/path.js';
import { ApiError } from '../ApiError.js';

@@ -84,3 +84,3 @@ import { Cred } from '../cred.js';

if (p) {
p = '/' + path.relative(folder, p);
p = '/' + relative(folder, p);
err.message = err.message.replace(err.path, p);

@@ -117,6 +117,6 @@ err.path = p;

if (wrapFirst) {
arguments[0] = path.join(this._folder, arguments[0]);
arguments[0] = join(this._folder, arguments[0]);
}
if (wrapSecond) {
arguments[1] = path.join(this._folder, arguments[1]);
arguments[1] = join(this._folder, arguments[1]);
}

@@ -133,6 +133,6 @@ arguments[arguments.length - 1] = wrapCallback(this._folder, arguments[arguments.length - 1]);

if (wrapFirst) {
arguments[0] = path.join(this._folder, arguments[0]);
arguments[0] = join(this._folder, arguments[0]);
}
if (wrapSecond) {
arguments[1] = path.join(this._folder, arguments[1]);
arguments[1] = join(this._folder, arguments[1]);
}

@@ -139,0 +139,0 @@ return this._wrapped[name].apply(this._wrapped, arguments);

@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import LockedFS from './Locked.js';
import * as path from 'path';
import { resolve, dirname } from '../emulation/path.js';
import { Cred } from '../cred.js';

@@ -191,3 +191,3 @@ import { CreateBackend } from './backend.js';

// Recursion! Should work for any nested files / folders.
yield this.rename(path.resolve(oldPath, name), path.resolve(newPath, name), cred);
yield this.rename(resolve(oldPath, name), resolve(newPath, name), cred);
}

@@ -247,3 +247,3 @@ }

// Recursion! Should work for any nested files / folders.
this.renameSync(path.resolve(oldPath, name), path.resolve(newPath, name), cred);
this.renameSync(resolve(oldPath, name), resolve(newPath, name), cred);
});

@@ -628,6 +628,6 @@ }

createParentDirectories(p, cred) {
let parent = path.dirname(p), toCreate = [];
let parent = dirname(p), toCreate = [];
while (!this._writable.existsSync(parent, cred)) {
toCreate.push(parent);
parent = path.dirname(parent);
parent = dirname(parent);
}

@@ -641,6 +641,6 @@ toCreate = toCreate.reverse();

return __awaiter(this, void 0, void 0, function* () {
let parent = path.dirname(p), toCreate = [];
let parent = dirname(p), toCreate = [];
while (!(yield this._writable.exists(parent, cred))) {
toCreate.push(parent);
parent = path.dirname(parent);
parent = dirname(parent);
}

@@ -647,0 +647,0 @@ toCreate = toCreate.reverse();

/// <reference types="node" resolution-mode="require"/>
import { Cred } from '../cred.js';
import { File, FileFlag, PreloadFile } from '../file.js';
import { FileFlag, PreloadFile } from '../file.js';
import { SynchronousFileSystem } from '../filesystem.js';

@@ -129,3 +129,3 @@ import { Stats } from '../stats.js';

}
export declare class SyncKeyValueFile extends PreloadFile<SyncKeyValueFileSystem> implements File {
export declare class SyncKeyValueFile extends PreloadFile<SyncKeyValueFileSystem> {
constructor(_fs: SyncKeyValueFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Buffer);

@@ -160,4 +160,4 @@ syncSync(): void;

statSync(p: string, cred: Cred): Stats;
createFileSync(p: string, flag: FileFlag, mode: number, cred: Cred): File;
openFileSync(p: string, flag: FileFlag, cred: Cred): File;
createFileSync(p: string, flag: FileFlag, mode: number, cred: Cred): SyncKeyValueFile;
openFileSync(p: string, flag: FileFlag, cred: Cred): SyncKeyValueFile;
unlinkSync(p: string, cred: Cred): void;

@@ -164,0 +164,0 @@ rmdirSync(p: string, cred: Cred): void;

@@ -1,2 +0,2 @@

import * as path from 'path';
import { dirname, basename, join, resolve, sep } from '../emulation/path.js';
import { ApiError, ErrorCode } from '../ApiError.js';

@@ -146,3 +146,3 @@ import { W_OK, R_OK } from '../emulation/constants.js';

renameSync(oldPath, newPath, cred) {
const tx = this.store.beginTransaction('readwrite'), oldParent = path.dirname(oldPath), oldName = path.basename(oldPath), newParent = path.dirname(newPath), newName = path.basename(newPath),
const tx = this.store.beginTransaction('readwrite'), oldParent = dirname(oldPath), oldName = basename(oldPath), newParent = dirname(newPath), newName = basename(newPath),
// Remove oldPath from parent's directory listing.

@@ -267,3 +267,3 @@ oldDirNode = this.findINode(tx, oldParent), oldDirList = this.getDirListing(tx, oldParent, oldDirNode);

// We use the _findInode helper because we actually need the INode id.
fileInodeId = this._findINode(tx, path.dirname(p), path.basename(p)), fileInode = this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);
fileInodeId = this._findINode(tx, dirname(p), basename(p)), fileInode = this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);
try {

@@ -308,3 +308,3 @@ // Sync data.

_findINode(tx, parent, filename, visited = new Set()) {
const currentPath = path.posix.join(parent, filename);
const currentPath = join(parent, filename);
if (visited.has(currentPath)) {

@@ -322,3 +322,3 @@ throw new ApiError(ErrorCode.EIO, 'Infinite loop detected while finding inode', currentPath);

else {
throw ApiError.ENOENT(path.resolve(parent, filename));
throw ApiError.ENOENT(resolve(parent, filename));
}

@@ -337,3 +337,3 @@ };

else {
return readDirectory(this.getINode(tx, parent + path.sep + filename, this._findINode(tx, path.dirname(parent), path.basename(parent), visited)));
return readDirectory(this.getINode(tx, parent + sep + filename, this._findINode(tx, dirname(parent), basename(parent), visited)));
}

@@ -348,3 +348,3 @@ }

findINode(tx, p) {
return this.getINode(tx, p, this._findINode(tx, path.dirname(p), path.basename(p)));
return this.getINode(tx, p, this._findINode(tx, dirname(p), basename(p)));
}

@@ -409,3 +409,3 @@ /**

commitNewFile(tx, p, type, mode, cred, data) {
const parentDir = path.dirname(p), fname = path.basename(p), parentNode = this.findINode(tx, parentDir), dirListing = this.getDirListing(tx, parentDir, parentNode), currTime = new Date().getTime();
const parentDir = dirname(p), fname = basename(p), parentNode = this.findINode(tx, parentDir), dirListing = this.getDirListing(tx, parentDir, parentNode), currTime = new Date().getTime();
//Check that the creater has correct access

@@ -450,3 +450,3 @@ if (!parentNode.toStats().hasAccess(0b0100 /* Write */, cred)) {

removeEntry(p, isDir, cred) {
const tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), parentNode = this.findINode(tx, parent), parentListing = this.getDirListing(tx, parent, parentNode), fileName = path.basename(p);
const tx = this.store.beginTransaction('readwrite'), parent = dirname(p), parentNode = this.findINode(tx, parent), parentListing = this.getDirListing(tx, parent, parentNode), fileName = basename(p);
if (!parentListing[fileName]) {

@@ -453,0 +453,0 @@ throw ApiError.ENOENT(p);

// Utilities and shared data
import { posix as path } from 'path';
import { resolve } from './path.js';
import { ApiError, ErrorCode } from '../ApiError.js';

@@ -55,3 +55,3 @@ import { Cred } from '../cred.js';

p = p.replaceAll(/\/+/g, '/');
return path.resolve(p);
return resolve(p);
}

@@ -133,3 +133,3 @@ export function normalizeOptions(options, defEnc, defFlag, defMode) {

}
mountPoint = path.resolve(mountPoint);
mountPoint = resolve(mountPoint);
if (mounts.has(mountPoint)) {

@@ -147,3 +147,3 @@ throw new ApiError(ErrorCode.EINVAL, 'Mount point ' + mountPoint + ' is already in use.');

}
mountPoint = path.resolve(mountPoint);
mountPoint = resolve(mountPoint);
if (!mounts.has(mountPoint)) {

@@ -150,0 +150,0 @@ throw new ApiError(ErrorCode.EINVAL, 'Mount point ' + mountPoint + ' is already unmounted.');

import { Stats, FileType } from './stats.js';
import * as path from 'path';
import * as path from './emulation/path.js';
/**

@@ -222,3 +222,3 @@ * A simple class for storing a filesystem index. Assumes that all paths passed

const dirpath = path.dirname(p);
const itemname = p.substr(dirpath.length + (dirpath === '/' ? 0 : 1));
const itemname = p.slice(dirpath.length + (dirpath === '/' ? 0 : 1));
return [dirpath, itemname];

@@ -225,0 +225,0 @@ }

@@ -15,3 +15,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */

import { FileFlag, ActionType } from './file.js';
import * as path from 'path';
import * as path from './emulation/path.js';
import { Buffer } from 'buffer';

@@ -18,0 +18,0 @@ /**

@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { ErrorCode, ApiError } from './ApiError.js';
import * as path from 'path';
import * as path from './emulation/path.js';
import { Buffer } from 'buffer';

@@ -14,0 +14,0 @@ /**

{
"name": "@zenfs/core",
"version": "0.0.7",
"version": "0.0.8",
"description": "A filesystem in your browser",

@@ -56,6 +56,4 @@ "main": "dist/index.js",

"esbuild": "^0.17.18",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^8.36.0",
"jest": "^29.5.0",
"path": "^0.12.7",
"prettier": "^2.8.7",

@@ -62,0 +60,0 @@ "ts-jest": "^29.1.0",

Sorry, the diff of this file is too big to display

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