@onekeyfe/hd-core 0.3.32 → 0.3.34-alpha.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.
Files changed (50) hide show
  1. package/dist/api/index.d.ts +4 -0
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/api/nostr/NostrDecryptMessage.d.ts +21 -0
  4. package/dist/api/nostr/NostrDecryptMessage.d.ts.map +1 -0
  5. package/dist/api/nostr/NostrEncryptMessage.d.ts +21 -0
  6. package/dist/api/nostr/NostrEncryptMessage.d.ts.map +1 -0
  7. package/dist/api/nostr/NostrGetPublicKey.d.ts +17 -0
  8. package/dist/api/nostr/NostrGetPublicKey.d.ts.map +1 -0
  9. package/dist/api/nostr/NostrSignEvent.d.ts +20 -0
  10. package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -0
  11. package/dist/api/nostr/helper/index.d.ts +4 -0
  12. package/dist/api/nostr/helper/index.d.ts.map +1 -0
  13. package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
  14. package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
  15. package/dist/api/polkadot/PolkadotSignTransaction.d.ts +1 -8
  16. package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
  17. package/dist/api/polkadot/networks.d.ts +19 -0
  18. package/dist/api/polkadot/networks.d.ts.map +1 -0
  19. package/dist/index.d.ts +88 -1
  20. package/dist/index.js +382 -17
  21. package/dist/inject.d.ts.map +1 -1
  22. package/dist/types/api/index.d.ts +8 -0
  23. package/dist/types/api/index.d.ts.map +1 -1
  24. package/dist/types/api/nostrDecryptMessage.d.ts +17 -0
  25. package/dist/types/api/nostrDecryptMessage.d.ts.map +1 -0
  26. package/dist/types/api/nostrEncryptMessage.d.ts +17 -0
  27. package/dist/types/api/nostrEncryptMessage.d.ts.map +1 -0
  28. package/dist/types/api/nostrGetPublicKey.d.ts +15 -0
  29. package/dist/types/api/nostrGetPublicKey.d.ts.map +1 -0
  30. package/dist/types/api/nostrSignEvent.d.ts +44 -0
  31. package/dist/types/api/nostrSignEvent.d.ts.map +1 -0
  32. package/dist/utils/patch.d.ts +1 -1
  33. package/dist/utils/patch.d.ts.map +1 -1
  34. package/package.json +4 -4
  35. package/src/api/index.ts +5 -0
  36. package/src/api/nostr/NostrDecryptMessage.ts +54 -0
  37. package/src/api/nostr/NostrEncryptMessage.ts +54 -0
  38. package/src/api/nostr/NostrGetPublicKey.ts +71 -0
  39. package/src/api/nostr/NostrSignEvent.ts +63 -0
  40. package/src/api/nostr/helper/index.ts +28 -0
  41. package/src/api/polkadot/PolkadotGetAddress.ts +3 -8
  42. package/src/api/polkadot/PolkadotSignTransaction.ts +2 -8
  43. package/src/api/polkadot/networks.ts +44 -0
  44. package/src/data/messages/messages.json +124 -0
  45. package/src/inject.ts +9 -0
  46. package/src/types/api/index.ts +13 -0
  47. package/src/types/api/nostrDecryptMessage.ts +24 -0
  48. package/src/types/api/nostrEncryptMessage.ts +24 -0
  49. package/src/types/api/nostrGetPublicKey.ts +24 -0
  50. package/src/types/api/nostrSignEvent.ts +52 -0
