Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private Credentials - Presentation Request #231

Open
wants to merge 97 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
3bab958
feature(private-credential)(wip): add mina_storePrivateCredential
martonmoro Nov 4, 2024
893a162
chore(private-credential): lint
martonmoro Nov 4, 2024
9cd3f41
chore(private-credential)(wip): add getPrivateCredential
martonmoro Nov 4, 2024
e27700c
Merge remote-tracking branch 'upstream/main' into feat/privCred-crede…
martonmoro Nov 6, 2024
6b23b7d
chore(private-credential): use minajs from pr and bump mina-credentials
martonmoro Nov 6, 2024
798d288
chore(private-credential)(wip): validation in sandbox
martonmoro Nov 7, 2024
d78bf14
Merge remote-tracking branch 'upstream/main' into feat/privCred-crede…
martonmoro Nov 7, 2024
31bb3ac
chore(private-credential): bun lock
martonmoro Nov 7, 2024
77d1e00
feat(extension): add sandbox for running smart contracts
mrcnk Nov 8, 2024
ab88eb0
feat(extension): add contract to showUserPrompt
mrcnk Nov 9, 2024
60be174
chore(private-credential)(wip): sandbox
martonmoro Nov 9, 2024
ba56a0f
chore(private-credential)(wip): modify sandbox
martonmoro Nov 11, 2024
14c40b9
Merge remote-tracking branch 'upstream/feat/enable-o1js-contracts' in…
martonmoro Nov 11, 2024
0759784
chore(private-credential)(wip): use prompt in mina-provider for crede…
martonmoro Nov 11, 2024
636ec20
chore(private-credential): update bun lock
martonmoro Nov 11, 2024
755c120
chore(private-credential): add contract result handling
martonmoro Nov 11, 2024
dd9ee57
chore(private-credential): remove dummy add and getPromptValue
martonmoro Nov 11, 2024
f7d94fa
chore(private-credential): rename contractResult to result
martonmoro Nov 11, 2024
0d93188
chore(private-credential): stringify validation error
martonmoro Nov 11, 2024
90d49b4
feat(private-credential): store json instead of string
martonmoro Nov 11, 2024
2629282
feat(private-credential): add skeleton for mina_requestPresentation a…
martonmoro Nov 12, 2024
d1c709d
chore(private-credential): skeleton for mina_requestPresentation and …
martonmoro Nov 13, 2024
0198cf1
feat(private-credential)(wip): credential selection
martonmoro Nov 13, 2024
99d0804
chore(private-credential): add credentialId to stored credential
martonmoro Nov 13, 2024
c3538a4
chore(object): refactor private credentials store
mrcnk Nov 13, 2024
9480c9e
feat(private-credential): seemingly working selector
martonmoro Nov 14, 2024
1163d89
chore(private-credential): todo
martonmoro Nov 14, 2024
9163eaf
chore(private-credential)(wip): signing presentation wip
martonmoro Nov 18, 2024
108bda1
chore(private-credential): add web-provider to features deps
martonmoro Nov 18, 2024
2cc6ad1
chore(private-credential): add windowid to signing request handler
martonmoro Nov 18, 2024
d9cf0fd
chore(private-credential): use sendMessage instead of runtime.sendMes…
martonmoro Nov 18, 2024
62fc8d0
feat(private-credential): mina_signFieldsWithPassphrase
martonmoro Nov 18, 2024
b873394
chore(private-credential)(wip): move field signing to startSubmitting
martonmoro Nov 18, 2024
b981a65
chore(private-credential): change to onSubmit in presentation-result …
martonmoro Nov 18, 2024
60c0b06
chore(private-credential)(wip): update messages in sandbox
martonmoro Nov 19, 2024
0846c74
chore(private-credential): update bunlock
martonmoro Nov 19, 2024
15bf705
chore(private-credential): change from onSubmit to runtime.sendMessage
martonmoro Nov 19, 2024
9b900d3
chore(private-credential): working signing from sandbox (left in logs…
martonmoro Nov 19, 2024
a4b6161
chore(private-credential): update UI for credential selector
martonmoro Nov 20, 2024
331d317
chore(private-credential): delete cases in listener
martonmoro Nov 20, 2024
6df3b92
chore(private-credential): add fromJSONs to sandbox and compile Prese…
martonmoro Nov 22, 2024
8710e8b
chore(private-credential): bump mina-credentials
martonmoro Nov 22, 2024
1300204
chore(private-credential)(wip): prepare works, finalize fails with in…
martonmoro Nov 22, 2024
8b58e1e
chore(private-credentials): comment out presentation verification
martonmoro Nov 24, 2024
6da4eab
chore(private-credential): add presentation request to payload, crede…
martonmoro Nov 25, 2024
a141335
chore(private-credential): add loading to create presentation
martonmoro Nov 25, 2024
a1aec4b
chore(private-credential): add loading message
martonmoro Nov 25, 2024
852aaa9
chore(private-credential): add loading message for credential validation
martonmoro Nov 25, 2024
2df1599
chore(private-credential): set verifierIdentity to origin
martonmoro Nov 26, 2024
c30e475
bump mina-credentials
martonmoro Nov 27, 2024
5e15a5f
chore(private-credential): exclude credential metadata from hash
martonmoro Nov 27, 2024
60ee4db
chore(private-credential): change prompt payload display for storing …
martonmoro Nov 27, 2024
57807fe
chore(private-credential): format credential payload in prompt (simple)
martonmoro Nov 27, 2024
ad16514
feat(credentials): add ui for credential management
Nov 27, 2024
334566a
Merge commit 'refs/pull/231/head' of github.com:palladians/pallad int…
Nov 27, 2024
7ed5f31
feat(private-credential): isCredential, decodeBytes
martonmoro Nov 27, 2024
7d99301
Merge remote-tracking branch 'upstream/feat/privCred-presentation' in…
martonmoro Nov 27, 2024
3be7847
chore(private-credential): change icon to IdCard
martonmoro Nov 27, 2024
649cff1
chore(private-credential): remove decode
martonmoro Nov 27, 2024
bfcbadd
refactor(private-credential): render-payload
martonmoro Nov 27, 2024
25f9f83
chore(private-credential): todo
martonmoro Nov 28, 2024
78c59fc
feat(private-credential): filter credentials for presentation request…
martonmoro Nov 28, 2024
7e42b38
chore(private-credential): extractDataFields
martonmoro Nov 28, 2024
5d01fa8
feat(private-credential): change credential card ui
martonmoro Nov 28, 2024
b1b7dcd
chore(private-credential): extract data fields from dynamic record
martonmoro Nov 29, 2024
bd4a267
feat(private-credential): selection form only lets user select correc…
martonmoro Nov 29, 2024
bc893f2
feat(private-credential): render presentation request properly
martonmoro Nov 30, 2024
91bf616
minor
martonmoro Dec 1, 2024
9060261
chore(private-credential): swap inputs and logic and add origin
martonmoro Dec 2, 2024
c480838
chore(private-credential): more human readable presentation request
martonmoro Dec 3, 2024
61b2e5b
chore(private-credential): add errors
martonmoro Dec 3, 2024
8657922
chore(private-credential): delete todo
martonmoro Dec 3, 2024
872ab6c
chore(private-credential): property path and verifier url
martonmoro Dec 4, 2024
1a035c8
chore(private-credential): bump mina-credentials, async fromJSON
martonmoro Dec 12, 2024
caf75dc
chore(private-credential): delete logs and comments
martonmoro Dec 18, 2024
281dee5
bump mina-credentials and o1js
martonmoro Dec 18, 2024
06cb3fb
chore(private-credential): remove try-catch from sandbox
martonmoro Dec 20, 2024
f43ff99
chore(private-credential): remove unnecessary parse
martonmoro Dec 20, 2024
5f5f95c
chore(private-credential): remove compile
martonmoro Dec 20, 2024
7240fc7
typo
martonmoro Dec 20, 2024
3920cdf
chore(private-credential): prompt title
martonmoro Dec 20, 2024
20c8dcb
chore(private-credential): better error msg in selection form
martonmoro Dec 20, 2024
abc9b98
chore(private-credential): expect payload with presentation in select…
martonmoro Dec 20, 2024
1e75800
chore(private-credential): remove sanitizePayload for sandbox
martonmoro Dec 20, 2024
21e8980
chore(private-credential): change error to any
martonmoro Dec 20, 2024
37e0a9b
chore(private-credential): sanitize error in render-payload
martonmoro Dec 20, 2024
9a50a8b
Merge branch 'main' into feat/privCred-presentation
mitschabaude Dec 20, 2024
87f34ea
chore(private-credential): add arithmetic nodes to formatLogicNode
martonmoro Dec 20, 2024
1f5da28
bump packages
mitschabaude Dec 20, 2024
f93feed
Merge branch 'feat/privCred-presentation' of github.com:zksecurity/pa…
mitschabaude Dec 20, 2024
ea0b926
chore(private-credential): constant node in formatLogicNode
martonmoro Dec 20, 2024
7317269
Merge branch 'feat/privCred-presentation' of github.com:zksecurity/pa…
mitschabaude Dec 20, 2024
ccc2e65
chore(private-credential): ifThenElse in formatLogicNode
martonmoro Dec 20, 2024
ebba555
chore(private-credential): change constant node rendering
martonmoro Dec 20, 2024
c3c8c76
Merge branch 'feat/privCred-presentation' of github.com:zksecurity/pa…
mitschabaude Dec 20, 2024
b45411d
chore(private-credential): braces in formatLogicNode
martonmoro Dec 21, 2024
067f688
Merge remote-tracking branch 'upstream/main' into feat/privCred-prese…
martonmoro Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/extension/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</head>

<body>
<iframe id="o1sandbox" title="Sandbox" src="/sandbox.html" allow="cross-origin-isolated" sandbox="allow-scripts" width="0" height="0"></iframe>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
Expand Down
15 changes: 14 additions & 1 deletion apps/extension/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ export const manifest: chrome.runtime.ManifestV3 = {
],
web_accessible_resources: [
{
resources: ["rpc.js"],
resources: ["rpc.js", "sandbox.html", "sandbox.js"],
matches: rpcMatches,
},
],
sandbox: {
pages: ["sandbox.html"],
},
host_permissions: ["https://*/*"],
commands: {
_execute_action: {
Expand All @@ -48,4 +51,14 @@ export const manifest: chrome.runtime.ManifestV3 = {
description: "Open the Pallad extension",
},
},
content_security_policy: {
sandbox:
"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'",
},
cross_origin_embedder_policy: {
value: "require-corp",
},
cross_origin_opener_policy: {
value: "same-origin",
},
}
34 changes: 11 additions & 23 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@palladxyz/extension",
"name": "@palladco/extension",
"version": "0.6.2",
"type": "module",
"scripts": {
Expand All @@ -15,30 +15,28 @@
"test:e2e:ui": "playwright test --ui"
},
"dependencies": {
"@mina-js/providers": "https://pkg.pr.new/palladians/mina-js/@mina-js/providers@a51d3b4",
"@palladxyz/common": "workspace:*",
"@palladxyz/features": "workspace:*",
"@palladxyz/key-management": "workspace:*",
"@palladxyz/vault": "workspace:*",
"@palladxyz/web-provider": "workspace:*",
"@mina-js/providers": "https://pkg.pr.new/palladians/mina-js/@mina-js/providers@3",
"@palladco/common": "workspace:*",
"@palladco/features": "workspace:*",
"@palladco/key-management": "workspace:*",
"@palladco/vault": "workspace:*",
"@palladco/web-provider": "workspace:*",
"@plasmohq/messaging": "0.6.2",
"buffer": "6.0.3",
"mina-credentials": "^0.2.6",
"mitt": "3.0.1",
"next-themes": "0.3.0",
"o1js": "https://pkg.pr.new/o1-labs/o1js@996ebb3",
"p-debounce": "4.0.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"serialize-error": "11.0.3",
"tailwindcss-animate": "1.0.7",
"vite-plugin-node-stdlib-browser": "0.2.1",
"ts-pattern": "^5.5.0",
"webext-bridge": "6.0.1",
"webextension-polyfill": "0.12.0",
"zod": "3.23.8"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@esbuild-plugins/node-modules-polyfill": "0.2.2",
"@originjs/vite-plugin-commonjs": "1.0.3",
"@playwright/test": "1.45.3",
"@total-typescript/ts-reset": "0.5.1",
"@tsconfig/vite-react": "3.0.2",
Expand All @@ -47,20 +45,10 @@
"@types/react-dom": "18.3.0",
"@types/webextension-polyfill": "0.10.7",
"@vitejs/plugin-react-swc": "3.7.0",
"dedent": "1.5.3",
"path": "0.12.7",
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-polyfill-node": "0.13.0",
"type-fest": "4.23.0",
"vite": "5.3.5",
"vite-plugin-commonjs": "0.10.1",
"vite-plugin-node-polyfills": "0.17.0",
"vite-plugin-require-transform": "1.0.21",
"vite-plugin-svgr": "4.2.0",
"vite-plugin-top-level-await": "1.4.2",
"vite-plugin-wasm": "3.3.0",
"vite-plugin-web-extension": "4.1.6",
"web-ext": "8.2.0",
"write-json-file": "6.0.0"
"web-ext": "8.2.0"
}
}
2 changes: 1 addition & 1 deletion apps/extension/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import postcssConfig from "@palladxyz/features/postcss.config.mjs"
import postcssConfig from "@palladco/features/postcss.config.mjs"

