libp2r2p 0.11.8 → 0.11.9
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
CHANGED
|
@@ -3,11 +3,21 @@ import { base64ToBytes, bytesToBase64 } from '../../../base64/index.js'
|
|
|
3
3
|
// The library transport uses its Base64 signer contract. Conversion stays at
|
|
4
4
|
// this adapter; the injected launcher/vault channel always carries raw bytes.
|
|
5
5
|
export function messengerSigner (signer) {
|
|
6
|
-
|
|
6
|
+
const adapter = {
|
|
7
7
|
getPublicKey: () => signer.getPublicKey(),
|
|
8
8
|
getRelays: () => signer.getRelays(),
|
|
9
9
|
signEvent: event => signer.signEvent(event),
|
|
10
10
|
nip44v3Encrypt: (peer, kind, scope, text) => signer.nip44v3.encrypt(peer, kind, scope, base64ToBytes(text).buffer),
|
|
11
11
|
nip44v3Decrypt: async (peer, kind, scope, ciphertext) => bytesToBase64(new Uint8Array(await signer.nip44v3.decrypt(peer, kind, scope, ciphertext)))
|
|
12
12
|
}
|
|
13
|
+
// Double DH stays opt-in by capability: a signer without both methods keeps
|
|
14
|
+
// the identity-only fallback that the private channel selects by itself.
|
|
15
|
+
if (typeof signer?.nip44v3?.encryptDoubleDH === 'function' &&
|
|
16
|
+
typeof signer?.nip44v3?.decryptDoubleDH === 'function') {
|
|
17
|
+
adapter.nip44EncryptDoubleDH = (peer, kind, scope, text, peerContentPubkey = '') =>
|
|
18
|
+
signer.nip44v3.encryptDoubleDH(peer, kind, scope, base64ToBytes(text).buffer, peerContentPubkey)
|
|
19
|
+
adapter.nip44DecryptDoubleDH = async (peer, kind, scope, ciphertext, peerContentPubkey = '', ownContentPubkey = '') =>
|
|
20
|
+
bytesToBase64(new Uint8Array(await signer.nip44v3.decryptDoubleDH(peer, kind, scope, ciphertext, peerContentPubkey, ownContentPubkey)))
|
|
21
|
+
}
|
|
22
|
+
return adapter
|
|
13
23
|
}
|