Skip to content

Commit 9b06f85

Browse files
committed
chore: update to latest nostr-crypto-utils
- Updated nostr-crypto-utils dependency - Added tsconfig.cjs.json for CommonJS builds - Removed jest.config.js as we've moved to vitest - Updated TypeScript configurations
1 parent 8af3e58 commit 9b06f85

File tree

8 files changed

+61
-59
lines changed

8 files changed

+61
-59
lines changed

jest.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

package-lock.json

Lines changed: 36 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
"exports": {
99
".": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js"
11+
"import": "./dist/index.js",
12+
"require": "./dist/cjs/index.js"
1213
}
1314
},
1415
"scripts": {
15-
"build": "tsc",
16+
"build": "tsc && tsc -p tsconfig.cjs.json",
1617
"test": "vitest run",
1718
"test:watch": "vitest",
1819
"test:coverage": "vitest run --coverage",
@@ -55,12 +56,13 @@
5556
},
5657
"homepage": "https://github.com/humanjavaenterprises/nostr-nsec-seedphrase#readme",
5758
"dependencies": {
58-
"@noble/hashes": "^1.3.3",
59+
"@noble/curves": "^1.3.0",
60+
"@noble/hashes": "^1.3.2",
5961
"@noble/secp256k1": "^2.1.0",
6062
"@scure/base": "^1.2.1",
6163
"bech32": "^2.0.0",
6264
"bip39": "^3.1.0",
63-
"nostr-crypto-utils": "^0.4.5",
65+
"nostr-crypto-utils": "file:../nostr-crypto-utils",
6466
"pino": "^8.17.2"
6567
},
6668
"devDependencies": {

src/nips/nip-19.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { logger } from '../utils/logger.js';
1111
import { npubEncode, nsecEncode, noteEncode, decode as nip19Decode } from 'nostr-crypto-utils';
12-
import type { Nip19Data } from 'nostr-crypto-utils';
12+
import type { Nip19DataType } from 'nostr-crypto-utils';
1313

1414
/**
1515
* Encodes a public key into npub format
@@ -75,11 +75,11 @@ export function hexToNote(hex: string): string {
7575
* const result = decode('npub1...');
7676
* returns { type: 'npub', data: '...' }
7777
*/
78-
export function decode(str: string): Nip19Data {
78+
export function decode(str: string): { type: Nip19DataType; data: string } {
7979
try {
8080
return nip19Decode(str);
8181
} catch (error) {
82-
logger.error({ error, str }, 'Failed to decode bech32-encoded string');
82+
logger.error({ error, str }, 'Failed to decode bech32 string');
8383
throw error;
8484
}
8585
}

src/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export type {
1515
PublicKeyDetails
1616
} from './keys.js';
1717

18-
// Import and re-export Nip19Data type from nostr-crypto-utils
19-
export type { Nip19Data } from 'nostr-crypto-utils';
18+
// Import and re-export NIP-19 type from nostr-crypto-utils
19+
export type { Nip19DataType } from 'nostr-crypto-utils';

src/utils/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type CustomLogger = Logger & {
2626
log: (obj: string | Record<string, unknown>, msg?: string) => void;
2727
};
2828

29-
// Create the logger instance with proper ESM/CJS compatibility
30-
const baseLogger = (pino.default || pino)(options) as Logger;
29+
// Create the logger instance
30+
const baseLogger = pino(options) as Logger;
3131

3232
// Create the custom logger instance
3333
const logger = baseLogger as CustomLogger;

tsconfig.cjs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"moduleResolution": "node",
6+
"outDir": "./dist/cjs"
7+
}
8+
}

tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"target": "ES2020",
4-
"module": "Node16",
5-
"moduleResolution": "Node16",
4+
"module": "ES2020",
5+
"moduleResolution": "bundler",
66
"declaration": true,
77
"declarationDir": "./dist",
88
"outDir": "./dist",
@@ -18,7 +18,8 @@
1818
"lib": ["es2020", "dom"],
1919
"types": ["vitest/globals", "node"],
2020
"allowJs": true,
21-
"resolveJsonModule": true
21+
"resolveJsonModule": true,
22+
"isolatedModules": true
2223
},
2324
"include": ["src/**/*"],
2425
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)