@entros/pulse-sdk 1.4.0 → 1.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/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +42 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -102,9 +102,9 @@ interface SubmissionResult {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Validator-signed receipt binding (wallet, commitment, validated_at) for the
|
|
105
|
-
* upcoming `mint_anchor` transaction
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* upcoming `mint_anchor` transaction. Returned in the `/validate-features`
|
|
106
|
+
* response when the request includes `commitment_new_hex` and the validator
|
|
107
|
+
* has a signing key configured.
|
|
108
108
|
*
|
|
109
109
|
* Wire fields are byte-identical to `entros_validation::SignedReceiptDto` and
|
|
110
110
|
* the executor's local mirror at `executor-node::validation::SignedReceiptDto`.
|
|
@@ -492,12 +492,12 @@ declare function submitViaWallet(proof: SolanaProof, commitment: Uint8Array, opt
|
|
|
492
492
|
relayerUrl?: string;
|
|
493
493
|
relayerApiKey?: string;
|
|
494
494
|
/**
|
|
495
|
-
* Validator-signed mint receipt
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
495
|
+
* Validator-signed mint receipt. Consumed only on the first-verification
|
|
496
|
+
* path: when present, the SDK prepends an `Ed25519Program::verify`
|
|
497
|
+
* instruction so on-chain `mint_anchor` can confirm the commitment was
|
|
498
|
+
* endorsed by the configured validator. Re-verification ignores the
|
|
499
|
+
* field entirely — `update_anchor` enforces binding via the
|
|
500
|
+
* VerificationResult PDA instead.
|
|
501
501
|
*/
|
|
502
502
|
signedReceipt?: SignedReceiptDto;
|
|
503
503
|
}): Promise<SubmissionResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -102,9 +102,9 @@ interface SubmissionResult {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Validator-signed receipt binding (wallet, commitment, validated_at) for the
|
|
105
|
-
* upcoming `mint_anchor` transaction
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* upcoming `mint_anchor` transaction. Returned in the `/validate-features`
|
|
106
|
+
* response when the request includes `commitment_new_hex` and the validator
|
|
107
|
+
* has a signing key configured.
|
|
108
108
|
*
|
|
109
109
|
* Wire fields are byte-identical to `entros_validation::SignedReceiptDto` and
|
|
110
110
|
* the executor's local mirror at `executor-node::validation::SignedReceiptDto`.
|
|
@@ -492,12 +492,12 @@ declare function submitViaWallet(proof: SolanaProof, commitment: Uint8Array, opt
|
|
|
492
492
|
relayerUrl?: string;
|
|
493
493
|
relayerApiKey?: string;
|
|
494
494
|
/**
|
|
495
|
-
* Validator-signed mint receipt
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
495
|
+
* Validator-signed mint receipt. Consumed only on the first-verification
|
|
496
|
+
* path: when present, the SDK prepends an `Ed25519Program::verify`
|
|
497
|
+
* instruction so on-chain `mint_anchor` can confirm the commitment was
|
|
498
|
+
* endorsed by the configured validator. Re-verification ignores the
|
|
499
|
+
* field entirely — `update_anchor` enforces binding via the
|
|
500
|
+
* VerificationResult PDA instead.
|
|
501
501
|
*/
|
|
502
502
|
signedReceipt?: SignedReceiptDto;
|
|
503
503
|
}): Promise<SubmissionResult>;
|
package/dist/index.js
CHANGED
|
@@ -1378,7 +1378,7 @@ function bytesToHex(bytes) {
|
|
|
1378
1378
|
function hexToBytes(hex, expectedLen) {
|
|
1379
1379
|
const trimmed = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
1380
1380
|
if (trimmed.length !== expectedLen * 2) return null;
|
|
1381
|
-
if (!/^[0-9a-
|
|
1381
|
+
if (!/^[0-9a-f]+$/.test(trimmed)) return null;
|
|
1382
1382
|
const out = new Uint8Array(expectedLen);
|
|
1383
1383
|
for (let i = 0; i < expectedLen; i += 1) {
|
|
1384
1384
|
out[i] = parseInt(trimmed.substr(i * 2, 2), 16);
|
|
@@ -1405,6 +1405,26 @@ async function buildEd25519ReceiptIx(receipt) {
|
|
|
1405
1405
|
|
|
1406
1406
|
// src/submit/wallet.ts
|
|
1407
1407
|
async function requestSasAttestation(wallet, walletAddress, relayerUrl, relayerApiKey, serverNonce) {
|
|
1408
|
+
if (!serverNonce) {
|
|
1409
|
+
sdkLog("[Entros SDK] Skipping SAS attestation: no server-issued nonce");
|
|
1410
|
+
return void 0;
|
|
1411
|
+
}
|
|
1412
|
+
if (!wallet?.signMessage) {
|
|
1413
|
+
sdkLog("[Entros SDK] Skipping SAS attestation: wallet does not support signMessage");
|
|
1414
|
+
return void 0;
|
|
1415
|
+
}
|
|
1416
|
+
let signature;
|
|
1417
|
+
let message;
|
|
1418
|
+
try {
|
|
1419
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
1420
|
+
message = `Entros-ATTEST:${walletAddress}:${timestamp}`;
|
|
1421
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
1422
|
+
const sigBytes = await wallet.signMessage(messageBytes);
|
|
1423
|
+
signature = Array.from(sigBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1424
|
+
} catch {
|
|
1425
|
+
sdkWarn("[Entros SDK] Wallet signMessage failed, skipping SAS attestation");
|
|
1426
|
+
return void 0;
|
|
1427
|
+
}
|
|
1408
1428
|
try {
|
|
1409
1429
|
const attestHeaders = {
|
|
1410
1430
|
"Content-Type": "application/json"
|
|
@@ -1416,21 +1436,12 @@ async function requestSasAttestation(wallet, walletAddress, relayerUrl, relayerA
|
|
|
1416
1436
|
const timer = setTimeout(() => controller.abort(), 15e3);
|
|
1417
1437
|
const baseUrl = new URL(relayerUrl);
|
|
1418
1438
|
const attestUrl = `${baseUrl.origin}/attest`;
|
|
1419
|
-
const attestBody = {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
const messageBytes = new TextEncoder().encode(attestMessage);
|
|
1426
|
-
const sigBytes = await wallet.signMessage(messageBytes);
|
|
1427
|
-
const sigHex = Array.from(sigBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1428
|
-
attestBody.signature = sigHex;
|
|
1429
|
-
attestBody.message = attestMessage;
|
|
1430
|
-
} catch {
|
|
1431
|
-
sdkWarn("Wallet signMessage failed, skipping ownership proof");
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1439
|
+
const attestBody = {
|
|
1440
|
+
wallet_address: walletAddress,
|
|
1441
|
+
nonce: serverNonce,
|
|
1442
|
+
signature,
|
|
1443
|
+
message
|
|
1444
|
+
};
|
|
1434
1445
|
const attestRes = await fetch(attestUrl, {
|
|
1435
1446
|
method: "POST",
|
|
1436
1447
|
headers: attestHeaders,
|
|
@@ -1646,21 +1657,22 @@ async function submitViaWallet(proof, commitment, options) {
|
|
|
1646
1657
|
let ed25519Ix = null;
|
|
1647
1658
|
if (options.signedReceipt) {
|
|
1648
1659
|
ed25519Ix = await buildEd25519ReceiptIx(options.signedReceipt);
|
|
1649
|
-
if (ed25519Ix) {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
sdkWarn(
|
|
1655
|
-
"[Entros SDK] signedReceipt provided but failed to decode; minting without binding"
|
|
1656
|
-
);
|
|
1660
|
+
if (!ed25519Ix) {
|
|
1661
|
+
return {
|
|
1662
|
+
success: false,
|
|
1663
|
+
error: "Validator returned a signed receipt that failed to decode (malformed hex or wrong byte length). Refusing to mint without a valid binding. The validator service may be misconfigured \u2014 check the validation-service logs."
|
|
1664
|
+
};
|
|
1657
1665
|
}
|
|
1666
|
+
sdkLog(
|
|
1667
|
+
"[Entros SDK] Bundling validator-signed mint receipt before mint_anchor"
|
|
1668
|
+
);
|
|
1658
1669
|
} else {
|
|
1659
1670
|
sdkLog(
|
|
1660
|
-
"[Entros SDK] No validator receipt available; minting without binding (
|
|
1671
|
+
"[Entros SDK] No validator receipt available; minting without binding (on-chain check is log-only today)"
|
|
1661
1672
|
);
|
|
1662
1673
|
}
|
|
1663
1674
|
const tx = new Transaction();
|
|
1675
|
+
tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 2e5 }));
|
|
1664
1676
|
if (ed25519Ix) tx.add(ed25519Ix);
|
|
1665
1677
|
tx.add(mintAnchorIx);
|
|
1666
1678
|
tx.feePayer = provider.wallet.publicKey;
|
|
@@ -2125,7 +2137,11 @@ async function extractFingerprintAndValidate(sensorData, config, walletAddress,
|
|
|
2125
2137
|
if (successBody.signed_receipt) {
|
|
2126
2138
|
signedReceipt = successBody.signed_receipt;
|
|
2127
2139
|
}
|
|
2128
|
-
} catch {
|
|
2140
|
+
} catch (err) {
|
|
2141
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2142
|
+
sdkWarn(
|
|
2143
|
+
`[Entros SDK] /validate-features returned 200 but body was not parseable JSON; proceeding without receipt: ${msg}`
|
|
2144
|
+
);
|
|
2129
2145
|
}
|
|
2130
2146
|
} catch (err) {
|
|
2131
2147
|
const msg = err instanceof Error ? err.message : String(err);
|