@shocknet/clink-sdk
Version:
sdk client for clink
23 lines • 1 kB
JavaScript
import { nip44, getPublicKey } from "nostr-tools";
import { sendRequest } from "./sender.js";
const { getConversationKey, encrypt } = nip44;
export const SendNofferRequest = async (pool, privateKey, relays, toPubKey, data, timeoutSeconds = 30, onReceipt) => {
const publicKey = getPublicKey(privateKey);
const content = encrypt(JSON.stringify(data), getConversationKey(privateKey, toPubKey));
const event = newNofferEvent(content, publicKey, toPubKey);
return sendRequest(pool, { privateKey, publicKey }, relays, toPubKey, event, 21001, timeoutSeconds, onReceipt);
};
export const newNofferEvent = (content, fromPub, toPub) => ({
content,
created_at: Math.floor(Date.now() / 1000),
kind: 21001,
pubkey: fromPub,
tags: [['p', toPub], ['clink_version', '1']]
});
export const newNofferFilter = (publicKey, eventId) => ({
since: Math.floor(Date.now() / 1000) - 1,
kinds: [21001],
'#p': [publicKey],
'#e': [eventId]
});
//# sourceMappingURL=noffer.js.map