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

@parse/fs-files-adapter

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parse/fs-files-adapter - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

.github/ISSUE_TEMPLATE/---1-report-an-issue.md

19

CHANGELOG.md

@@ -1,5 +0,10 @@

# Change Log
## [1.2.2](https://github.com/parse-community/parse-server-fs-adapter/compare/1.2.1...1.2.2) (2022-03-28)
## [1.2.1](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.2.1) (2021-10-15)
### Bug Fixes
* security update minimist from 1.2.5 to 1.2.6 ([#32](https://github.com/parse-community/parse-server-fs-adapter/issues/32)) ([af182bb](https://github.com/parse-community/parse-server-fs-adapter/commit/af182bb3ee8e84716464dd384ea7145b99faef49))
# [1.2.1](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.2.1) (2021-10-15)
Bug Fixes

@@ -11,11 +16,11 @@ - bump ansi-regex from 5.0.0 to 5.0.1 ([54afe1e](https://github.com/mtrezza/parse-server-fs-adapter/commit/54afe1e97038d8d40509b1d4064e211db1111efb))

## [1.2.0](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.2.0) (2020-10-25)
# [1.2.0](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.2.0) (2020-10-25)
- Switch from fileKey to encryptionKey [\#17](https://github.com/parse-community/parse-server-fs-adapter/pull/17) (thanks to [Corey](https://github.com/cbaker6))
## [1.1.0](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.1.0) (2020-10-21)
# [1.1.0](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.1.0) (2020-10-21)
- Added AES encryption/decryption using native crypto [\#15](https://github.com/parse-community/parse-server-fs-adapter/pull/15) (thanks to [Corey](https://github.com/cbaker6))
## [1.0.1](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.0.1) (2016-08-15)
# [1.0.1](https://github.com/parse-server-modules/parse-server-fs-adapter/tree/1.0.1) (2016-08-15)
**Closed issues:**

@@ -29,5 +34,1 @@

- Fix issue \#1 [\#2](https://github.com/parse-server-modules/parse-server-fs-adapter/pull/2) ([dtsolis](https://github.com/dtsolis))
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
{
"name": "@parse/fs-files-adapter",
"version": "1.2.1",
"version": "1.2.2",
"description": "File system adapter for parse-server",

@@ -23,6 +23,13 @@ "main": "index.js",

"devDependencies": {
"nyc": "^15.1.0",
"jasmine": "^3.5.0",
"parse-server-conformance-tests": "^1.0.0"
"@semantic-release/changelog": "5.0.1",
"@semantic-release/commit-analyzer": "8.0.1",
"@semantic-release/git": "9.0.0",
"@semantic-release/github": "7.2.3",
"@semantic-release/npm": "7.1.3",
"@semantic-release/release-notes-generator": "9.0.3",
"jasmine": "4.0.2",
"nyc": "15.1.0",
"parse-server-conformance-tests": "1.0.0",
"semantic-release": "17.4.6"
}
}

@@ -1,14 +0,25 @@

# parse-server-fs-adapter
<a href="https://www.npmjs.com/package/@parse/fs-files-adapter"><img alt="npm version" src="https://img.shields.io/npm/v/@parse/fs-files-adapter.svg?style=flat"></a>
[![codecov.io](https://codecov.io/github/parse-community/parse-server-fs-adapter/coverage.svg?branch=master)](https://codecov.io/github/parse-community/parse-server-fs-adapter?branch=master)
<a href="https://github.com/parse-community/parse-server-fs-adapter/actions?query=workflow%3Aci+branch%3Amain">
<img alt="Build status" src="https://github.com/parse-community/parse-server-fs-adapter/workflows/ci/badge.svg?branch=main">
</a>
# Parse Server FS Adapter <!-- omit in toc -->
parse-server file system storage adapter.
[![Build Status](https://github.com/parse-community/parse-server-fs-adapter/workflows/ci/badge.svg?branch=main)](https://github.com/parse-community/parse-server-fs-adapter/actions?query=workflow%3Aci+branch%3Amain)
[![Snyk Badge](https://snyk.io/test/github/parse-community/parse-server-fs-adapter/badge.svg)](https://snyk.io/test/github/parse-community/parse-server-fs-adapter)
[![Coverage](https://img.shields.io/codecov/c/github/parse-community/parse-server-fs-adapter/main.svg)](https://codecov.io/github/parse-community/parse-server-fs-adapter?branch=main)
[![auto-release](https://img.shields.io/badge/%F0%9F%9A%80-auto--release-9e34eb.svg)](https://github.com/parse-community/parse-server-fs-adapter/releases)
[![npm latest version](https://img.shields.io/npm/v/@parse/fs-files-adapter.svg)](https://www.npmjs.com/package/@parse/fs-files-adapter)
# Multiple instances of parse-server
When using parse-server-fs-adapter across multiple parse-server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/recieving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using parse-server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All parse-server instances need to be able to read and write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.
---
The Parse Server File System Storage Adapter.
---
- [Installation](#installation)
- [Configuration](#configuration)
- [Parse Server Config](#parse-server-config)
- [In-Code Instance](#in-code-instance)
- [Rotating Encryption Key](#rotating-encryption-key)
- [Encrypting Previously Unencrypted Files](#encrypting-previously-unencrypted-files)
- [Encrypting Previously Encrypted Files](#encrypting-previously-encrypted-files)
- [Other Considerations](#other-considerations)
# Installation

@@ -18,5 +29,5 @@

# Usage with parse-server
# Configuration
### Using a config file
## Parse Server Config

@@ -28,7 +39,8 @@ ```javascript

// other options
// ...
"filesAdapter": {
"module": "@parse/fs-files-adapter",
"options": {
"filesSubDirectory": "my/files/folder", // optional, defaults to ./files
"encryptionKey": "someKey" //optional, but mandatory if you want to encrypt files
"filesSubDirectory": "my/files/folder", // Optional, defaults to `./files`
"encryptionKey": "someKey" // Optional, but mandatory if you want to encrypt files
}

@@ -39,3 +51,3 @@ }

### Passing as an instance
## In-Code Instance

@@ -57,6 +69,10 @@ ```javascript

### Rotating to a new encryptionKey
Periodically you may want to rotate your encryptionKey for security reasons. When this is the case, you can start up a development parse-server that has the same configuration as your production server. In the development server, initialize the file adapter with the new key and do the following in your `index.js`:
## Rotating Encryption Key
#### Files were previously unencrypted and you want to encrypt
Periodically you may want to rotate your encryptionKey for security reasons. When this is the case, you can start up a development parse-server that has the same configuration as your production server. In the development server, initialize the file adapter with the new key and use the examples below.
Note that the examples below to rotate keys are are not optimized for performance. Is it therefore not recommended to rotate a large number of files using the code below in a production environment; instead use dedicated resources for that.
### Encrypting Previously Unencrypted Files
```javascript

@@ -66,4 +82,4 @@ var FSFilesAdapter = require('@parse/fs-files-adapter');

var fsAdapter = new FSFilesAdapter({
"filesSubDirectory": "my/files/folder", // optional, defaults to ./files
"encryptionKey": "newKey" //Use the newKey
"filesSubDirectory": "my/files/folder", // Optional, defaults to `./files`
"encryptionKey": "newKey" // Use the new key
});

@@ -75,9 +91,7 @@

filesAdapter: fsAdapter
})
});
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
//It is not recommended to do this on the production server, deploy a development server to complete the process.
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey();
const { rotated, notRotated } = await api.filesAdapter.rotateEncryptionKey();
console.log('Files rotated to newKey: ' + rotated);
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
console.log('Files that couldn\'t be rotated to newKey: ' + notRotated);
```

@@ -88,18 +102,24 @@

#### Files were previously encrypted with `oldKey` and you want to encrypt with `newKey`
The same process as above, but pass in your `oldKey` to `rotateEncryptionKey()`.
### Encrypting Previously Encrypted Files
To encrypt files with a new key that were previously encrypted with a different key, the same process applies as above, but you pass in your `oldKey` to `rotateEncryptionKey()`.
```javascript
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey});
console.log('Files rotated to newKey: ' + rotated);
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
console.log('Files that couldn\'t be rotated to newKey: ' + notRotated);
```
#### Only rotate a select list of files that were previously encrypted with `oldKey` and you want to encrypt with `newKey`
This is useful if for some reason there errors and some of the files werent rotated and returned in `notRotated`. The same process as above, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
You can also only rotate a select list of files that were previously encrypted with `oldKey` and you want to encrypt with `newKey`. This is useful if for some reason there errors and some of the files werent rotated and returned in `notRotated`. The same process as above, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
```javascript
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"]});
const { rotated, notRotated } = await api.filesAdapter.rotateEncryptionKey({ oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"] });
console.log('Files rotated to newKey: ' + rotated);
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
console.log('Files that couldn\'t be rotated to newKey: ' + notRotated);
```
# Other Considerations
- Multiple Instances of Parse Server
When using the adapter across multiple Parse Server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/receiving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using parse-server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All parse-server instances need to be able to read and write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.

@@ -22,3 +22,3 @@ 'use strict';

it('should create file location based on config', async function(done) {
it('should create file location based on config', async function () {
var fsAdapter = new FileSystemAdapter();

@@ -28,6 +28,5 @@ var config = {mount: '/parse', applicationId: 'yolo'}

expect(location).toBe('/parse/files/yolo/hello.txt');
done()
}, 5000)
it("should save encrypted file in default directory", async function(done) {
it("should save encrypted file in default directory", async function() {
var adapter = new FileSystemAdapter({

@@ -44,6 +43,5 @@ encryptionKey: '89E4AFF1-DFE4-4603-9574-BFA16BB446FD'

expect(data.toString('utf-8')).not.toEqual("hello world");
done()
}, 5000);
it("should save encrypted file in specified directory", async function(done) {
it("should save encrypted file in specified directory", async function() {
var adapter = new FileSystemAdapter({

@@ -61,6 +59,5 @@ filesSubDirectory: directory,

expect(data.toString('utf-8')).not.toEqual("hello world");
done()
}, 5000);
it("should save encrypted file in specified directory when directory starts with /", async function(done) {
it("should save encrypted file in specified directory when directory starts with /", async function() {
var adapter = new FileSystemAdapter({

@@ -78,6 +75,5 @@ filesSubDirectory: '/sub1/sub2',

expect(data.toString('utf-8')).not.toEqual("hello world");
done()
}, 5000);
it("should rotate key of all unencrypted files to encrypted files", async function(done) {
it("should rotate key of all unencrypted files to encrypted files", async function() {
const unEncryptedAdapter = new FileSystemAdapter({

@@ -123,6 +119,5 @@ filesSubDirectory: directory

expect(encryptedData2.toString('utf-8')).not.toEqual(unEncryptedData2);
done()
}, 5000);
it("should rotate key of all old encrypted files to files encrypted with a new key", async function(done) {
it("should rotate key of all old encrypted files to files encrypted with a new key", async function() {
const oldEncryptionKey = 'oldKeyThatILoved';

@@ -170,6 +165,5 @@ const oldEncryptedAdapter = new FileSystemAdapter({

expect(encryptedData2.toString('utf-8')).not.toEqual(oldEncryptedData2);
done()
}, 5000);
it("should rotate key of all old encrypted files to unencrypted files", async function(done) {
it("should rotate key of all old encrypted files to unencrypted files", async function() {
const oldEncryptionKey = 'oldKeyThatILoved';

@@ -216,6 +210,5 @@ const oldEncryptedAdapter = new FileSystemAdapter({

expect(encryptedData2.toString('utf-8')).not.toEqual(oldEncryptedData2);
done()
}, 5000);
it("should only encrypt specified fileNames with the new key", async function(done) {
it("should only encrypt specified fileNames with the new key", async function() {
const oldEncryptionKey = 'oldKeyThatILoved';

@@ -271,6 +264,5 @@ const oldEncryptedAdapter = new FileSystemAdapter({

expect(encryptedData2.toString('utf-8')).not.toEqual(oldEncryptedData2);
done()
}, 5000);
it("should return fileNames of those it can't encrypt with the new key", async function(done) {
it("should return fileNames of those it can't encrypt with the new key", async function() {
const oldEncryptionKey = 'oldKeyThatILoved';

@@ -330,4 +322,3 @@ const oldEncryptedAdapter = new FileSystemAdapter({

expect(encryptedData2.toString('utf-8')).not.toEqual(oldEncryptedData2);
done()
}, 5000);
})

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