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

jupiter-fs

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupiter-fs - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

2

package.json
{
"name": "jupiter-fs",
"version": "0.0.10",
"version": "0.0.11",
"description": "A small file system implementation for the Jupiter blockchain.",

@@ -5,0 +5,0 @@ "main": "./dist/JupiterFs.js",

import assert from 'assert'
import fs from 'fs'
import path from 'path'
import { v1 as uuidv1 } from 'uuid'
import JupiterFs from './JupiterFs'

@@ -12,10 +13,17 @@

describe('JupiterFs', function() {
this.timeout(5000)
this.timeout(10000)
assert(process.env.JUPITER_ADDRESS, 'JUPITER_ADDRESS env variable is not set')
assert(
process.env.JUPITER_PASSPHRASE,
'JUPITER_PASSPHRASE env variable is not set'
)
// const fs = JupiterFs({ server: 'http://localhost:7876' })
const jupFs = JupiterFs({
server: 'https://jpr4.gojupiter.tech',
address: '',
passphrase: '',
server: process.env.JUPITER_SERVER || 'https://jpr4.gojupiter.tech',
address: process.env.JUPITER_ADDRESS,
passphrase: process.env.JUPITER_PASSPHRASE,
})
const testFilename = `${uuidv1()}.js`

@@ -32,3 +40,2 @@ describe('#newBinaryAddress()', function() {

const addy = await jupFs.getOrCreateBinaryAddress()
// console.log('ADDY', addy)
assert.strictEqual(typeof addy.address === 'string', true)

@@ -41,3 +48,2 @@ })

const files = await jupFs.ls()
// console.log('FILES', files)
assert.strictEqual(files instanceof Array, true)

@@ -48,4 +54,2 @@ })

describe('#writeFile()', function() {
this.timeout(10000)
it(`should write a file to a jupiter account without error`, async () => {

@@ -56,8 +60,4 @@ const fileData = await fs.promises.readFile(

)
const res = await jupFs.writeFile(
'JupiterFs.ts',
fileData,
(err: Error) => console.error(`Error writing file`, err)
)
assert.strictEqual(res.fileName, 'JupiterFs.ts')
const res = await jupFs.writeFile(testFilename, fileData, assert.fail)
assert.strictEqual(res.fileName, testFilename)
assert.strictEqual(res.txns.length > 0, true)

@@ -69,11 +69,12 @@ })

it(`should get the binary data for a file specified`, async () => {
const fileData = await jupFs.getFile({ name: `JupiterFs.ts` })
await fs.promises.writeFile(
const fileData = await jupFs.getFile({ name: testFilename })
const origFileData = await fs.promises.readFile(
path.join(__dirname, 'JupiterFs.ts'),
fileData
'utf-8'
)
assert.strictEqual(fileData instanceof Buffer, true)
assert.strictEqual(fileData.length > 0, true)
assert.strictEqual(origFileData, fileData.toString('utf-8'))
})
})
})

@@ -196,2 +196,3 @@ import assert from 'assert'

await this.getOrCreateBinaryAddress()
const unconfTxns = await this.binaryClient.getAllUnconfirmedTransactions()
const files = await this.ls()

@@ -208,20 +209,33 @@ const targetFile = files.find(

): Promise<string[]> => {
const getBase64Chunk = async (decryptedMessage: string) => {
const jsonWithData = await this.binaryClient.decrypt(decryptedMessage)
const base64Chunk = JSON.parse(jsonWithData).data
if (readableStream)
readableStream.push(Buffer.from(base64Chunk, 'base64'))
return base64Chunk
}
const allBase64Strings: string[] = await Promise.all(
dataTxns.map(async (txnId: string) => {
const { data } = await this.binaryClient.request('post', '/nxt', {
params: {
requestType: 'readMessage',
secretPhrase: encryptSecret || this.binaryClient.passphrase,
transaction: txnId,
},
})
if (data.errorCode > 0) throw new Error(JSON.stringify(data))
const jsonWithData = await this.binaryClient.decrypt(
data.decryptedMessage
)
try {
const { data } = await this.binaryClient.request('post', '/nxt', {
params: {
requestType: 'readMessage',
secretPhrase: encryptSecret || this.binaryClient.passphrase,
transaction: txnId,
},
})
if (data.errorCode > 0) throw new Error(JSON.stringify(data))
return await getBase64Chunk(data.decryptedMessage)
} catch (err) {
const txn = unconfTxns.find(
(txn: any) => txn.transaction === txnId
)
if (!txn) throw new Error(`target file was not found`)
const base64Chunk = JSON.parse(jsonWithData).data
if (readableStream)
readableStream.push(Buffer.from(base64Chunk, 'base64'))
return base64Chunk
const decryptedMessage = await this.binaryClient.decryptRecord(
txn.attachment.encryptedMessage
)
return await getBase64Chunk(decryptedMessage)
}
})

@@ -228,0 +242,0 @@ )

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