@zkproofport-app/sdk 0.2.2 → 0.2.3
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.
- package/README.md +53 -26
- package/dist/ProofportSDK.d.ts +1 -0
- package/dist/constants.d.ts +28 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +100 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +100 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -40
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +18 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -67,6 +67,12 @@ const CIRCUIT_METADATA = {
|
|
|
67
67
|
publicInputsCount: 14,
|
|
68
68
|
publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'country_list', 'country_list_length', 'is_included'],
|
|
69
69
|
},
|
|
70
|
+
oidc_domain_attestation: {
|
|
71
|
+
name: 'OIDC Domain',
|
|
72
|
+
description: 'Prove email domain affiliation via OIDC JWT',
|
|
73
|
+
publicInputsCount: 420,
|
|
74
|
+
publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier'],
|
|
75
|
+
},
|
|
70
76
|
};
|
|
71
77
|
/**
|
|
72
78
|
* Standard verifier contract ABI shared across all Barretenberg-generated verifiers.
|
|
@@ -198,6 +204,34 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
|
|
|
198
204
|
NULLIFIER_START: 118,
|
|
199
205
|
NULLIFIER_END: 149,
|
|
200
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* OIDC Domain Attestation circuit public input layout (byte offsets).
|
|
209
|
+
* Defines the byte positions of each field in the flattened public inputs array.
|
|
210
|
+
*
|
|
211
|
+
* Public inputs are packed as individual field elements (one byte per element):
|
|
212
|
+
* - pubkey_modulus_limbs: 18 x u128 = 18 x 16 bytes = 288 bytes → fields 0–287
|
|
213
|
+
* - domain (BoundedVec<u8, 64>): 4-byte length (u32) + 64-byte storage = 68 fields → fields 288–355
|
|
214
|
+
* - scope: 32 bytes → fields 356–387
|
|
215
|
+
* - nullifier: 32 bytes → fields 388–419
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const scope = publicInputs.slice(
|
|
220
|
+
* OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT.SCOPE_START,
|
|
221
|
+
* OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT.SCOPE_END + 1
|
|
222
|
+
* );
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
const OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = {
|
|
226
|
+
PUBKEY_MODULUS_START: 0,
|
|
227
|
+
PUBKEY_MODULUS_END: 287,
|
|
228
|
+
DOMAIN_START: 288,
|
|
229
|
+
DOMAIN_END: 355,
|
|
230
|
+
SCOPE_START: 356,
|
|
231
|
+
SCOPE_END: 387,
|
|
232
|
+
NULLIFIER_START: 388,
|
|
233
|
+
NULLIFIER_END: 419,
|
|
234
|
+
};
|
|
201
235
|
|
|
202
236
|
/**
|
|
203
237
|
* Deep Link utilities for ZKProofport SDK
|
|
@@ -450,7 +484,7 @@ function validateProofRequest(request) {
|
|
|
450
484
|
if (!request.circuit) {
|
|
451
485
|
return { valid: false, error: 'Missing circuit type' };
|
|
452
486
|
}
|
|
453
|
-
if (!['coinbase_attestation', 'coinbase_country_attestation'].includes(request.circuit)) {
|
|
487
|
+
if (!['coinbase_attestation', 'coinbase_country_attestation', 'oidc_domain_attestation'].includes(request.circuit)) {
|
|
454
488
|
return { valid: false, error: `Invalid circuit type: ${request.circuit}` };
|
|
455
489
|
}
|
|
456
490
|
if (!request.callbackUrl) {
|
|
@@ -480,6 +514,15 @@ function validateProofRequest(request) {
|
|
|
480
514
|
return { valid: false, error: 'isIncluded is required and must be a boolean' };
|
|
481
515
|
}
|
|
482
516
|
}
|
|
517
|
+
else if (request.circuit === 'oidc_domain_attestation') {
|
|
518
|
+
const inputs = request.inputs;
|
|
519
|
+
if (!inputs.domain || typeof inputs.domain !== 'string' || inputs.domain.trim() === '') {
|
|
520
|
+
return { valid: false, error: 'domain is required and must be a non-empty string' };
|
|
521
|
+
}
|
|
522
|
+
if (!inputs.scope || typeof inputs.scope !== 'string' || inputs.scope.trim() === '') {
|
|
523
|
+
return { valid: false, error: 'scope is required and must be a non-empty string' };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
483
526
|
// Check expiry
|
|
484
527
|
if (request.expiresAt && Date.now() > request.expiresAt) {
|
|
485
528
|
return { valid: false, error: 'Request has expired' };
|
|
@@ -3781,6 +3824,10 @@ function extractScopeFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3781
3824
|
start = 86;
|
|
3782
3825
|
end = 117;
|
|
3783
3826
|
}
|
|
3827
|
+
else if (circuit === 'oidc_domain_attestation') {
|
|
3828
|
+
start = 356;
|
|
3829
|
+
end = 387;
|
|
3830
|
+
}
|
|
3784
3831
|
else {
|
|
3785
3832
|
start = 64;
|
|
3786
3833
|
end = 95;
|
|
@@ -3814,6 +3861,10 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3814
3861
|
start = 118;
|
|
3815
3862
|
end = 149;
|
|
3816
3863
|
}
|
|
3864
|
+
else if (circuit === 'oidc_domain_attestation') {
|
|
3865
|
+
start = 388;
|
|
3866
|
+
end = 419;
|
|
3867
|
+
}
|
|
3817
3868
|
else {
|
|
3818
3869
|
start = 96;
|
|
3819
3870
|
end = 127;
|
|
@@ -4705,53 +4756,26 @@ class ProofportSDK {
|
|
|
4705
4756
|
}
|
|
4706
4757
|
return await response.json();
|
|
4707
4758
|
}
|
|
4708
|
-
/**
|
|
4709
|
-
* Creates a proof request through the relay server.
|
|
4710
|
-
*
|
|
4711
|
-
* This is the recommended way to create proof requests. The relay server:
|
|
4712
|
-
* - Issues a server-side requestId (validated by the mobile app)
|
|
4713
|
-
* - Tracks request status in Redis
|
|
4714
|
-
* - Builds the deep link with relay callback URL
|
|
4715
|
-
* - Stores inputs hash for deep link integrity verification
|
|
4716
|
-
*
|
|
4717
|
-
* @param circuit - Circuit type identifier
|
|
4718
|
-
* @param inputs - Circuit-specific inputs
|
|
4719
|
-
* @param options - Request options (message, dappName, dappIcon, nonce)
|
|
4720
|
-
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
4721
|
-
* @throws Error if signer not set or relay request fails
|
|
4722
|
-
*
|
|
4723
|
-
* @example
|
|
4724
|
-
* ```typescript
|
|
4725
|
-
* const sdk = ProofportSDK.create();
|
|
4726
|
-
* sdk.setSigner(signer);
|
|
4727
|
-
*
|
|
4728
|
-
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
4729
|
-
* scope: 'myapp.com'
|
|
4730
|
-
* }, { dappName: 'My DApp' });
|
|
4731
|
-
*
|
|
4732
|
-
* // Generate QR code from relay deep link
|
|
4733
|
-
* const qr = await sdk.generateQRCode(relay.deepLink);
|
|
4734
|
-
*
|
|
4735
|
-
* // Wait for proof (WebSocket primary, polling fallback)
|
|
4736
|
-
* const result = await sdk.waitForProof(relay.requestId);
|
|
4737
|
-
* ```
|
|
4738
|
-
*/
|
|
4739
4759
|
async createRelayRequest(circuit, inputs, options = {}) {
|
|
4740
|
-
if (!this.signer) {
|
|
4741
|
-
throw new Error('Signer not set. Call setSigner() first.');
|
|
4742
|
-
}
|
|
4743
4760
|
if (!this.relayUrl) {
|
|
4744
4761
|
throw new Error('relayUrl is required. Set it in ProofportSDK config.');
|
|
4745
4762
|
}
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4763
|
+
const needsSignature = ProofportSDK.WALLET_SIGNATURE_CIRCUITS.includes(circuit);
|
|
4764
|
+
if (needsSignature && !this.signer) {
|
|
4765
|
+
throw new Error('Signer not set. Call setSigner() first. Wallet signature is required for this circuit.');
|
|
4766
|
+
}
|
|
4767
|
+
// Get challenge + requestId from relay
|
|
4768
|
+
const { requestId, challenge } = await this.getChallenge();
|
|
4749
4769
|
const body = {
|
|
4770
|
+
requestId,
|
|
4750
4771
|
circuitId: circuit,
|
|
4751
4772
|
inputs,
|
|
4752
4773
|
challenge,
|
|
4753
|
-
signature,
|
|
4754
4774
|
};
|
|
4775
|
+
// Sign challenge for circuits that require wallet signature
|
|
4776
|
+
if (needsSignature && this.signer) {
|
|
4777
|
+
body.signature = await this.signer.signMessage(challenge);
|
|
4778
|
+
}
|
|
4755
4779
|
if (options.message)
|
|
4756
4780
|
body.message = options.message;
|
|
4757
4781
|
if (options.dappName)
|
|
@@ -5028,6 +5052,42 @@ class ProofportSDK {
|
|
|
5028
5052
|
return extractNullifierFromPublicInputs(publicInputs, circuit);
|
|
5029
5053
|
}
|
|
5030
5054
|
}
|
|
5055
|
+
/**
|
|
5056
|
+
* Creates a proof request through the relay server.
|
|
5057
|
+
*
|
|
5058
|
+
* This is the recommended way to create proof requests. The relay server:
|
|
5059
|
+
* - Issues a server-side requestId (validated by the mobile app)
|
|
5060
|
+
* - Tracks request status in Redis
|
|
5061
|
+
* - Builds the deep link with relay callback URL
|
|
5062
|
+
* - Stores inputs hash for deep link integrity verification
|
|
5063
|
+
*
|
|
5064
|
+
* @param circuit - Circuit type identifier
|
|
5065
|
+
* @param inputs - Circuit-specific inputs
|
|
5066
|
+
* @param options - Request options (message, dappName, dappIcon, nonce)
|
|
5067
|
+
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
5068
|
+
* @throws Error if signer not set or relay request fails
|
|
5069
|
+
*
|
|
5070
|
+
* @example
|
|
5071
|
+
* ```typescript
|
|
5072
|
+
* const sdk = ProofportSDK.create();
|
|
5073
|
+
* sdk.setSigner(signer);
|
|
5074
|
+
*
|
|
5075
|
+
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
5076
|
+
* scope: 'myapp.com'
|
|
5077
|
+
* }, { dappName: 'My DApp' });
|
|
5078
|
+
*
|
|
5079
|
+
* // Generate QR code from relay deep link
|
|
5080
|
+
* const qr = await sdk.generateQRCode(relay.deepLink);
|
|
5081
|
+
*
|
|
5082
|
+
* // Wait for proof (WebSocket primary, polling fallback)
|
|
5083
|
+
* const result = await sdk.waitForProof(relay.requestId);
|
|
5084
|
+
* ```
|
|
5085
|
+
*/
|
|
5086
|
+
// Circuits that require wallet signature (used as circuit input)
|
|
5087
|
+
ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
5088
|
+
'coinbase_attestation',
|
|
5089
|
+
'coinbase_country_attestation',
|
|
5090
|
+
];
|
|
5031
5091
|
|
|
5032
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5092
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5033
5093
|
//# sourceMappingURL=index.mjs.map
|