diff --git a/README.md b/README.md index 7c1ec3b..793b306 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,11 @@ This module: var SecretStack = require('secret-stack') var databasePlugin = require('./some-database') var bluetoothPlugin = require('./bluetooth') -var config = require('./some-config') +const ssbKeys = require('ssb-keys') +var keys = ssbKeys.loadOrCreateSync(path.join(__dirname, 'secret')) + +// keys are necessary for multiserver address +var config = { keys } var App = SecretStack({ appKey: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=' }) .use(databasePlugin) diff --git a/example.js b/example.js new file mode 100644 index 0000000..bf96414 --- /dev/null +++ b/example.js @@ -0,0 +1,45 @@ +const SecretStack = require('./lib') +const ssbKeys = require('ssb-keys') +const S = require('pull-stream') +const path = require('path') +var keys = ssbKeys.loadOrCreateSync(path.join(__dirname, 'secret')) + +var myPlugin = { + name: 'myPlugin', + version: '0.0.0', + manifest: { + foo: 'async', + bar: 'source' + }, + + init: (api, opts) => { + // .. do things + + // console.log('api', api) + // console.log('opts', opts) + + // return things promised by the manifest: + return { + foo: function (cb) { // an async function (takes a callback) + process.nextTick(() => { + cb(null, 'foo') + }) + }, + + bar: function () { // a function which returns a pull-stream source + return S.values([1,2,3]) + } + } + } +} + +var App = SecretStack({ + appKey: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', + permissions: {} +}) + .use(myPlugin) + +var app = App({ keys }) +// var app = App({}) + +console.log('address', app.getAddress()) diff --git a/package.json b/package.json index e890d51..05f11d7 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "muxrpc": "^6.5.2", "pull-inactivity": "~2.1.1", "pull-rate": "^1.0.2", - "pull-stream": "^3.4.5", + "pull-stream": "^3.6.14", "to-camel-case": "^1.0.0" }, "engines": { @@ -29,9 +29,9 @@ "@types/node": "^12.12.2", "@typescript-eslint/eslint-plugin": "^5.13.0", "@typescript-eslint/parser": "^5.13.0", + "mkdirp": "~1.0.4", "pull-pushable": "^2.0.1", "ssb-keys": "^8.2.0", - "mkdirp": "~1.0.4", "standardx": "^7.0.0", "tape": "^5.5.2", "typescript": "~4.5.0" diff --git a/secret b/secret new file mode 100644 index 0000000..4b06335 --- /dev/null +++ b/secret @@ -0,0 +1,20 @@ +# WARNING: Never show this to anyone. +# WARNING: Never edit it or use it on multiple devices at once. +# +# This is your SECRET, it gives you magical powers. With your secret you can +# sign your messages so that your friends can verify that the messages came +# from you. If anyone learns your secret, they can use it to impersonate you. +# +# If you use this secret on more than one device you will create a fork and +# your friends will stop replicating your content. +# +{ + "curve": "ed25519", + "public": "QoTBm8zpeGFuwHC6M1urxgvjSprK+g2trWt6/hahMUY=.ed25519", + "private": "1UIxX/PBATjEw1D8OEoO6W+Y5jfH5aFmX7NhncwrDABChMGbzOl4YW7AcLozW6vGC+NKmsr6Da2ta3r+FqExRg==.ed25519", + "id": "@QoTBm8zpeGFuwHC6M1urxgvjSprK+g2trWt6/hahMUY=.ed25519" +} +# +# The only part of this file that's safe to share is your public name: +# +# @QoTBm8zpeGFuwHC6M1urxgvjSprK+g2trWt6/hahMUY=.ed25519 \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index b305d5b..3c6602c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,4 +21,4 @@ "esModuleInterop": false }, "exclude": ["node_modules", "test", "lib"] -} \ No newline at end of file +}