-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
043d179
commit 4915957
Showing
15 changed files
with
1,313 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: client | ||
env: | ||
CI: true | ||
FORCE_COLOR: 1 | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- 'packages/client/**' | ||
- .github/workflows/client.yml | ||
- pnpm-lock.yaml | ||
pull_request: | ||
paths: | ||
- 'packages/client/**' | ||
- .github/workflows/client.yml | ||
- pnpm-lock.yaml | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: latest | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
cache: pnpm | ||
- run: pnpm install | ||
- run: pnpm run build | ||
- run: pnpm -r --filter @fission-codes/client run lint | ||
- run: pnpm -r --filter @fission-codes/client run test | ||
- run: pnpm -r --filter @fission-codes/client exec depcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"name": "@fission-codes/client", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"description": "Fission server client.", | ||
"author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)", | ||
"license": "MIT", | ||
"homepage": "https://github.com/fission-codes/stack/tree/main/packages/client", | ||
"repository": { | ||
"url": "fission-codes/stack", | ||
"directory": "packages/client" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"default": "./src/index.js" | ||
}, | ||
"./types": { | ||
"types": "./dist/src/types.d.ts" | ||
} | ||
}, | ||
"main": "src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
".": [ | ||
"dist/src/index" | ||
], | ||
"./types": [ | ||
"dist/src/types" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist/src/*.d.ts", | ||
"dist/src/*.d.ts.map" | ||
], | ||
"scripts": { | ||
"lint": "tsc --build && eslint . && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", | ||
"build": "tsc --build", | ||
"update-msw": "msw init test/mocks/ --save", | ||
"test": "pnpm run test:node && pnpm run test:browser", | ||
"test:node": "playwright-test 'test/**/!(*.browser).test.js' --mode node", | ||
"test:browser": "playwright-test 'test/**/!(*.node).test.js' --assets test/mocks" | ||
}, | ||
"dependencies": { | ||
"@fission-codes/ucan": "workspace:^", | ||
"iso-did": "^1.6.0", | ||
"iso-signatures": "^0.3.2", | ||
"iso-web": "^1.0.4", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
"@testcontainers/postgresql": "^10.6.0", | ||
"@types/node": "^20.11.15", | ||
"execa": "^8.0.1", | ||
"iso-websocket": "^0.2.0", | ||
"msw": "^2.1.5", | ||
"p-defer": "^4.0.0", | ||
"p-wait-for": "^5.0.2", | ||
"playwright-test": "^14.1.0", | ||
"tempy": "^3.1.0", | ||
"testcontainers": "^10.6.0", | ||
"type-fest": "^4.10.2" | ||
}, | ||
"publishConfig": { | ||
"provenance": true | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"@fission-codes" | ||
], | ||
"env": { | ||
"mocha": true | ||
}, | ||
"ignorePatterns": [ | ||
"dist" | ||
] | ||
}, | ||
"depcheck": { | ||
"specials": [ | ||
"bin" | ||
], | ||
"ignores": [ | ||
"@types/*" | ||
] | ||
}, | ||
"msw": { | ||
"workerDirectory": [ | ||
"test/mocks" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import path from 'path' | ||
import fs from 'fs/promises' | ||
import { fileURLToPath } from 'url' | ||
import { PostgreSqlContainer } from '@testcontainers/postgresql' | ||
import { execa } from 'execa' | ||
import { request } from 'iso-web/http' | ||
import { temporaryDirectory } from 'tempy' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
/** | ||
* Build a config file for the server | ||
* | ||
* @param {string} dbURL | ||
* @param {string} keypairPath | ||
*/ | ||
function serverConfig(dbURL, keypairPath) { | ||
return ` | ||
[database] | ||
url = "${dbURL}" | ||
connect_timeout = 3 | ||
[healthcheck] | ||
enabled = false | ||
interval_ms = 5000 | ||
max_retries = 3 | ||
[ipfs] | ||
peers = [ | ||
"/ip4/127.0.0.1/tcp/4002/ws/p2p/12D3KooWLXH5BFzscChpdjtotAvv94hDR6bVxMKLHBHrSnugCRWs", | ||
"/ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/uEiC4_sAMUfcxEJtqIlVWRGlHrTSSYuyk5Ulqfl6CjRiOHw/certhash/uEiANUHX9dRBqphQzZINo5WzkStJ7qevCr_2ZAUzLEbqoFw/p2p/12D3KooWLXH5BFzscChpdjtotAvv94hDR6bVxMKLHBHrSnugCRWs" | ||
] | ||
[mailgun] | ||
api_key = 0 | ||
sender_address = "noreply@mail.fission.codes" | ||
sender_name = "Fission" | ||
domain = "mail.fission.codes" | ||
subject = "Your Fission Verification Code" | ||
from_address = "noreply@mail.fission.codes" | ||
from_name = "Fission" | ||
template = "test-email-verification" | ||
[monitoring] | ||
process_collector_interval = 10 | ||
[otel] | ||
exporter_otlp_endpoint = "http://localhost:4317" | ||
[dns] | ||
server_port = 1053 | ||
default_soa = "dns1.fission.systems hostmaster.fission.codes 0 10800 3600 604800 3600" | ||
default_ttl = 1800 | ||
origin = "localhost" | ||
users_origin = "localhost" | ||
[server] | ||
environment = "local" | ||
keypair_path = "${keypairPath}" | ||
metrics_port = 4000 | ||
port = 3000 | ||
timeout_ms = 30000 | ||
` | ||
} | ||
|
||
/** | ||
* @type {import('@testcontainers/postgresql').StartedPostgreSqlContainer}')} | ||
*/ | ||
let container | ||
|
||
/** | ||
* @type {import('execa').ExecaChildProcess}')} | ||
*/ | ||
let server | ||
|
||
/** | ||
* @param {import('playwright-test').RunnerOptions} config | ||
* @returns {import('playwright-test').RunnerOptions} | ||
*/ | ||
function buildConfig(config) { | ||
return { | ||
buildConfig: { | ||
// bundle: config.mode !== 'node', | ||
}, | ||
async beforeTests(env) { | ||
container = await new PostgreSqlContainer().start() | ||
const dir = temporaryDirectory() | ||
const dbURL = container.getConnectionUri() | ||
const keypairPath = `${dir}/server.ed25519.pem` | ||
const settingsPath = `${dir}/settings.toml` | ||
|
||
await fs.writeFile(settingsPath, serverConfig(dbURL, keypairPath)) | ||
|
||
server = execa( | ||
path.join(__dirname, 'test/mocks/fission-server'), | ||
[ | ||
'--ephemeral-db', | ||
'--close-on-stdin-close', | ||
'--gen-key-if-needed', | ||
'--config-path', | ||
settingsPath, | ||
], | ||
{ | ||
// env: { | ||
// RUST_LOG: 'none', | ||
// }, | ||
// stdio: 'pipe', | ||
} | ||
) | ||
// server.stderr.on('data', (data) => { | ||
// console.error(data.toString()) | ||
// }) | ||
|
||
// server.stdout.on('data', (data) => { | ||
// console.log(data.toString()) | ||
// }) | ||
|
||
const { error } = await request.json( | ||
'http://localhost:3000/healthcheck', | ||
{ | ||
retry: { | ||
retries: 10, | ||
}, | ||
} | ||
) | ||
|
||
if (error) { | ||
throw error | ||
} | ||
|
||
env.SERVER_URL = 'http://localhost:3000' | ||
}, | ||
|
||
async afterTests() { | ||
await container.stop() | ||
|
||
server.kill() | ||
// server.kill() | ||
}, | ||
} | ||
} | ||
|
||
export default buildConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Fission server client | ||
|
||
[![npm (scoped)](https://img.shields.io/npm/v/%40fission-codes/client)](https://www.npmjs.com/package/@fission-codes/client) | ||
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/fission-codes/stack/client.yml)](https://github.com/fission-codes/stack/actions/workflows/client.yml) | ||
[![Built by FISSION](https://img.shields.io/badge/built_by-⌘_Fission-purple.svg)](https://fission.codes) | ||
[![Discord](https://img.shields.io/discord/478735028319158273?&color=mediumslateblue)](https://discord.gg/zAQBDEq) | ||
[![Discourse users](<https://img.shields.io/discourse/users?server=https%3A%2F%2Ftalk.fission.codes&label=talk&color=rgb(14%2C%20118%2C%20178)>)](https://talk.fission.codes) | ||
|
||
## Installation | ||
|
||
```bash | ||
pnpm install @fission-codes/client | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { Client } from '@fission-codes/client' | ||
import { EdDSASigner } from 'iso-signatures/signers/eddsa.js' | ||
|
||
const ucan = await UCAN.create({ | ||
issuer: signer, | ||
audience: audience.did, | ||
capabilities: { 'ucan:*': { '*': [{}] } }, | ||
}) | ||
``` | ||
|
||
## Docs | ||
|
||
Check <https://fission-codes.github.io/stack> | ||
|
||
## Fission server | ||
|
||
```bash | ||
cargo build -p fission-server --release --target aarch64-apple-darwin | ||
./fission-server --config-path ./config/settings.toml --ephemeral-db | ||
|
||
|
||
``` | ||
|
||
## Contributing | ||
|
||
Read contributing guidelines [here](.github/CONTRIBUTING.md). | ||
|
||
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/fission-codes/stack) | ||
|
||
## License | ||
|
||
This project is licensed under either of | ||
|
||
- Apache License, Version 2.0, ([LICENSE-APACHE](./LICENSE-APACHE) or | ||
[http://www.apache.org/licenses/LICENSE-2.0][apache]) | ||
- MIT license ([LICENSE-MIT](./LICENSE-MIT) or | ||
[http://opensource.org/licenses/MIT][mit]) | ||
|
||
at your option. | ||
|
||
### Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally | ||
submitted for inclusion in the work by you, as defined in the Apache-2.0 | ||
license, shall be dual licensed as above, without any additional terms or | ||
conditions. | ||
|
||
[apache]: https://www.apache.org/licenses/LICENSE-2.0 | ||
[mit]: http://opensource.org/licenses/MIT |
Oops, something went wrong.