nostr-crypto-utils 0.4.14 → 0.4.15
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/package.json +10 -27
- package/dist/esm/__tests__/setup.d.ts +0 -6
- package/dist/esm/__tests__/setup.d.ts.map +0 -1
- package/dist/esm/constants.d.ts +0 -50
- package/dist/esm/constants.d.ts.map +0 -1
- package/dist/esm/core/constants.d.ts +0 -90
- package/dist/esm/core/constants.d.ts.map +0 -1
- package/dist/esm/core/errors.d.ts +0 -78
- package/dist/esm/core/errors.d.ts.map +0 -1
- package/dist/esm/core/index.d.ts +0 -8
- package/dist/esm/core/index.d.ts.map +0 -1
- package/dist/esm/core/types/crypto.d.ts +0 -46
- package/dist/esm/core/types/crypto.d.ts.map +0 -1
- package/dist/esm/core/types/events.d.ts +0 -59
- package/dist/esm/core/types/events.d.ts.map +0 -1
- package/dist/esm/core/types/index.d.ts +0 -8
- package/dist/esm/core/types/index.d.ts.map +0 -1
- package/dist/esm/core/types/protocol.d.ts +0 -73
- package/dist/esm/core/types/protocol.d.ts.map +0 -1
- package/dist/esm/crypto-utils.d.ts +0 -8
- package/dist/esm/crypto-utils.d.ts.map +0 -1
- package/dist/esm/crypto.d.ts +0 -106
- package/dist/esm/crypto.d.ts.map +0 -1
- package/dist/esm/encoding/base64.d.ts +0 -94
- package/dist/esm/encoding/base64.d.ts.map +0 -1
- package/dist/esm/encoding/binary.d.ts +0 -97
- package/dist/esm/encoding/binary.d.ts.map +0 -1
- package/dist/esm/encoding/hex.d.ts +0 -93
- package/dist/esm/encoding/hex.d.ts.map +0 -1
- package/dist/esm/encoding/index.d.ts +0 -23
- package/dist/esm/encoding/index.d.ts.map +0 -1
- package/dist/esm/event/creation.d.ts +0 -30
- package/dist/esm/event/creation.d.ts.map +0 -1
- package/dist/esm/event/index.d.ts +0 -7
- package/dist/esm/event/index.d.ts.map +0 -1
- package/dist/esm/event/signing.d.ts +0 -31
- package/dist/esm/event/signing.d.ts.map +0 -1
- package/dist/esm/index.d.ts +0 -15
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/integration/index.d.ts +0 -14
- package/dist/esm/integration/index.d.ts.map +0 -1
- package/dist/esm/nips/index.d.ts +0 -20
- package/dist/esm/nips/index.d.ts.map +0 -1
- package/dist/esm/nips/nip-01.d.ts +0 -56
- package/dist/esm/nips/nip-01.d.ts.map +0 -1
- package/dist/esm/nips/nip-04.d.ts +0 -42
- package/dist/esm/nips/nip-04.d.ts.map +0 -1
- package/dist/esm/nips/nip-19.d.ts +0 -77
- package/dist/esm/nips/nip-19.d.ts.map +0 -1
- package/dist/esm/nips/nip-26.d.ts +0 -51
- package/dist/esm/nips/nip-26.d.ts.map +0 -1
- package/dist/esm/protocol/constants.d.ts +0 -100
- package/dist/esm/protocol/constants.d.ts.map +0 -1
- package/dist/esm/protocol/index.d.ts +0 -124
- package/dist/esm/protocol/index.d.ts.map +0 -1
- package/dist/esm/protocol/transport.d.ts +0 -15
- package/dist/esm/protocol/transport.d.ts.map +0 -1
- package/dist/esm/transport/index.d.ts +0 -31
- package/dist/esm/transport/index.d.ts.map +0 -1
- package/dist/esm/types/base.d.ts +0 -124
- package/dist/esm/types/base.d.ts.map +0 -1
- package/dist/esm/types/guards.d.ts +0 -30
- package/dist/esm/types/guards.d.ts.map +0 -1
- package/dist/esm/types/index.d.ts +0 -75
- package/dist/esm/types/index.d.ts.map +0 -1
- package/dist/esm/types/messages.d.ts +0 -3
- package/dist/esm/types/messages.d.ts.map +0 -1
- package/dist/esm/types/protocol.d.ts +0 -7
- package/dist/esm/types/protocol.d.ts.map +0 -1
- package/dist/esm/utils/encoding.d.ts +0 -28
- package/dist/esm/utils/encoding.d.ts.map +0 -1
- package/dist/esm/utils/events.d.ts +0 -36
- package/dist/esm/utils/events.d.ts.map +0 -1
- package/dist/esm/utils/functions.d.ts +0 -40
- package/dist/esm/utils/functions.d.ts.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -9
- package/dist/esm/utils/index.d.ts.map +0 -1
- package/dist/esm/utils/integration.d.ts +0 -77
- package/dist/esm/utils/integration.d.ts.map +0 -1
- package/dist/esm/utils/logger.d.ts +0 -40
- package/dist/esm/utils/logger.d.ts.map +0 -1
- package/dist/esm/utils/validation.d.ts +0 -62
- package/dist/esm/utils/validation.d.ts.map +0 -1
- package/dist/esm/validation/index.d.ts +0 -111
- package/dist/esm/validation/index.d.ts.map +0 -1
- package/dist/esm/validation/keys.d.ts +0 -7
- package/dist/esm/validation/keys.d.ts.map +0 -1
- /package/dist/{cjs → types}/__tests__/setup.d.ts +0 -0
- /package/dist/{cjs → types}/__tests__/setup.d.ts.map +0 -0
- /package/dist/{cjs → types}/constants.d.ts +0 -0
- /package/dist/{cjs → types}/constants.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/constants.d.ts +0 -0
- /package/dist/{cjs → types}/core/constants.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/errors.d.ts +0 -0
- /package/dist/{cjs → types}/core/errors.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/index.d.ts +0 -0
- /package/dist/{cjs → types}/core/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/types/crypto.d.ts +0 -0
- /package/dist/{cjs → types}/core/types/crypto.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/types/events.d.ts +0 -0
- /package/dist/{cjs → types}/core/types/events.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/types/index.d.ts +0 -0
- /package/dist/{cjs → types}/core/types/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/core/types/protocol.d.ts +0 -0
- /package/dist/{cjs → types}/core/types/protocol.d.ts.map +0 -0
- /package/dist/{cjs → types}/crypto-utils.d.ts +0 -0
- /package/dist/{cjs → types}/crypto-utils.d.ts.map +0 -0
- /package/dist/{cjs → types}/crypto.d.ts +0 -0
- /package/dist/{cjs → types}/crypto.d.ts.map +0 -0
- /package/dist/{cjs → types}/encoding/base64.d.ts +0 -0
- /package/dist/{cjs → types}/encoding/base64.d.ts.map +0 -0
- /package/dist/{cjs → types}/encoding/binary.d.ts +0 -0
- /package/dist/{cjs → types}/encoding/binary.d.ts.map +0 -0
- /package/dist/{cjs → types}/encoding/hex.d.ts +0 -0
- /package/dist/{cjs → types}/encoding/hex.d.ts.map +0 -0
- /package/dist/{cjs → types}/encoding/index.d.ts +0 -0
- /package/dist/{cjs → types}/encoding/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/event/creation.d.ts +0 -0
- /package/dist/{cjs → types}/event/creation.d.ts.map +0 -0
- /package/dist/{cjs → types}/event/index.d.ts +0 -0
- /package/dist/{cjs → types}/event/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/event/signing.d.ts +0 -0
- /package/dist/{cjs → types}/event/signing.d.ts.map +0 -0
- /package/dist/{cjs → types}/index.d.ts +0 -0
- /package/dist/{cjs → types}/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/integration/index.d.ts +0 -0
- /package/dist/{cjs → types}/integration/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/nips/index.d.ts +0 -0
- /package/dist/{cjs → types}/nips/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/nips/nip-01.d.ts +0 -0
- /package/dist/{cjs → types}/nips/nip-01.d.ts.map +0 -0
- /package/dist/{cjs → types}/nips/nip-04.d.ts +0 -0
- /package/dist/{cjs → types}/nips/nip-04.d.ts.map +0 -0
- /package/dist/{cjs → types}/nips/nip-19.d.ts +0 -0
- /package/dist/{cjs → types}/nips/nip-19.d.ts.map +0 -0
- /package/dist/{cjs → types}/nips/nip-26.d.ts +0 -0
- /package/dist/{cjs → types}/nips/nip-26.d.ts.map +0 -0
- /package/dist/{cjs → types}/protocol/constants.d.ts +0 -0
- /package/dist/{cjs → types}/protocol/constants.d.ts.map +0 -0
- /package/dist/{cjs → types}/protocol/index.d.ts +0 -0
- /package/dist/{cjs → types}/protocol/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/protocol/transport.d.ts +0 -0
- /package/dist/{cjs → types}/protocol/transport.d.ts.map +0 -0
- /package/dist/{cjs → types}/transport/index.d.ts +0 -0
- /package/dist/{cjs → types}/transport/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/types/base.d.ts +0 -0
- /package/dist/{cjs → types}/types/base.d.ts.map +0 -0
- /package/dist/{cjs → types}/types/guards.d.ts +0 -0
- /package/dist/{cjs → types}/types/guards.d.ts.map +0 -0
- /package/dist/{cjs → types}/types/index.d.ts +0 -0
- /package/dist/{cjs → types}/types/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/types/messages.d.ts +0 -0
- /package/dist/{cjs → types}/types/messages.d.ts.map +0 -0
- /package/dist/{cjs → types}/types/protocol.d.ts +0 -0
- /package/dist/{cjs → types}/types/protocol.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/encoding.d.ts +0 -0
- /package/dist/{cjs → types}/utils/encoding.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/events.d.ts +0 -0
- /package/dist/{cjs → types}/utils/events.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/functions.d.ts +0 -0
- /package/dist/{cjs → types}/utils/functions.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/index.d.ts +0 -0
- /package/dist/{cjs → types}/utils/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/integration.d.ts +0 -0
- /package/dist/{cjs → types}/utils/integration.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/logger.d.ts +0 -0
- /package/dist/{cjs → types}/utils/logger.d.ts.map +0 -0
- /package/dist/{cjs → types}/utils/validation.d.ts +0 -0
- /package/dist/{cjs → types}/utils/validation.d.ts.map +0 -0
- /package/dist/{cjs → types}/validation/index.d.ts +0 -0
- /package/dist/{cjs → types}/validation/index.d.ts.map +0 -0
- /package/dist/{cjs → types}/validation/keys.d.ts +0 -0
- /package/dist/{cjs → types}/validation/keys.d.ts.map +0 -0
package/package.json
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-crypto-utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Core cryptographic utilities for Nostr protocol",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "commonjs",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
8
|
-
"types": "./dist/
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
11
12
|
"import": "./dist/esm/index.js",
|
|
12
13
|
"require": "./dist/cjs/index.js",
|
|
13
|
-
"
|
|
14
|
-
},
|
|
15
|
-
"./crypto": {
|
|
16
|
-
"import": "./dist/esm/crypto.js",
|
|
17
|
-
"require": "./dist/cjs/crypto.js",
|
|
18
|
-
"types": "./dist/esm/crypto.d.ts"
|
|
19
|
-
},
|
|
20
|
-
"./validation": {
|
|
21
|
-
"import": "./dist/esm/validation/index.js",
|
|
22
|
-
"require": "./dist/cjs/validation/index.js",
|
|
23
|
-
"types": "./dist/esm/validation/index.d.ts"
|
|
24
|
-
},
|
|
25
|
-
"./protocol": {
|
|
26
|
-
"import": "./dist/esm/protocol/index.js",
|
|
27
|
-
"require": "./dist/cjs/protocol/index.js",
|
|
28
|
-
"types": "./dist/esm/protocol/index.d.ts"
|
|
29
|
-
},
|
|
30
|
-
"./nips": {
|
|
31
|
-
"import": "./dist/esm/nips/index.js",
|
|
32
|
-
"require": "./dist/cjs/nips/index.js",
|
|
33
|
-
"types": "./dist/esm/nips/index.d.ts"
|
|
14
|
+
"default": "./dist/cjs/index.js"
|
|
34
15
|
}
|
|
35
16
|
},
|
|
36
17
|
"files": [
|
|
@@ -40,15 +21,17 @@
|
|
|
40
21
|
"LICENSE"
|
|
41
22
|
],
|
|
42
23
|
"scripts": {
|
|
43
|
-
"build": "npm run build:
|
|
44
|
-
"build:
|
|
24
|
+
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:browser",
|
|
25
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
26
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
27
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
45
28
|
"build:browser": "webpack --config webpack.config.cjs",
|
|
46
29
|
"test": "vitest run",
|
|
47
30
|
"test:watch": "vitest",
|
|
48
31
|
"test:coverage": "vitest run --coverage",
|
|
49
32
|
"lint": "eslint src --ext .ts",
|
|
50
33
|
"clean": "rimraf dist",
|
|
51
|
-
"prepare": "npm run
|
|
34
|
+
"prepare": "npm run build"
|
|
52
35
|
},
|
|
53
36
|
"keywords": [
|
|
54
37
|
"nostr",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/esm/constants.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants used throughout the library
|
|
3
|
-
*/
|
|
4
|
-
export declare const NOSTR_MESSAGE_TYPE: {
|
|
5
|
-
readonly EVENT: "EVENT";
|
|
6
|
-
readonly REQ: "REQ";
|
|
7
|
-
readonly CLOSE: "CLOSE";
|
|
8
|
-
readonly NOTICE: "NOTICE";
|
|
9
|
-
readonly EOSE: "EOSE";
|
|
10
|
-
readonly OK: "OK";
|
|
11
|
-
readonly AUTH: "AUTH";
|
|
12
|
-
readonly ERROR: "ERROR";
|
|
13
|
-
};
|
|
14
|
-
export declare const NOSTR_EVENT_KIND: {
|
|
15
|
-
readonly SET_METADATA: 0;
|
|
16
|
-
readonly TEXT_NOTE: 1;
|
|
17
|
-
readonly RECOMMEND_SERVER: 2;
|
|
18
|
-
readonly CONTACT_LIST: 3;
|
|
19
|
-
readonly ENCRYPTED_DIRECT_MESSAGE: 4;
|
|
20
|
-
readonly DELETE: 5;
|
|
21
|
-
readonly REPOST: 6;
|
|
22
|
-
readonly REACTION: 7;
|
|
23
|
-
readonly BADGE_AWARD: 8;
|
|
24
|
-
readonly CHANNEL_CREATE: 40;
|
|
25
|
-
readonly CHANNEL_METADATA: 41;
|
|
26
|
-
readonly CHANNEL_MESSAGE: 42;
|
|
27
|
-
readonly CHANNEL_HIDE_MESSAGE: 43;
|
|
28
|
-
readonly CHANNEL_MUTE_USER: 44;
|
|
29
|
-
readonly CHANNEL_RESERVED_FIRST: 40;
|
|
30
|
-
readonly CHANNEL_RESERVED_LAST: 49;
|
|
31
|
-
readonly REPORTING: 1984;
|
|
32
|
-
readonly ZAP_REQUEST: 9734;
|
|
33
|
-
readonly ZAP: 9735;
|
|
34
|
-
readonly MUTE_LIST: 10000;
|
|
35
|
-
readonly PIN_LIST: 10001;
|
|
36
|
-
readonly RELAY_LIST_METADATA: 10002;
|
|
37
|
-
readonly CLIENT_AUTH: 22242;
|
|
38
|
-
readonly CLIENT_ERROR: 23;
|
|
39
|
-
readonly PARAMETERIZED_REPLACEABLE_FIRST: 30000;
|
|
40
|
-
readonly PARAMETERIZED_REPLACEABLE_LAST: 39999;
|
|
41
|
-
readonly REPLACEABLE_FIRST: 10000;
|
|
42
|
-
readonly REPLACEABLE_LAST: 19999;
|
|
43
|
-
readonly EPHEMERAL_FIRST: 20000;
|
|
44
|
-
readonly EPHEMERAL_LAST: 29999;
|
|
45
|
-
readonly REGULAR_FIRST: 1000;
|
|
46
|
-
readonly REGULAR_LAST: 9999;
|
|
47
|
-
readonly CUSTOM_FIRST: 40000;
|
|
48
|
-
readonly CUSTOM_LAST: 49999;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;CASrB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCnB,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core constants used throughout the library
|
|
3
|
-
* @module core/constants
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Nostr event kinds as defined in NIPs
|
|
7
|
-
*/
|
|
8
|
-
export declare const NostrEventKind: {
|
|
9
|
-
readonly SET_METADATA: 0;
|
|
10
|
-
readonly TEXT_NOTE: 1;
|
|
11
|
-
readonly RECOMMEND_RELAY: 2;
|
|
12
|
-
readonly CONTACTS: 3;
|
|
13
|
-
readonly ENCRYPTED_DIRECT_MESSAGE: 4;
|
|
14
|
-
readonly DELETE: 5;
|
|
15
|
-
readonly REPOST: 6;
|
|
16
|
-
readonly REACTION: 7;
|
|
17
|
-
readonly BADGE_AWARD: 8;
|
|
18
|
-
readonly CHANNEL_CREATE: 40;
|
|
19
|
-
readonly CHANNEL_METADATA: 41;
|
|
20
|
-
readonly CHANNEL_MESSAGE: 42;
|
|
21
|
-
readonly CHANNEL_HIDE_MESSAGE: 43;
|
|
22
|
-
readonly CHANNEL_MUTE_USER: 44;
|
|
23
|
-
readonly LONG_FORM_CONTENT: 30023;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Nostr relay message types
|
|
27
|
-
*/
|
|
28
|
-
export declare const NostrMessageType: {
|
|
29
|
-
readonly EVENT: "EVENT";
|
|
30
|
-
readonly REQ: "REQ";
|
|
31
|
-
readonly CLOSE: "CLOSE";
|
|
32
|
-
readonly NOTICE: "NOTICE";
|
|
33
|
-
readonly EOSE: "EOSE";
|
|
34
|
-
readonly OK: "OK";
|
|
35
|
-
readonly AUTH: "AUTH";
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Validation constants
|
|
39
|
-
*/
|
|
40
|
-
export declare const Validation: {
|
|
41
|
-
readonly MAX_EVENT_TAGS: 2000;
|
|
42
|
-
readonly MAX_CONTENT_LENGTH: 64000;
|
|
43
|
-
readonly MIN_POW_DIFFICULTY: 0;
|
|
44
|
-
readonly MAX_TIMESTAMP_DRIFT: number;
|
|
45
|
-
readonly MAX_EXPONENTIAL_BACKOFF: number;
|
|
46
|
-
readonly DEFAULT_TIMEOUT: 5000;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Core cryptographic constants
|
|
50
|
-
*/
|
|
51
|
-
export declare const Crypto: {
|
|
52
|
-
readonly PRIVATE_KEY_LENGTH: 32;
|
|
53
|
-
readonly PUBLIC_KEY_LENGTH: 32;
|
|
54
|
-
readonly SIGNATURE_LENGTH: 64;
|
|
55
|
-
readonly HASH_LENGTH: 32;
|
|
56
|
-
readonly SHARED_SECRET_LENGTH: 32;
|
|
57
|
-
readonly IV_LENGTH: 16;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Core encoding constants
|
|
61
|
-
*/
|
|
62
|
-
export declare const Encoding: {
|
|
63
|
-
readonly HEX_PREFIX: "0x";
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Protocol constants
|
|
67
|
-
*/
|
|
68
|
-
export declare const Protocol: {
|
|
69
|
-
readonly DEFAULT_RELAY_URL: "wss://relay.nostr.info";
|
|
70
|
-
readonly RECONNECT_DELAY: 1000;
|
|
71
|
-
readonly MAX_RECONNECT_DELAY: 30000;
|
|
72
|
-
readonly PING_INTERVAL: 30000;
|
|
73
|
-
readonly SUBSCRIPTION_TIMEOUT: 10000;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Default values
|
|
77
|
-
*/
|
|
78
|
-
export declare const Defaults: {
|
|
79
|
-
readonly KIND: 1;
|
|
80
|
-
readonly CREATED_AT: () => number;
|
|
81
|
-
readonly TAGS: string[][];
|
|
82
|
-
readonly CONTENT: "";
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Regular expressions for validation
|
|
86
|
-
*/
|
|
87
|
-
export declare const Regex: {
|
|
88
|
-
readonly HEX: RegExp;
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAgBjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;CAQnB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;CAOb,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;;CAEX,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;CAMX,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;;;mBAGP,MAAM,EAAE,EAAE;;CAEd,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,KAAK;;CAER,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core error types and error handling utilities
|
|
3
|
-
* @module core/errors
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Base error class for all Nostr-related errors
|
|
7
|
-
*/
|
|
8
|
-
export declare class NostrError extends Error {
|
|
9
|
-
code: string;
|
|
10
|
-
constructor(message: string, code: string);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Error thrown when cryptographic operations fail
|
|
14
|
-
*/
|
|
15
|
-
export declare class CryptoError extends NostrError {
|
|
16
|
-
constructor(message: string, code?: string);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Error thrown when validation fails
|
|
20
|
-
*/
|
|
21
|
-
export declare class ValidationError extends NostrError {
|
|
22
|
-
constructor(message: string, code?: string);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Error thrown when encoding/decoding fails
|
|
26
|
-
*/
|
|
27
|
-
export declare class EncodingError extends NostrError {
|
|
28
|
-
constructor(message: string, code?: string);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Error thrown when protocol-related operations fail
|
|
32
|
-
*/
|
|
33
|
-
export declare class ProtocolError extends NostrError {
|
|
34
|
-
constructor(message: string, code?: string);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Error thrown when event-related operations fail
|
|
38
|
-
*/
|
|
39
|
-
export declare class EventError extends NostrError {
|
|
40
|
-
constructor(message: string, code?: string);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Error codes for different types of errors
|
|
44
|
-
*/
|
|
45
|
-
export declare const ErrorCodes: {
|
|
46
|
-
readonly INVALID_KEY: "INVALID_KEY";
|
|
47
|
-
readonly SIGNING_FAILED: "SIGNING_FAILED";
|
|
48
|
-
readonly VERIFICATION_FAILED: "VERIFICATION_FAILED";
|
|
49
|
-
readonly ENCRYPTION_FAILED: "ENCRYPTION_FAILED";
|
|
50
|
-
readonly DECRYPTION_FAILED: "DECRYPTION_FAILED";
|
|
51
|
-
readonly INVALID_EVENT: "INVALID_EVENT";
|
|
52
|
-
readonly INVALID_SIGNATURE: "INVALID_SIGNATURE";
|
|
53
|
-
readonly INVALID_FILTER: "INVALID_FILTER";
|
|
54
|
-
readonly INVALID_SUBSCRIPTION: "INVALID_SUBSCRIPTION";
|
|
55
|
-
readonly INVALID_HEX: "INVALID_HEX";
|
|
56
|
-
readonly INVALID_BASE64: "INVALID_BASE64";
|
|
57
|
-
readonly INVALID_BECH32: "INVALID_BECH32";
|
|
58
|
-
readonly ENCODING_FAILED: "ENCODING_FAILED";
|
|
59
|
-
readonly RELAY_ERROR: "RELAY_ERROR";
|
|
60
|
-
readonly CONNECTION_ERROR: "CONNECTION_ERROR";
|
|
61
|
-
readonly SUBSCRIPTION_ERROR: "SUBSCRIPTION_ERROR";
|
|
62
|
-
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
63
|
-
readonly EVENT_CREATION_FAILED: "EVENT_CREATION_FAILED";
|
|
64
|
-
readonly EVENT_VALIDATION_FAILED: "EVENT_VALIDATION_FAILED";
|
|
65
|
-
readonly EVENT_SERIALIZATION_FAILED: "EVENT_SERIALIZATION_FAILED";
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Type for error codes
|
|
69
|
-
*/
|
|
70
|
-
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
71
|
-
/**
|
|
72
|
-
* Create an error with the appropriate type based on the error code
|
|
73
|
-
* @param message Error message
|
|
74
|
-
* @param code Error code
|
|
75
|
-
* @returns Appropriate error instance
|
|
76
|
-
*/
|
|
77
|
-
export declare function createError(message: string, code: ErrorCode): NostrError;
|
|
78
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACC,IAAI,EAAE,MAAM;gBAApC,OAAO,EAAE,MAAM,EAAS,IAAI,EAAE,MAAM;CAIjD;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,SAAiB;CAInD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAqB;CAIvD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,SAAmB;CAIrD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,SAAmB;CAIrD;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;gBAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,SAAgB;CAIlD;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CA8Bb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAmCxE"}
|
package/dist/esm/core/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core cryptographic types
|
|
3
|
-
* @module core/types/crypto
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Public key formats supported in core crypto operations
|
|
7
|
-
*/
|
|
8
|
-
export type PublicKey = string | {
|
|
9
|
-
type: 'hex';
|
|
10
|
-
data: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Private key formats supported in core crypto operations
|
|
14
|
-
*/
|
|
15
|
-
export type PrivateKey = string | {
|
|
16
|
-
type: 'hex';
|
|
17
|
-
data: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Basic encryption options
|
|
21
|
-
*/
|
|
22
|
-
export interface EncryptionOptions {
|
|
23
|
-
iv?: Buffer;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Basic key pair structure
|
|
27
|
-
*/
|
|
28
|
-
export interface KeyPair {
|
|
29
|
-
privateKey: string;
|
|
30
|
-
publicKey: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Signature verification result
|
|
34
|
-
*/
|
|
35
|
-
export interface SignatureVerification {
|
|
36
|
-
valid: boolean;
|
|
37
|
-
reason?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Basic encryption result
|
|
41
|
-
*/
|
|
42
|
-
export interface EncryptionResult {
|
|
43
|
-
ciphertext: string;
|
|
44
|
-
iv: string;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../../src/core/types/crypto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAChC,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core event types for Nostr
|
|
3
|
-
* @module core/types/events
|
|
4
|
-
*/
|
|
5
|
-
import { NostrEventKind, NostrMessageType } from '../constants';
|
|
6
|
-
/**
|
|
7
|
-
* Basic Nostr event structure
|
|
8
|
-
*/
|
|
9
|
-
export interface NostrEvent {
|
|
10
|
-
id?: string;
|
|
11
|
-
pubkey?: string;
|
|
12
|
-
created_at: number;
|
|
13
|
-
kind: number;
|
|
14
|
-
tags: string[][];
|
|
15
|
-
content: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Signed Nostr event with id, pubkey, and sig
|
|
19
|
-
*/
|
|
20
|
-
export interface SignedNostrEvent extends NostrEvent {
|
|
21
|
-
id: string;
|
|
22
|
-
pubkey: string;
|
|
23
|
-
sig: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Event kinds type
|
|
27
|
-
*/
|
|
28
|
-
export type EventKind = typeof NostrEventKind[keyof typeof NostrEventKind];
|
|
29
|
-
/**
|
|
30
|
-
* Message types for relay communication
|
|
31
|
-
*/
|
|
32
|
-
export type MessageType = typeof NostrMessageType[keyof typeof NostrMessageType];
|
|
33
|
-
/**
|
|
34
|
-
* Event creation options
|
|
35
|
-
*/
|
|
36
|
-
export interface EventOptions {
|
|
37
|
-
kind?: EventKind;
|
|
38
|
-
tags?: string[][];
|
|
39
|
-
content?: string;
|
|
40
|
-
created_at?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Event verification result
|
|
44
|
-
*/
|
|
45
|
-
export interface EventVerification {
|
|
46
|
-
valid: boolean;
|
|
47
|
-
reason?: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Event with optional fields for creation
|
|
51
|
-
*/
|
|
52
|
-
export type PartialEvent = Partial<NostrEvent>;
|
|
53
|
-
/**
|
|
54
|
-
* Event with required fields for signing
|
|
55
|
-
*/
|
|
56
|
-
export type UnsignedEvent = Omit<NostrEvent, 'id' | 'sig' | 'pubkey'> & {
|
|
57
|
-
pubkey: string;
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/core/types/events.ts"],"names":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
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core protocol types for Nostr
|
|
3
|
-
* @module core/types/protocol
|
|
4
|
-
*/
|
|
5
|
-
import { NostrEvent, SignedNostrEvent } from './events';
|
|
6
|
-
/**
|
|
7
|
-
* Filter for querying events
|
|
8
|
-
*/
|
|
9
|
-
export interface NostrFilter {
|
|
10
|
-
ids?: string[];
|
|
11
|
-
authors?: string[];
|
|
12
|
-
kinds?: number[];
|
|
13
|
-
'#e'?: string[];
|
|
14
|
-
'#p'?: string[];
|
|
15
|
-
since?: number;
|
|
16
|
-
until?: number;
|
|
17
|
-
limit?: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Subscription to events
|
|
21
|
-
*/
|
|
22
|
-
export interface NostrSubscription {
|
|
23
|
-
id: string;
|
|
24
|
-
filters: NostrFilter[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Relay information
|
|
28
|
-
*/
|
|
29
|
-
export interface RelayInfo {
|
|
30
|
-
url: string;
|
|
31
|
-
status: 'connected' | 'connecting' | 'disconnected';
|
|
32
|
-
supported_nips?: number[];
|
|
33
|
-
software?: string;
|
|
34
|
-
version?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Message from relay
|
|
38
|
-
*/
|
|
39
|
-
export type RelayMessage = ['EVENT', string, NostrEvent] | ['NOTICE', string] | ['EOSE', string] | ['OK', string, boolean, string] | ['AUTH', string];
|
|
40
|
-
/**
|
|
41
|
-
* Message to relay
|
|
42
|
-
*/
|
|
43
|
-
export type ClientMessage = ['EVENT', NostrEvent] | ['REQ', string, ...NostrFilter[]] | ['CLOSE', string] | ['AUTH', string];
|
|
44
|
-
/**
|
|
45
|
-
* Relay event handler
|
|
46
|
-
*/
|
|
47
|
-
export interface RelayEventHandlers {
|
|
48
|
-
onEvent?: (event: SignedNostrEvent) => void;
|
|
49
|
-
onEose?: (subscriptionId: string) => void;
|
|
50
|
-
onNotice?: (message: string) => void;
|
|
51
|
-
onOk?: (eventId: string, accepted: boolean, message: string) => void;
|
|
52
|
-
onAuth?: (challenge: string) => void;
|
|
53
|
-
onError?: (error: Error) => void;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Relay connection options
|
|
57
|
-
*/
|
|
58
|
-
export interface RelayOptions {
|
|
59
|
-
reconnect?: boolean;
|
|
60
|
-
maxReconnectAttempts?: number;
|
|
61
|
-
reconnectDelay?: number;
|
|
62
|
-
timeout?: number;
|
|
63
|
-
skipVerification?: boolean;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Subscription options
|
|
67
|
-
*/
|
|
68
|
-
export interface SubscriptionOptions {
|
|
69
|
-
oneShot?: boolean;
|
|
70
|
-
timeout?: number;
|
|
71
|
-
skipVerification?: boolean;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/core/types/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IAC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AAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module crypto-utils
|
|
3
|
-
* @description Cryptographic utilities for Nostr
|
|
4
|
-
*/
|
|
5
|
-
import { encryptMessage, decryptMessage } from './nips/nip-04';
|
|
6
|
-
import { customCrypto, signSchnorr, verifySchnorrSignature, generateKeyPair, getPublicKey, validateKeyPair, getCompressedPublicKey, getSchnorrPublicKey, createEvent, signEvent, verifySignature } from './crypto';
|
|
7
|
-
export { customCrypto, signSchnorr, verifySchnorrSignature, generateKeyPair, getPublicKey, validateKeyPair, getCompressedPublicKey, getSchnorrPublicKey, createEvent, signEvent, verifySignature, encryptMessage, decryptMessage };
|
|
8
|
-
//# sourceMappingURL=crypto-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-utils.d.ts","sourceRoot":"","sources":["../../src/crypto-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,YAAY,EACZ,WAAW,EACX,sBAAsB,EAGtB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EAGnB,WAAW,EACX,SAAS,EACT,eAAe,EAGf,cAAc,EACd,cAAc,EACf,CAAC"}
|
package/dist/esm/crypto.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module crypto
|
|
3
|
-
* @description Cryptographic utilities for Nostr
|
|
4
|
-
*
|
|
5
|
-
* IMPORTANT: Nostr Protocol Cryptographic Requirements
|
|
6
|
-
* While secp256k1 is the underlying elliptic curve used by Nostr, the protocol specifically
|
|
7
|
-
* requires schnorr signatures as defined in NIP-01. This means:
|
|
8
|
-
*
|
|
9
|
-
* 1. Always use schnorr-specific functions:
|
|
10
|
-
* - schnorr.getPublicKey() for public key generation
|
|
11
|
-
* - schnorr.sign() for signing
|
|
12
|
-
* - schnorr.verify() for verification
|
|
13
|
-
*
|
|
14
|
-
* 2. Avoid using secp256k1 functions directly:
|
|
15
|
-
* - DON'T use secp256k1.getPublicKey()
|
|
16
|
-
* - DON'T use secp256k1.sign()
|
|
17
|
-
* - DON'T use secp256k1.verify()
|
|
18
|
-
*
|
|
19
|
-
* While both might work in some cases (as they use the same curve), the schnorr signature
|
|
20
|
-
* scheme has specific requirements for key and signature formats that aren't guaranteed
|
|
21
|
-
* when using the lower-level secp256k1 functions directly.
|
|
22
|
-
*/
|
|
23
|
-
import { KeyPair, PublicKeyDetails, NostrEvent, SignedNostrEvent, PublicKey } from './types/index';
|
|
24
|
-
/**
|
|
25
|
-
* Custom crypto interface for cross-platform compatibility
|
|
26
|
-
*/
|
|
27
|
-
export interface CryptoSubtle {
|
|
28
|
-
subtle: {
|
|
29
|
-
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKeyPair>;
|
|
30
|
-
importKey(format: 'raw' | 'pkcs8' | 'spki', keyData: ArrayBuffer, algorithm: RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
|
|
31
|
-
encrypt(algorithm: {
|
|
32
|
-
name: string;
|
|
33
|
-
iv: Uint8Array;
|
|
34
|
-
}, key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
35
|
-
decrypt(algorithm: {
|
|
36
|
-
name: string;
|
|
37
|
-
iv: Uint8Array;
|
|
38
|
-
}, key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
39
|
-
};
|
|
40
|
-
getRandomValues<T extends Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array>(array: T): T;
|
|
41
|
-
}
|
|
42
|
-
declare global {
|
|
43
|
-
interface Window {
|
|
44
|
-
crypto: CryptoSubtle;
|
|
45
|
-
}
|
|
46
|
-
interface Global {
|
|
47
|
-
crypto: CryptoSubtle;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Crypto implementation that works in both Node.js and browser environments
|
|
52
|
-
*/
|
|
53
|
-
declare class CustomCrypto {
|
|
54
|
-
private cryptoInstance;
|
|
55
|
-
private initPromise;
|
|
56
|
-
constructor();
|
|
57
|
-
private initialize;
|
|
58
|
-
private ensureInitialized;
|
|
59
|
-
getSubtle(): Promise<CryptoSubtle['subtle']>;
|
|
60
|
-
getRandomValues<T extends Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array>(array: T): Promise<T>;
|
|
61
|
-
}
|
|
62
|
-
export declare const customCrypto: CustomCrypto;
|
|
63
|
-
export declare const signSchnorr: (message: import("@noble/curves/abstract/utils").Hex, privateKey: import("@noble/curves/abstract/utils").PrivKey, auxRand?: import("@noble/curves/abstract/utils").Hex) => Uint8Array;
|
|
64
|
-
export declare const verifySchnorrSignature: (signature: import("@noble/curves/abstract/utils").Hex, message: import("@noble/curves/abstract/utils").Hex, publicKey: import("@noble/curves/abstract/utils").Hex) => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Gets the compressed public key (33 bytes with prefix)
|
|
67
|
-
*/
|
|
68
|
-
export declare function getCompressedPublicKey(privateKeyBytes: Uint8Array): Uint8Array;
|
|
69
|
-
/**
|
|
70
|
-
* Gets the schnorr public key (32 bytes x-coordinate) as per BIP340
|
|
71
|
-
*/
|
|
72
|
-
export declare function getSchnorrPublicKey(privateKeyBytes: Uint8Array): Uint8Array;
|
|
73
|
-
/**
|
|
74
|
-
* Generates a new key pair
|
|
75
|
-
*/
|
|
76
|
-
export declare function generateKeyPair(): Promise<KeyPair>;
|
|
77
|
-
/**
|
|
78
|
-
* Gets a public key from a private key
|
|
79
|
-
*/
|
|
80
|
-
export declare function getPublicKey(privateKey: string): Promise<PublicKeyDetails>;
|
|
81
|
-
/**
|
|
82
|
-
* Validates a key pair
|
|
83
|
-
*/
|
|
84
|
-
export declare function validateKeyPair(keyPair: KeyPair): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a new event
|
|
87
|
-
*/
|
|
88
|
-
export declare function createEvent(event: Partial<NostrEvent>): NostrEvent;
|
|
89
|
-
/**
|
|
90
|
-
* Signs an event
|
|
91
|
-
*/
|
|
92
|
-
export declare function signEvent(event: NostrEvent, privateKey: string): Promise<SignedNostrEvent>;
|
|
93
|
-
/**
|
|
94
|
-
* Verifies an event signature
|
|
95
|
-
*/
|
|
96
|
-
export declare function verifySignature(event: SignedNostrEvent): Promise<boolean>;
|
|
97
|
-
/**
|
|
98
|
-
* Encrypts a message using NIP-04
|
|
99
|
-
*/
|
|
100
|
-
export declare function encrypt(message: string, recipientPubKey: PublicKey | string, senderPrivKey: string): Promise<string>;
|
|
101
|
-
/**
|
|
102
|
-
* Decrypts a message using NIP-04
|
|
103
|
-
*/
|
|
104
|
-
export declare function decrypt(encryptedMessage: string, senderPubKey: PublicKey | string, recipientPrivKey: string): Promise<string>;
|
|
105
|
-
export {};
|
|
106
|
-
//# sourceMappingURL=crypto.d.ts.map
|
package/dist/esm/crypto.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAInG;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,WAAW,CACT,SAAS,EAAE,qBAAqB,GAAG,cAAc,EACjD,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,SAAS,QAAQ,EAAE,GAC7B,OAAO,CAAC,aAAa,CAAC,CAAC;QAC1B,SAAS,CACP,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,EAChC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,qBAAqB,GAAG,iBAAiB,GAAG,eAAe,EACtE,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,SAAS,QAAQ,EAAE,GAC7B,OAAO,CAAC,SAAS,CAAC,CAAC;QACtB,OAAO,CACL,SAAS,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,UAAU,CAAA;SAAE,EAC3C,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,WAAW,CAAC,CAAC;QACxB,OAAO,CACL,SAAS,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,UAAU,CAAA;SAAE,EAC3C,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,WAAW,CAAC,CAAC;KACzB,CAAC;IACF,eAAe,CAAC,CAAC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