@zkproofport-app/sdk 0.4.1 → 0.4.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 +33 -25
- package/dist/ProofportSDK.d.ts +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +27 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/dist/relayStatus.d.ts +9 -0
- package/dist/types.d.ts +20 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2054,6 +2054,17 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}
|
|
2056
2056
|
|
|
2057
|
+
/**
|
|
2058
|
+
* The statuses a relay request ends in, as a runtime list. `satisfies` keeps it
|
|
2059
|
+
* in step with the `RelayTerminalStatus` type in both directions: a status
|
|
2060
|
+
* added to the type and not here, or here and not in the type, fails to compile.
|
|
2061
|
+
*/
|
|
2062
|
+
const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'expired'];
|
|
2063
|
+
/** True when `status` is one a relay request ends in. */
|
|
2064
|
+
function isTerminalRelayStatus(status) {
|
|
2065
|
+
return RELAY_TERMINAL_STATUSES.includes(status);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2057
2068
|
/**
|
|
2058
2069
|
* Proofport SDK - Main class
|
|
2059
2070
|
*/
|
|
@@ -3116,6 +3127,13 @@ class ProofportSDK {
|
|
|
3116
3127
|
inputs,
|
|
3117
3128
|
challenge,
|
|
3118
3129
|
};
|
|
3130
|
+
// The relay never reads `inputs`, so the scope is also sent on the envelope,
|
|
3131
|
+
// where the relay counts requests per scope. The app proves the scope inside
|
|
3132
|
+
// `inputs` and uses the envelope copy only when `inputs` has none; both are
|
|
3133
|
+
// the same string here.
|
|
3134
|
+
const scope = inputs.scope;
|
|
3135
|
+
if (typeof scope === 'string' && scope.length > 0)
|
|
3136
|
+
body.scope = scope;
|
|
3119
3137
|
// Sign challenge for circuits that require wallet signature
|
|
3120
3138
|
if (needsSignature && this.signer) {
|
|
3121
3139
|
body.signature = await this.signer.signMessage(challenge);
|
|
@@ -3179,7 +3197,9 @@ class ProofportSDK {
|
|
|
3179
3197
|
return await response.json();
|
|
3180
3198
|
}
|
|
3181
3199
|
/**
|
|
3182
|
-
* Polls the relay until
|
|
3200
|
+
* Polls the relay until the request reaches a terminal status
|
|
3201
|
+
* (`completed`, `error`, `failed`, `cancelled` or `expired`), with
|
|
3202
|
+
* configurable interval and timeout. Branch on `result.status`.
|
|
3183
3203
|
*
|
|
3184
3204
|
* @param requestId - The relay-issued request ID
|
|
3185
3205
|
* @param options - Polling options
|
|
@@ -3200,7 +3220,10 @@ class ProofportSDK {
|
|
|
3200
3220
|
lastStatus = result.status;
|
|
3201
3221
|
options.onStatusChange?.(result);
|
|
3202
3222
|
}
|
|
3203
|
-
|
|
3223
|
+
// Every terminal status ends the wait, not only success: an app error,
|
|
3224
|
+
// a cancellation and a relay-side timeout are answers too, and polling
|
|
3225
|
+
// past them would only end in this method's own timeout.
|
|
3226
|
+
if (isTerminalRelayStatus(result.status)) {
|
|
3204
3227
|
return result;
|
|
3205
3228
|
}
|
|
3206
3229
|
await new Promise(resolve => setTimeout(resolve, interval));
|
|
@@ -3218,7 +3241,7 @@ class ProofportSDK {
|
|
|
3218
3241
|
* @param requestId - The relay-issued request ID to subscribe to
|
|
3219
3242
|
* @param callbacks - Event callbacks for status changes and results
|
|
3220
3243
|
* @param callbacks.onStatus - Called on status updates (pending, generating)
|
|
3221
|
-
* @param callbacks.onResult - Called
|
|
3244
|
+
* @param callbacks.onResult - Called once with the terminal result: completed, error, failed, cancelled or expired
|
|
3222
3245
|
* @param callbacks.onError - Called on errors
|
|
3223
3246
|
* @returns Unsubscribe function to clean up the connection
|
|
3224
3247
|
* @throws Error if relayUrl not set or socket.io-client not installed
|
|
@@ -3437,6 +3460,7 @@ exports.MDL_KR_PUBLIC_INPUT_LAYOUT = MDL_KR_PUBLIC_INPUT_LAYOUT;
|
|
|
3437
3460
|
exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
3438
3461
|
exports.PLANNED_CIRCUIT_IDS = PLANNED_CIRCUIT_IDS;
|
|
3439
3462
|
exports.ProofportSDK = ProofportSDK;
|
|
3463
|
+
exports.RELAY_TERMINAL_STATUSES = RELAY_TERMINAL_STATUSES;
|
|
3440
3464
|
exports.SUPPORTED_CIRCUIT_IDS = SUPPORTED_CIRCUIT_IDS;
|
|
3441
3465
|
exports.circuitActionBinding = circuitActionBinding;
|
|
3442
3466
|
exports.default = ProofportSDK;
|
|
@@ -3446,6 +3470,7 @@ exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
|
|
|
3446
3470
|
exports.getCircuitSupportStatus = getCircuitSupportStatus;
|
|
3447
3471
|
exports.isCircuitId = isCircuitId;
|
|
3448
3472
|
exports.isSupportedCircuitId = isSupportedCircuitId;
|
|
3473
|
+
exports.isTerminalRelayStatus = isTerminalRelayStatus;
|
|
3449
3474
|
exports.parseTypedAction = parseTypedAction;
|
|
3450
3475
|
exports.validateTypedAction = validateTypedAction;
|
|
3451
3476
|
exports.verifyProofOffChain = verifyProofOffChain;
|