@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
|
@@ -16,7 +16,7 @@ declare function verifyTx(input: VerifyTxInput): Promise<VerifyReport>;
|
|
|
16
16
|
* Use this when you trust an upstream indexer for the (metadataCbor,
|
|
17
17
|
* blockTime, blockSlot, numConfirmations) tuple and want to skip the
|
|
18
18
|
* /tx_cbor + /tx_info round-trip. The caller is responsible for the
|
|
19
|
-
* confidence that the supplied bytes actually came from
|
|
19
|
+
* confidence that the supplied bytes actually came from the label-309
|
|
20
20
|
* metadata field of a confirmed Cardano transaction.
|
|
21
21
|
*/
|
|
22
22
|
declare function verifyResolved(input: {
|
|
@@ -86,7 +86,7 @@ interface ResolvedTx {
|
|
|
86
86
|
}
|
|
87
87
|
declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
88
88
|
declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
89
|
-
declare class
|
|
89
|
+
declare class NotALabel309RecordError extends Error {
|
|
90
90
|
readonly code: "METADATA_NOT_FOUND";
|
|
91
91
|
constructor(message: string);
|
|
92
92
|
}
|
|
@@ -173,4 +173,4 @@ declare function fetchItemCiphertext(args: FetchItemCiphertextArgs): Promise<Uin
|
|
|
173
173
|
|
|
174
174
|
declare function verifyReportToDict(report: VerifyReport): Record<string, unknown>;
|
|
175
175
|
|
|
176
|
-
export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL,
|
|
176
|
+
export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL, NotALabel309RecordError, Profile, type ResolvedTx, type TxComponents, VerifyItemDecryption, VerifyMerkleCheck, VerifyRecordSignature, VerifyReport, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, VerifyUriCheck, decodeTxSummary, decodeTxWitnesses, exitCodeForVerdict, extractLabel309Metadata, fetchItemCiphertext, planProfileSkips, profileImplements, resolveCardanoTx, sliceLabel309Value, sliceTxComponents, tryDecryptions, verifyMerkleCommitments, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };
|
package/dist/verifier/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare function verifyTx(input: VerifyTxInput): Promise<VerifyReport>;
|
|
|
16
16
|
* Use this when you trust an upstream indexer for the (metadataCbor,
|
|
17
17
|
* blockTime, blockSlot, numConfirmations) tuple and want to skip the
|
|
18
18
|
* /tx_cbor + /tx_info round-trip. The caller is responsible for the
|
|
19
|
-
* confidence that the supplied bytes actually came from
|
|
19
|
+
* confidence that the supplied bytes actually came from the label-309
|
|
20
20
|
* metadata field of a confirmed Cardano transaction.
|
|
21
21
|
*/
|
|
22
22
|
declare function verifyResolved(input: {
|
|
@@ -86,7 +86,7 @@ interface ResolvedTx {
|
|
|
86
86
|
}
|
|
87
87
|
declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
88
88
|
declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
89
|
-
declare class
|
|
89
|
+
declare class NotALabel309RecordError extends Error {
|
|
90
90
|
readonly code: "METADATA_NOT_FOUND";
|
|
91
91
|
constructor(message: string);
|
|
92
92
|
}
|
|
@@ -173,4 +173,4 @@ declare function fetchItemCiphertext(args: FetchItemCiphertextArgs): Promise<Uin
|
|
|
173
173
|
|
|
174
174
|
declare function verifyReportToDict(report: VerifyReport): Record<string, unknown>;
|
|
175
175
|
|
|
176
|
-
export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL,
|
|
176
|
+
export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL, NotALabel309RecordError, Profile, type ResolvedTx, type TxComponents, VerifyItemDecryption, VerifyMerkleCheck, VerifyRecordSignature, VerifyReport, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, VerifyUriCheck, decodeTxSummary, decodeTxWitnesses, exitCodeForVerdict, extractLabel309Metadata, fetchItemCiphertext, planProfileSkips, profileImplements, resolveCardanoTx, sliceLabel309Value, sliceTxComponents, tryDecryptions, verifyMerkleCommitments, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };
|
package/dist/verifier/index.js
CHANGED
|
@@ -150,7 +150,7 @@ function decodeCanonicalCbor(bytes) {
|
|
|
150
150
|
...cdeDecodeOptions,
|
|
151
151
|
rejectStreaming: true,
|
|
152
152
|
rejectDuplicateKeys: true,
|
|
153
|
-
// A
|
|
153
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
154
154
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
155
155
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
156
156
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -276,7 +276,7 @@ function decodeCanonicalCbor2(bytes) {
|
|
|
276
276
|
...cdeDecodeOptions,
|
|
277
277
|
rejectStreaming: true,
|
|
278
278
|
rejectDuplicateKeys: true,
|
|
279
|
-
// A
|
|
279
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
280
280
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
281
281
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
282
282
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -377,7 +377,7 @@ function buildSigStructure(args) {
|
|
|
377
377
|
args.payload
|
|
378
378
|
]);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function buildLabel309SigStructure(args) {
|
|
381
381
|
const toSign = new Uint8Array(
|
|
382
382
|
CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length + args.recordBodyCbor.length
|
|
383
383
|
);
|
|
@@ -451,7 +451,7 @@ function decodeCoseSign1(bytes) {
|
|
|
451
451
|
signature: signatureRaw
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function coseSign1Label309Verify(args) {
|
|
455
455
|
let decoded;
|
|
456
456
|
try {
|
|
457
457
|
decoded = decodeCoseSign1(args.message);
|
|
@@ -518,7 +518,7 @@ function coseSign1Cip309Verify(args) {
|
|
|
518
518
|
payload: hashedPayload
|
|
519
519
|
});
|
|
520
520
|
} else {
|
|
521
|
-
sigStructureBytes =
|
|
521
|
+
sigStructureBytes = buildLabel309SigStructure({
|
|
522
522
|
bodyProtectedBytes: decoded.protectedBytes,
|
|
523
523
|
recordBodyCbor: args.detachedRecordBodyCbor
|
|
524
524
|
});
|
|
@@ -878,11 +878,7 @@ function validateOneUri(chunks, path, errors) {
|
|
|
878
878
|
const uri = reconstructed.uri;
|
|
879
879
|
if (uri.includes("#")) {
|
|
880
880
|
errors.push(
|
|
881
|
-
issue(
|
|
882
|
-
"INVALID_URI",
|
|
883
|
-
path,
|
|
884
|
-
"URI contains a fragment identifier ('#'), which is forbidden"
|
|
885
|
-
)
|
|
881
|
+
issue("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
|
|
886
882
|
);
|
|
887
883
|
return;
|
|
888
884
|
}
|
|
@@ -912,21 +908,13 @@ function validateOneUri(chunks, path, errors) {
|
|
|
912
908
|
const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
913
909
|
if (!validateCidProfile(cid)) {
|
|
914
910
|
errors.push(
|
|
915
|
-
issue(
|
|
916
|
-
"INVALID_URI",
|
|
917
|
-
path,
|
|
918
|
-
"ipfs:// URI is not a valid CID under the CIP-309 profile"
|
|
919
|
-
)
|
|
911
|
+
issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
|
|
920
912
|
);
|
|
921
913
|
}
|
|
922
914
|
return;
|
|
923
915
|
}
|
|
924
916
|
errors.push(
|
|
925
|
-
issue(
|
|
926
|
-
"INVALID_URI",
|
|
927
|
-
path,
|
|
928
|
-
"unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}"
|
|
929
|
-
)
|
|
917
|
+
issue("INVALID_URI", path, "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}")
|
|
930
918
|
);
|
|
931
919
|
}
|
|
932
920
|
function checkItemEnc(item, idx, errors) {
|
|
@@ -968,7 +956,7 @@ function checkItemEnc(item, idx, errors) {
|
|
|
968
956
|
issue(
|
|
969
957
|
"UNAUTHENTICATED_CIPHER_FORBIDDEN",
|
|
970
958
|
[...basePath, "aead"],
|
|
971
|
-
`'${enc.aead}' is an unauthenticated cipher;
|
|
959
|
+
`'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
|
|
972
960
|
)
|
|
973
961
|
);
|
|
974
962
|
return;
|
|
@@ -3292,7 +3280,9 @@ async function tryDecryptions(args) {
|
|
|
3292
3280
|
let plaintext = null;
|
|
3293
3281
|
let failure = null;
|
|
3294
3282
|
if (reqHasSecret) {
|
|
3295
|
-
const envelope = sealedEnvelopeFromParsed(
|
|
3283
|
+
const envelope = sealedEnvelopeFromParsed(
|
|
3284
|
+
enc
|
|
3285
|
+
);
|
|
3296
3286
|
if (envelope === null) {
|
|
3297
3287
|
out.push({
|
|
3298
3288
|
item_index: idx,
|
|
@@ -3411,7 +3401,7 @@ function decodeCanonicalCbor3(bytes) {
|
|
|
3411
3401
|
...cdeDecodeOptions,
|
|
3412
3402
|
rejectStreaming: true,
|
|
3413
3403
|
rejectDuplicateKeys: true,
|
|
3414
|
-
// A
|
|
3404
|
+
// A Label 309 record carries integers, byte/text strings, arrays, maps and
|
|
3415
3405
|
// `null` — and nothing else. Without these rejections the major-type-7
|
|
3416
3406
|
// surface leaks into the decoder: a float16/32/64 that happens to hold an
|
|
3417
3407
|
// integral value (e.g. 1.0) silently decodes to the integer 1 and passes
|
|
@@ -3984,11 +3974,11 @@ function decodeIntKey(h) {
|
|
|
3984
3974
|
// src/verifier/resolve.ts
|
|
3985
3975
|
var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
|
|
3986
3976
|
var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
|
|
3987
|
-
var
|
|
3977
|
+
var NotALabel309RecordError = class extends Error {
|
|
3988
3978
|
code = "METADATA_NOT_FOUND";
|
|
3989
3979
|
constructor(message) {
|
|
3990
3980
|
super(message);
|
|
3991
|
-
this.name = "
|
|
3981
|
+
this.name = "NotALabel309RecordError";
|
|
3992
3982
|
}
|
|
3993
3983
|
};
|
|
3994
3984
|
async function resolveCardanoTx(args) {
|
|
@@ -3999,7 +3989,7 @@ async function resolveCardanoTx(args) {
|
|
|
3999
3989
|
try {
|
|
4000
3990
|
return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
|
|
4001
3991
|
} catch (e) {
|
|
4002
|
-
if (e instanceof
|
|
3992
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4003
3993
|
lastErr = e;
|
|
4004
3994
|
}
|
|
4005
3995
|
}
|
|
@@ -4007,7 +3997,7 @@ async function resolveCardanoTx(args) {
|
|
|
4007
3997
|
try {
|
|
4008
3998
|
return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
|
|
4009
3999
|
} catch (e) {
|
|
4010
|
-
if (e instanceof
|
|
4000
|
+
if (e instanceof NotALabel309RecordError) throw e;
|
|
4011
4001
|
lastErr = e;
|
|
4012
4002
|
}
|
|
4013
4003
|
}
|
|
@@ -4025,7 +4015,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4025
4015
|
}
|
|
4026
4016
|
const cborJson = parseJson(cborRes.bytes);
|
|
4027
4017
|
if (!Array.isArray(cborJson) || cborJson.length === 0) {
|
|
4028
|
-
throw new
|
|
4018
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
|
|
4029
4019
|
}
|
|
4030
4020
|
const cborEntry = cborJson[0];
|
|
4031
4021
|
if (typeof cborEntry.cbor !== "string") {
|
|
@@ -4046,7 +4036,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
|
|
|
4046
4036
|
}
|
|
4047
4037
|
const infoJson = parseJson(infoRes.bytes);
|
|
4048
4038
|
if (!Array.isArray(infoJson) || infoJson.length === 0) {
|
|
4049
|
-
throw new
|
|
4039
|
+
throw new NotALabel309RecordError("koios returned empty array for tx_info");
|
|
4050
4040
|
}
|
|
4051
4041
|
const infoEntry = infoJson[0];
|
|
4052
4042
|
if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
|
|
@@ -4191,7 +4181,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
|
|
|
4191
4181
|
return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
|
|
4192
4182
|
}
|
|
4193
4183
|
const { pub, signerType } = resolved;
|
|
4194
|
-
const verifyResult =
|
|
4184
|
+
const verifyResult = coseSign1Label309Verify({
|
|
4195
4185
|
message: coseBytes,
|
|
4196
4186
|
detachedRecordBodyCbor: recordBodyCbor,
|
|
4197
4187
|
expectedSignerKey: pub
|
|
@@ -4420,7 +4410,8 @@ function decodeTxSummary(txBodyBytes, witnessSetBytes, network) {
|
|
|
4420
4410
|
else if (typeof invalidBefore === "bigint") summary.invalid_before = Number(invalidBefore);
|
|
4421
4411
|
const invalidHereafter = body.get(BODY_KEY_INVALID_HEREAFTER);
|
|
4422
4412
|
if (typeof invalidHereafter === "number") summary.invalid_hereafter = invalidHereafter;
|
|
4423
|
-
else if (typeof invalidHereafter === "bigint")
|
|
4413
|
+
else if (typeof invalidHereafter === "bigint")
|
|
4414
|
+
summary.invalid_hereafter = Number(invalidHereafter);
|
|
4424
4415
|
if (requiredSigners.length > 0) summary.required_signer_key_hashes = requiredSigners;
|
|
4425
4416
|
const networkId = body.get(BODY_KEY_NETWORK_ID);
|
|
4426
4417
|
if (typeof networkId === "number") summary.network_id = networkId;
|
|
@@ -4539,7 +4530,7 @@ async function verifyTx(input) {
|
|
|
4539
4530
|
try {
|
|
4540
4531
|
resolved = await resolveCardanoTx({ input, fetchFn });
|
|
4541
4532
|
} catch (e) {
|
|
4542
|
-
if (e instanceof
|
|
4533
|
+
if (e instanceof NotALabel309RecordError) {
|
|
4543
4534
|
return base({
|
|
4544
4535
|
verdict: "failed",
|
|
4545
4536
|
exit_code: 1,
|
|
@@ -4632,7 +4623,16 @@ async function verifyResolved(input) {
|
|
|
4632
4623
|
return report;
|
|
4633
4624
|
}
|
|
4634
4625
|
async function verifyResolvedRecord(args) {
|
|
4635
|
-
const {
|
|
4626
|
+
const {
|
|
4627
|
+
input,
|
|
4628
|
+
metadataBytes,
|
|
4629
|
+
txCbor,
|
|
4630
|
+
numConfirmations,
|
|
4631
|
+
blockTime,
|
|
4632
|
+
blockSlot,
|
|
4633
|
+
httpCalls,
|
|
4634
|
+
fetchFn
|
|
4635
|
+
} = args;
|
|
4636
4636
|
const profile = input.profile ?? DEFAULT_PROFILE;
|
|
4637
4637
|
const threshold = input.confirmationDepthThreshold ?? CONFIRMATION_DEPTH_THRESHOLD_DEFAULT;
|
|
4638
4638
|
const txDescription = txCbor !== void 0 ? decodeTxDescription(txCbor, input) : {};
|
|
@@ -4843,6 +4843,6 @@ function verifyReportToDict(report) {
|
|
|
4843
4843
|
(*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *)
|
|
4844
4844
|
*/
|
|
4845
4845
|
|
|
4846
|
-
export { BLOCKFROST_MAINNET_HOST, BodyTooLargeError, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_OUTBOUND_MAX_BYTES, DEFAULT_PROFILE, DENY_HOSTS_DEFAULT, DenyHostError, KOIOS_MAINNET_URL,
|
|
4846
|
+
export { BLOCKFROST_MAINNET_HOST, BodyTooLargeError, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_OUTBOUND_MAX_BYTES, DEFAULT_PROFILE, DENY_HOSTS_DEFAULT, DenyHostError, KOIOS_MAINNET_URL, NotALabel309RecordError, OutboundExhaustedError, PROFILE_RANK, UnsupportedMethodError, UnsupportedProtocolError, decodeTxSummary, decodeTxWitnesses, defaultFetchOutbound, exitCodeForVerdict, extractLabel309Metadata, fetchItemCiphertext, fetchOutbound, planProfileSkips, profileImplements, resolveCardanoTx, sliceLabel309Value, sliceTxComponents, tryDecryptions, verifyMerkleCommitments, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx, wrapFetchOutbound };
|
|
4847
4847
|
//# sourceMappingURL=index.js.map
|
|
4848
4848
|
//# sourceMappingURL=index.js.map
|