@zkproofport-app/sdk 0.4.2 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,27 +11,28 @@
11
11
  * (through mopro's native Barretenberg); it was only the JavaScript side that
12
12
  * had no such thing.
13
13
  *
14
- * HOW IT WORKS. Proofs here are made with `--oracle_hash keccak` and ZK on, so
15
- * the matching check is `acirVerifyUltraKeccakZkHonk(proof, vk)`. Two things
16
- * have to line up:
14
+ * HOW IT WORKS. Proofs here are made for the EVM target (`bb prove -t evm`:
15
+ * keccak transcript, ZK on), so the matching check is bb.js's
16
+ * `UltraHonkVerifierBackend.verifyProof(..., { verifierTarget: 'evm' })`. Two
17
+ * things have to line up:
17
18
  *
18
- * The version. `@aztec/bb.js@1.0.0-nightly.20250723` is the WASM build of the
19
- * same bb the circuits are compiled with. Versions are not interchangeable:
20
- * measured on the Korea Mobile ID age circuit, the pinned bb writes a 16256-
21
- * byte proof where bb 1.2.0 writes 16224 for the identical circuit and
22
- * witness — and the verification key comes out the SAME either way, so the
23
- * key cannot warn you. A mismatch shows up only as verification failing.
19
+ * The version. `@aztec/bb.js` must be the WASM build of the same bb the
20
+ * circuits are compiled with -- `BB_VERSION` in circuits/toolchain.env,
21
+ * 4.2.0-aztecnr-rc.2 since the beta.19 toolchain. Versions are not
22
+ * interchangeable: on the Korea Mobile ID age circuit the 2025 nightly wrote
23
+ * a 16256-byte proof where bb 1.2.0 wrote 16224 for the identical circuit and
24
+ * witness, with the SAME verification key, so the key cannot warn you. A
25
+ * mismatch shows up only as verification failing.
24
26
  *
25
- * The flavour. There are four verify entry points and picking the wrong one
26
- * is not a polite false. `acirVerifyUltraZKHonk` (poseidon) answers false for
27
- * a perfectly good proof, and `acirVerifyUltraKeccakHonk` — keccak without ZK
28
- * — TRAPS the WebAssembly with a bare "unreachable", which looks exactly like
29
- * a corrupt proof, a mismatched key, or a missing SRS.
27
+ * The target. Verifying an EVM proof as any other target is not a polite
28
+ * false. With the 2025 nightly, keccak-without-ZK trapped the WebAssembly
29
+ * with a bare "unreachable" and the poseidon flavour answered false for a
30
+ * good proof.
30
31
  *
31
32
  * THE PROOF ARRIVES IN TWO PIECES. The mobile app splits what Barretenberg
32
33
  * produced into `proof` and `publicInputs` before sending it, because the
33
- * Solidity verifier takes them separately. Verifying needs them joined back, in
34
- * that order, which is what `reconstructHonkProof` does.
34
+ * Solidity verifier takes them separately. bb.js 4.x's verifier takes the same
35
+ * two pieces, so nothing is joined back here.
35
36
  */
36
37
  import { type CircuitId } from './circuits';
37
38
  export interface OffChainVerifyResult {
@@ -1,34 +1 @@
1
- /**
2
- * Checking the EIP-712 action a `giwa_attestation` proof binds to.
3
- *
4
- * Three places need this answer and they have to agree: a dapp building the
5
- * request, this SDK validating a deep link, and the mobile app before it asks
6
- * a wallet to sign. The check lived in the mobile app's demo screen and
7
- * nowhere else, so an action arriving from a dapp reached the prover
8
- * unexamined — and that is the path that ships.
9
- *
10
- * The circuit hashes the domain and the struct and proves the wallet signed
11
- * them. It never learns what the action says, so a malformed one does not
12
- * fail: it produces a valid proof of the wrong thing.
13
- */
14
- import type { TypedAction } from './types';
15
- export type { TypedAction };
16
- /**
17
- * The reason the value is not a usable action, or `null` when it is one.
18
- *
19
- * Structural validation only, not application authorization policy. Consumers
20
- * (e.g. EligibilityGate) must independently enforce the expected chain, verifying
21
- * contract, actor, action parameters, nonce and deadline as applicable.
22
- * EIP-712 signs only fields declared in types, not extra message properties.
23
- *
24
- * A string rather than a boolean because every caller shows it to somebody —
25
- * a dapp developer reading a validation error, or a person looking at the
26
- * mobile app's demo screen.
27
- */
28
- export declare function validateTypedAction(value: unknown): string | null;
29
- /** The action, or the reason it is not one. For text a person typed. */
30
- export declare function parseTypedAction(text: string): {
31
- action: TypedAction;
32
- } | {
33
- error: string;
34
- };
1
+ export * from '@zkproofport-app/core/typedAction';
@@ -1,77 +1,2 @@
1
- const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
2
- /**
3
- * The reason the value is not a usable action, or `null` when it is one.
4
- *
5
- * Structural validation only, not application authorization policy. Consumers
6
- * (e.g. EligibilityGate) must independently enforce the expected chain, verifying
7
- * contract, actor, action parameters, nonce and deadline as applicable.
8
- * EIP-712 signs only fields declared in types, not extra message properties.
9
- *
10
- * A string rather than a boolean because every caller shows it to somebody —
11
- * a dapp developer reading a validation error, or a person looking at the
12
- * mobile app's demo screen.
13
- */
14
- function validateTypedAction(value) {
15
- if (value === undefined || value === null) {
16
- return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';
17
- }
18
- if (typeof value !== 'object' || Array.isArray(value)) {
19
- return 'action must be an object.';
20
- }
21
- const a = value;
22
- const d = a.domain;
23
- if (!d || typeof d !== 'object') {
24
- return 'action.domain is required.';
25
- }
26
- for (const k of ['name', 'version', 'verifyingContract']) {
27
- if (typeof d[k] !== 'string' || !d[k]) {
28
- return `action.domain.${k} must be a non-empty string.`;
29
- }
30
- }
31
- if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {
32
- return 'action.domain.chainId must be an integer.';
33
- }
34
- if (!ADDRESS.test(d.verifyingContract)) {
35
- return 'action.domain.verifyingContract must be a 20-byte hex address.';
36
- }
37
- if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {
38
- return 'action.types is required.';
39
- }
40
- if (typeof a.primaryType !== 'string' || !a.primaryType) {
41
- return 'action.primaryType is required.';
42
- }
43
- if (!(a.primaryType in a.types)) {
44
- return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;
45
- }
46
- if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {
47
- return 'action.message is required.';
48
- }
49
- // Every field the struct declares must be present, or the wallet signs a
50
- // different message than the one the caller described.
51
- const fields = a.types[a.primaryType];
52
- if (!Array.isArray(fields) || fields.length === 0) {
53
- return `action.types.${a.primaryType} declares no fields.`;
54
- }
55
- const missing = fields
56
- .map(f => f?.name)
57
- .filter(n => typeof n === 'string' && !(n in a.message));
58
- if (missing.length) {
59
- return `action.message is missing: ${missing.join(', ')}`;
60
- }
61
- return null;
62
- }
63
- /** The action, or the reason it is not one. For text a person typed. */
64
- function parseTypedAction(text) {
65
- let raw;
66
- try {
67
- raw = JSON.parse(text);
68
- }
69
- catch (e) {
70
- return { error: `Not valid JSON: ${e.message}` };
71
- }
72
- const error = validateTypedAction(raw);
73
- return error ? { error } : { action: raw };
74
- }
75
-
76
- export { parseTypedAction, validateTypedAction };
1
+ export * from '@zkproofport-app/core/typedAction';
77
2
  //# sourceMappingURL=typedAction.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedAction.esm.js","sources":["../src/typedAction.ts"],"sourcesContent":["/**\n * Checking the EIP-712 action a `giwa_attestation` proof binds to.\n *\n * Three places need this answer and they have to agree: a dapp building the\n * request, this SDK validating a deep link, and the mobile app before it asks\n * a wallet to sign. The check lived in the mobile app's demo screen and\n * nowhere else, so an action arriving from a dapp reached the prover\n * unexamined — and that is the path that ships.\n *\n * The circuit hashes the domain and the struct and proves the wallet signed\n * them. It never learns what the action says, so a malformed one does not\n * fail: it produces a valid proof of the wrong thing.\n */\nimport type { TypedAction } from './types';\n\nexport type { TypedAction };\n\nconst ADDRESS = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The reason the value is not a usable action, or `null` when it is one.\n *\n * Structural validation only, not application authorization policy. Consumers\n * (e.g. EligibilityGate) must independently enforce the expected chain, verifying\n * contract, actor, action parameters, nonce and deadline as applicable.\n * EIP-712 signs only fields declared in types, not extra message properties.\n *\n * A string rather than a boolean because every caller shows it to somebody —\n * a dapp developer reading a validation error, or a person looking at the\n * mobile app's demo screen.\n */\nexport function validateTypedAction(value: unknown): string | null {\n if (value === undefined || value === null) {\n return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';\n }\n if (typeof value !== 'object' || Array.isArray(value)) {\n return 'action must be an object.';\n }\n const a = value as Partial<TypedAction>;\n\n const d = a.domain;\n if (!d || typeof d !== 'object') {\n return 'action.domain is required.';\n }\n for (const k of ['name', 'version', 'verifyingContract'] as const) {\n if (typeof d[k] !== 'string' || !d[k]) {\n return `action.domain.${k} must be a non-empty string.`;\n }\n }\n if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {\n return 'action.domain.chainId must be an integer.';\n }\n if (!ADDRESS.test(d.verifyingContract)) {\n return 'action.domain.verifyingContract must be a 20-byte hex address.';\n }\n\n if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {\n return 'action.types is required.';\n }\n if (typeof a.primaryType !== 'string' || !a.primaryType) {\n return 'action.primaryType is required.';\n }\n if (!(a.primaryType in a.types)) {\n return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;\n }\n if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {\n return 'action.message is required.';\n }\n\n // Every field the struct declares must be present, or the wallet signs a\n // different message than the one the caller described.\n const fields = a.types[a.primaryType];\n if (!Array.isArray(fields) || fields.length === 0) {\n return `action.types.${a.primaryType} declares no fields.`;\n }\n const missing = fields\n .map(f => f?.name)\n .filter(n => typeof n === 'string' && !(n in (a.message as object)));\n if (missing.length) {\n return `action.message is missing: ${missing.join(', ')}`;\n }\n\n return null;\n}\n\n/** The action, or the reason it is not one. For text a person typed. */\nexport function parseTypedAction(text: string): { action: TypedAction } | { error: string } {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (e) {\n return { error: `Not valid JSON: ${(e as Error).message}` };\n }\n const error = validateTypedAction(raw);\n return error ? { error } : { action: raw as TypedAction };\n}\n"],"names":[],"mappings":"AAiBA,MAAM,OAAO,GAAG,qBAAqB;AAErC;;;;;;;;;;;AAWG;AACG,SAAU,mBAAmB,CAAC,KAAc,EAAA;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;AACzC,QAAA,OAAO,2HAA2H;IACpI;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAA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ict';
2
2
 
3
- const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
4
- /**
5
- * The reason the value is not a usable action, or `null` when it is one.
6
- *
7
- * Structural validation only, not application authorization policy. Consumers
8
- * (e.g. EligibilityGate) must independently enforce the expected chain, verifying
9
- * contract, actor, action parameters, nonce and deadline as applicable.
10
- * EIP-712 signs only fields declared in types, not extra message properties.
11
- *
12
- * A string rather than a boolean because every caller shows it to somebody —
13
- * a dapp developer reading a validation error, or a person looking at the
14
- * mobile app's demo screen.
15
- */
16
- function validateTypedAction(value) {
17
- if (value === undefined || value === null) {
18
- return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';
19
- }
20
- if (typeof value !== 'object' || Array.isArray(value)) {
21
- return 'action must be an object.';
22
- }
23
- const a = value;
24
- const d = a.domain;
25
- if (!d || typeof d !== 'object') {
26
- return 'action.domain is required.';
27
- }
28
- for (const k of ['name', 'version', 'verifyingContract']) {
29
- if (typeof d[k] !== 'string' || !d[k]) {
30
- return `action.domain.${k} must be a non-empty string.`;
31
- }
32
- }
33
- if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {
34
- return 'action.domain.chainId must be an integer.';
35
- }
36
- if (!ADDRESS.test(d.verifyingContract)) {
37
- return 'action.domain.verifyingContract must be a 20-byte hex address.';
38
- }
39
- if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {
40
- return 'action.types is required.';
41
- }
42
- if (typeof a.primaryType !== 'string' || !a.primaryType) {
43
- return 'action.primaryType is required.';
44
- }
45
- if (!(a.primaryType in a.types)) {
46
- return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;
47
- }
48
- if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {
49
- return 'action.message is required.';
50
- }
51
- // Every field the struct declares must be present, or the wallet signs a
52
- // different message than the one the caller described.
53
- const fields = a.types[a.primaryType];
54
- if (!Array.isArray(fields) || fields.length === 0) {
55
- return `action.types.${a.primaryType} declares no fields.`;
56
- }
57
- const missing = fields
58
- .map(f => f?.name)
59
- .filter(n => typeof n === 'string' && !(n in a.message));
60
- if (missing.length) {
61
- return `action.message is missing: ${missing.join(', ')}`;
62
- }
63
- return null;
64
- }
65
- /** The action, or the reason it is not one. For text a person typed. */
66
- function parseTypedAction(text) {
67
- let raw;
68
- try {
69
- raw = JSON.parse(text);
70
- }
71
- catch (e) {
72
- return { error: `Not valid JSON: ${e.message}` };
73
- }
74
- const error = validateTypedAction(raw);
75
- return error ? { error } : { action: raw };
76
- }
3
+ var typedAction = require('@zkproofport-app/core/typedAction');
77
4
 
78
- exports.parseTypedAction = parseTypedAction;
79
- exports.validateTypedAction = validateTypedAction;
5
+
6
+
7
+ Object.keys(typedAction).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return typedAction[k]; }
11
+ });
12
+ });
80
13
  //# sourceMappingURL=typedAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedAction.js","sources":["../src/typedAction.ts"],"sourcesContent":["/**\n * Checking the EIP-712 action a `giwa_attestation` proof binds to.\n *\n * Three places need this answer and they have to agree: a dapp building the\n * request, this SDK validating a deep link, and the mobile app before it asks\n * a wallet to sign. The check lived in the mobile app's demo screen and\n * nowhere else, so an action arriving from a dapp reached the prover\n * unexamined — and that is the path that ships.\n *\n * The circuit hashes the domain and the struct and proves the wallet signed\n * them. It never learns what the action says, so a malformed one does not\n * fail: it produces a valid proof of the wrong thing.\n */\nimport type { TypedAction } from './types';\n\nexport type { TypedAction };\n\nconst ADDRESS = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The reason the value is not a usable action, or `null` when it is one.\n *\n * Structural validation only, not application authorization policy. Consumers\n * (e.g. EligibilityGate) must independently enforce the expected chain, verifying\n * contract, actor, action parameters, nonce and deadline as applicable.\n * EIP-712 signs only fields declared in types, not extra message properties.\n *\n * A string rather than a boolean because every caller shows it to somebody —\n * a dapp developer reading a validation error, or a person looking at the\n * mobile app's demo screen.\n */\nexport function validateTypedAction(value: unknown): string | null {\n if (value === undefined || value === null) {\n return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';\n }\n if (typeof value !== 'object' || Array.isArray(value)) {\n return 'action must be an object.';\n }\n const a = value as Partial<TypedAction>;\n\n const d = a.domain;\n if (!d || typeof d !== 'object') {\n return 'action.domain is required.';\n }\n for (const k of ['name', 'version', 'verifyingContract'] as const) {\n if (typeof d[k] !== 'string' || !d[k]) {\n return `action.domain.${k} must be a non-empty string.`;\n }\n }\n if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {\n return 'action.domain.chainId must be an integer.';\n }\n if (!ADDRESS.test(d.verifyingContract)) {\n return 'action.domain.verifyingContract must be a 20-byte hex address.';\n }\n\n if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {\n return 'action.types is required.';\n }\n if (typeof a.primaryType !== 'string' || !a.primaryType) {\n return 'action.primaryType is required.';\n }\n if (!(a.primaryType in a.types)) {\n return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;\n }\n if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {\n return 'action.message is required.';\n }\n\n // Every field the struct declares must be present, or the wallet signs a\n // different message than the one the caller described.\n const fields = a.types[a.primaryType];\n if (!Array.isArray(fields) || fields.length === 0) {\n return `action.types.${a.primaryType} declares no fields.`;\n }\n const missing = fields\n .map(f => f?.name)\n .filter(n => typeof n === 'string' && !(n in (a.message as object)));\n if (missing.length) {\n return `action.message is missing: ${missing.join(', ')}`;\n }\n\n return null;\n}\n\n/** The action, or the reason it is not one. For text a person typed. */\nexport function parseTypedAction(text: string): { action: TypedAction } | { error: string } {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (e) {\n return { error: `Not valid JSON: ${(e as Error).message}` };\n }\n const error = validateTypedAction(raw);\n return error ? { error } : { action: raw as TypedAction };\n}\n"],"names":[],"mappings":";;AAiBA,MA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MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC;AACtC,IAAA,OAAO,KAAK,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAkB,EAAE;AAC3D;;;;;"}
