@lerna-labs/hydra-sdk 1.0.0-beta.25 → 1.0.0-beta.26

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/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { getAdmin } from './mesh/get-admin.js';
11
11
  export { createMultisigAddress, createNativeScript } from './mesh/native-script.js';
12
12
  export { submitTx } from './tx3/submit-tx.js';
13
13
  export { chunkString } from './utils/chunk-string.js';
14
- export { bufferToAscii, bufferToHex, verifySignature } from './utils/verify-signature.js';
14
+ export { BECH32_DECODE_LIMIT, bufferToAscii, bufferToHex, decodeBech32Address, verifySignature, } from './utils/verify-signature.js';
15
15
  export { CommitArgs, UTxORef, Wrangler } from './wrangler.js';
package/dist/index.js CHANGED
@@ -7,5 +7,5 @@ export { getAdmin } from './mesh/get-admin.js';
7
7
  export { createMultisigAddress, createNativeScript } from './mesh/native-script.js';
8
8
  export { submitTx } from './tx3/submit-tx.js';
9
9
  export { chunkString } from './utils/chunk-string.js';
10
- export { bufferToAscii, bufferToHex, verifySignature } from './utils/verify-signature.js';
10
+ export { BECH32_DECODE_LIMIT, bufferToAscii, bufferToHex, decodeBech32Address, verifySignature, } from './utils/verify-signature.js';
11
11
  export { Wrangler } from './wrangler.js';
@@ -1,7 +1,22 @@
1
+ import { Buffer } from 'node:buffer';
1
2
  /** Convert a buffer-like value to a hex string. */
2
3
  export declare const bufferToHex: (buffer: Uint8Array | string) => string;
3
4
  /** Convert a buffer-like value to an ASCII string. */
4
5
  export declare const bufferToAscii: (buffer: Uint8Array | string) => string;
6
+ /**
7
+ * Character limit used for bech32 decoding. The library defaults to 90, which truncates
8
+ * Cardano base addresses (payment + staking) that are commonly 103+ characters. We raise
9
+ * the ceiling well above any realistic Cardano encoding (addr, stake, drep, pool, cc_*).
10
+ */
11
+ export declare const BECH32_DECODE_LIMIT = 1023;
12
+ /**
13
+ * Decode a Cardano bech32 string (addr, stake, pool, drep, cc_*) with a character
14
+ * limit high enough to accommodate base addresses that include a staking component.
15
+ */
16
+ export declare function decodeBech32Address(address: string): {
17
+ prefix: string;
18
+ addressBytes: Buffer;
19
+ };
5
20
  /**
6
21
  * Verify a CIP-30 COSE_Sign1 signature against an expected message and address.
7
22
  *
@@ -8,6 +8,20 @@ import { chunkString } from './chunk-string.js';
8
8
  export const bufferToHex = (buffer) => Buffer.from(buffer).toString('hex');
9
9
  /** Convert a buffer-like value to an ASCII string. */
10
10
  export const bufferToAscii = (buffer) => Buffer.from(buffer).toString('ascii');
11
+ /**
12
+ * Character limit used for bech32 decoding. The library defaults to 90, which truncates
13
+ * Cardano base addresses (payment + staking) that are commonly 103+ characters. We raise
14
+ * the ceiling well above any realistic Cardano encoding (addr, stake, drep, pool, cc_*).
15
+ */
16
+ export const BECH32_DECODE_LIMIT = 1023;
17
+ /**
18
+ * Decode a Cardano bech32 string (addr, stake, pool, drep, cc_*) with a character
19
+ * limit high enough to accommodate base addresses that include a staking component.
20
+ */
21
+ export function decodeBech32Address(address) {
22
+ const { words, prefix } = bech32.decode(address, BECH32_DECODE_LIMIT);
23
+ return { prefix, addressBytes: Buffer.from(bech32.fromWords(words)) };
24
+ }
11
25
  /**
12
26
  * Verify a CIP-30 COSE_Sign1 signature against an expected message and address.
13
27
  *
@@ -23,8 +37,7 @@ export function verifySignature(signature, message, signingAddress, signatureKey
23
37
  const signatureBytes = coseSign1.signature();
24
38
  const [, , , payload1] = cbor.decode(bufferToHex(coseSign1.signed_data().to_bytes()));
25
39
  const signaturePayloadAscii = bufferToAscii(payload1);
26
- const { words, prefix } = bech32.decode(signingAddress);
27
- const addressBytes = Buffer.from(bech32.fromWords(words));
40
+ const { prefix, addressBytes } = decodeBech32Address(signingAddress);
28
41
  const coseSigKey = cbor.decode(signatureKey);
29
42
  const cosePublicKey = coseSigKey.get(-2);
30
43
  const sigKey = CSL.PublicKey.from_bytes(cosePublicKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerna-labs/hydra-sdk",
3
- "version": "1.0.0-beta.25",
3
+ "version": "1.0.0-beta.26",
4
4
  "description": "TypeScript SDK for managing Cardano Hydra Heads — lifecycle, UTxO queries, wallet management, transaction submission, and signature verification",
5
5
  "keywords": [
6
6
  "cardano",