Skip to content

Commit 881380a

Browse files
committed
chore: up
chore: remove dialog chore: sav chore: save chore: update title chore: update porto chore: fix patch chore: fix chore: switch to GET fix: add notfound error chore: disable typecheck chore: ci chore: continue on error chore: add build step to ci chore: set pnpm version chore: set pnpm version chore: lower case porto import chore: improve readme feat: smart placement chore: organize chore: remove expired key chore: cleanup feat: delete any problematic schedule chore: improve feat: swap kv with d1 for key storage chore: add mermaid chore: save chore: remove kv reference chore: update cover chore: delete key on conflict
1 parent 4d7cf5c commit 881380a

29 files changed

+1335
-1288
lines changed

.github/cover.png

-93.3 KB
Binary file not shown.

.github/cover.svg

Lines changed: 31 additions & 0 deletions
Loading

.github/workflows/deploy.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Deploy
22

3+
34
on:
45
workflow_dispatch:
56
push:
@@ -33,28 +34,26 @@ jobs:
3334
node-version: 'lts/*'
3435

3536
- name: 'Install Dependencies'
36-
run: pnpm install
37+
run: pnpm install --frozen-lockfile
3738

38-
- name: 'Lint, Check'
39+
- name: 'Lint, Check, Build'
3940
run: |
4041
pnpm dlx @biomejs/biome check . --reporter='github'
41-
# disabled until https://github.com/ithacaxyz/porto/pull/37 is merged
42-
# pnpm typecheck
42+
pnpm build
43+
pnpm typecheck
4344
4445
- name: '🔸 Cloudflare Workers - Deploy Server'
4546
working-directory: 'server'
46-
continue-on-error: true
4747
env:
4848
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4949
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5050
run: |
51-
pnpm dlx wrangler@latest deploy --env='production' --config='wrangler.toml'
51+
pnpm dlx wrangler@latest deploy --config='wrangler.toml' --env='production' --keep-vars
5252
5353
- name: '🔸 Cloudflare Workers - Deploy Client'
5454
working-directory: 'client'
5555
env:
5656
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5757
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5858
run: |
59-
pnpm build
6059
pnpm dlx wrangler@latest deploy --config='wrangler.toml'

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
auto-install-peers=false
22
link-workspace-packages=deep
33
strict-peer-dependencies=false
4+
node-options='--disable-warning=ExperimentalWarning'

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"[json]": {
1010
"editor.defaultFormatter": "biomejs.biome"
1111
},
12+
"[jsonc]": {
13+
"editor.defaultFormatter": "biomejs.biome"
14+
},
1215
"[javascript]": {
1316
"editor.defaultFormatter": "biomejs.biome"
1417
},
@@ -24,6 +27,9 @@
2427
"[markdown]": {
2528
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
2629
},
30+
"[html]": {
31+
"editor.defaultFormatter": "vscode.html-language-features"
32+
},
2733
"files.exclude": {
2834
"**/.wrangler": true
2935
},
@@ -35,6 +41,7 @@
3541
".dev.vars.example": "dotenv"
3642
},
3743
"search.exclude": {
44+
"**/dist": true,
3845
"pnpm-lock.yaml": true,
3946
"**/node_modules": true
4047
}

README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
1-
# EXP-0003: App Sessions feat. Permissions
1+
# EXP-0003: Offline Actions
22

3-
![Cover](./.github/cover.png)
3+
![Cover](./.github/cover.svg)
44