1
+ {"version":3,"file":"typedAction.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,77 +1,2 @@
1
- const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
2
- /**
3
- * The reason the value is not a usable action, or `null` when it is one.
4
- *
5
- * Structural validation only, not application authorization policy. Consumers
6
- * (e.g. EligibilityGate) must independently enforce the expected chain, verifying
7
- * contract, actor, action parameters, nonce and deadline as applicable.
8
- * EIP-712 signs only fields declared in types, not extra message properties.
9
- *
10
- * A string rather than a boolean because every caller shows it to somebody —
11
- * a dapp developer reading a validation error, or a person looking at the
12
- * mobile app's demo screen.
13
- */
14
- function validateTypedAction(value) {
15
- if (value === undefined || value === null) {
16
- return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';
17
- }
18
- if (typeof value !== 'object' || Array.isArray(value)) {
19
- return 'action must be an object.';
20
- }
21
- const a = value;
22
- const d = a.domain;
23
- if (!d || typeof d !== 'object') {
24
- return 'action.domain is required.';
25
- }
26
- for (const k of ['name', 'version', 'verifyingContract']) {
27
- if (typeof d[k] !== 'string' || !d[k]) {
28
- return `action.domain.${k} must be a non-empty string.`;
29
- }
30
- }
31
- if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {
32
- return 'action.domain.chainId must be an integer.';
33
- }
34
- if (!ADDRESS.test(d.verifyingContract)) {
35
- return 'action.domain.verifyingContract must be a 20-byte hex address.';
36
- }
37
- if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {
38
- return 'action.types is required.';
39
- }
40
- if (typeof a.primaryType !== 'string' || !a.primaryType) {
41
- return 'action.primaryType is required.';
42
- }
43
- if (!(a.primaryType in a.types)) {
44
- return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;
45
- }
46
- if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {
47
- return 'action.message is required.';
48
- }
49
- // Every field the struct declares must be present, or the wallet signs a
50
- // different message than the one the caller described.
51
- const fields = a.types[a.primaryType];
52
- if (!Array.isArray(fields) || fields.length === 0) {
53
- return `action.types.${a.primaryType} declares no fields.`;
54
- }
55
- const missing = fields
56
- .map(f => f?.name)
57
- .filter(n => typeof n === 'string' && !(n in a.message));
58
- if (missing.length) {
59
- return `action.message is missing: ${missing.join(', ')}`;
60
- }
61
- return null;
62
- }
63
- /** The action, or the reason it is not one. For text a person typed. */
64
- function parseTypedAction(text) {
65
- let raw;
66
- try {
67
- raw = JSON.parse(text);
68
- }
69
- catch (e) {
70
- return { error: `Not valid JSON: ${e.message}` };
71
- }
72
- const error = validateTypedAction(raw);
73
- return error ? { error } : { action: raw };
74
- }
75
-
76
- export { parseTypedAction, validateTypedAction };
1
+ export * from '@zkproofport-app/core/typedAction';
77
2
  //# sourceMappingURL=typedAction.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedAction.mjs","sources":["../src/typedAction.ts"],"sourcesContent":["/**\n * Checking the EIP-712 action a `giwa_attestation` proof binds to.\n *\n * Three places need this answer and they have to agree: a dapp building the\n * request, this SDK validating a deep link, and the mobile app before it asks\n * a wallet to sign. The check lived in the mobile app's demo screen and\n * nowhere else, so an action arriving from a dapp reached the prover\n * unexamined — and that is the path that ships.\n *\n * The circuit hashes the domain and the struct and proves the wallet signed\n * them. It never learns what the action says, so a malformed one does not\n * fail: it produces a valid proof of the wrong thing.\n */\nimport type { TypedAction } from './types';\n\nexport type { TypedAction };\n\nconst ADDRESS = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The reason the value is not a usable action, or `null` when it is one.\n *\n * Structural validation only, not application authorization policy. Consumers\n * (e.g. EligibilityGate) must independently enforce the expected chain, verifying\n * contract, actor, action parameters, nonce and deadline as applicable.\n * EIP-712 signs only fields declared in types, not extra message properties.\n *\n * A string rather than a boolean because every caller shows it to somebody —\n * a dapp developer reading a validation error, or a person looking at the\n * mobile app's demo screen.\n */\nexport function validateTypedAction(value: unknown): string | null {\n if (value === undefined || value === null) {\n return 'action is required. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';\n }\n if (typeof value !== 'object' || Array.isArray(value)) {\n return 'action must be an object.';\n }\n const a = value as Partial<TypedAction>;\n\n const d = a.domain;\n if (!d || typeof d !== 'object') {\n return 'action.domain is required.';\n }\n for (const k of ['name', 'version', 'verifyingContract'] as const) {\n if (typeof d[k] !== 'string' || !d[k]) {\n return `action.domain.${k} must be a non-empty string.`;\n }\n }\n if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {\n return 'action.domain.chainId must be an integer.';\n }\n if (!ADDRESS.test(d.verifyingContract)) {\n return 'action.domain.verifyingContract must be a 20-byte hex address.';\n }\n\n if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {\n return 'action.types is required.';\n }\n if (typeof a.primaryType !== 'string' || !a.primaryType) {\n return 'action.primaryType is required.';\n }\n if (!(a.primaryType in a.types)) {\n return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;\n }\n if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {\n return 'action.message is required.';\n }\n\n // Every field the struct declares must be present, or the wallet signs a\n // different message than the one the caller described.\n const fields = a.types[a.primaryType];\n if (!Array.isArray(fields) || fields.length === 0) {\n return `action.types.${a.primaryType} declares no fields.`;\n }\n const missing = fields\n .map(f => f?.name)\n .filter(n => typeof n === 'string' && !(n in (a.message as object)));\n if (missing.length) {\n return `action.message is missing: ${missing.join(', ')}`;\n }\n\n return null;\n}\n\n/** The action, or the reason it is not one. For text a person typed. */\nexport function parseTypedAction(text: string): { action: TypedAction } | { error: string } {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (e) {\n return { error: `Not valid JSON: ${(e as Error).message}` };\n }\n const error = validateTypedAction(raw);\n return error ? { error } : { action: raw as Typed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AAA,CAAE,EAAE;IAC7D;AACA,IAAA,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC;AACtC,IAAA,OAAO,KAAK,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAkB,EAAE;AAC3D;;;;"}
1
+ {"version":3,"file":"typedAction.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/types.d.ts CHANGED
@@ -1,24 +1,8 @@
1
1
  /**
2
2
  * ZKProofport SDK Types
3
3
  */
4
- import type { CircuitId } from './circuits';
5
- /**
6
- * Zero-knowledge circuit identifiers.
7
- * Uses canonical circuit names matching Nargo.toml circuit definitions.
8
- *
9
- * Alias of {@link CircuitId}, which is defined in `./circuits` — the single
10
- * source of truth for circuit identifiers. Adding a circuit there widens this
11
- * type automatically, so the two can never disagree.
12
- *
13
- * Note that this union includes circuits marked `planned` in
14
- * `CIRCUIT_SUPPORT_STATUS`; being assignable is not a support guarantee.
15
- *
16
- * @example
17
- * ```typescript
18
- * const circuit: CircuitType = 'coinbase_attestation';
19
- * ```
20
- */
21
- export type CircuitType = CircuitId;
4
+ import type { CircuitType, TypedAction, ParsedProof, VerifierContract } from '@zkproofport-app/core';
5
+ export type { CircuitType, TypedAction, ParsedProof, VerifierContract };
22
6
  /**
23
7
  * Proof request lifecycle status.
24
8
  *
@@ -167,43 +151,6 @@ export interface MdlKrRegionInputs {
167
151
  */
168
152
  export interface EmptyInputs {
169
153
  }
170
- /**
171
- * The EIP-712 action a `giwa_attestation` proof binds the wallet's signature to.
172
- *
173
- * Exactly what `eth_signTypedData_v4` takes, because that is what the wallet is
174
- * shown and what it signs. The app does not build this — the dapp does — so the
175
- * user reads the dapp's own field names and values in their wallet instead of
176
- * an opaque hash.
177
- *
178
- * @example
179
- * ```typescript
180
- * const action: TypedAction = {
181
- * domain: { name: 'MyVault', version: '1', chainId: 91342,
182
- * verifyingContract: '0x…' },
183
- * types: { Deposit: [ { name: 'amount', type: 'uint256' },
184
- * { name: 'nonce', type: 'uint256' } ] },
185
- * primaryType: 'Deposit',
186
- * message: { amount: '1000000', nonce: '7' },
187
- * };
188
- * ```
189
- */
190
- export interface TypedAction {
191
- domain: {
192
- name: string;
193
- version: string;
194
- chainId: number;
195
- /** The contract that will verify this signature. */
196
- verifyingContract: string;
197
- };
198
- /** EIP-712 struct definitions. `EIP712Domain` is added by the wallet. */
199
- types: Record<string, Array<{
200
- name: string;
201
- type: string;
202
- }>>;
203
- /** Which struct in `types` the message is. */
204
- primaryType: string;
205
- message: Record<string, unknown>;
206
- }
207
154
  /**
208
155
  * Input parameters for circuits that can bind an EIP-712 action
209
156
  * (`giwa_attestation`).
@@ -334,20 +281,6 @@ export interface ProofResponse {
334
281
  /** Chain ID where verifier contract is deployed (provided by mobile app) */
335
282
  chainId?: number;
336
283
  }
337
- /**
338
- * Parsed and formatted proof data ready for on-chain verification.
339
- *
340
- * Internal representation used by the SDK to prepare proof data
341
- * for smart contract verification calls.
342
- */
343
- export interface ParsedProof {
344
- /** Proof bytes as hex string with 0x prefix */
345
- proofHex: string;
346
- /** Public inputs as array of hex strings with 0x prefix */
347
- publicInputsHex: string[];
348
- /** Number of public inputs (must match circuit specification) */
349
- numPublicInputs: number;
350
- }
351
284
  /**
352
285
  * QR code generation options for deep link encoding.
353
286
  *
@@ -376,20 +309,6 @@ export interface QRCodeOptions {
376
309
  /** Background color as hex string (default: #ffffff) */
377
310
  lightColor?: string;
378
311
  }
379
- /**
380
- * Verifier smart contract configuration.
381
- *
382
- * Contains the address and ABI for a circuit's verifier contract on a specific chain.
383
- * Each circuit has its own verifier contract that validates proofs on-chain.
384
- */
385
- export interface VerifierContract {
386
- /** Verifier contract address (checksummed) */
387
- address: string;
388
- /** Chain ID where contract is deployed (e.g., 84532 for Base Sepolia) */
389
- chainId: number;
390
- /** Contract ABI for verify function (ethers v6 format) */
391
- abi: string[];
392
- }
393
312
  /**
394
313
  * ZKProofport SDK configuration options.
395
314
  *