diff --git a/apps/client-web/CHANGELOG.md b/apps/client-web/CHANGELOG.md index 13dffde..3cacb95 100644 --- a/apps/client-web/CHANGELOG.md +++ b/apps/client-web/CHANGELOG.md @@ -1,5 +1,14 @@ # client-web +## 0.0.16 + +### Patch Changes + +- Updated dependencies + - @parcnet-js/podspec@1.1.3 + - @parcnet-js/client-rpc@1.1.6 + - @parcnet-js/client-helpers@1.0.7 + ## 0.0.15 ### Patch Changes diff --git a/apps/client-web/package.json b/apps/client-web/package.json index fe2e6eb..8c538a4 100644 --- a/apps/client-web/package.json +++ b/apps/client-web/package.json @@ -1,7 +1,7 @@ { "name": "client-web", "private": true, - "version": "0.0.15", + "version": "0.0.16", "type": "module", "scripts": { "dev": "vite", diff --git a/examples/test-app/CHANGELOG.md b/examples/test-app/CHANGELOG.md index def9745..f55c281 100644 --- a/examples/test-app/CHANGELOG.md +++ b/examples/test-app/CHANGELOG.md @@ -1,5 +1,16 @@ # test-app +## 1.0.20 + +### Patch Changes + +- Updated dependencies + - @parcnet-js/podspec@1.1.3 + - @parcnet-js/app-connector@1.1.8 + - @parcnet-js/client-rpc@1.1.6 + - @parcnet-js/ticket-spec@1.1.6 + - @parcnet-js/app-connector-react@1.0.3 + ## 1.0.19 ### Patch Changes diff --git a/examples/test-app/package.json b/examples/test-app/package.json index d13d55f..2d7c8f8 100644 --- a/examples/test-app/package.json +++ b/examples/test-app/package.json @@ -1,6 +1,6 @@ { "name": "test-app", - "version": "1.0.19", + "version": "1.0.20", "private": true, "type": "module", "scripts": { diff --git a/packages/app-connector-react/CHANGELOG.md b/packages/app-connector-react/CHANGELOG.md index d6a501f..a43e1fd 100644 --- a/packages/app-connector-react/CHANGELOG.md +++ b/packages/app-connector-react/CHANGELOG.md @@ -1,5 +1,11 @@ # @parcnet-js/app-connector-react +## 1.0.3 + +### Patch Changes + +- @parcnet-js/app-connector@1.1.8 + ## 1.0.2 ### Patch Changes diff --git a/packages/app-connector-react/package.json b/packages/app-connector-react/package.json index 1ccf485..3a38a29 100644 --- a/packages/app-connector-react/package.json +++ b/packages/app-connector-react/package.json @@ -1,6 +1,6 @@ { "name": "@parcnet-js/app-connector-react", - "version": "1.0.2", + "version": "1.0.3", "license": "GPL-3.0-or-later", "type": "module", "main": "dist/index.cjs", diff --git a/packages/app-connector/CHANGELOG.md b/packages/app-connector/CHANGELOG.md index 8ee91d4..ac199d1 100644 --- a/packages/app-connector/CHANGELOG.md +++ b/packages/app-connector/CHANGELOG.md @@ -1,5 +1,13 @@ # @parcnet-js/app-connector +## 1.1.8 + +### Patch Changes + +- Updated dependencies + - @parcnet-js/podspec@1.1.3 + - @parcnet-js/client-rpc@1.1.6 + ## 1.1.7 ### Patch Changes diff --git a/packages/app-connector/package.json b/packages/app-connector/package.json index 62be797..88bc047 100644 --- a/packages/app-connector/package.json +++ b/packages/app-connector/package.json @@ -1,6 +1,6 @@ { "name": "@parcnet-js/app-connector", - "version": "1.1.7", + "version": "1.1.8", "license": "GPL-3.0-or-later", "type": "module", "main": "dist/index.cjs", diff --git a/packages/app-connector/test/parcnet-connector.spec.ts b/packages/app-connector/test/parcnet-connector.spec.ts index c67e497..f93c95b 100644 --- a/packages/app-connector/test/parcnet-connector.spec.ts +++ b/packages/app-connector/test/parcnet-connector.spec.ts @@ -35,10 +35,16 @@ describe("parcnet-client should work", function () { const client = new ParcnetRPCConnector(chan.port2, mockDialog); expect(client.isConnected()).to.be.false; - client.start(() => { - // This is called when the connection is established - expect(client.isConnected()).to.be.true; - }); + client.start( + () => { + // This is called when the connection is established + expect(client.isConnected()).to.be.true; + }, + () => { + // This is called if the connection fails. We should never get here. + assert(false); + } + ); postRPCMessage(chan.port1, { type: RPCMessageType.PARCNET_CLIENT_READY diff --git a/packages/app-connector/test/utils.ts b/packages/app-connector/test/utils.ts index 524ade4..b79c60a 100644 --- a/packages/app-connector/test/utils.ts +++ b/packages/app-connector/test/utils.ts @@ -1,5 +1,5 @@ import { RPCMessageType } from "@parcnet-js/client-rpc"; -import { expect } from "vitest"; +import { assert, expect } from "vitest"; import type { DialogController } from "../src/adapters/iframe.js"; import { postRPCMessage } from "../src/adapters/iframe.js"; import { ParcnetRPCConnector } from "../src/rpc_client.js"; @@ -19,10 +19,16 @@ export async function connectedClient(): Promise<{ }> { const chan = new MessageChannel(); const client = new ParcnetRPCConnector(chan.port2, mockDialog); - client.start(() => { - // This is called when the connection is established - expect(client.isConnected()).to.be.true; - }); + client.start( + () => { + // This is called when the connection is established + expect(client.isConnected()).to.be.true; + }, + () => { + // This is called if the connection fails. We should never get here. + assert(false); + } + ); postRPCMessage(chan.port1, { type: RPCMessageType.PARCNET_CLIENT_READY diff --git a/packages/client-helpers/CHANGELOG.md b/packages/client-helpers/CHANGELOG.md index 2d4ef28..edc482c 100644 --- a/packages/client-helpers/CHANGELOG.md +++ b/packages/client-helpers/CHANGELOG.md @@ -1,5 +1,11 @@ # @parcnet-js/client-helpers +## 1.0.7 + +### Patch Changes + +- @parcnet-js/client-rpc@1.1.6 + ## 1.0.6 ### Patch Changes diff --git a/packages/client-helpers/package.json b/packages/client-helpers/package.json index 2a2f225..a28e797 100644 --- a/packages/client-helpers/package.json +++ b/packages/client-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@parcnet-js/client-helpers", - "version": "1.0.6", + "version": "1.0.7", "license": "GPL-3.0-or-later", "type": "module", "main": "dist/index.js", diff --git a/packages/client-rpc/CHANGELOG.md b/packages/client-rpc/CHANGELOG.md index 0426e20..482754c 100644 --- a/packages/client-rpc/CHANGELOG.md +++ b/packages/client-rpc/CHANGELOG.md @@ -1,5 +1,12 @@ # @parcnet-js/client-rpc +## 1.1.6 + +### Patch Changes + +- Updated dependencies + - @parcnet-js/podspec@1.1.3 + ## 1.1.5 ### Patch Changes diff --git a/packages/client-rpc/package.json b/packages/client-rpc/package.json index cff2242..102daa8 100644 --- a/packages/client-rpc/package.json +++ b/packages/client-rpc/package.json @@ -1,7 +1,7 @@ { "name": "@parcnet-js/client-rpc", "type": "module", - "version": "1.1.5", + "version": "1.1.6", "license": "GPL-3.0-or-later", "main": "dist/index.js", "module": "dist/index.js", diff --git a/packages/podspec/CHANGELOG.md b/packages/podspec/CHANGELOG.md index a780747..e3bb0c9 100644 --- a/packages/podspec/CHANGELOG.md +++ b/packages/podspec/CHANGELOG.md @@ -1,5 +1,11 @@ # @parcnet-js/podspec +## 1.1.3 + +### Patch Changes + +- Fix compatibility with POD serialization restrictions on membership list names + ## 1.1.2 ### Patch Changes diff --git a/packages/podspec/package.json b/packages/podspec/package.json index a78aa71..d8d159d 100644 --- a/packages/podspec/package.json +++ b/packages/podspec/package.json @@ -1,6 +1,6 @@ { "name": "@parcnet-js/podspec", - "version": "1.1.2", + "version": "1.1.3", "license": "GPL-3.0-or-later", "main": "dist/index.cjs", "module": "dist/index.js", @@ -30,8 +30,8 @@ }, "scripts": { "lint": "eslint . --max-warnings 0", - "build": "tsup 'src/**/*@(ts|tsx)' --format cjs,esm --clean --sourcemap", - "prepublish": "tsup 'src/**/*@(ts|tsx)' --format cjs,esm --clean --sourcemap --dts", + "build": "tsup 'src/**/*@(ts|tsx)' --format cjs,esm --clean --sourcemap --no-splitting", + "prepublish": "tsup 'src/**/*@(ts|tsx)' --format cjs,esm --clean --sourcemap --dts --no-splitting", "test": "vitest run --typecheck" }, "files": ["dist", "./README.md", "./LICENSE"], diff --git a/packages/podspec/src/gpc/proof_request.ts b/packages/podspec/src/gpc/proof_request.ts index 3334bcf..04dcc14 100644 --- a/packages/podspec/src/gpc/proof_request.ts +++ b/packages/podspec/src/gpc/proof_request.ts @@ -9,6 +9,7 @@ import type { } from "@pcd/gpc"; import type { POD, PODName, PODValue } from "@pcd/pod"; import { PodSpec } from "../parse/pod.js"; +import { $e } from "../pod_value_utils.js"; import type { EntriesSchema } from "../schemas/entries.js"; import type { PODSchema } from "../schemas/pod.js"; @@ -183,9 +184,9 @@ function makeProofRequest

