@zkproofport-app/sdk 0.2.2 → 0.2.4
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 +79 -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 +103 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +103 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -40
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +23 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,36 @@ const relay = await sdk.createRelayRequest('coinbase_country_attestation', {
|
|
|
122
122
|
});
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
### `oidc_domain_attestation`
|
|
126
|
+
|
|
127
|
+
Prove email domain affiliation via Google Sign-In. The mobile app handles authentication and proof generation entirely on-device — the user's email is never revealed.
|
|
128
|
+
|
|
129
|
+
| Field | Type | Required | Description |
|
|
130
|
+
|-------|------|----------|-------------|
|
|
131
|
+
| `domain` | `string` | Yes | Target email domain to prove (e.g., `'google.com'`, `'company.com'`) |
|
|
132
|
+
| `scope` | `string` | Yes | dApp scope identifier for proof uniqueness |
|
|
133
|
+
| `provider` | `string` | No | OIDC workspace provider for organization membership verification. Currently supported: `'google'`. |
|
|
134
|
+
|
|
135
|
+
**Email domain verification (default):**
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const relay = await sdk.createRelayRequest('oidc_domain_attestation', {
|
|
139
|
+
domain: 'gmail.com',
|
|
140
|
+
scope: 'myapp.com',
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Organization membership verification (Google Workspace):**
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const relay = await sdk.createRelayRequest('oidc_domain_attestation', {
|
|
148
|
+
domain: 'company.com',
|
|
149
|
+
scope: 'myapp.com',
|
|
150
|
+
provider: 'google',
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> When `provider` is set, the mobile app verifies the user's account is managed by the specified workspace provider (e.g., Google Workspace `hd` claim). Without `provider`, only the email domain is verified.
|
|
126
155
|
|
|
127
156
|
## Integration Guide
|
|
128
157
|
|
|
@@ -159,6 +188,8 @@ interface WalletSigner {
|
|
|
159
188
|
|
|
160
189
|
Any ethers v5/v6 `Signer` is compatible.
|
|
161
190
|
|
|
191
|
+
> **OIDC Domain note:** Wallet signer is not required for OIDC Domain proofs. See Step 3 for OIDC-specific usage.
|
|
192
|
+
|
|
162
193
|
#### About challenge-signature
|
|
163
194
|
|
|
164
195
|
The challenge-signature mechanism was developed **for relay nonce replay prevention**. Each challenge is one-time use and consumed immediately. The signer's recovered address is recorded as `clientId` in relay server logs, which helps the relay operator track requests.
|
|
@@ -192,6 +223,33 @@ const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
|
192
223
|
// relay.pollUrl — Relative URL for HTTP polling
|
|
193
224
|
```
|
|
194
225
|
|
|
226
|
+
**OIDC Domain Attestation:**
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
// Email domain verification
|
|
230
|
+
const relay = await sdk.createRelayRequest('oidc_domain_attestation', {
|
|
231
|
+
domain: 'company.com',
|
|
232
|
+
scope: 'myapp.com',
|
|
233
|
+
}, {
|
|
234
|
+
dappName: 'My DApp',
|
|
235
|
+
dappIcon: 'https://myapp.com/icon.png',
|
|
236
|
+
message: 'Verify your email domain',
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Organization membership verification (Google Workspace)
|
|
240
|
+
const relay = await sdk.createRelayRequest('oidc_domain_attestation', {
|
|
241
|
+
domain: 'company.com',
|
|
242
|
+
scope: 'myapp.com',
|
|
243
|
+
provider: 'google',
|
|
244
|
+
}, {
|
|
245
|
+
dappName: 'My DApp',
|
|
246
|
+
dappIcon: 'https://myapp.com/icon.png',
|
|
247
|
+
message: 'Verify your organization membership',
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The mobile app prompts Google Sign-In and generates the proof locally. When `provider` is set, the app additionally verifies organization membership (e.g., Google Workspace `hd` claim).
|
|
252
|
+
|
|
195
253
|
### Step 4: Display QR Code
|
|
196
254
|
|
|
197
255
|
Generate a QR code from the relay deep link for the user to scan with the ZKProofport mobile app:
|
|
@@ -314,9 +372,11 @@ if (result.status === 'completed') {
|
|
|
314
372
|
|
|
315
373
|
The **nullifier** serves as a privacy-preserving user identifier:
|
|
316
374
|
- Deterministic: same user + same scope = same nullifier (enables duplicate detection)
|
|
317
|
-
- Privacy-preserving: the wallet address is never revealed
|
|
375
|
+
- Privacy-preserving: the wallet address (Coinbase) or email (OIDC) is never revealed
|
|
318
376
|
- Scope-bound: different scopes produce different nullifiers for the same user
|
|
319
377
|
|
|
378
|
+
> **OIDC Domain:** The nullifier is a hash of the user's email and scope. The same email + scope always produces the same nullifier, enabling Sybil resistance without revealing the email address.
|
|
379
|
+
|
|
320
380
|
**Standalone utility functions** are also available for use outside the SDK class:
|
|
321
381
|
|
|
322
382
|
```typescript
|
|
@@ -389,21 +449,7 @@ async function verifyUser() {
|
|
|
389
449
|
|
|
390
450
|
## Configuration
|
|
391
451
|
|
|
392
|
-
`ProofportSDK.create()` returns a fully configured SDK instance. No manual configuration is needed
|
|
393
|
-
|
|
394
|
-
For advanced scenarios (e.g., custom verifier deployments), pass a `ProofportConfig`:
|
|
395
|
-
|
|
396
|
-
```typescript
|
|
397
|
-
const sdk = new ProofportSDK({
|
|
398
|
-
relayUrl: 'https://relay.zkproofport.app',
|
|
399
|
-
verifiers: {
|
|
400
|
-
coinbase_attestation: {
|
|
401
|
-
verifierAddress: '0x...',
|
|
402
|
-
chainId: 8453,
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
});
|
|
406
|
-
```
|
|
452
|
+
`ProofportSDK.create()` returns a fully configured SDK instance. No manual configuration is needed — relay URLs, verifier contracts, and chain settings are all built-in.
|
|
407
453
|
|
|
408
454
|
## Types Reference
|
|
409
455
|
|
|
@@ -415,6 +461,7 @@ import type {
|
|
|
415
461
|
ProofRequestStatus,
|
|
416
462
|
CoinbaseKycInputs,
|
|
417
463
|
CoinbaseCountryInputs,
|
|
464
|
+
OidcDomainInputs,
|
|
418
465
|
CircuitInputs,
|
|
419
466
|
ProofRequest,
|
|
420
467
|
ProofResponse,
|
|
@@ -425,27 +472,36 @@ import type {
|
|
|
425
472
|
WalletSigner,
|
|
426
473
|
RelayProofRequest,
|
|
427
474
|
RelayProofResult,
|
|
428
|
-
SDKEnvironment,
|
|
429
475
|
} from '@zkproofport-app/sdk';
|
|
430
476
|
```
|
|
431
477
|
|
|
432
478
|
| Type | Description |
|
|
433
479
|
|------|-------------|
|
|
434
|
-
| `CircuitType` | `'coinbase_attestation' \| 'coinbase_country_attestation'` |
|
|
480
|
+
| `CircuitType` | `'coinbase_attestation' \| 'coinbase_country_attestation' \| 'oidc_domain_attestation'` |
|
|
435
481
|
| `ProofRequestStatus` | `'pending' \| 'completed' \| 'error' \| 'cancelled'` |
|
|
436
482
|
| `CoinbaseKycInputs` | Inputs for `coinbase_attestation` (`{ scope, userAddress?, rawTransaction? }`) |
|
|
437
483
|
| `CoinbaseCountryInputs` | Inputs for `coinbase_country_attestation` (`{ scope, countryList, isIncluded, ... }`) |
|
|
438
|
-
| `
|
|
484
|
+
| `OidcDomainInputs` | Inputs for `oidc_domain_attestation` (`{ domain, scope, provider? }`) |
|
|
485
|
+
| `CircuitInputs` | Union: `CoinbaseKycInputs \| CoinbaseCountryInputs \| OidcDomainInputs` |
|
|
439
486
|
| `ProofRequest` | Proof request object with `requestId`, `circuit`, `inputs`, metadata, and expiry |
|
|
440
487
|
| `ProofResponse` | Proof response with `status`, `proof`, `publicInputs`, `verifierAddress`, `chainId` |
|
|
441
488
|
| `QRCodeOptions` | QR customization: `width`, `margin`, `darkColor`, `lightColor`, `errorCorrectionLevel` |
|
|
442
489
|
| `VerifierContract` | Verifier contract info: `{ address, chainId, abi }` |
|
|
443
|
-
| `ProofportConfig` | SDK configuration
|
|
490
|
+
| `ProofportConfig` | SDK configuration (internal use — `ProofportSDK.create()` handles defaults) |
|
|
444
491
|
| `ChallengeResponse` | Challenge from relay: `{ challenge, expiresAt }` |
|
|
445
492
|
| `WalletSigner` | Signer interface: `{ signMessage(msg), getAddress() }` |
|
|
446
493
|
| `RelayProofRequest` | Relay response: `{ requestId, deepLink, status, pollUrl }` |
|
|
447
494
|
| `RelayProofResult` | Relay result: `{ requestId, status, proof?, publicInputs?, circuit?, error? }` |
|
|
448
|
-
|
|
495
|
+
|
|
496
|
+
The `OidcDomainInputs` interface:
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
interface OidcDomainInputs {
|
|
500
|
+
domain: string; // Target email domain (e.g., 'google.com')
|
|
501
|
+
scope: string; // dApp scope identifier
|
|
502
|
+
provider?: string; // Workspace provider for org membership (currently: 'google')
|
|
503
|
+
}
|
|
504
|
+
```
|
|
449
505
|
|
|
450
506
|
## Error Handling
|
|
451
507
|
|
|
@@ -467,10 +523,7 @@ try {
|
|
|
467
523
|
|
|
468
524
|
## Networks
|
|
469
525
|
|
|
470
|
-
|
|
471
|
-
|---------|----------|--------|
|
|
472
|
-
| Base Mainnet | 8453 | Production |
|
|
473
|
-
| Base Sepolia | 84532 | Testnet |
|
|
526
|
+
Proofs are verified on **Base** (Ethereum L2). The SDK handles network configuration automatically — no manual setup required.
|
|
474
527
|
|
|
475
528
|
## Development
|
|
476
529
|
|
package/dist/ProofportSDK.d.ts
CHANGED
|
@@ -763,6 +763,7 @@ export declare class ProofportSDK {
|
|
|
763
763
|
* const result = await sdk.waitForProof(relay.requestId);
|
|
764
764
|
* ```
|
|
765
765
|
*/
|
|
766
|
+
private static readonly WALLET_SIGNATURE_CIRCUITS;
|
|
766
767
|
createRelayRequest(circuit: CircuitType, inputs: CircuitInputs, options?: {
|
|
767
768
|
message?: string;
|
|
768
769
|
dappName?: string;
|
package/dist/constants.d.ts
CHANGED
|
@@ -183,3 +183,31 @@ export declare const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT: {
|
|
|
183
183
|
readonly NULLIFIER_START: 118;
|
|
184
184
|
readonly NULLIFIER_END: 149;
|
|
185
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* OIDC Domain Attestation circuit public input layout (byte offsets).
|
|
188
|
+
* Defines the byte positions of each field in the flattened public inputs array.
|
|
189
|
+
*
|
|
190
|
+
* Public inputs are packed as individual field elements (one byte per element):
|
|
191
|
+
* - pubkey_modulus_limbs: 18 x u128 = 18 x 16 bytes = 288 bytes → fields 0–287
|
|
192
|
+
* - domain (BoundedVec<u8, 64>): 4-byte length (u32) + 64-byte storage = 68 fields → fields 288–355
|
|
193
|
+
* - scope: 32 bytes → fields 356–387
|
|
194
|
+
* - nullifier: 32 bytes → fields 388–419
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const scope = publicInputs.slice(
|
|
199
|
+
* OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT.SCOPE_START,
|
|
200
|
+
* OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT.SCOPE_END + 1
|
|
201
|
+
* );
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare const OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT: {
|
|
205
|
+
readonly PUBKEY_MODULUS_START: 0;
|
|
206
|
+
readonly PUBKEY_MODULUS_END: 287;
|
|
207
|
+
readonly DOMAIN_START: 288;
|
|
208
|
+
readonly DOMAIN_END: 355;
|
|
209
|
+
readonly SCOPE_START: 356;
|
|
210
|
+
readonly SCOPE_END: 387;
|
|
211
|
+
readonly NULLIFIER_START: 388;
|
|
212
|
+
readonly NULLIFIER_END: 419;
|
|
213
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* ```typescript
|
|
8
8
|
* import { ProofportSDK } from '@zkproofport-app/sdk';
|
|
9
9
|
*
|
|
10
|
-
* // Initialize
|
|
11
|
-
* const sdk = ProofportSDK.create(
|
|
10
|
+
* // Initialize SDK
|
|
11
|
+
* const sdk = ProofportSDK.create();
|
|
12
12
|
*
|
|
13
13
|
* // Set wallet signer
|
|
14
14
|
* sdk.setSigner(signer);
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export { ProofportSDK, default } from './ProofportSDK';
|
|
29
29
|
export { extractScopeFromPublicInputs, extractNullifierFromPublicInputs, } from './verifier';
|
|
30
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, } from './constants';
|
|
31
|
-
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult, SDKEnvironment, } from './types';
|
|
30
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, } from './constants';
|
|
31
|
+
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, OidcDomainInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult, SDKEnvironment, } from './types';
|
package/dist/index.esm.js
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,18 @@ 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
|
+
if (inputs.provider !== undefined && (typeof inputs.provider !== 'string' || inputs.provider.trim() === '')) {
|
|
526
|
+
return { valid: false, error: 'provider must be a non-empty string when specified' };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
483
529
|
// Check expiry
|
|
484
530
|
if (request.expiresAt && Date.now() > request.expiresAt) {
|
|
485
531
|
return { valid: false, error: 'Request has expired' };
|
|
@@ -3781,6 +3827,10 @@ function extractScopeFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3781
3827
|
start = 86;
|
|
3782
3828
|
end = 117;
|
|
3783
3829
|
}
|
|
3830
|
+
else if (circuit === 'oidc_domain_attestation') {
|
|
3831
|
+
start = 356;
|
|
3832
|
+
end = 387;
|
|
3833
|
+
}
|
|
3784
3834
|
else {
|
|
3785
3835
|
start = 64;
|
|
3786
3836
|
end = 95;
|
|
@@ -3814,6 +3864,10 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3814
3864
|
start = 118;
|
|
3815
3865
|
end = 149;
|
|
3816
3866
|
}
|
|
3867
|
+
else if (circuit === 'oidc_domain_attestation') {
|
|
3868
|
+
start = 388;
|
|
3869
|
+
end = 419;
|
|
3870
|
+
}
|
|
3817
3871
|
else {
|
|
3818
3872
|
start = 96;
|
|
3819
3873
|
end = 127;
|
|
@@ -4705,53 +4759,26 @@ class ProofportSDK {
|
|
|
4705
4759
|
}
|
|
4706
4760
|
return await response.json();
|
|
4707
4761
|
}
|
|
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
4762
|
async createRelayRequest(circuit, inputs, options = {}) {
|
|
4740
|
-
if (!this.signer) {
|
|
4741
|
-
throw new Error('Signer not set. Call setSigner() first.');
|
|
4742
|
-
}
|
|
4743
4763
|
if (!this.relayUrl) {
|
|
4744
4764
|
throw new Error('relayUrl is required. Set it in ProofportSDK config.');
|
|
4745
4765
|
}
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4766
|
+
const needsSignature = ProofportSDK.WALLET_SIGNATURE_CIRCUITS.includes(circuit);
|
|
4767
|
+
if (needsSignature && !this.signer) {
|
|
4768
|
+
throw new Error('Signer not set. Call setSigner() first. Wallet signature is required for this circuit.');
|
|
4769
|
+
}
|
|
4770
|
+
// Get challenge + requestId from relay
|
|
4771
|
+
const { requestId, challenge } = await this.getChallenge();
|
|
4749
4772
|
const body = {
|
|
4773
|
+
requestId,
|
|
4750
4774
|
circuitId: circuit,
|
|
4751
4775
|
inputs,
|
|
4752
4776
|
challenge,
|
|
4753
|
-
signature,
|
|
4754
4777
|
};
|
|
4778
|
+
// Sign challenge for circuits that require wallet signature
|
|
4779
|
+
if (needsSignature && this.signer) {
|
|
4780
|
+
body.signature = await this.signer.signMessage(challenge);
|
|
4781
|
+
}
|
|
4755
4782
|
if (options.message)
|
|
4756
4783
|
body.message = options.message;
|
|
4757
4784
|
if (options.dappName)
|
|
@@ -5028,6 +5055,42 @@ class ProofportSDK {
|
|
|
5028
5055
|
return extractNullifierFromPublicInputs(publicInputs, circuit);
|
|
5029
5056
|
}
|
|
5030
5057
|
}
|
|
5058
|
+
/**
|
|
5059
|
+
* Creates a proof request through the relay server.
|
|
5060
|
+
*
|
|
5061
|
+
* This is the recommended way to create proof requests. The relay server:
|
|
5062
|
+
* - Issues a server-side requestId (validated by the mobile app)
|
|
5063
|
+
* - Tracks request status in Redis
|
|
5064
|
+
* - Builds the deep link with relay callback URL
|
|
5065
|
+
* - Stores inputs hash for deep link integrity verification
|
|
5066
|
+
*
|
|
5067
|
+
* @param circuit - Circuit type identifier
|
|
5068
|
+
* @param inputs - Circuit-specific inputs
|
|
5069
|
+
* @param options - Request options (message, dappName, dappIcon, nonce)
|
|
5070
|
+
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
5071
|
+
* @throws Error if signer not set or relay request fails
|
|
5072
|
+
*
|
|
5073
|
+
* @example
|
|
5074
|
+
* ```typescript
|
|
5075
|
+
* const sdk = ProofportSDK.create();
|
|
5076
|
+
* sdk.setSigner(signer);
|
|
5077
|
+
*
|
|
5078
|
+
* const relay = await sdk.createRelayRequest('coinbase_attestation', {
|
|
5079
|
+
* scope: 'myapp.com'
|
|
5080
|
+
* }, { dappName: 'My DApp' });
|
|
5081
|
+
*
|
|
5082
|
+
* // Generate QR code from relay deep link
|
|
5083
|
+
* const qr = await sdk.generateQRCode(relay.deepLink);
|
|
5084
|
+
*
|
|
5085
|
+
* // Wait for proof (WebSocket primary, polling fallback)
|
|
5086
|
+
* const result = await sdk.waitForProof(relay.requestId);
|
|
5087
|
+
* ```
|
|
5088
|
+
*/
|
|
5089
|
+
// Circuits that require wallet signature (used as circuit input)
|
|
5090
|
+
ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
5091
|
+
'coinbase_attestation',
|
|
5092
|
+
'coinbase_country_attestation',
|
|
5093
|
+
];
|
|
5031
5094
|
|
|
5032
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5095
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5033
5096
|
//# sourceMappingURL=index.esm.js.map
|