@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.
@@ -151,7 +151,7 @@ function decodeCanonicalCbor(bytes) {
151
151
  ...cdeDecodeOptions,
152
152
  rejectStreaming: true,
153
153
  rejectDuplicateKeys: true,
154
- // A CIP-309 record carries integers, byte/text strings, arrays, maps and
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 CIP-309 record carries integers, byte/text strings, arrays, maps and
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 buildCip309SigStructure(args) {
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 coseSign1Cip309Verify(args) {
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 = buildCip309SigStructure({
522
+ sigStructureBytes = buildLabel309SigStructure({
523
523
  bodyProtectedBytes: decoded.protectedBytes,
524
524
  recordBodyCbor: args.detachedRecordBodyCbor
525
525
  });
@@ -879,11 +879,7 @@ function validateOneUri(chunks, path, errors) {
879
879
  const uri = reconstructed.uri;
880
880
  if (uri.includes("#")) {
881
881
  errors.push(
882
- issue(
883
- "INVALID_URI",
884
- path,
885
- "URI contains a fragment identifier ('#'), which is forbidden"
886
- )
882
+ issue("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
887
883
  );
888
884
  return;
889
885
  }
@@ -913,21 +909,13 @@ function validateOneUri(chunks, path, errors) {
913
909
  const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
914
910
  if (!validateCidProfile(cid)) {
915
911
  errors.push(
916
- issue(
917
- "INVALID_URI",
918
- path,
919
- "ipfs:// URI is not a valid CID under the CIP-309 profile"
920
- )
912
+ issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
921
913
  );
922
914
  }
923
915
  return;
924
916
  }
925
917
  errors.push(
926
- issue(
927
- "INVALID_URI",
928
- path,
929
- "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}"
930
- )
918
+ issue("INVALID_URI", path, "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}")
931
919
  );
932
920
  }
933
921
  function checkItemEnc(item, idx, errors) {
@@ -969,7 +957,7 @@ function checkItemEnc(item, idx, errors) {
969
957
  issue(
970
958
  "UNAUTHENTICATED_CIPHER_FORBIDDEN",
971
959
  [...basePath, "aead"],
972
- `'${enc.aead}' is an unauthenticated cipher; CIP-309 mandates an authenticated (AEAD) cipher`
960
+ `'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
973
961
  )
974
962
  );
975
963
  return;
@@ -3288,7 +3276,9 @@ async function tryDecryptions(args) {
3288
3276
  let plaintext = null;
3289
3277
  let failure = null;
3290
3278
  if (reqHasSecret) {
3291
- const envelope = sealedEnvelopeFromParsed(enc);
3279
+ const envelope = sealedEnvelopeFromParsed(
3280
+ enc
3281
+ );
3292
3282
  if (envelope === null) {
3293
3283
  out.push({
3294
3284
  item_index: idx,
@@ -3407,7 +3397,7 @@ function decodeCanonicalCbor3(bytes) {
3407
3397
  ...cdeDecodeOptions,
3408
3398
  rejectStreaming: true,
3409
3399
  rejectDuplicateKeys: true,
3410
- // A CIP-309 record carries integers, byte/text strings, arrays, maps and
3400
+ // A Label 309 record carries integers, byte/text strings, arrays, maps and
3411
3401
  // `null` — and nothing else. Without these rejections the major-type-7
3412
3402
  // surface leaks into the decoder: a float16/32/64 that happens to hold an
3413
3403
  // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
@@ -3977,11 +3967,11 @@ function decodeIntKey(h) {
3977
3967
  // src/verifier/resolve.ts
3978
3968
  var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
3979
3969
  var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
3980
- var NotACip309RecordError = class extends Error {
3970
+ var NotALabel309RecordError = class extends Error {
3981
3971
  code = "METADATA_NOT_FOUND";
3982
3972
  constructor(message) {
3983
3973
  super(message);
3984
- this.name = "NotACip309RecordError";
3974
+ this.name = "NotALabel309RecordError";
3985
3975
  }
3986
3976
  };
3987
3977
  async function resolveCardanoTx(args) {
@@ -3992,7 +3982,7 @@ async function resolveCardanoTx(args) {
3992
3982
  try {
3993
3983
  return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
3994
3984
  } catch (e) {
3995
- if (e instanceof NotACip309RecordError) throw e;
3985
+ if (e instanceof NotALabel309RecordError) throw e;
3996
3986
  lastErr = e;
3997
3987
  }
3998
3988
  }
@@ -4000,7 +3990,7 @@ async function resolveCardanoTx(args) {
4000
3990
  try {
4001
3991
  return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
4002
3992
  } catch (e) {
4003
- if (e instanceof NotACip309RecordError) throw e;
3993
+ if (e instanceof NotALabel309RecordError) throw e;
4004
3994
  lastErr = e;
4005
3995
  }
4006
3996
  }
@@ -4018,7 +4008,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
4018
4008
  }
4019
4009
  const cborJson = parseJson(cborRes.bytes);
4020
4010
  if (!Array.isArray(cborJson) || cborJson.length === 0) {
4021
- throw new NotACip309RecordError("koios returned empty array for tx_cbor; tx may not exist");
4011
+ throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
4022
4012
  }
4023
4013
  const cborEntry = cborJson[0];
4024
4014
  if (typeof cborEntry.cbor !== "string") {
@@ -4039,7 +4029,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
4039
4029
  }
4040
4030
  const infoJson = parseJson(infoRes.bytes);
4041
4031
  if (!Array.isArray(infoJson) || infoJson.length === 0) {
4042
- throw new NotACip309RecordError("koios returned empty array for tx_info");
4032
+ throw new NotALabel309RecordError("koios returned empty array for tx_info");
4043
4033
  }
4044
4034
  const infoEntry = infoJson[0];
4045
4035
  if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
@@ -4184,7 +4174,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
4184
4174
  return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
4185
4175
  }
4186
4176
  const { pub, signerType } = resolved;
4187
- const verifyResult = coseSign1Cip309Verify({
4177
+ const verifyResult = coseSign1Label309Verify({
4188
4178
  message: coseBytes,
4189
4179
  detachedRecordBodyCbor: recordBodyCbor,
4190
4180
  expectedSignerKey: pub
@@ -4413,7 +4403,8 @@ function decodeTxSummary(txBodyBytes, witnessSetBytes, network) {
4413
4403
  else if (typeof invalidBefore === "bigint") summary.invalid_before = Number(invalidBefore);
4414
4404
  const invalidHereafter = body.get(BODY_KEY_INVALID_HEREAFTER);
4415
4405
  if (typeof invalidHereafter === "number") summary.invalid_hereafter = invalidHereafter;
4416
- else if (typeof invalidHereafter === "bigint") summary.invalid_hereafter = Number(invalidHereafter);
4406
+ else if (typeof invalidHereafter === "bigint")
4407
+ summary.invalid_hereafter = Number(invalidHereafter);
4417
4408
  if (requiredSigners.length > 0) summary.required_signer_key_hashes = requiredSigners;
4418
4409
  const networkId = body.get(BODY_KEY_NETWORK_ID);
4419
4410
  if (typeof networkId === "number") summary.network_id = networkId;
@@ -4532,7 +4523,7 @@ async function verifyTx(input) {
4532
4523
  try {
4533
4524
  resolved = await resolveCardanoTx({ input, fetchFn });
4534
4525
  } catch (e) {
4535
- if (e instanceof NotACip309RecordError) {
4526
+ if (e instanceof NotALabel309RecordError) {
4536
4527
  return base({
4537
4528
  verdict: "failed",
4538
4529
  exit_code: 1,
@@ -4593,7 +4584,16 @@ async function verifyTx(input) {
4593
4584
  });
4594
4585
  }
4595
4586
  async function verifyResolvedRecord(args) {
4596
- const { input, metadataBytes, txCbor, numConfirmations, blockTime, blockSlot, httpCalls, fetchFn } = args;
4587
+ const {
4588
+ input,
4589
+ metadataBytes,
4590
+ txCbor,
4591
+ numConfirmations,
4592
+ blockTime,
4593
+ blockSlot,
4594
+ httpCalls,
4595
+ fetchFn
4596
+ } = args;
4597
4597
  const profile = input.profile ?? DEFAULT_PROFILE;
4598
4598
  const threshold = input.confirmationDepthThreshold ?? CONFIRMATION_DEPTH_THRESHOLD_DEFAULT;
4599
4599
  const txDescription = txCbor !== void 0 ? decodeTxDescription(txCbor, input) : {};
@@ -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 CIP-309 verifier against a single
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.`;