export default postcssConfig
1 change: 1 addition & 0 deletions apps/extension/prompt.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>

<body>
<iframe id="o1sandbox" title="Sandbox" src="/sandbox.html" allow="cross-origin-isolated" sandbox="allow-scripts" width="0" height="0"></iframe>
<div id="root"></div>
<script type="module" src="/src/prompt.tsx"></script>
</body>
Expand Down
13 changes: 13 additions & 0 deletions apps/extension/sandbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pallad</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/sandbox/index.ts"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions apps/extension/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@palladxyz/features/dist/index.css"
import "@palladco/features/dist/index.css"
import "./assets/app.css"

import { Router } from "@palladxyz/features"
import { Router } from "@palladco/features"
import { ThemeProvider } from "next-themes"
import { useEffect } from "react"

Expand Down
6 changes: 3 additions & 3 deletions apps/extension/src/background/handlers/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useVault } from "@palladxyz/vault"
import type { NetworkId } from "@palladxyz/vault"
import { createMinaProvider } from "@palladxyz/web-provider"
import { useVault } from "@palladco/vault"
import type { NetworkId } from "@palladco/vault"
import { createMinaProvider } from "@palladco/web-provider"
import { serializeError } from "serialize-error"
import type { Handler } from "./"

Expand Down
48 changes: 47 additions & 1 deletion apps/extension/src/background/handlers/web-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import {
GetBalanceRequestParamsSchema,
GetStateRequestParamsSchema,
NetworkIdRequestParamsSchema,
PresentationRequestParamsSchema,
RequestAccountsRequestParamsSchema,
SendTransactionRequestParamsSchema,
SetStateRequestParamsSchema,
SignFieldsRequestParamsSchema,
SignRequestParamsSchema,
SignTransactionRequestParamsSchema,
StorePrivateCredentialRequestParamsSchema,
SwitchChainRequestParamsSchema,
signFieldsWithPassphraseRequestParamsSchema,
} from "@mina-js/providers"
import { createMinaProvider } from "@palladxyz/web-provider"
import { createMinaProvider } from "@palladco/web-provider"
import { serializeError } from "serialize-error"
import { z } from "zod"
import type { Handler } from "."
Expand Down Expand Up @@ -146,6 +149,21 @@ export const minaSignFields: Handler = async ({ data }) => {
}
}