@@ -0,0 +1,44 @@
1
+ import type { DeviceFirmwareRange } from '../../types';
2
+
3
+ // 100% sure which networks are supported
4
+ enum Networks {
5
+ Polkadot = 'polkadot',
6
+ Westend = 'westend',
7
+ Kusama = 'kusama',
8
+ Astar = 'astar',
9
+ JoyStream = 'joystream',
10
+ }
11
+
12
+ // All polkadot networks are included in no special case
13
+ const baseVersionRange = {
14
+ model_mini: {
15
+ min: '3.0.0',
16
+ },
17
+ model_touch: {
18
+ min: '4.3.0',
19
+ },
20
+ };
21
+
22
+ const specialVersionRange: Record<string, DeviceFirmwareRange> = {
23
+ [Networks.JoyStream]: {
24
+ model_mini: {
25
+ min: '3.6.0',
26
+ },
27
+ model_touch: {
28
+ min: '4.7.0',
29
+ },
30
+ },
31
+ };
32
+
33
+ export default Networks;
34
+
35
+ export function getPolkadotVersionRange(network: string) {
36
+ return specialVersionRange[network] ?? baseVersionRange;
37
+ }
38
+
39
+ export function getPolkadotVersionRangeWithBundle(networks: string[]) {
40
+ if (networks.includes(Networks.JoyStream)) {
41
+ return specialVersionRange[Networks.JoyStream];
42
+ }
43
+ return baseVersionRange;
44
+ }
@@ -8081,6 +8081,122 @@
8081
8081
  }
8082
8082
  }
8083
8083
  },
