@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.cjs
CHANGED
|
@@ -173,7 +173,7 @@ function decodeCanonicalCbor(bytes) {
|
|
|
173
173
|
...cbor2.cdeDecodeOptions,
|
|
174
174
|
rejectStreaming: true,
|
|
175
175
|
rejectDuplicateKeys: true,
|
|
176
|
-
// A
|
|
176
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
177
177
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
178
178
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
179
179
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -299,7 +299,7 @@ function decodeCanonicalCbor2(bytes) {
|
|
|
299
299
|
...cbor2.cdeDecodeOptions,
|
|
300
300
|
rejectStreaming: true,
|
|
301
301
|
rejectDuplicateKeys: true,
|
|
302
|
-
// A
|
|
302
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
303
303
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
304
304
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
305
305
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -400,7 +400,7 @@ function buildSigStructure(args) {
|
|
|
400
400
|
args.payload
|
|
401
401
|
]);
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function buildLabel309SigStructure(args) {
|
|
404
404
|
const toSign = new Uint8Array(
|
|
405
405
|
CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length + args.recordBodyCbor.length
|
|
406
406
|
);
|
|
@@ -474,7 +474,7 @@ function decodeCoseSign1(bytes) {
|
|
|
474
474
|
signature: signatureRaw
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function coseSign1Label309Verify(args) {
|
|
478
478
|
let decoded;
|
|
479
479
|
try {
|
|
480
480
|
decoded = decodeCoseSign1(args.message);
|
|
@@ -541,7 +541,7 @@ function coseSign1Cip309Verify(args) {
|
|
|
541
541
|
payload: hashedPayload
|
|
542
542
|
});
|
|
543
543
|
} else {
|
|
544
|
-
sigStructureBytes =
|
|
544
|
+
sigStructureBytes = buildLabel309SigStructure({
|
|
545
545
|
bodyProtectedBytes: decoded.protectedBytes,
|
|
546
546
|
recordBodyCbor: args.detachedRecordBodyCbor
|
|
547
547
|
});
|
|
@@ -931,7 +931,7 @@ function validateOneUri(chunks, path, errors) {
|
|
|
931
931
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
932
932
|
if (!validateCidProfile(cid)) {
|
|
933
933
|
errors.push(
|
|
934
|
-
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the
|
|
934
|
+
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
935
935
|
);
|
|
936
936
|
}
|
|
937
937
|
return;
|
|
@@ -979,7 +979,7 @@ function checkItemEnc(item, idx, errors) {
|
|
|
979
979
|
issue(
|
|
980
980
|
"UNAUTHENTICATED_CIPHER_FORBIDDEN",
|
|
981
981
|
[...basePath, "aead"],
|
|
982
|
-
`'${enc.aead}' is an unauthenticated cipher;
|
|
982
|
+
`'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
|
|
983
983
|
)
|
|
984
984
|
);
|
|
985
985
|
return;
|
|
@@ -3419,7 +3419,7 @@ function decodeCanonicalCbor3(bytes) {
|
|
|
3419
3419
|
...cbor2.cdeDecodeOptions,
|
|
3420
3420
|
rejectStreaming: true,
|
|
3421
3421
|
rejectDuplicateKeys: true,
|
|
3422
|
-
// A
|
|
3422
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
3423
3423
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
3424
3424
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
3425
3425
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -3989,11 +3989,11 @@ function decodeIntKey(h) {
|
|
|
3989
3989
|
// src/verifier/resolve.ts
|
|
3990
3990
|
var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
3991
3991
|
var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
3992
|
-
var
|
|
3992
|
+
var NotALabel309RecordError = class extends Error {
|
|
3993
3993
|
code = "METADATA_NOT_FOUND";
|
|
3994
3994
|
constructor(message) {
|
|
3995
3995
|
super(message);
|
|
3996
|
-
this.name = "
|
|
3996
|
+
this.name = "NotALabel309RecordError";
|
|
3997
3997
|
}
|
|
3998
3998
|
};
|
|
3999
3999
|
async function resolveCardanoTx(args) {
|
|
@@ -4004,7 +4004,7 @@ async function resolveCardanoTx(args) {
|
|
|
4004
4004
|
try {
|
|
4005
4005
|
return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
|
|
4006
4006
|
} catch (e) {
|
|
4007
|
-
if (e instanceof
|
|
4007
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4008
4008
|
lastErr = e;
|
|
4009
4009
|
}
|
|
4010
4010
|
}
|
|
@@ -4012,7 +4012,7 @@ async function resolveCardanoTx(args) {
|
|
|
4012
4012
|
try {
|
|
4013
4013
|
return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
|
|
4014
4014
|
} catch (e) {
|
|
4015
|
-
if (e instanceof
|
|
4015
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4016
4016
|
lastErr = e;
|
|
4017
4017
|
}
|
|
4018
4018
|
}
|
|
@@ -4030,7 +4030,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4030
4030
|
}
|
|
4031
4031
|
const cborJson = parseJson(cborRes.bytes);
|
|
4032
4032
|
if (!Array.isArray(cborJson) || cborJson.length === 0) {
|
|
4033
|
-
throw new
|
|
4033
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
|
|
4034
4034
|
}
|
|
4035
4035
|
const cborEntry = cborJson[0];
|
|
4036
4036
|
if (typeof cborEntry.cbor !== "string") {
|
|
@@ -4051,7 +4051,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4051
4051
|
}
|
|
4052
4052
|
const infoJson = parseJson(infoRes.bytes);
|
|
4053
4053
|
if (!Array.isArray(infoJson) || infoJson.length === 0) {
|
|
4054
|
-
throw new
|
|
4054
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_info");
|
|
4055
4055
|
}
|
|
4056
4056
|
const infoEntry = infoJson[0];
|
|
4057
4057
|
if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
|
|
@@ -4196,7 +4196,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
|
|
|
4196
4196
|
return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
|
|
4197
4197
|
}
|
|
4198
4198
|
const { pub, signerType } = resolved;
|
|
4199
|
-
const verifyResult =
|
|
4199
|
+
const verifyResult = coseSign1Label309Verify({
|
|
4200
4200
|
message: coseBytes,
|
|
4201
4201
|
detachedRecordBodyCbor: recordBodyCbor,
|
|
4202
4202
|
expectedSignerKey: pub
|
|
@@ -4545,7 +4545,7 @@ async function verifyTx(input) {
|
|
|
4545
4545
|
try {
|
|
4546
4546
|
resolved = await resolveCardanoTx({ input, fetchFn });
|
|
4547
4547
|
} catch (e) {
|
|
4548
|
-
if (e instanceof
|
|
4548
|
+
if (e instanceof NotALabel309RecordError) {
|
|
4549
4549
|
return base({
|
|
4550
4550
|
verdict: "failed",
|
|
4551
4551
|
exit_code: 1,
|
|
@@ -4830,7 +4830,7 @@ var USAGE = `Usage: cardanowall-sdk-conformance <tx-hash> [--gateway <url>] [--t
|
|
|
4830
4830
|
cardanowall-sdk-conformance --version
|
|
4831
4831
|
cardanowall-sdk-conformance --help
|
|
4832
4832
|
|
|
4833
|
-
Runs the @cardanowall/sdk-ts standalone
|
|
4833
|
+
Runs the @cardanowall/sdk-ts standalone Label 309 verifier against a single
|
|
4834
4834
|
Cardano transaction. Exit codes:
|
|
4835
4835
|
0 = valid, 1 = failed (integrity), 2 = failed (network), 3 = pending,
|
|
4836
4836
|
4 = CLI input error.`;
|