export const minaSignFieldsWithPassphrase: Handler = async ({ data }) => {
try {
const provider = await createMinaProvider()
const payload = signFieldsWithPassphraseRequestParamsSchema.parse({
method: "mina_signFieldsWithPassphrase",
params: data.params,
context: data.context,
})
const response = await provider.request(payload)
return response
} catch (error: unknown) {
return { error: serializeError(error) }
}
}

export const minaSignTransaction: Handler = async ({ data }) => {
try {
const provider = await createMinaProvider()
Expand Down Expand Up @@ -200,3 +218,31 @@ export const minaSendTransaction: Handler = async ({ data }) => {
return { error: serializeError(error) }
}
}

export const minaStorePrivateCredential: Handler = async ({ data }) => {
try {
const provider = await createMinaProvider()
const payload = StorePrivateCredentialRequestParamsSchema.parse({
method: "mina_storePrivateCredential",
params: data.params,
context: data.context,
})
return await provider.request(payload)
} catch (error: unknown) {
return { error: serializeError(error) }
}
}

export const minaRequestPresentation: Handler = async ({ data }) => {
try {
const provider = await createMinaProvider()
const payload = PresentationRequestParamsSchema.parse({
method: "mina_requestPresentation",
params: data.params,
context: data.context,
})
return await provider.request(payload)
} catch (error: unknown) {
return { error: serializeError(error) }
}
}
8 changes: 7 additions & 1 deletion apps/extension/src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMinaProvider } from "@palladxyz/web-provider"
import { createMinaProvider } from "@palladco/web-provider"
import { onMessage, sendMessage } from "webext-bridge/background"
import { runtime, tabs } from "webextension-polyfill"
import {
Expand All @@ -10,11 +10,14 @@ import {
minaNetworkId,
minaRequestAccounts,
minaRequestNetwork,
minaRequestPresentation,
minaSendTransaction,
minaSetState,
minaSign,
minaSignFields,
minaSignFieldsWithPassphrase,
minaSignTransaction,
minaStorePrivateCredential,
minaSwitchChain,
palladConnected,
palladSidePanel,
Expand All @@ -40,6 +43,9 @@ onMessage("mina_signTransaction", minaSignTransaction)
onMessage("mina_getBalance", minaGetBalance)
onMessage("mina_createNullifier", minaCreateNullifier)
onMessage("mina_sendTransaction", minaSendTransaction)
onMessage("mina_storePrivateCredential", minaStorePrivateCredential)
onMessage("mina_requestPresentation", minaRequestPresentation)
onMessage("mina_signFieldsWithPassphrase", minaSignFieldsWithPassphrase)

/**
* Wallet handlers
Expand Down
4 changes: 2 additions & 2 deletions apps/extension/src/prompt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@palladxyz/features/dist/index.css"
import "@palladco/features/dist/index.css"
import "@total-typescript/ts-reset"

import { WebConnectorRoute } from "@palladxyz/features"
import { WebConnectorRoute } from "@palladco/features"
import { ThemeProvider } from "next-themes"
import React from "react"
import ReactDOM from "react-dom/client"
Expand Down
Loading