Skip to content

Commit 482fe20

Browse files
mrcnkmartonmoroTomasz Marciniakmitschabaude
authored
Feat/priv cred presentation (#238)
* feature(private-credential)(wip): add mina_storePrivateCredential * chore(private-credential): lint * chore(private-credential)(wip): add getPrivateCredential * chore(private-credential): use minajs from pr and bump mina-credentials * chore(private-credential)(wip): validation in sandbox * chore(private-credential): bun lock * feat(extension): add sandbox for running smart contracts * feat(extension): add contract to showUserPrompt * chore(private-credential)(wip): sandbox * chore(private-credential)(wip): modify sandbox * chore(private-credential)(wip): use prompt in mina-provider for credential * chore(private-credential): update bun lock * chore(private-credential): add contract result handling * chore(private-credential): remove dummy add and getPromptValue * chore(private-credential): rename contractResult to result * chore(private-credential): stringify validation error * feat(private-credential): store json instead of string * feat(private-credential): add skeleton for mina_requestPresentation and modify minajs version * chore(private-credential): skeleton for mina_requestPresentation and sandbox * feat(private-credential)(wip): credential selection * chore(private-credential): add credentialId to stored credential * chore(object): refactor private credentials store * feat(private-credential): seemingly working selector * chore(private-credential): todo * chore(private-credential)(wip): signing presentation wip * chore(private-credential): add web-provider to features deps * chore(private-credential): add windowid to signing request handler * chore(private-credential): use sendMessage instead of runtime.sendMessage * feat(private-credential): mina_signFieldsWithPassphrase * chore(private-credential)(wip): move field signing to startSubmitting * chore(private-credential): change to onSubmit in presentation-result listener * chore(private-credential)(wip): update messages in sandbox * chore(private-credential): update bunlock * chore(private-credential): change from onSubmit to runtime.sendMessage * chore(private-credential): working signing from sandbox (left in logs for later) * chore(private-credential): update UI for credential selector * chore(private-credential): delete cases in listener * chore(private-credential): add fromJSONs to sandbox and compile Presentation * chore(private-credential): bump mina-credentials * chore(private-credential)(wip): prepare works, finalize fails with invalid owner sig * chore(private-credentials): comment out presentation verification * chore(private-credential): add presentation request to payload, credentialToStore * chore(private-credential): add loading to create presentation * chore(private-credential): add loading message * chore(private-credential): add loading message for credential validation * chore(private-credential): set verifierIdentity to origin * bump mina-credentials * chore(private-credential): exclude credential metadata from hash * chore(private-credential): change prompt payload display for storing credential * chore(private-credential): format credential payload in prompt (simple) * feat(credentials): add ui for credential management * feat(private-credential): isCredential, decodeBytes * chore(private-credential): change icon to IdCard * chore(private-credential): remove decode * refactor(private-credential): render-payload * chore(private-credential): todo * feat(private-credential): filter credentials for presentation request (only working for one credential in request) * chore(private-credential): extractDataFields * feat(private-credential): change credential card ui * chore(private-credential): extract data fields from dynamic record * feat(private-credential): selection form only lets user select correct credentials * feat(private-credential): render presentation request properly * minor * chore(private-credential): swap inputs and logic and add origin * chore(private-credential): more human readable presentation request * chore(private-credential): add errors * chore(private-credential): delete todo * chore(private-credential): property path and verifier url * chore(private-credential): bump mina-credentials, async fromJSON * chore(private-credential): delete logs and comments * bump mina-credentials and o1js * chore(private-credential): remove try-catch from sandbox * chore(private-credential): remove unnecessary parse * chore(private-credential): remove compile * typo * chore(private-credential): prompt title * chore(private-credential): better error msg in selection form * chore(private-credential): expect payload with presentation in selection form * chore(private-credential): remove sanitizePayload for sandbox * chore(private-credential): change error to any * chore(private-credential): sanitize error in render-payload * chore(private-credential): add arithmetic nodes to formatLogicNode * bump packages * chore(private-credential): constant node in formatLogicNode * chore(private-credential): ifThenElse in formatLogicNode * chore(private-credential): change constant node rendering * chore(private-credential): braces in formatLogicNode * chore(private-credential): extend Provider types with signFieldsWithPassphrase related schemas * chore(private-credentials): set mina-js deps to current main (a9d6774) * use locally defined zod schemas for private credentials * move mina att dep back into extensions package * fix presentation request rendering * move pretty-printing to mina atts * chore(deps): bump * chore(deps): bump --------- Co-authored-by: Marton Moro <moro.marton@gmail.com> Co-authored-by: Tomasz Marciniak <tomek@Tomaszs-Air.lan> Co-authored-by: Gregor <gregor.mitscha-baude@gmx.at>
1 parent a111fc2 commit 482fe20

File tree

210 files changed

+5440
-805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+5440
-805
lines changed

apps/extension/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</head>
2323

2424
<body>
25+
<iframe id="o1sandbox" title="Sandbox" src="/sandbox.html" allow="cross-origin-isolated" sandbox="allow-scripts" width="0" height="0"></iframe>
2526
<div id="root"></div>
2627
<script type="module" src="/src/main.tsx"></script>
2728
</body>

apps/extension/manifest.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ export const manifest: chrome.runtime.ManifestV3 = {
3232
],
3333
web_accessible_resources: [
3434
{
35-
resources: ["rpc.js"],
35+
resources: ["rpc.js", "sandbox.html", "sandbox.js"],
3636
matches: rpcMatches,
3737
},
3838
],
39+
sandbox: {
40+
pages: ["sandbox.html"],
41+
},
3942
host_permissions: ["https://*/*"],
4043
commands: {
4144
_execute_action: {
@@ -48,4 +51,14 @@ export const manifest: chrome.runtime.ManifestV3 = {
4851
description: "Open the Pallad extension",
4952
},
5053
},
54+
content_security_policy: {
55+
sandbox:
56+
"sandbox allow-scripts allow-forms allow-popups allow-modals; script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'; worker-src blob: 'self'; child-src blob: 'self'",
57+
},
58+
cross_origin_embedder_policy: {
59+
value: "require-corp",
60+
},
61+
cross_origin_opener_policy: {
62+
value: "same-origin",
63+
},
5164
}

apps/extension/package.json

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@palladxyz/extension",
3-
"version": "0.6.3",
2+
"name": "@palladco/extension",
3+
"version": "0.7.0",
44
"type": "module",
55
"scripts": {
66
"dev": "bunx --bun vite",
@@ -15,30 +15,28 @@
1515
"test:e2e:ui": "playwright test --ui"
1616
},
1717
"dependencies": {
18-
"@mina-js/providers": "https://pkg.pr.new/palladians/mina-js/@mina-js/providers@a51d3b4",
19-
"@palladxyz/common": "workspace:*",
20-
"@palladxyz/features": "workspace:*",
21-
"@palladxyz/key-management": "workspace:*",
22-
"@palladxyz/vault": "workspace:*",
23-
"@palladxyz/web-provider": "workspace:*",
18+
"@mina-js/providers": "0.1.0",
19+
"@palladco/common": "workspace:*",
20+
"@palladco/features": "workspace:*",
21+
"@palladco/key-management": "workspace:*",
22+
"@palladco/vault": "workspace:*",
23+
"@palladco/web-provider": "workspace:*",
2424
"@plasmohq/messaging": "0.6.2",
2525
"buffer": "6.0.3",
26+
"mina-attestations": "^0.3.6",
2627
"mitt": "3.0.1",
2728
"next-themes": "0.3.0",
29+
"o1js": "https://pkg.pr.new/o1-labs/o1js@1dc90e4",
2830
"p-debounce": "4.0.0",
2931
"react": "18.3.1",
3032
"react-dom": "18.3.1",
3133
"serialize-error": "11.0.3",
32-
"tailwindcss-animate": "1.0.7",
33-
"vite-plugin-node-stdlib-browser": "0.2.1",
34+
"ts-pattern": "^5.5.0",
3435
"webext-bridge": "6.0.1",
3536
"webextension-polyfill": "0.12.0",
3637
"zod": "3.23.8"
3738
},
3839
"devDependencies": {
39-
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
40-
"@esbuild-plugins/node-modules-polyfill": "0.2.2",
41-
"@originjs/vite-plugin-commonjs": "1.0.3",
4240
"@playwright/test": "1.45.3",
4341
"@total-typescript/ts-reset": "0.5.1",
4442
"@tsconfig/vite-react": "3.0.2",
@@ -47,20 +45,10 @@
4745
"@types/react-dom": "18.3.0",
4846
"@types/webextension-polyfill": "0.10.7",
4947
"@vitejs/plugin-react-swc": "3.7.0",
50-
"dedent": "1.5.3",
51-
"path": "0.12.7",
52-
"rollup-plugin-node-polyfills": "0.2.1",
53-
"rollup-plugin-polyfill-node": "0.13.0",
54-
"type-fest": "4.23.0",
5548
"vite": "5.3.5",
56-
"vite-plugin-commonjs": "0.10.1",
5749
"vite-plugin-node-polyfills": "0.17.0",
58-
"vite-plugin-require-transform": "1.0.21",
5950
"vite-plugin-svgr": "4.2.0",
60-
"vite-plugin-top-level-await": "1.4.2",
61-
"vite-plugin-wasm": "3.3.0",
6251
"vite-plugin-web-extension": "4.1.6",
63-
"web-ext": "8.2.0",
64-
"write-json-file": "6.0.0"
52+
"web-ext": "8.2.0"
6553
}
6654
}

