Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,15 @@
**/common/temp
**/common/deploy
**/compose
node_modules
.git
.idea
.github
.vscode
Dockerfile
.dockerignore
docker-compose*

common/temp
dist
build
!./common/deploy
15 changes: 13 additions & 2 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
# syntax=docker/dockerfile:1

FROM node:16
FROM node:16 as fula-pack
ENV NODE_ENV=production


COPY ./ /opt/fula
WORKDIR /opt/fula

RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose --to @functionland/fula-client-react --to @functionland/box || true
RUN npm install -g @microsoft/rush && rush update && rush rebuild --verbose


FROM node:16 as examples
ENV NODE_ENV=production
ARG EXAMPLE_PATH

COPY --from=fula-pack /opt/fula /opt/fula
WORKDIR $EXAMPLE_PATH

RUN npm install

CMD npm start
35 changes: 35 additions & 0 deletions apps/box/CHANGELOG.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
{
"name": "@functionland/box",
"entries": [
{
"version": "0.6.4",
"tag": "@functionland/box_v0.6.4",
"date": "Tue, 10 May 2022 07:15:54 GMT",
"comments": {
"patch": [
{
"comment": "fix replication propagation"
}
]
}
},
{
"version": "0.6.3",
"tag": "@functionland/box_v0.6.3",
"date": "Tue, 10 May 2022 06:52:04 GMT",
"comments": {
"patch": [
{
"comment": "fix fatal error on box protocol implimention."
}
],
"dependency": [
{
"comment": "Updating dependency \"@functionland/file-protocol\" from `~0.3.5` to `~0.3.6`"
},
{
"comment": "Updating dependency \"@functionland/graph-protocol\" from `~0.2.1` to `~0.2.2`"
},
{
"comment": "Updating dependency \"async-later\" from `0.1.10` to `0.1.11`"
}
]
}
},
{
"version": "0.6.2",
"tag": "@functionland/box_v0.6.2",
Expand Down
16 changes: 15 additions & 1 deletion apps/box/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
# Change Log - @functionland/box

This log was last generated on Sun, 24 Apr 2022 09:20:16 GMT and should not be manually modified.
This log was last generated on Tue, 10 May 2022 07:15:54 GMT and should not be manually modified.

## 0.6.4
Tue, 10 May 2022 07:15:54 GMT

### Patches

- fix replication propagation

## 0.6.3
Tue, 10 May 2022 06:52:04 GMT

### Patches

- fix fatal error on box protocol implimention.

## 0.6.2
Sun, 24 Apr 2022 09:20:16 GMT
Expand Down
9 changes: 4 additions & 5 deletions apps/box/package.json
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/box",
"version": "0.6.2",
"version": "0.6.4",
"description": "Reference implementation of box server in Node.js",
"main": "dist/index.js",
"bin": "./cli.js",
Expand All@@ -27,10 +27,10 @@
"homepage": "https://github.com/functionland/fula#readme",
"dependencies": {
"@chainsafe/libp2p-noise": "~5.0.2",
"@functionland/file-protocol": "~0.3.5",
"@functionland/graph-protocol": "~0.2.1",
"@functionland/file-protocol": "~0.3.6",
"@functionland/graph-protocol": "~0.2.2",
"@ipld/dag-json": "~8.0.8",
"async-later": "0.1.10",
"async-later": "0.1.11",
"graphql": "16.3.0",
"graphql-tag": "2.12.6",
"graphql-tools": "8.2.0",
Expand DownExpand Up@@ -63,7 +63,6 @@
"@typescript-eslint/eslint-plugin": "~5.13.0",
"@typescript-eslint/parser": "~5.13.0",
"@web-std/file": "~3.0.2",
"build-helpers": "~0.0.1",
"debug": "~4.3.3",
"esbuild": "~0.14.25",
"esbuild-runner": "~2.2.1",
Expand Down
2 changes: 0 additions & 2 deletions apps/box/scripts/build.mjs
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
import { build } from 'esbuild';
import path from 'path';
import fs from 'fs';
import {clean} from 'build-helpers'

clean()
const packages = JSON.parse(
fs.readFileSync(path.resolve('./package.json'), { encoding: 'utf8' })
);
Expand Down
3 changes: 2 additions & 1 deletion apps/box/src/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ const getPeerId = async () => {
const identity = JSON.parse(fs.readFileSync(LIBP2P_PATH + '/identity.json'));
return await peerId.createFromJSON(identity)
} else {
let identity = await peerId.create()
const identity = await peerId.create()
fs.writeFileSync(LIBP2P_PATH + '/identity.json', JSON.stringify(identity.toJSON()))
return identity
}
Expand All@@ -28,6 +28,7 @@ const getNetSecret = ()=> {
if(config.get("network.key_path")===""){
return undefined
}
console.log("Private Mode Enabled")
const key = fs.readFileSync(config.get("network.key_path"))
return new Protector(key)
}
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/build-cache.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
*
* See https://rushjs.io/pages/maintainer/build_cache/ for details about this experimental feature.
*/
"buildCacheEnabled": false,
"buildCacheEnabled": true,

/**
* (Required) Choose where project build outputs will be cached.
Expand Down
41 changes: 22 additions & 19 deletions docker-compose.dev.yaml
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,35 +2,38 @@ version: '3.8'

services:
box:
build: .
build:
context: .
dockerfile: Dockerfile
target: fula-pack
working_dir: /opt/fula/apps/box
command: rushx start

react-cra:
build: .
working_dir: /opt/fula/examples/react-cra
command: rushx start

react-gallery:
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/gallery/simple/react-app
ports:
- 3000:3000
depends_on:
- box

react-todo-app:
build: .
working_dir: /opt/fula/examples/react-todo-app
build:
context: .
dockerfile: Dockerfile
target: examples
args:
EXAMPLE_PATH: /opt/fula/examples/react-todo-app
volumes:
- ./examples/react-todo-app/src:/opt/fula/examples/react-todo-app/src
command: rushx start
environment:
PORT: 3001
ports:
- 3001:3001

react-gallery:
build: .
working_dir: /opt/fula/examples/react-gallery
volumes:
- ./examples/react-gallery/src:/opt/fula/examples/react-gallery/src
command: rushx start
environment:
PORT: 3002
ports:
- 3002:3002
depends_on:
- box
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/doc-sync/fuludocs/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,17 +16,17 @@
"license": "ISC",
"devDependencies": {
"parcel": "^2.4.1",
"parcel-resolver-ignore": "^2.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1"
},
"dependencies": {
"@functionland/fula": "0.6.3",
"@functionland/fula": "../../../libraries/fula-client",
"markdown-it": "^12.3.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.3.1",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"wrtc": "^0.4.7"
"react-router-dom": "^6.3.0"
}
}
16 changes: 16 additions & 0 deletions examples/gallery/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
# Gallery
Galley is our example on how to use Fula for creating dApp.
Gallery has to part:
- react-app a simple gallery with upload feature.
- nodejs uploader for uploading some cool image of our Elephant to gallery.
## Simple
- How connect to Boxes
- How to upload/download Photos using File-API.
- How to use graphql to Store and Retrieve `JSON`.
## Private
- How to use pnet in react app and nodejs
## Fula-sec
- How to use fula DIDs
- How to encrypt and store Images.
- How to load and decrypt Images

24 changes: 24 additions & 0 deletions examples/gallery/fula-sec/react-app/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
# Gallery in react

It's a React web app that you can play with and learn:
- How Use @functionland/fula-sec, for create and importing DIDs.
- How to encrypt data and store it in Box with DID.
- How to retrieve data and decrypt it in Client with DID.

## Installation
Clone the repository and change to project directory
```bash
cd ./examples/gallery/fula-sec/react-app
npm install
```

## Usage

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
"react-scripts": "5.0.1",
"react-icons": "^4.3.1",
"web-vitals": "^2.1.4",
"@functionland/fula-sec":"^1.0.0",
"@functionland/fula-sec":"^0.6.3",
"@functionland/fula": "~0.6.4"
},
"devDependencies": {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,11 +31,6 @@ function App() {
// User DID
const [userDID, setDidObj] = useState(null);

// const createDID = async () => {
// const DID = new FulaDID();
// const didObj = await DID.create();
// console.log('didObj', didObj);
// };

useEffect(() => {
if (page === pages.GALLERY && status === Status.Online && fula) {
Expand DownExpand Up@@ -78,7 +73,7 @@ function App() {
}
})();
}
}, [page, status, fula, userDID.did]);
}, [page, status, fula, userDID?.did]);

const onSet = (peers, key_file) => {
if (peers.length > 0) {
Expand DownExpand Up@@ -149,7 +144,7 @@ function App() {

return <>
<div className="app">
<Identity onSetting={onDIDSet}/>
<Identity onDIDSet={onDIDSet}/>
{(() => {
switch (page) {
case pages.CONFIG:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
import React, { useState } from 'react';
// import { Status } from '@functionland/fula';
import { FulaDID } from '@functionland/fula-sec';

// import {
// IoCloudOfflineSharp,
// IoCloudSharp,
// IoBanSharp,
// IoSettingsSharp
// } from 'react-icons/io5';
export const Identity = ({ status, onSetting, info }) => {

export const Identity = ({onDIDSet}) => {
const [mode, setMode] = useState('None');
const [mnemonicText, setMnemonicText] = useState('');
const [importType, setImportType] = useState('Mnemonic');
Expand All@@ -23,7 +17,7 @@ export const Identity = ({ status, onSetting, info }) => {
didObj = await DID.importPrivateKey(mnemonicText);
}
setDidObj(didObj);
onSetting(DID)
onDIDSet(DID)
} catch (error) {
alert(error);
}
Expand Down
21 changes: 21 additions & 0 deletions examples/gallery/fula-sec/uploader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
# uploader

A command line interface for uploading file image for react-gallery

Execute the cmd passing in the path to the file you want upload.

## Install

```
> npm install
```

## Run

### Upload all file in folder

```
> node index.js -i [folder-path] --boxid [Box ID] -p
./swarm.key -u [Your Mnemonic]
```

Loading