applesauce-wallet-connect 0.0.0-next-20251209200210 → 0.0.0-next-20251231055351
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/helpers/notification.js +23 -10
- package/dist/helpers/request.js +21 -12
- package/dist/helpers/response.js +24 -12
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHiddenContentUnlocked, notifyEventUpdate, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers";
|
|
1
|
+
import { getHiddenContent, isHiddenContentUnlocked, notifyEventUpdate, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers";
|
|
2
2
|
export const WALLET_NOTIFICATION_KIND = 23197;
|
|
3
3
|
export const WALLET_LEGACY_NOTIFICATION_KIND = 23196;
|
|
4
4
|
/** A symbol used to cache the wallet notification on the event */
|
|
@@ -8,25 +8,38 @@ setHiddenContentEncryptionMethod(WALLET_NOTIFICATION_KIND, "nip44");
|
|
|
8
8
|
setHiddenContentEncryptionMethod(WALLET_LEGACY_NOTIFICATION_KIND, "nip04");
|
|
9
9
|
/** Checks if a kind 23196 or 23197 event is locked */
|
|
10
10
|
export function isWalletNotificationUnlocked(notification) {
|
|
11
|
-
|
|
11
|
+
// Wrap in try catch to avoid throwing validation errors
|
|
12
|
+
try {
|
|
13
|
+
return (WalletNotificationSymbol in notification ||
|
|
14
|
+
(isHiddenContentUnlocked(notification) && getWalletNotification(notification) !== undefined));
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
17
|
+
return false;
|
|
12
18
|
}
|
|
13
19
|
/** Unlocks a kind 23196 or 23197 event */
|
|
14
20
|
export async function unlockWalletNotification(notification, signer) {
|
|
15
|
-
if (
|
|
21
|
+
if (WalletNotificationSymbol in notification)
|
|
16
22
|
return notification[WalletNotificationSymbol];
|
|
17
|
-
|
|
18
|
-
const parsed =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
notifyEventUpdate(notification);
|
|
23
|
+
await unlockHiddenContent(notification, signer);
|
|
24
|
+
const parsed = getWalletNotification(notification);
|
|
25
|
+
if (!parsed)
|
|
26
|
+
throw new Error("Failed to unlock wallet notification");
|
|
22
27
|
return parsed;
|
|
23
28
|
}
|
|
24
29
|
/** Gets the wallet notification from a kind 23196 or 23197 event */
|
|
25
30
|
export function getWalletNotification(notification) {
|
|
26
|
-
if (
|
|
31
|
+
if (WalletNotificationSymbol in notification)
|
|
27
32
|
return notification[WalletNotificationSymbol];
|
|
28
|
-
|
|
33
|
+
// Get the encrypted content
|
|
34
|
+
const content = getHiddenContent(notification);
|
|
35
|
+
if (!content)
|
|
29
36
|
return undefined;
|
|
37
|
+
// Parse the content as a wallet notification
|
|
38
|
+
const parsed = JSON.parse(content);
|
|
39
|
+
// Save the parsed content
|
|
40
|
+
Reflect.set(notification, WalletNotificationSymbol, parsed);
|
|
41
|
+
notifyEventUpdate(notification);
|
|
42
|
+
return parsed;
|
|
30
43
|
}
|
|
31
44
|
/** Checks if an event is a valid wallet notification event */
|
|
32
45
|
export function isValidWalletNotification(notification) {
|
package/dist/helpers/request.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isNIP04Encrypted } from "applesauce-core/helpers/encryption";
|
|
2
|
-
import { notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
3
|
-
import {
|
|
4
|
-
import { isHiddenContentUnlocked, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers/hidden-content";
|
|
2
|
+
import { getTagValue, notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
3
|
+
import { getHiddenContent, isHiddenContentUnlocked, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers/hidden-content";
|
|
5
4
|
import { unixNow } from "applesauce-core/helpers/time";
|
|
6
5
|
export const WALLET_REQUEST_KIND = 23194;
|
|
7
6
|
// Set the encryption method to use for request kind
|
|
@@ -10,25 +9,35 @@ setHiddenContentEncryptionMethod(WALLET_REQUEST_KIND, "nip44");
|
|
|
10
9
|
export const WalletRequestSymbol = Symbol("wallet-request");
|
|
11
10
|
/** Checks if a kind 23194 event is locked */
|
|
12
11
|
export function isWalletRequestUnlocked(request) {
|
|
13
|
-
|
|
12
|
+
// Wrap in try catch to avoid throwing validation errors
|
|
13
|
+
try {
|
|
14
|
+
return (WalletRequestSymbol in request || (isHiddenContentUnlocked(request) && getWalletRequest(request) !== undefined));
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
17
|
+
return false;
|
|
14
18
|
}
|
|
15
19
|
/** Unlocks a kind 23194 event */
|
|
16
20
|
export async function unlockWalletRequest(request, signer) {
|
|
17
|
-
if (
|
|
21
|
+
if (WalletRequestSymbol in request)
|
|
18
22
|
return request[WalletRequestSymbol];
|
|
19
|
-
|
|
20
|
-
const parsed =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
notifyEventUpdate(request);
|
|
23
|
+
await unlockHiddenContent(request, signer);
|
|
24
|
+
const parsed = getWalletRequest(request);
|
|
25
|
+
if (!parsed)
|
|
26
|
+
throw new Error("Failed to unlock wallet request");
|
|
24
27
|
return parsed;
|
|
25
28
|
}
|
|
26
29
|
/** Gets the wallet request from a kind 23194 event */
|
|
27
30
|
export function getWalletRequest(request) {
|
|
28
|
-
if (
|
|
31
|
+
if (WalletRequestSymbol in request)
|
|
29
32
|
return request[WalletRequestSymbol];
|
|
30
|
-
|
|
33
|
+
const content = getHiddenContent(request);
|
|
34
|
+
if (!content)
|
|
31
35
|
return undefined;
|
|
36
|
+
const parsed = JSON.parse(content);
|
|
37
|
+
// Save the parsed content
|
|
38
|
+
Reflect.set(request, WalletRequestSymbol, parsed);
|
|
39
|
+
notifyEventUpdate(request);
|
|
40
|
+
return parsed;
|
|
32
41
|
}
|
|
33
42
|
export function getWalletRequestServicePubkey(request) {
|
|
34
43
|
return getTagValue(request, "p");
|
package/dist/helpers/response.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isNIP04Encrypted } from "applesauce-core/helpers/encryption";
|
|
2
|
-
import { notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
3
|
-
import {
|
|
4
|
-
import { isHiddenContentUnlocked, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers/hidden-content";
|
|
2
|
+
import { getTagValue, notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
3
|
+
import { getHiddenContent, isHiddenContentUnlocked, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "applesauce-core/helpers/hidden-content";
|
|
5
4
|
export const WALLET_RESPONSE_KIND = 23195;
|
|
6
5
|
// Set the encryption method to use for response kind
|
|
7
6
|
setHiddenContentEncryptionMethod(WALLET_RESPONSE_KIND, "nip04");
|
|
@@ -9,26 +8,39 @@ setHiddenContentEncryptionMethod(WALLET_RESPONSE_KIND, "nip04");
|
|
|
9
8
|
export const WalletResponseSymbol = Symbol("wallet-response");
|
|
10
9
|
/** Checks if a kind 23195 event is locked */
|
|
11
10
|
export function isWalletResponseUnlocked(response) {
|
|
12
|
-
|
|
11
|
+
// Wrap in try catch to avoid throwing validation errors
|
|
12
|
+
try {
|
|
13
|
+
return (WalletResponseSymbol in response ||
|
|
14
|
+
(isHiddenContentUnlocked(response) && getWalletResponse(response) !== undefined));
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
17
|
+
return false;
|
|
13
18
|
}
|
|
14
19
|
/** Unlocks a kind 23195 event */
|
|
15
20
|
export async function unlockWalletResponse(response, signer, override) {
|
|
16
|
-
if (
|
|
21
|
+
if (WalletResponseSymbol in response)
|
|
17
22
|
return response[WalletResponseSymbol];
|
|
23
|
+
// Unlock the hidden content
|
|
18
24
|
const encryption = override ?? (!isNIP04Encrypted(response.content) ? "nip44" : "nip04");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
await unlockHiddenContent(response, signer, encryption);
|
|
26
|
+
// Get the wallet response
|
|
27
|
+
const parsed = getWalletResponse(response);
|
|
28
|
+
if (!parsed)
|
|
29
|
+
throw new Error("Failed to unlock wallet response");
|
|
24
30
|
return parsed;
|
|
25
31
|
}
|
|
26
32
|
/** Gets the wallet response from a kind 23195 event */
|
|
27
33
|
export function getWalletResponse(response) {
|
|
28
|
-
if (
|
|
34
|
+
if (WalletResponseSymbol in response)
|
|
29
35
|
return response[WalletResponseSymbol];
|
|
30
|
-
|
|
36
|
+
const content = getHiddenContent(response);
|
|
37
|
+
if (!content)
|
|
31
38
|
return undefined;
|
|
39
|
+
const parsed = JSON.parse(content);
|
|
40
|
+
// Save the parsed content
|
|
41
|
+
Reflect.set(response, WalletResponseSymbol, parsed);
|
|
42
|
+
notifyEventUpdate(response);
|
|
43
|
+
return parsed;
|
|
32
44
|
}
|
|
33
45
|
export function getWalletResponseClientPubkey(response) {
|
|
34
46
|
return getTagValue(response, "p");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-wallet-connect",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20251231055351",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@noble/hashes": "^1.7.1",
|
|
62
|
-
"applesauce-common": "0.0.0-next-
|
|
63
|
-
"applesauce-core": "0.0.0-next-
|
|
62
|
+
"applesauce-common": "0.0.0-next-20251231055351",
|
|
63
|
+
"applesauce-core": "0.0.0-next-20251231055351",
|
|
64
64
|
"rxjs": "^7.8.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
68
|
-
"applesauce-signers": "0.0.0-next-
|
|
68
|
+
"applesauce-signers": "0.0.0-next-20251231055351",
|
|
69
69
|
"@types/debug": "^4.1.12",
|
|
70
70
|
"rimraf": "^6.0.1",
|
|
71
71
|
"typescript": "^5.8.3",
|