@cardanowall/sdk-ts 0.1.0 → 0.2.0
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 +14 -14
- package/dist/client/index.cjs +34 -34
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +52 -52
- package/dist/client/index.d.ts +52 -52
- package/dist/client/index.js +33 -33
- package/dist/client/index.js.map +1 -1
- package/dist/conformance/cli.cjs +17 -17
- package/dist/conformance/cli.cjs.map +1 -1
- package/dist/conformance/cli.js +17 -17
- package/dist/conformance/cli.js.map +1 -1
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.d.cts +1 -1
- package/dist/identity/index.d.ts +1 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/ids/index.cjs.map +1 -1
- package/dist/ids/index.js.map +1 -1
- package/dist/index.cjs +50 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +48 -48
- package/dist/index.js.map +1 -1
- package/dist/merkle/index.cjs +1 -1
- package/dist/merkle/index.cjs.map +1 -1
- package/dist/merkle/index.js +1 -1
- package/dist/merkle/index.js.map +1 -1
- package/dist/{types-BQMtbRCb.d.cts → types-DGsZTMuZ.d.cts} +6 -6
- package/dist/{types-BQMtbRCb.d.ts → types-DGsZTMuZ.d.ts} +6 -6
- package/dist/verifier/index.cjs +17 -17
- package/dist/verifier/index.cjs.map +1 -1
- package/dist/verifier/index.d.cts +3 -3
- package/dist/verifier/index.d.ts +3 -3
- package/dist/verifier/index.js +17 -17
- package/dist/verifier/index.js.map +1 -1
- package/package.json +8 -8
package/dist/conformance/cli.js
CHANGED
|
@@ -151,7 +151,7 @@ function decodeCanonicalCbor(bytes) {
|
|
|
151
151
|
...cdeDecodeOptions,
|
|
152
152
|
rejectStreaming: true,
|
|
153
153
|
rejectDuplicateKeys: true,
|
|
154
|
-
// A
|
|
154
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
155
155
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
156
156
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
157
157
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -277,7 +277,7 @@ function decodeCanonicalCbor2(bytes) {
|
|
|
277
277
|
...cdeDecodeOptions,
|
|
278
278
|
rejectStreaming: true,
|
|
279
279
|
rejectDuplicateKeys: true,
|
|
280
|
-
// A
|
|
280
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
281
281
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
282
282
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
283
283
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -378,7 +378,7 @@ function buildSigStructure(args) {
|
|
|
378
378
|
args.payload
|
|
379
379
|
]);
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function buildLabel309SigStructure(args) {
|
|
382
382
|
const toSign = new Uint8Array(
|
|
383
383
|
CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length + args.recordBodyCbor.length
|
|
384
384
|
);
|
|
@@ -452,7 +452,7 @@ function decodeCoseSign1(bytes) {
|
|
|
452
452
|
signature: signatureRaw
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function coseSign1Label309Verify(args) {
|
|
456
456
|
let decoded;
|
|
457
457
|
try {
|
|
458
458
|
decoded = decodeCoseSign1(args.message);
|
|
@@ -519,7 +519,7 @@ function coseSign1Cip309Verify(args) {
|
|
|
519
519
|
payload: hashedPayload
|
|
520
520
|
});
|
|
521
521
|
} else {
|
|
522
|
-
sigStructureBytes =
|
|
522
|
+
sigStructureBytes = buildLabel309SigStructure({
|
|
523
523
|
bodyProtectedBytes: decoded.protectedBytes,
|
|
524
524
|
recordBodyCbor: args.detachedRecordBodyCbor
|
|
525
525
|
});
|
|
@@ -909,7 +909,7 @@ function validateOneUri(chunks, path, errors) {
|
|
|
909
909
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
910
910
|
if (!validateCidProfile(cid)) {
|
|
911
911
|
errors.push(
|
|
912
|
-
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the
|
|
912
|
+
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
913
913
|
);
|
|
914
914
|
}
|
|
915
915
|
return;
|
|
@@ -957,7 +957,7 @@ function checkItemEnc(item, idx, errors) {
|
|
|
957
957
|
issue(
|
|
958
958
|
"UNAUTHENTICATED_CIPHER_FORBIDDEN",
|
|
959
959
|
[...basePath, "aead"],
|
|
960
|
-
`'${enc.aead}' is an unauthenticated cipher;
|
|
960
|
+
`'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
|
|
961
961
|
)
|
|
962
962
|
);
|
|
963
963
|
return;
|
|
@@ -3397,7 +3397,7 @@ function decodeCanonicalCbor3(bytes) {
|
|
|
3397
3397
|
...cdeDecodeOptions,
|
|
3398
3398
|
rejectStreaming: true,
|
|
3399
3399
|
rejectDuplicateKeys: true,
|
|
3400
|
-
// A
|
|
3400
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
3401
3401
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
3402
3402
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
3403
3403
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -3967,11 +3967,11 @@ function decodeIntKey(h) {
|
|
|
3967
3967
|
// src/verifier/resolve.ts
|
|
3968
3968
|
var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
3969
3969
|
var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
3970
|
-
var
|
|
3970
|
+
var NotALabel309RecordError = class extends Error {
|
|
3971
3971
|
code = "METADATA_NOT_FOUND";
|
|
3972
3972
|
constructor(message) {
|
|
3973
3973
|
super(message);
|
|
3974
|
-
this.name = "
|
|
3974
|
+
this.name = "NotALabel309RecordError";
|
|
3975
3975
|
}
|
|
3976
3976
|
};
|
|
3977
3977
|
async function resolveCardanoTx(args) {
|
|
@@ -3982,7 +3982,7 @@ async function resolveCardanoTx(args) {
|
|
|
3982
3982
|
try {
|
|
3983
3983
|
return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
|
|
3984
3984
|
} catch (e) {
|
|
3985
|
-
if (e instanceof
|
|
3985
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
3986
3986
|
lastErr = e;
|
|
3987
3987
|
}
|
|
3988
3988
|
}
|
|
@@ -3990,7 +3990,7 @@ async function resolveCardanoTx(args) {
|
|
|
3990
3990
|
try {
|
|
3991
3991
|
return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
|
|
3992
3992
|
} catch (e) {
|
|
3993
|
-
if (e instanceof
|
|
3993
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
3994
3994
|
lastErr = e;
|
|
3995
3995
|
}
|
|
3996
3996
|
}
|
|
@@ -4008,7 +4008,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4008
4008
|
}
|
|
4009
4009
|
const cborJson = parseJson(cborRes.bytes);
|
|
4010
4010
|
if (!Array.isArray(cborJson) || cborJson.length === 0) {
|
|
4011
|
-
throw new
|
|
4011
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
|
|
4012
4012
|
}
|
|
4013
4013
|
const cborEntry = cborJson[0];
|
|
4014
4014
|
if (typeof cborEntry.cbor !== "string") {
|
|
@@ -4029,7 +4029,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4029
4029
|
}
|
|
4030
4030
|
const infoJson = parseJson(infoRes.bytes);
|
|
4031
4031
|
if (!Array.isArray(infoJson) || infoJson.length === 0) {
|
|
4032
|
-
throw new
|
|
4032
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_info");
|
|
4033
4033
|
}
|
|
4034
4034
|
const infoEntry = infoJson[0];
|
|
4035
4035
|
if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
|
|
@@ -4174,7 +4174,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
|
|
|
4174
4174
|
return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
|
|
4175
4175
|
}
|
|
4176
4176
|
const { pub, signerType } = resolved;
|
|
4177
|
-
const verifyResult =
|
|
4177
|
+
const verifyResult = coseSign1Label309Verify({
|
|
4178
4178
|
message: coseBytes,
|
|
4179
4179
|
detachedRecordBodyCbor: recordBodyCbor,
|
|
4180
4180
|
expectedSignerKey: pub
|
|
@@ -4523,7 +4523,7 @@ async function verifyTx(input) {
|
|
|
4523
4523
|
try {
|
|
4524
4524
|
resolved = await resolveCardanoTx({ input, fetchFn });
|
|
4525
4525
|
} catch (e) {
|
|
4526
|
-
if (e instanceof
|
|
4526
|
+
if (e instanceof NotALabel309RecordError) {
|
|
4527
4527
|
return base({
|
|
4528
4528
|
verdict: "failed",
|
|
4529
4529
|
exit_code: 1,
|
|
@@ -4808,7 +4808,7 @@ var USAGE = `Usage: cardanowall-sdk-conformance <tx-hash> [--gateway <url>] [--t
|
|
|
4808
4808
|
cardanowall-sdk-conformance --version
|
|
4809
4809
|
cardanowall-sdk-conformance --help
|
|
4810
4810
|
|
|
4811
|
-
Runs the @cardanowall/sdk-ts standalone
|
|
4811
|
+
Runs the @cardanowall/sdk-ts standalone Label 309 verifier against a single
|
|
4812
4812
|
Cardano transaction. Exit codes:
|
|
4813
4813
|
0 = valid, 1 = failed (integrity), 2 = failed (network), 3 = pending,
|
|
4814
4814
|
4 = CLI input error.`;
|