Skip to content

Commit 41fefd3

Browse files
authored
fix: update markdown linter
1 parent ad49bd4 commit 41fefd3

File tree

9 files changed

+896
-513
lines changed

9 files changed

+896
-513
lines changed

design/api.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# API Design <!-- omit from toc -->
2+
3+
Table of Contents
4+
5+
- [Overview](#overview)
6+
- [@fission/auth](#fissionauth)
7+
- [API](#api)
8+
- [Notes](#notes)
9+
- [Identifier Providers](#identifier-providers)
10+
- [Types](#types)
11+
- [Fission Client](#fission-client)
12+
- [Agent](#agent)
13+
- [Channels](#channels)
14+
- [Auth Protocol](#auth-protocol)
15+
- [@fission/data](#fissiondata)
16+
- [Notes](#notes-1)
17+
- [@fission/compute](#fissioncompute)
18+
- [Ucan Protocol](#ucan-protocol)
19+
20+
## Overview
21+
22+
![Alt text](architecture.excalidraw.svg)
23+
24+
## @fission/auth
25+
26+
### API
27+
28+
```ts
29+
export type AuthResponse<R> =
30+
| {
31+
error: undefined
32+
result: R
33+
}
34+
| {
35+
error: Error
36+
result: undefined
37+
}
38+
39+
interface RegisterCredentials {
40+
username: string
41+
email: string
42+
options: {
43+
emailRedirectUrl?: string
44+
}
45+
}
46+
interface Credentials {
47+
username: string
48+
}
49+
50+
interface Account {
51+
did: string
52+
username: string
53+
email: string
54+
}
55+
56+
interface Session {
57+
agent: Agent
58+
account: Account
59+
expiresAt: number
60+
identifierDelegation: Ucan
61+
accountDelegation: Ucan
62+
}
63+
64+
interface AuthConfig {
65+
name?: string // defaults to origin
66+
debug?: boolean
67+
identifier: IdentifierProvider
68+
agent: Agent // Handles signatures, dids, ucans and storage
69+
client: FissionClient // Handles server requests should be a generic client for a Auth UCAN Protocol
70+
}
71+
72+
declare class Auth {
73+
constructor(config: AuthConfig)
74+
}
75+
76+
interface IAuth {
77+
new (config: AuthConfig): Auth
78+
/**
79+
* Trigger an email flow to register a user
80+
* Signs a Register UCAN with an Identifier
81+
*/
82+
register(credentials: RegisterCredentials): Promise<
83+
AuthResponse<{
84+
account: Account
85+
}>
86+
>
87+
88+
/**
89+
* Used to exchange a code from an email link for a session
90+
*/
91+
exchangeCodeForSession(code: string): Promise<
92+
AuthResponse<{
93+
session: Session
94+
account: Account
95+
}>
96+
>
97+
98+
/**
99+
* Requests an Identifier Delegation and IF NEEDED Server Delegations
100+
*
101+
* Should we control Session TTL with Identifier Delegation exp and/or Server Delegation exp?
102+
*/
103+
login(credentials: Credentials): Promise<
104+
AuthResponse<{
105+
session: Session
106+
account: Account
107+
}>
108+
>
109+
110+
/**
111+
* Delete Identifier and server Delegations
112+
*
113+
* Should we delete all agent data as well?
114+
*/
115+
logout(session: Session): Promise<void>
116+
117+
/**
118+
* Subscribe to auth state changes
119+
*/
120+
onStateChange(
121+
cb: (
122+
state: 'Login' | 'Logout' | 'Register' | 'Expired',
123+
session: null | Session
124+
) => void
125+
): UnsubscribeFn
126+
}
127+
```
128+
129+
### Notes
130+
131+
- Should keep tabs in sync when in browser
132+
- Revocation api ?
133+
134+
### Identifier Providers
135+
136+
Providers SHOULD:
137+
138+
- Depend only on UCAN (did:key, signer) and optionally on a [channel](#channels). They can have other dependencies but they should be environment specific. They SHOULD NOT depend on an [Agent](#agent).
139+
- Be able to receive a DID and a set of capabilities and return a powerbox style UCAN with those capabilities.
140+
- Be able to send a root delegation over a [channel](#channels) to another device or origin. (see [Delegated](#types))
141+
142+
A powerbox style delegation to an Agent should be treated as a Session.
143+
144+
#### Types
145+
146+
- Local: Only exists on device normally sandboxed to an origin (webcrypto, wallet, metamask snap and local passkeys)
147+
- Synced: Exists on device and is synced with a server (synced passkey)
148+
- Remote: The identifier lives in another device or origin and it needs a [channel](#channels) (websocket, MessageChannel) to request capabilities and receive UCANs. An example could be a personal lobby or a mobile app (wallet).
149+
- Delegated: The identifier has a wildcard delegation from a Remote Identifier Provider. Does NOT have the root keypair just a root delegation. This is useful for Phase 0 device link with QR Code. (same as local but with a wildcard delegation)
150+
151+
### Fission Client
152+
153+
Client SHOULD only handle HTTP logic, it should receive UCAN delegations, set bearer tokens according to [Spec](https://github.com/ucan-wg/ucan-http-bearer-token) and handle HTTP requests.
154+
155+
In the future this SHOULD be a generic UCAN-RPC client that can be used for any UCAN-RPC protocol, given a set of Capabilities.
156+
157+
### Agent
158+
159+
DID, UCAN, Storage and Channels
160+
161+
- Depends on a Identifier Provider, DID resolver, Signer, Storage and Channels
162+
- Should provide persistent storage for UCANs and other data
163+
- Should provide Agent to Agent communication (see [Channels](#channels)), e.g., to sync WNFS keys
164+
- Should be able to delegate UCANs to other Agents.
165+
166+
### Channels
167+
168+
- pairing mechanics (qr-code, deep-link, shared id, etc)
169+
- transport (websocket, MessageChannel)
170+
- encryption (AWAKE MLS)
171+
172+
Comms channel SHOULD a have a generic implementation that can be reused.
173+
174+
### Auth Protocol
175+
176+
Set of UCAN capabilities necessary for Identifier -> Agent -> Server communication
177+
178+
Agent SHOULD only ask Identifier for capabilities it needs NOT wildcard delegation.
179+
180+
## @fission/data
181+
182+
WNFS
183+
184+
### Notes
185+
186+
- Needs to sync keys, we already have device link in auth, we should have a generic and safe comms channel implementation that can be reused or provided by the agent.
187+
-
188+
189+
## @fission/compute
190+
191+
IPVM
192+
193+
## Ucan Protocol

design/architecture.excalidraw.svg

Lines changed: 17 additions & 0 deletions
Loading

examples/demo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"package1": "*"
1919
},
2020
"devDependencies": {
21-
"@babel/core": "^7.23.0",
22-
"@types/node": "^20.7.0",
23-
"hd-scripts": "^9.0.4",
21+
"@babel/core": "^7.23.2",
22+
"@types/node": "^20.8.9",
23+
"hd-scripts": "^9.0.6",
2424
"typescript": "5.2.2",
25-
"vite": "^4.4.9"
25+
"vite": "^4.5.0"
2626
},
2727
"eslintConfig": {
2828
"extends": [

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
},
2323
"devDependencies": {
2424
"@fission-codes/eslint-config": "workspace:^",
25-
"depcheck": "^1.4.6",
26-
"lint-staged": "^14.0.1",
25+
"depcheck": "^1.4.7",
26+
"lint-staged": "^15.0.2",
2727
"prettier": "3.0.3",
2828
"simple-git-hooks": "^2.9.0",
29-
"typedoc": "^0.25.1",
29+
"typedoc": "^0.25.2",
3030
"typedoc-plugin-missing-exports": "^2.1.0",
3131
"typedoc-plugin-zod": "^1.1.0",
3232
"typescript": "5.2.2"

packages/eslint-config/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,33 @@
2424
"test": "mocha 'test/**/*.test.js' --timeout 10000"
2525
},
2626
"dependencies": {
27-
"@typescript-eslint/eslint-plugin": "^6.7.3",
28-
"@typescript-eslint/parser": "^6.7.3",
29-
"eslint": "^8.50.0",
27+
"@typescript-eslint/eslint-plugin": "^6.9.0",
28+
"@typescript-eslint/parser": "^6.9.0",
29+
"eslint": "^8.52.0",
3030
"eslint-config-prettier": "^9.0.0",
3131
"eslint-config-standard": "^17.1.0",
32-
"eslint-config-standard-with-typescript": "^39.1.0",
32+
"eslint-config-standard-with-typescript": "^39.1.1",
3333
"eslint-plugin-eslint-comments": "^3.2.0",
3434
"eslint-plugin-etc": "^2.0.3",
3535
"eslint-plugin-html": "^7.1.0",
36-
"eslint-plugin-import": "^2.28.1",
36+
"eslint-plugin-import": "^2.29.0",
3737
"eslint-plugin-jsdoc": "^46.8.2",
38-
"eslint-plugin-jsonc": "^2.9.0",
38+
"eslint-plugin-jsonc": "^2.10.0",
3939
"eslint-plugin-markdown": "^3.0.1",
40-
"eslint-plugin-n": "^16.1.0",
40+
"eslint-plugin-n": "^16.2.0",
4141
"eslint-plugin-no-only-tests": "^3.1.0",
4242
"eslint-plugin-promise": "^6.1.1",
4343
"eslint-plugin-react": "^7.33.2",
4444
"eslint-plugin-react-hooks": "^4.6.0",
4545
"eslint-plugin-unicorn": "^48.0.1",
46-
"eslint-plugin-yml": "^1.9.0",
46+
"eslint-plugin-yml": "^1.10.0",
4747
"typescript": "^5.2.2"
4848
},
4949
"devDependencies": {
50-
"@types/assert": "^1.5.7",
51-
"@types/eslint": "^8.44.3",
52-
"@types/mocha": "^10.0.1",
53-
"@types/node": "^20.7.0",
50+
"@types/assert": "^1.5.8",
51+
"@types/eslint": "^8.44.6",
52+
"@types/mocha": "^10.0.3",
53+
"@types/node": "^20.8.9",
5454
"assert": "^2.1.0",
5555
"mocha": "^10.2.0"
5656
},

packages/eslint-config/readme.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,16 @@ pnpm install @fission-codes/eslint-config
5555
"extends": "@fission-codes/eslint-config/tsconfig.json",
5656
"compilerOptions": {
5757
"outDir": "dist",
58-
"emitDeclarationOnly": true
58+
"noEmit": true, // for apps or anything that is not published to npm
59+
"emitDeclarationOnly": true, // for TS with JSDocs
60+
"module": "NodeNext", // for TS packages
61+
"moduleResolution": "NodeNext" // for TS packages
5962
},
60-
"include": ["src", "test.js", "cli.js", "package.json"]
63+
"include": ["src", "test"]
6164
}
6265
```
6366

64-
For typescript code bases:
65-
66-
```json
67-
{
68-
"extends": "@fission-codes/eslint-config/tsconfig.json",
69-
"compilerOptions": {
70-
"outDir": "dist",
71-
"module": "NodeNext",
72-
"moduleResolution": "NodeNext"
73-
},
74-
"include": ["src", "test.js", "cli.js", "package.json"]
75-
}
76-
```
77-
78-
In monorepos you can install `@fission-codes/eslint-config` only in the root and extends the root `tsconfig.json` in the packages.
67+
In monorepos you can install `@fission-codes/eslint-config` only in the root and extend the root `tsconfig.json` in the packages.
7968

8069
## Contributing
8170

packages/eslint-config/src/configs/markdown.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const offRules = {
77
'react/prop-types': 'off',
88
'no-unused-vars': 'off',
99
'no-undef': 'off',
10+
'no-console': 'off',
11+
'unicorn/filename-case': 'off',
1012
}
1113

1214
exports.config = [

packages/package1/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
"test:browser": "playwright-test 'test/**/!(*.node).test.js'"
4747
},
4848
"devDependencies": {
49-
"@types/assert": "^1.5.7",
50-
"@types/mocha": "^10.0.1",
51-
"@types/node": "^20.7.0",
49+
"@types/assert": "^1.5.8",
50+
"@types/mocha": "^10.0.3",
51+
"@types/node": "^20.8.9",
5252
"assert": "^2.1.0",
5353
"mocha": "^10.2.0",
54-
"playwright-test": "^12.3.5"
54+
"playwright-test": "^12.4.3"
5555
},
5656
"publishConfig": {
5757
"provenance": true

0 commit comments

Comments
 (0)