55
[Read the Blog Post](https://www.ithaca.xyz/writings/exp-0003)
66

77
## Overview
88

9-
### Keywords
10-
11-
- Client: The frontend application running in the browser,
12-
- Server: The Cloudflare Worker that handles key generation, preparing and sending calls, scheduling and managing CRON jobs.
9+
<details>
10+
<summary>Sequence Diagram</summary>
11+
12+
```mermaid
13+
sequenceDiagram
14+
autonumber
15+
participant C as Client
16+
participant S as Server
17+
participant P as Porton
18+
19+
C ->> S: GET /keys/:address?expiry&expiry=
20+
S ->> S: keyPair = P256.randomKeyPair()
21+
note right of S: Server encrypts and saves privateKey
22+
S -->> C: { type: 'p256', publicKey }
23+
C ->> P: experimental_grantPermissions(permissions)
24+
C -) S: POST /schedule <br/> { address, action: "mint", "schedule": "*****" }
25+
loop CRON
26+
S ->> P: { digest, request } = wallet_prepareCalls(calls)
27+
S ->> S: signature = P256.sign(digest, key)
28+
S ->> P: hash = wallet_sendPreparedCalls(request, signature)
29+
end
30+
```
31+
32+
</details>
1333

1434
### Live demo
1535

1636
- <a href="https://exp-0003-client.evm.workers.dev" target="_blank">exp-0003-client.evm.workers.dev</a> - Client
1737
- <a href="https://exp-0003-server.evm.workers.dev" target="_blank">exp-0003-server.evm.workers.dev</a> - Server
1838

39+
### Keywords
40+
41+
- Client: frontend application running in the browser,
42+
- Server: handles key generation, preparing and sending calls, scheduling and managing CRON jobs.
43+
1944
## Getting Started
2045

2146
### Prerequisites
@@ -27,6 +52,16 @@ npm install --global pnpm@latest
2752
pnpm install
2853
```
2954

55+
### Setup Server database (Cloudflare D1)
56+
57+
```shell
58+
# create database
59+
# this will fail if the database already exists
60+
pnpm --filter='server' db:create
61+
# run the next command to bootstrap the existing database.
62+
pnpm --filter='server' db:bootstrap
63+
```
64+
3065
### Start dev for worker and client
3166

3267
```shell
@@ -35,7 +70,7 @@ pnpm --filter='server' --filter='client' dev
3570

3671
## Deploying
3772

38-
### Prerequisites
73+
### Requirements
3974

4075
- a Cloudflare account
4176
- `wrangler` CLI: `pnpm add --global wrangler@latest`,

client/index.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="UTF-8" />
4+
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>EXP-0003</title>
7-
<meta name="description" content="App Sessions feat. Permissions">
8-
<meta name="keywords" content="Ithaca,web3,app sessions,permissions">
7+
<meta name="keywords" content="Ithaca,web3,offline actions,permissions">
98
<link
109
rel="icon"
1110
sizes="310x270"
1211
type="image/png"
1312
href="https://ithaca.xyz/icon.png"
1413
>
1514
<meta name="theme-color" content="#4285f4">
16-
<meta name="application-name" content="Ithaca - EXP-0003">
17-
<meta name="description" content="App Sessions feat. Permissions">
15+
<meta name="application-name" content="Ithaca - EXP-0003 Demo">
16+
<meta name="description" content="Offline Actions">
1817

1918
<!-- SOCIAL -->
2019
<meta
@@ -25,15 +24,15 @@
2524
<meta property="og:locale" content="en_US">
2625
<meta property="article:author" content="Ithaca">
2726
<meta property="og:image" content="/exp-0003.png">
28-
<meta property="og:title" content="Ithaca - EXP-0003">
29-
<meta property="og:site_name" content="Ithaca - EXP-0003">
27+
<meta property="og:title" content="Ithaca - EXP-0003 Demo">
28+
<meta property="og:site_name" content="Ithaca - EXP-0003 Demo">
3029
<meta property="og:url" content="http://exp0003.ithaca.xyz">
3130
<meta property="og:description" content="App Sessions feat. Permissions">
3231

3332
<meta name="twitter:card" content="summary">
3433
<meta name="twitter:site" content="@site_account">
3534
<meta name="twitter:image" content="/exp-0003.png">
36-
<meta name="twitter:title" content="Ithaca - EXP-0003">
35+
<meta name="twitter:title" content="Ithaca - EXP-0003 Demo">
3736
<meta name="twitter:creator" content="@individual_account">
3837
<meta name="twitter:url" content="http://exp0003.ithaca.xyz">
3938
<meta name="twitter:description" content="App Sessions feat. Permissions">
@@ -42,7 +41,7 @@
4241
<body>
4342
<header>
4443
<h1>EXP-0003</h1>
45-
<h3>App Sessions feat. Permissions</h3>
44+
<h3>Offline Actions</h3>
4645
</header>
4746
<div id="root"></div>
4847
<script type="module" src="/src/main.tsx"></script>

client/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,23 @@
99
"typecheck": "tsc --noEmit --project tsconfig.json"
1010
},
1111
"dependencies": {
12-
"@tanstack/react-query": "^5.66.0",
12+
"@tanstack/react-query": "^5.66.3",
1313
"ox": "catalog:",
1414
"porto": "catalog:",
1515
"react": "^19.0.0",
1616
"react-dom": "^19.0.0",
17-
"viem": "catalog:",
1817
"wagmi": "catalog:"
1918
},
2019
"devDependencies": {
21-
"@tanstack/react-query-devtools": "^5.66.0",
20+
"@tanstack/react-query-devtools": "^5.66.3",
2221
"@types/node": "catalog:",
23-
"@types/react": "^19.0.8",
22+
"@types/react": "^19.0.9",
2423
"@types/react-dom": "^19.0.3",
2524
"@vitejs/plugin-react": "^4.3.4",
26-
"globals": "^15.14.0",
27-
"prool": "^0.0.17",
25+
"globals": "^15.15.0",
2826
"typed-query-selector": "^2.12.0",
2927
"typescript": "catalog:",
30-
"vite": "^6.1.0"
28+
"vite": "^6.1.0",
29+
"wrangler": "catalog:"
3130
}
3231
}

0 commit comments

Comments
 (0)