8084
+ "NostrGetPublicKey": {
8085
+ "fields": {
8086
+ "address_n": {
8087
+ "rule": "repeated",
8088
+ "type": "uint32",
8089
+ "id": 1,
8090
+ "options": {
8091
+ "packed": false
8092
+ }
8093
+ },
8094
+ "show_display": {
8095
+ "type": "bool",
8096
+ "id": 2
8097
+ }
8098
+ }
8099
+ },
8100
+ "NostrPublicKey": {
8101
+ "fields": {
8102
+ "publickey": {
8103
+ "type": "string",
8104
+ "id": 1
8105
+ },
8106
+ "npub": {
8107
+ "type": "string",
8108
+ "id": 2
8109
+ }
8110
+ }
8111
+ },
8112
+ "NostrSignEvent": {
8113
+ "fields": {
8114
+ "address_n": {
8115
+ "rule": "repeated",
8116
+ "type": "uint32",
8117
+ "id": 1,
8118
+ "options": {
8119
+ "packed": false
8120
+ }
8121
+ },
8122
+ "event": {
8123
+ "rule": "required",
8124
+ "type": "bytes",
8125
+ "id": 2
8126
+ }
8127
+ }
8128
+ },
8129
+ "NostrSignedEvent": {
8130
+ "fields": {
8131
+ "event": {
8132
+ "rule": "required",
8133
+ "type": "bytes",
8134
+ "id": 1
8135
+ }
8136
+ }
8137
+ },
8138
+ "NostrEncryptMessage": {
8139
+ "fields": {
8140
+ "address_n": {
8141
+ "rule": "repeated",
8142
+ "type": "uint32",
8143
+ "id": 1,
8144
+ "options": {
8145
+ "packed": false
8146
+ }
8147
+ },
8148
+ "pubkey": {
8149
+ "rule": "required",
8150
+ "type": "string",
8151
+ "id": 2
8152
+ },
8153
+ "msg": {
8154
+ "rule": "required",
8155
+ "type": "string",
8156
+ "id": 3
8157
+ }
8158
+ }
8159
+ },
8160
+ "NostrEncryptedMessage": {
8161
+ "fields": {
8162
+ "msg": {
8163
+ "rule": "required",
8164
+ "type": "string",
8165
+ "id": 1
8166
+ }
8167
+ }
8168
+ },
8169
+ "NostrDecryptMessage": {
8170
+ "fields": {
8171
+ "address_n": {
8172
+ "rule": "repeated",
8173
+ "type": "uint32",
8174
+ "id": 1,
8175
+ "options": {
8176
+ "packed": false
8177
+ }
8178
+ },
8179
+ "pubkey": {
8180
+ "rule": "required",
8181
+ "type": "string",
8182
+ "id": 2
8183
+ },
8184
+ "msg": {
8185
+ "rule": "required",
8186
+ "type": "string",
8187
+ "id": 3
8188
+ }
8189
+ }
8190
+ },
8191
+ "NostrDecryptedMessage": {
8192
+ "fields": {
8193
+ "msg": {
8194
+ "rule": "required",
8195
+ "type": "string",
8196
+ "id": 1
8197
+ }
8198
+ }
8199
+ },
8084
8200
  "PolkadotGetAddress": {
8085
8201
  "fields": {
8086
8202
  "address_n": {
@@ -10215,6 +10331,14 @@
10215
10331
  "MessageType_NexaSignedTx": 11403,
10216
10332
  "MessageType_NexaTxInputRequest": 11404,
10217
10333
  "MessageType_NexaTxInputAck": 11405,
10334
+ "MessageType_NostrGetPublicKey": 11500,
10335
+ "MessageType_NostrPublicKey": 11501,
10336
+ "MessageType_NostrSignEvent": 11502,
10337
+ "MessageType_NostrSignedEvent": 11503,
10338
+ "MessageType_NostrEncryptMessage": 11504,
10339
+ "MessageType_NostrEncryptedMessage": 11505,
10340
+ "MessageType_NostrDecryptMessage": 11506,
10341
+ "MessageType_NostrDecryptedMessage": 11507,
10218
10342
  "MessageType_DeviceBackToBoot": 903,
10219
10343
  "MessageType_DeviceInfoSettings": 10001,
10220
10344
  "MessageType_GetDeviceInfo": 10002,
package/src/inject.ts CHANGED
@@ -267,4 +267,13 @@ export const createCoreApi = (
267
267
  call({ ...params, connectId, deviceId, method: 'nexaGetAddress' }),
268
268
  nexaSignTransaction: (connectId, deviceId, params) =>
269
269
  call({ ...params, connectId, deviceId, method: 'nexaSignTransaction' }),
270
+
271
+ nostrGetPublicKey: (connectId, deviceId, params) =>
272
+ call({ ...params, connectId, deviceId, method: 'nostrGetPublicKey' }),
273
+ nostrSignEvent: (connectId, deviceId, params) =>
274
+ call({ ...params, connectId, deviceId, method: 'nostrSignEvent' }),
275
+ nostrEncryptMessage: (connectId, deviceId, params) =>
276
+ call({ ...params, connectId, deviceId, method: 'nostrEncryptMessage' }),
277
+ nostrDecryptMessage: (connectId, deviceId, params) =>
278
+ call({ ...params, connectId, deviceId, method: 'nostrDecryptMessage' }),
270
279
  });
@@ -112,6 +112,11 @@ import { kaspaSignTransaction } from './kaspaSignTransaction';
112
112
  import { nexaGetAddress } from './nexaGetAddress';
113
113
  import { nexaSignTransaction } from './nexaSignTransaction';
114
114
 
115
+ import { nostrGetPublicKey } from './nostrGetPublicKey';
116
+ import { nostrSignEvent } from './nostrSignEvent';
117
+ import { nostrEncryptMessage } from './nostrEncryptMessage';
118
+ import { nostrDecryptMessage } from './nostrDecryptMessage';
119
+
115
120
  export * from './export';
116
121
 
117
122
  export type CoreApi = {
@@ -301,4 +306,12 @@ export type CoreApi = {
301
306
  */
302
307
  nexaGetAddress: typeof nexaGetAddress;
303
308
  nexaSignTransaction: typeof nexaSignTransaction;
309
+
310
+ /**
311
+ * Nostr function
312
+ */
313
+ nostrGetPublicKey: typeof nostrGetPublicKey;
314
+ nostrSignEvent: typeof nostrSignEvent;
315
+ nostrEncryptMessage: typeof nostrEncryptMessage;
316
+ nostrDecryptMessage: typeof nostrDecryptMessage;
304
317
  };
@@ -0,0 +1,24 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type NostrDecryptedMessage = {
4
+ msg: string;
5
+ };
6
+
7
+ export interface NostrDecryptMessageParams {
8
+ path: string | number[];
9
+ pubkey: string;
10
+ ciphertext: string;
11
+ }
12
+
13
+ export type NostrDecryptedMessageResponse = {
14
+ path: string;
15
+ pubkey: string;
16
+ ciphertext: string;
17
+ decryptedMessage: string;
18
+ };
19
+
20
+ export declare function nostrDecryptMessage(
21
+ connectId: string,
22
+ deviceId: string,
23
+ params: CommonParams & NostrDecryptMessageParams
24
+ ): Response<NostrDecryptedMessageResponse>;
@@ -0,0 +1,24 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type NostrEncryptedMessage = {
4
+ msg: string;
5
+ };
6
+
7
+ export interface NostrEncryptMessageParams {
8
+ path: string | number[];
9
+ pubkey: string;
10
+ plaintext: string;
11
+ }
12
+
13
+ export type NostrEncryptedMessageResponse = {
14
+ path: string;
15
+ pubkey: string;
16
+ plaintext: string;
17
+ encryptedMessage: string;
18
+ };
19
+
20
+ export declare function nostrEncryptMessage(
21
+ connectId: string,
22
+ deviceId: string,
23
+ params: CommonParams & NostrEncryptMessageParams
24
+ ): Response<NostrEncryptedMessageResponse>;
@@ -0,0 +1,24 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type NostrPublicKey = {
4
+ npub?: string;
5
+ publickey?: string;
6
+ path: string;
7
+ };
8
+
9
+ export interface NostrPublicKeyParams {
10
+ path: string | number[];
11
+ showOnOneKey?: boolean;
12
+ }
13
+
14
+ export declare function nostrGetPublicKey(
15
+ connectId: string,
16
+ deviceId: string,
17
+ params: CommonParams & NostrPublicKeyParams
18
+ ): Response<NostrPublicKey>;
19
+
20
+ export declare function nostrGetPublicKey(
21
+ connectId: string,
22
+ deviceId: string,
23
+ params: CommonParams & { bundle?: NostrPublicKeyParams[] }
24
+ ): Response<Array<NostrPublicKey>>;
@@ -0,0 +1,52 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export enum EventKind {
4
+ Metadata = 0,
5
+ Text = 1,
6
+ RelayRec = 2,
7
+ Contacts = 3,
8
+ DM = 4,
9
+ Deleted = 5,
10
+ Reaction = 7,
11
+ BadgeAward = 8,
12
+ ChannelCreation = 40,
13
+ ChannelMetadata = 41,
14
+ ChannelMessage = 42,
15
+ ChannelHideMessage = 43,
16
+ Reporting = 1984,
17
+ ZapRequest = 9734,
18
+ Zap = 9735,
19
+ RelayListMetadata = 10002,
20
+ ClientAuthentication = 22242,
21
+ NostrConnect = 24133,
22
+ ProfileBadges = 30008,
23
+ BadgeDefinition = 30009,
24
+ LongFormContent = 30023,
25
+ ApplicationSpecificData = 30078,
26
+ }
27
+
28
+ export type NostrEvent = {
29
+ id?: string;
30
+ kind: EventKind;
31
+ pubkey?: string;
32
+ content: string;
33
+ tags: string[][];
34
+ created_at: number;
35
+ sig?: string;
36
+ };
37
+
38
+ export type NostrSignedEvent = {
39
+ path: string;
40
+ event: NostrEvent;
41
+ };
42
+
43
+ export interface NostrSignEventParams {
44
+ path: string | number[];
45
+ event: NostrEvent;
46
+ }
47
+
48
+ export declare function nostrSignEvent(
49
+ connectId: string,
50
+ deviceId: string,
51
+ params: CommonParams & NostrSignEventParams
52
+ ): Response<NostrSignedEvent>;