apps/extension/postcss.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import postcssConfig from "@palladxyz/features/postcss.config.mjs"
1+
import postcssConfig from "@palladco/features/postcss.config.mjs"
22

33
export default postcssConfig

apps/extension/prompt.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</head>
1919

2020
<body>
21+
<iframe id="o1sandbox" title="Sandbox" src="/sandbox.html" allow="cross-origin-isolated" sandbox="allow-scripts" width="0" height="0"></iframe>
2122
<div id="root"></div>
2223
<script type="module" src="/src/prompt.tsx"></script>
2324
</body>

apps/extension/sandbox.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Pallad</title>
7+
</head>
8+
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/sandbox/index.ts"></script>
12+
</body>
13+
</html>

apps/extension/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import "@palladxyz/features/dist/index.css"
1+
import "@palladco/features/dist/index.css"
22
import "./assets/app.css"
33

4-
import { Router } from "@palladxyz/features"
4+
import { Router } from "@palladco/features"
55
import { ThemeProvider } from "next-themes"
66
import { useEffect } from "react"
77

apps/extension/src/assets/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import url('reset.css');
1+
@import url("reset.css");
22

33
body {
44
font-size: 16px;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@font-face {
2-
font-family: 'Hanken Grotesk Variable';
2+
font-family: "Hanken Grotesk Variable";
33
font-style: normal;
44
font-display: swap;
55
font-weight: 100 900;
6-
src: url(/HankenGrotesk.ttf) format('ttf');
6+
src: url(/HankenGrotesk.ttf) format("ttf");
77
}

apps/extension/src/assets/reset.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ dd {
2020
}
2121

2222
/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
23-
ul[role='list'],
24-
ol[role='list'] {
23+
ul[role="list"],
24+
ol[role="list"] {
2525
list-style: none;
2626
}
2727

0 commit comments

Comments
 (0)