This is an example on how to run a PKSA in service mode
- Clone this repository
- Make sure you have latest LTS or greater version of Node JS installed
- Go inside the cloned folder and type
npm install
- Rename
storage.example.json
tostorage.json
and update it to fit your needs (see below). - Rename
keys.example.json
tokeys.json
and update it to fit your needs (see below)
The storage.json
file is where the PKSA will store its configuration, the accounts it manages and their access tokens.
Structure
{
"pksa_name": string
"auth_req_secret": string (optional)
"auth_req_approve": boolean
"auth_req_reject": boolean
"token_timeout_days": number
"accounts": [
{
"name": "string"
"auths": [
{
"token": string
"expire": number
"key": string
"app": string
}
]
},
{ ... }
]
}
pksa_name
: the PKSA nameencryption secret used to encrypt/decrypt theauth_key
when an app send it with itsauth_req
. Should be defined only if the PKSA runs in "service mode"auth_req_secret
: the PKSA encryption secret used to encrypt/decrypt theauth_key
when an app send it with itsauth_req
. Should be defined only if the PKSA runs in "service mode"auth_req_approve
: if set to true, the PKSA will automatically approve authentication requests and create new tokens for the managed accounts. It should be left to false for secury reasons.auth_req_reject
: if set to true, the PKSA will automatically reply with anauth_nack
to any incomingauth_req
, preventing any other PKSA to approve them.sign_req_reject
: if set to true, the PKSA will automatically reply with ansign_nack
to any incomingsign_req
, preventing any other PKSA to approve them.challenge_req_reject
: if set to true, the PKSA will automatically reply with achallenge_nack
to any incomingchallenge_req
, preventing any other PKSA to approve them.token_timeout_days
: (optional) the number of days before an app token expires. The default value if not present is 1 day.accounts
: an array of account objects for each account managed by the PKSAname
: Hive usernameauths
: an array of auth objects for each access token createdtoken
: the access token (usually a uuid)expire
: UNIX time when the token expirekey
: the symetric encryption key used to enrypt communication between the App and the PKSA, usually a uuid (encryption key should be unique per session)app
: any string that identify the app (example: "peakd.com")
Example
{
"pksa_name": "MyPKSA",
"auth_req_secret": "A.v3ry-$tr0nG/And>$3cUr3.$3Cr3t-K3Y",
"auth_req_approve": false,
"auth_req_reject": false,
"sign_req_reject": false,
"challenge_req_reject": false,
"token_timeout_days": 1,
"accounts": [
{
"name": "account1",
"auths": [
{
"token": "82b31850-00e0-40b4-a8a5-64a2ad8a43ff",
"expire": 1634590013188,
"key": "45e9e195-b5d1-47f4-bc74-ce1da747424e",
"app": "peakd.com"
},
{
"token": "0c0eeeca-88a5-48b0-ab93-d90320baa1a2",
"expire": 1634591331195,
"key": "ed880eee-f354-41a2-84bb-ef08f18c891a",
"app": "peakd-mobile"
}
]
},
{
"name": "account2",
"auths": [
{
"token": "82b31850-00e0-40b4-a8a5-64a2ad8a9876",
"expire": 1634590013188,
"key": "45e9e195-b5d1-47f4-bc74-ce1da7471a2e",
"app": "peakd.com"
},
{
"token": "0c0eeeca-88a5-48b0-ab93-d90320ba9b6f",
"expire": 1634591331195,
"key": "ed880eee-f354-41a2-84bb-ef08f18c8899",
"app": "splinterlands"
}
]
}
]
}
The keys.json
file is where the private keys of the Hive accounts managed by the PKSA are stored.
Structure
[
{
"name": string,
"posting": string,
"active": string ,
"memo": string
},
{ ... }
]
name
: the hive account usernameposting
: (optional) the account posting private keyactive
: (optional) the account active private keymemo
: (optional) the account memo private key
Example
[
{
"name": "user1",
"posting": "5...",
"active": "5..."
},
{
"name": "user2",
"posting": "5...",
"memo": "5..."
}
]
To run the app continuously in background, you can use use PM2.
Generate ecosystem.config.js
file with pm2 init
command.
When you are done start the PKSA with following command.
pm2 start ecosystem.config.js --env production
If you have any suggestions or want to report bugs, please create an issue.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.