( } for (const entriesTupleSchema of podSchema.tuples ?? []) { - const tupleName = `tuple_${podName}_entries_${entriesTupleSchema.entries.join( - "_" - )}`; + const tupleName = `tuple_${podName}_entries_${entriesTupleSchema.entries + .map((entryName) => entryName.replace("$", "_")) + .join("_")}`; tuples[tupleName] = { entries: entriesTupleSchema.entries.map( (entryName) => `${podName}.${entryName}` satisfies PODEntryIdentifier @@ -220,6 +221,26 @@ function makeProofRequest

( } } + if (podSchema.signerPublicKey) { + podConfig.signerPublicKey = { + isRevealed: podSchema.signerPublicKey.isRevealed ?? false + }; + if (podSchema.signerPublicKey.isMemberOf) { + // Double underscore to avoid collision with entry names. + membershipLists[`allowlist_${podName}__signerPublicKey`] = $e( + podSchema.signerPublicKey.isMemberOf + ); + podConfig.signerPublicKey.isMemberOf = `allowlist_${podName}__signerPublicKey`; + } + if (podSchema.signerPublicKey.isNotMemberOf) { + // Double underscore to avoid collision with entry names. + membershipLists[`blocklist_${podName}__signerPublicKey`] = $e( + podSchema.signerPublicKey.isNotMemberOf + ); + podConfig.signerPublicKey.isNotMemberOf = `blocklist_${podName}__signerPublicKey`; + } + } + pods[podName] = podConfig; } diff --git a/packages/podspec/src/schemas/pod.ts b/packages/podspec/src/schemas/pod.ts index e474e36..a34ffa9 100644 --- a/packages/podspec/src/schemas/pod.ts +++ b/packages/podspec/src/schemas/pod.ts @@ -15,6 +15,7 @@ export type PODSchema = { isNotMemberOf?: PODValue[][]; }[]; signerPublicKey?: { + isRevealed?: boolean; isMemberOf?: string[]; isNotMemberOf?: string[]; }; diff --git a/packages/podspec/test/constants.ts b/packages/podspec/test/constants.ts new file mode 100644 index 0000000..2b7960c --- /dev/null +++ b/packages/podspec/test/constants.ts @@ -0,0 +1,6 @@ +import path from "path"; + +export const GPC_NPM_ARTIFACTS_PATH = path.join( + __dirname, + "../node_modules/@pcd/proto-pod-gpc-artifacts" +); diff --git a/packages/podspec/test/podspec.spec.ts b/packages/podspec/test/podspec.spec.ts index 692e017..1d7a3d0 100644 --- a/packages/podspec/test/podspec.spec.ts +++ b/packages/podspec/test/podspec.spec.ts @@ -1,8 +1,6 @@ -import path from "path"; import type { GPCBoundConfig } from "@pcd/gpc"; import { gpcProve, gpcVerify } from "@pcd/gpc"; -import { POD } from "@pcd/pod"; -import { POD_INT_MAX, POD_INT_MIN } from "@pcd/pod/podTypes"; +import { POD, POD_INT_MAX, POD_INT_MIN } from "@pcd/pod"; import { v4 as uuidv4 } from "uuid"; import { assert, describe, expect, it } from "vitest"; import type { @@ -14,13 +12,9 @@ import { IssueCode } from "../src/error.js"; import * as p from "../src/index.js"; import { $c, $i, $s } from "../src/pod_value_utils.js"; import type { EntriesTupleSchema } from "../src/schemas/entries.js"; +import { GPC_NPM_ARTIFACTS_PATH } from "./constants.js"; import { generateKeyPair, generateRandomHex } from "./utils.js"; -export const GPC_NPM_ARTIFACTS_PATH = path.join( - __dirname, - "../node_modules/@pcd/proto-pod-gpc-artifacts" -); - describe("podspec should work", function () { it("should validate POD entries", () => { // To begin with, we can create a specification for POD entries. diff --git a/packages/podspec/test/serialization.spec.ts b/packages/podspec/test/serialization.spec.ts new file mode 100644 index 0000000..fb8c0dd --- /dev/null +++ b/packages/podspec/test/serialization.spec.ts @@ -0,0 +1,83 @@ +import { + type GPCBoundConfig, + boundConfigToJSON, + gpcProve, + podMembershipListsToJSON, + proofConfigToJSON, + revealedClaimsToJSON +} from "@pcd/gpc"; +import { POD } from "@pcd/pod"; +import { describe, expect, it } from "vitest"; +import * as p from "../src/index.js"; +import { GPC_NPM_ARTIFACTS_PATH } from "./constants.js"; +import { generateKeyPair } from "./utils.js"; + +describe("should be able to serialize outputs", function () { + it("should serialize proof request outputs", async function () { + const { publicKey, privateKey } = generateKeyPair(); + + const pod1 = p.pod({ + entries: { + foo: { type: "string" }, + bar: { + type: "int", + inRange: { min: 0n, max: 10n } + } + }, + signerPublicKey: { + isMemberOf: [publicKey] + }, + tuples: [ + { + entries: ["$signerPublicKey", "foo", "bar"], + isMemberOf: [ + [ + { type: "eddsa_pubkey", value: publicKey }, + { type: "string", value: "test" }, + { type: "int", value: 5n } + ] + ] + } + ] + }); + const prs = p.proofRequest({ + pods: { + pod1: pod1.proofConfig({ revealed: { foo: true, bar: true } }) + }, + watermark: { type: "string", value: "1" }, + externalNullifier: { type: "string", value: "1" } + }); + + const pr = prs.getProofRequest(); + console.dir(pr, { depth: null }); + + expect(() => proofConfigToJSON(pr.proofConfig)).to.not.throw; + expect(() => podMembershipListsToJSON(pr.membershipLists)).to.not.throw; + + const pod = POD.sign( + { + foo: { type: "string", value: "test" }, + bar: { type: "int", value: 5n } + }, + privateKey + ); + + const proof = await gpcProve( + pr.proofConfig, + { + membershipLists: pr.membershipLists, + pods: { pod1: pod } + }, + GPC_NPM_ARTIFACTS_PATH + ); + + pr.proofConfig.circuitIdentifier = proof.boundConfig.circuitIdentifier; + const boundConfig: GPCBoundConfig = { + ...pr.proofConfig, + circuitIdentifier: proof.boundConfig.circuitIdentifier + }; + + expect(() => boundConfigToJSON(boundConfig)).to.not.throw; + expect(() => revealedClaimsToJSON(proof.revealedClaims)).to.not.throw; + }); +}); diff --git a/packages/podspec/test/ticket-example.spec.ts b/packages/podspec/test/ticket-example.spec.ts index 175c668..51bee30 100644 --- a/packages/podspec/test/ticket-example.spec.ts +++ b/packages/podspec/test/ticket-example.spec.ts @@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid"; import { assert, describe, expect, it } from "vitest"; import * as p from "../src/index.js"; import { $s } from "../src/pod_value_utils.js"; -import { GPC_NPM_ARTIFACTS_PATH } from "./podspec.spec.js"; +import { GPC_NPM_ARTIFACTS_PATH } from "./constants.js"; import { generateKeyPair } from "./utils.js"; /** diff --git a/packages/ticket-spec/CHANGELOG.md b/packages/ticket-spec/CHANGELOG.md index c85a31d..21c1eb9 100644 --- a/packages/ticket-spec/CHANGELOG.md +++ b/packages/ticket-spec/CHANGELOG.md @@ -1,5 +1,13 @@ # @parcnet-js/ticket-spec +## 1.1.6 + +### Patch Changes + +- Updated dependencies + - @parcnet-js/podspec@1.1.3 + - @parcnet-js/client-rpc@1.1.6 + ## 1.1.5 ### Patch Changes diff --git a/packages/ticket-spec/package.json b/packages/ticket-spec/package.json index a1e09c0..2f5cd35 100644 --- a/packages/ticket-spec/package.json +++ b/packages/ticket-spec/package.json @@ -1,6 +1,6 @@ { "name": "@parcnet-js/ticket-spec", - "version": "1.1.5", + "version": "1.1.6", "license": "GPL-3.0-or-later", "type": "module", "main": "dist/index.js",