@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.mjs
CHANGED
|
@@ -4916,6 +4916,17 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
4916
4916
|
}
|
|
4917
4917
|
}
|
|
4918
4918
|
|
|
4919
|
+
/**
|
|
4920
|
+
* The statuses a relay request ends in, as a runtime list. `satisfies` keeps it
|
|
4921
|
+
* in step with the `RelayTerminalStatus` type in both directions: a status
|
|
4922
|
+
* added to the type and not here, or here and not in the type, fails to compile.
|
|
4923
|
+
*/
|
|
4924
|
+
const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'expired'];
|
|
4925
|
+
/** True when `status` is one a relay request ends in. */
|
|
4926
|
+
function isTerminalRelayStatus(status) {
|
|
4927
|
+
return RELAY_TERMINAL_STATUSES.includes(status);
|
|
4928
|
+
}
|
|
4929
|
+
|
|
4919
4930
|
/**
|
|
4920
4931
|
* Proofport SDK - Main class
|
|
4921
4932
|
*/
|
|
@@ -5978,6 +5989,13 @@ class ProofportSDK {
|
|
|
5978
5989
|
inputs,
|
|
5979
5990
|
challenge,
|
|
5980
5991
|
};
|
|
5992
|
+
// The relay never reads `inputs`, so the scope is also sent on the envelope,
|
|
5993
|
+
// where the relay counts requests per scope. The app proves the scope inside
|
|
5994
|
+
// `inputs` and uses the envelope copy only when `inputs` has none; both are
|
|
5995
|
+
// the same string here.
|
|
5996
|
+
const scope = inputs.scope;
|
|
5997
|
+
if (typeof scope === 'string' && scope.length > 0)
|
|
5998
|
+
body.scope = scope;
|
|
5981
5999
|
// Sign challenge for circuits that require wallet signature
|
|
5982
6000
|
if (needsSignature && this.signer) {
|
|
5983
6001
|
body.signature = await this.signer.signMessage(challenge);
|
|
@@ -6041,7 +6059,9 @@ class ProofportSDK {
|
|
|
6041
6059
|
return await response.json();
|
|
6042
6060
|
}
|
|
6043
6061
|
/**
|
|
6044
|
-
* Polls the relay until
|
|
6062
|
+
* Polls the relay until the request reaches a terminal status
|
|
6063
|
+
* (`completed`, `error`, `failed`, `cancelled` or `expired`), with
|
|
6064
|
+
* configurable interval and timeout. Branch on `result.status`.
|
|
6045
6065
|
*
|
|
6046
6066
|
* @param requestId - The relay-issued request ID
|
|
6047
6067
|
* @param options - Polling options
|
|
@@ -6062,7 +6082,10 @@ class ProofportSDK {
|
|
|
6062
6082
|
lastStatus = result.status;
|
|
6063
6083
|
options.onStatusChange?.(result);
|
|
6064
6084
|
}
|
|
6065
|
-
|
|
6085
|
+
// Every terminal status ends the wait, not only success: an app error,
|
|
6086
|
+
// a cancellation and a relay-side timeout are answers too, and polling
|
|
6087
|
+
// past them would only end in this method's own timeout.
|
|
6088
|
+
if (isTerminalRelayStatus(result.status)) {
|
|
6066
6089
|
return result;
|
|
6067
6090
|
}
|
|
6068
6091
|
await new Promise(resolve => setTimeout(resolve, interval));
|
|
@@ -6080,7 +6103,7 @@ class ProofportSDK {
|
|
|
6080
6103
|
* @param requestId - The relay-issued request ID to subscribe to
|
|
6081
6104
|
* @param callbacks - Event callbacks for status changes and results
|
|
6082
6105
|
* @param callbacks.onStatus - Called on status updates (pending, generating)
|
|
6083
|
-
* @param callbacks.onResult - Called
|
|
6106
|
+
* @param callbacks.onResult - Called once with the terminal result: completed, error, failed, cancelled or expired
|
|
6084
6107
|
* @param callbacks.onError - Called on errors
|
|
6085
6108
|
* @returns Unsubscribe function to clean up the connection
|
|
6086
6109
|
* @throws Error if relayUrl not set or socket.io-client not installed
|
|
@@ -6287,5 +6310,5 @@ class ProofportSDK {
|
|
|
6287
6310
|
}
|
|
6288
6311
|
}
|
|
6289
6312
|
|
|
6290
|
-
export { ALL_CIRCUIT_IDS, CIRCUIT_ACTION_BINDING, CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, CIRCUIT_VK_PATHS, COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, EXPERIMENTAL_CIRCUIT_IDS, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, PLANNED_CIRCUIT_IDS, ProofportSDK, SUPPORTED_CIRCUIT_IDS, circuitActionBinding, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs, getCircuitSupportStatus, isCircuitId, isSupportedCircuitId, parseTypedAction, validateTypedAction, verifyProofOffChain };
|
|
6313
|
+
export { ALL_CIRCUIT_IDS, CIRCUIT_ACTION_BINDING, CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, CIRCUIT_VK_PATHS, COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, EXPERIMENTAL_CIRCUIT_IDS, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, PLANNED_CIRCUIT_IDS, ProofportSDK, RELAY_TERMINAL_STATUSES, SUPPORTED_CIRCUIT_IDS, circuitActionBinding, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs, getCircuitSupportStatus, isCircuitId, isSupportedCircuitId, isTerminalRelayStatus, parseTypedAction, validateTypedAction, verifyProofOffChain };
|
|
6291
6314
|
//# sourceMappingURL=index.mjs.map
|