@zkproofport-app/sdk 0.4.1 → 0.4.2
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 +31 -25
- package/dist/ProofportSDK.d.ts +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +20 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -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
|
*/
|
|
@@ -3179,7 +3190,9 @@ class ProofportSDK {
|
|
|
3179
3190
|
return await response.json();
|
|
3180
3191
|
}
|
|
3181
3192
|
/**
|
|
3182
|
-
* Polls the relay until
|
|
3193
|
+
* Polls the relay until the request reaches a terminal status
|
|
3194
|
+
* (`completed`, `error`, `failed`, `cancelled` or `expired`), with
|
|
3195
|
+
* configurable interval and timeout. Branch on `result.status`.
|
|
3183
3196
|
*
|
|
3184
3197
|
* @param requestId - The relay-issued request ID
|
|
3185
3198
|
* @param options - Polling options
|
|
@@ -3200,7 +3213,10 @@ class ProofportSDK {
|
|
|
3200
3213
|
lastStatus = result.status;
|
|
3201
3214
|
options.onStatusChange?.(result);
|
|
3202
3215
|
}
|
|
3203
|
-
|
|
3216
|
+
// Every terminal status ends the wait, not only success: an app error,
|
|
3217
|
+
// a cancellation and a relay-side timeout are answers too, and polling
|
|
3218
|
+
// past them would only end in this method's own timeout.
|
|
3219
|
+
if (isTerminalRelayStatus(result.status)) {
|
|
3204
3220
|
return result;
|
|
3205
3221
|
}
|
|
3206
3222
|
await new Promise(resolve => setTimeout(resolve, interval));
|
|
@@ -3218,7 +3234,7 @@ class ProofportSDK {
|
|
|
3218
3234
|
* @param requestId - The relay-issued request ID to subscribe to
|
|
3219
3235
|
* @param callbacks - Event callbacks for status changes and results
|
|
3220
3236
|
* @param callbacks.onStatus - Called on status updates (pending, generating)
|
|
3221
|
-
* @param callbacks.onResult - Called
|
|
3237
|
+
* @param callbacks.onResult - Called once with the terminal result: completed, error, failed, cancelled or expired
|
|
3222
3238
|
* @param callbacks.onError - Called on errors
|
|
3223
3239
|
* @returns Unsubscribe function to clean up the connection
|
|
3224
3240
|
* @throws Error if relayUrl not set or socket.io-client not installed
|
|
@@ -3437,6 +3453,7 @@ exports.MDL_KR_PUBLIC_INPUT_LAYOUT = MDL_KR_PUBLIC_INPUT_LAYOUT;
|
|
|
3437
3453
|
exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
3438
3454
|
exports.PLANNED_CIRCUIT_IDS = PLANNED_CIRCUIT_IDS;
|
|
3439
3455
|
exports.ProofportSDK = ProofportSDK;
|
|
3456
|
+
exports.RELAY_TERMINAL_STATUSES = RELAY_TERMINAL_STATUSES;
|
|
3440
3457
|
exports.SUPPORTED_CIRCUIT_IDS = SUPPORTED_CIRCUIT_IDS;
|
|
3441
3458
|
exports.circuitActionBinding = circuitActionBinding;
|
|
3442
3459
|
exports.default = ProofportSDK;
|
|
@@ -3446,6 +3463,7 @@ exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
|
|
|
3446
3463
|
exports.getCircuitSupportStatus = getCircuitSupportStatus;
|
|
3447
3464
|
exports.isCircuitId = isCircuitId;
|
|
3448
3465
|
exports.isSupportedCircuitId = isSupportedCircuitId;
|
|
3466
|
+
exports.isTerminalRelayStatus = isTerminalRelayStatus;
|
|
3449
3467
|
exports.parseTypedAction = parseTypedAction;
|
|
3450
3468
|
exports.validateTypedAction = validateTypedAction;
|
|
3451
3469
|
exports.verifyProofOffChain = verifyProofOffChain;
|