minor improvements

This commit is contained in:
pablof7z
2023-06-28 21:44:39 +02:00
parent f949c116db
commit db0c9ae3fb
6 changed files with 40 additions and 25 deletions

View File

@@ -1,15 +1,19 @@
FROM --platform=linux/amd64 node:19 as build
FROM --platform=linux/amd64 node:19-buster-slim as build
WORKDIR /app
COPY package.json package-lock.json .
RUN npm i
COPY src/ src/
COPY prisma/ prisma/
COPY prisma/schema.prisma prisma/
COPY tsconfig.json .
RUN apt-get update -y && apt-get install -y openssl
RUN npm run build
RUN npx prisma generate
RUN npx prisma migrate deploy
ENTRYPOINT [ "node", "dist/index.js" ]
CMD ["start"]

View File

@@ -5,8 +5,21 @@ Daemon to remotely sign nostr events using keys.
To quickly install `nsecbunkerd` via Docker just run:
### Prepare your config directory
```
docker run -d --name nsecbunkerd pablof7z/nsecbunkerd start --admin <your-npub>
mkdir $HOME/.nsecbunker-config
```
### Start nsecbunkerd
```
docker run -d --name nsecbunkerd -v $HOME/.nsecbunker-config:/app/config pablof7z/nsecbunkerd start --admin <your-npub>
docker exec -i nsecbunkerd npx prisma db push
```
### Get the connection string
```
docker exec nsecbunkerd cat /app/connection.txt
```
nsecBunker will give you a connection string like:
@@ -15,7 +28,8 @@ nsecBunker will give you a connection string like:
bunker://npub1tj2dmc4udvgafxxxxxxxrtgne8j8l6rgrnaykzc8sys9mzfcz@relay.nsecbunker.com
```
You can visit https://app.nsecbunker.com/ to administrate your nsecBunker remotely.
You can visit https://app.nsecbunker.com/ to administrate your nsecBunker remotely, or explore `nsecbunkerd`'s CLI
to find the options to add and approve keys from the CLI.
## Hard setup:
(If you installed via docker you don't need to do any of this, skip to the [Configure](#configure) section)

View File

@@ -1,6 +1,6 @@
{
"name": "nsecbunkerd",
"version": "0.6.2",
"version": "0.6.4",
"description": "nsecbunker daemon",
"main": "dist/index.js",
"bin": {
@@ -16,7 +16,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/sanity-island/nsecbunker"
"url": "https://github.com/kind-0/nsecbunkerd"
},
"scripts": {
"build": "tsc",

View File

@@ -1,40 +1,36 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./nsecbunker.db"
url = "file:../config/nsecbunker.db"
}
model KeyUser {
id Int @id @default(autoincrement())
keyName String
userPubkey String
description String?
signingConditions SigningCondition[]
logs Log[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
lastUsedAt DateTime?
description String?
logs Log[]
signingConditions SigningCondition[]
Token Token[]
@@unique([keyName, userPubkey], name: "unique_key_user")
}
model SigningCondition {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
method String?
kind String?
content String?
keyUserKeyName String?
allowed Boolean?
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
keyUserId Int?
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
}
model Log {
@@ -43,18 +39,18 @@ model Log {
type String
method String?
params String?
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
keyUserId Int?
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
}
model Policy {
id Int @id @default(autoincrement())
name String
description String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
deletedAt DateTime?
expiresAt DateTime?
deletedAt DateTime?
description String?
rules PolicyRule[]
Token Token[]
}
@@ -65,9 +61,8 @@ model PolicyRule {
kind String?
maxUsageCount Int?
currentUsageCount Int?
Policy Policy? @relation(fields: [policyId], references: [id])
policyId Int?
policyId Int?
Policy Policy? @relation(fields: [policyId], references: [id])
}
model Token {
@@ -81,8 +76,8 @@ model Token {
deletedAt DateTime?
expiresAt DateTime?
redeemedAt DateTime?
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
keyUserId Int?
policy Policy? @relation(fields: [policyId], references: [id])
policyId Int?
policy Policy? @relation(fields: [policyId], references: [id])
KeyUser KeyUser? @relation(fields: [keyUserId], references: [id])
}

View File

@@ -38,6 +38,8 @@ function getKeys(config: DaemonConfig) {
const key = {
name,
npub: user.npub,
userCount: await prisma.keyUser.count({ where: { keyName: name } }),
tokenCount: await prisma.token.count({ where: { keyName: name } })
};
lockedKeyNames = lockedKeyNames.filter((keyName) => keyName !== name);

View File

@@ -68,7 +68,7 @@ const argv = yargs(hideBin(process.argv))
alias: 'c',
type: 'string',
description: 'Path to config file',
default: 'nsecbunker.json',
default: 'config/nsecbunker.json',
},
})
.demandCommand(0, 1)