@cardanowall/sdk-ts 0.0.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 +23 -19
- 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 +34 -34
- package/dist/conformance/cli.cjs.map +1 -1
- package/dist/conformance/cli.js +34 -34
- 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 +67 -67
- 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 +65 -65
- 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 +34 -34
- 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 +34 -34
- package/dist/verifier/index.js.map +1 -1
- package/package.json +10 -9
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
|
});
|
|
@@ -901,11 +901,7 @@ function validateOneUri(chunks, path, errors) {
|
|
|
901
901
|
const uri = reconstructed.uri;
|
|
902
902
|
if (uri.includes("#")) {
|
|
903
903
|
errors.push(
|
|
904
|
-
issue(
|
|
905
|
-
"INVALID_URI",
|
|
906
|
-
path,
|
|
907
|
-
"URI contains a fragment identifier ('#'), which is forbidden"
|
|
908
|
-
)
|
|
904
|
+
issue("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
|
|
909
905
|
);
|
|
910
906
|
return;
|
|
911
907
|
}
|
|
@@ -935,21 +931,13 @@ function validateOneUri(chunks, path, errors) {
|
|
|
935
931
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
936
932
|
if (!validateCidProfile(cid)) {
|
|
937
933
|
errors.push(
|
|
938
|
-
issue(
|
|
939
|
-
"INVALID_URI",
|
|
940
|
-
path,
|
|
941
|
-
"ipfs:// URI is not a valid CID under the CIP-309 profile"
|
|
942
|
-
)
|
|
934
|
+
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
943
935
|
);
|
|
944
936
|
}
|
|
945
937
|
return;
|
|
946
938
|
}
|
|
947
939
|
errors.push(
|
|
948
|
-
issue(
|
|
949
|
-
"INVALID_URI",
|
|
950
|
-
path,
|
|
951
|
-
"unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}"
|
|
952
|
-
)
|
|
940
|
+
issue("INVALID_URI", path, "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}")
|
|
953
941
|
);
|
|
954
942
|
}
|
|
955
943
|
function checkItemEnc(item, idx, errors) {
|
|
@@ -991,7 +979,7 @@ function checkItemEnc(item, idx, errors) {
|
|
|
991
979
|
issue(
|
|
992
980
|
"UNAUTHENTICATED_CIPHER_FORBIDDEN",
|
|
993
981
|
[...basePath, "aead"],
|
|
994
|
-
`'${enc.aead}' is an unauthenticated cipher;
|
|
982
|
+
`'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
|
|
995
983
|
)
|
|
996
984
|
);
|
|
997
985
|
return;
|
|
@@ -3310,7 +3298,9 @@ async function tryDecryptions(args) {
|
|
|
3310
3298
|
let plaintext = null;
|
|
3311
3299
|
let failure = null;
|
|
3312
3300
|
if (reqHasSecret) {
|
|
3313
|
-
const envelope = sealedEnvelopeFromParsed(
|
|
3301
|
+
const envelope = sealedEnvelopeFromParsed(
|
|
3302
|
+
enc
|
|
3303
|
+
);
|
|
3314
3304
|
if (envelope === null) {
|
|
3315
3305
|
out.push({
|
|
3316
3306
|
item_index: idx,
|
|
@@ -3429,7 +3419,7 @@ function decodeCanonicalCbor3(bytes) {
|
|
|
3429
3419
|
...cbor2.cdeDecodeOptions,
|
|
3430
3420
|
rejectStreaming: true,
|
|
3431
3421
|
rejectDuplicateKeys: true,
|
|
3432
|
-
// A
|
|
3422
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
3433
3423
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
3434
3424
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
3435
3425
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -3999,11 +3989,11 @@ function decodeIntKey(h) {
|
|
|
3999
3989
|
// src/verifier/resolve.ts
|
|
4000
3990
|
var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
4001
3991
|
var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
4002
|
-
var
|
|
3992
|
+
var NotALabel309RecordError = class extends Error {
|
|
4003
3993
|
code = "METADATA_NOT_FOUND";
|
|
4004
3994
|
constructor(message) {
|
|
4005
3995
|
super(message);
|
|
4006
|
-
this.name = "
|
|
3996
|
+
this.name = "NotALabel309RecordError";
|
|
4007
3997
|
}
|
|
4008
3998
|
};
|
|
4009
3999
|
async function resolveCardanoTx(args) {
|
|
@@ -4014,7 +4004,7 @@ async function resolveCardanoTx(args) {
|
|
|
4014
4004
|
try {
|
|
4015
4005
|
return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
|
|
4016
4006
|
} catch (e) {
|
|
4017
|
-
if (e instanceof
|
|
4007
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4018
4008
|
lastErr = e;
|
|
4019
4009
|
}
|
|
4020
4010
|
}
|
|
@@ -4022,7 +4012,7 @@ async function resolveCardanoTx(args) {
|
|
|
4022
4012
|
try {
|
|
4023
4013
|
return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
|
|
4024
4014
|
} catch (e) {
|
|
4025
|
-
if (e instanceof
|
|
4015
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4026
4016
|
lastErr = e;
|
|
4027
4017
|
}
|
|
4028
4018
|
}
|
|
@@ -4040,7 +4030,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4040
4030
|
}
|
|
4041
4031
|
const cborJson = parseJson(cborRes.bytes);
|
|
4042
4032
|
if (!Array.isArray(cborJson) || cborJson.length === 0) {
|
|
4043
|
-
throw new
|
|
4033
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
|
|
4044
4034
|
}
|
|
4045
4035
|
const cborEntry = cborJson[0];
|
|
4046
4036
|
if (typeof cborEntry.cbor !== "string") {
|
|
@@ -4061,7 +4051,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4061
4051
|
}
|
|
4062
4052
|
const infoJson = parseJson(infoRes.bytes);
|
|
4063
4053
|
if (!Array.isArray(infoJson) || infoJson.length === 0) {
|
|
4064
|
-
throw new
|
|
4054
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_info");
|
|
4065
4055
|
}
|
|
4066
4056
|
const infoEntry = infoJson[0];
|
|
4067
4057
|
if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
|
|
@@ -4206,7 +4196,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
|
|
|
4206
4196
|
return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
|
|
4207
4197
|
}
|
|
4208
4198
|
const { pub, signerType } = resolved;
|
|
4209
|
-
const verifyResult =
|
|
4199
|
+
const verifyResult = coseSign1Label309Verify({
|
|
4210
4200
|
message: coseBytes,
|
|
4211
4201
|
detachedRecordBodyCbor: recordBodyCbor,
|
|
4212
4202
|
expectedSignerKey: pub
|
|
@@ -4435,7 +4425,8 @@ function decodeTxSummary(txBodyBytes, witnessSetBytes, network) {
|
|
|
4435
4425
|
else if (typeof invalidBefore === "bigint") summary.invalid_before = Number(invalidBefore);
|
|
4436
4426
|
const invalidHereafter = body.get(BODY_KEY_INVALID_HEREAFTER);
|
|
4437
4427
|
if (typeof invalidHereafter === "number") summary.invalid_hereafter = invalidHereafter;
|
|
4438
|
-
else if (typeof invalidHereafter === "bigint")
|
|
4428
|
+
else if (typeof invalidHereafter === "bigint")
|
|
4429
|
+
summary.invalid_hereafter = Number(invalidHereafter);
|
|
4439
4430
|
if (requiredSigners.length > 0) summary.required_signer_key_hashes = requiredSigners;
|
|
4440
4431
|
const networkId = body.get(BODY_KEY_NETWORK_ID);
|
|
4441
4432
|
if (typeof networkId === "number") summary.network_id = networkId;
|
|
@@ -4554,7 +4545,7 @@ async function verifyTx(input) {
|
|
|
4554
4545
|
try {
|
|
4555
4546
|
resolved = await resolveCardanoTx({ input, fetchFn });
|
|
4556
4547
|
} catch (e) {
|
|
4557
|
-
if (e instanceof
|
|
4548
|
+
if (e instanceof NotALabel309RecordError) {
|
|
4558
4549
|
return base({
|
|
4559
4550
|
verdict: "failed",
|
|
4560
4551
|
exit_code: 1,
|
|
@@ -4615,7 +4606,16 @@ async function verifyTx(input) {
|
|
|
4615
4606
|
});
|
|
4616
4607
|
}
|
|
4617
4608
|
async function verifyResolvedRecord(args) {
|
|
4618
|
-
const {
|
|
4609
|
+
const {
|
|
4610
|
+
input,
|
|
4611
|
+
metadataBytes,
|
|
4612
|
+
txCbor,
|
|
4613
|
+
numConfirmations,
|
|
4614
|
+
blockTime,
|
|
4615
|
+
blockSlot,
|
|
4616
|
+
httpCalls,
|
|
4617
|
+
fetchFn
|
|
4618
|
+
} = args;
|
|
4619
4619
|
const profile = input.profile ?? DEFAULT_PROFILE;
|
|
4620
4620
|
const threshold = input.confirmationDepthThreshold ?? CONFIRMATION_DEPTH_THRESHOLD_DEFAULT;
|
|
4621
4621
|
const txDescription = txCbor !== void 0 ? decodeTxDescription(txCbor, input) : {};
|
|
@@ -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.`;
|