@1sat/actions 0.0.231 → 0.0.232
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mandala/index.d.ts +0 -1
- package/dist/mandala/index.d.ts.map +1 -1
- package/dist/mandala/index.js +0 -1
- package/dist/mandala/index.js.map +1 -1
- package/dist/mandala/receive.d.ts +16 -4
- package/dist/mandala/receive.d.ts.map +1 -1
- package/dist/mandala/receive.js +30 -86
- package/dist/mandala/receive.js.map +1 -1
- package/dist/mandala/send.d.ts +1 -1
- package/dist/mandala/send.d.ts.map +1 -1
- package/dist/mandala/send.js +9 -23
- package/dist/mandala/send.js.map +1 -1
- package/dist/mandala/send.test.js +3 -3
- package/dist/mandala/send.test.js.map +1 -1
- package/dist/{mandala → metanet}/brc78.d.ts.map +1 -1
- package/dist/{mandala → metanet}/brc78.js.map +1 -1
- package/dist/metanet/deliver.d.ts +26 -0
- package/dist/metanet/deliver.d.ts.map +1 -0
- package/dist/metanet/deliver.js +34 -0
- package/dist/metanet/deliver.js.map +1 -0
- package/dist/{mandala → metanet}/envelope.d.ts.map +1 -1
- package/dist/{mandala → metanet}/envelope.js.map +1 -1
- package/dist/metanet/envelope.test.d.ts.map +1 -0
- package/dist/{mandala → metanet}/envelope.test.js.map +1 -1
- package/dist/metanet/inbox.d.ts +51 -0
- package/dist/metanet/inbox.d.ts.map +1 -0
- package/dist/metanet/inbox.js +100 -0
- package/dist/metanet/inbox.js.map +1 -0
- package/dist/metanet/index.d.ts +8 -0
- package/dist/metanet/index.d.ts.map +1 -0
- package/dist/metanet/index.js +9 -0
- package/dist/metanet/index.js.map +1 -0
- package/dist/metanet/receive.d.ts +50 -0
- package/dist/metanet/receive.d.ts.map +1 -0
- package/dist/metanet/receive.js +107 -0
- package/dist/metanet/receive.js.map +1 -0
- package/dist/{mandala → metanet}/relay.d.ts +3 -2
- package/dist/{mandala → metanet}/relay.d.ts.map +1 -1
- package/dist/{mandala → metanet}/relay.js +3 -2
- package/dist/{mandala → metanet}/relay.js.map +1 -1
- package/dist/payments/index.d.ts +32 -1
- package/dist/payments/index.d.ts.map +1 -1
- package/dist/payments/index.js +118 -6
- package/dist/payments/index.js.map +1 -1
- package/dist/payments/sendBsvHandle.test.d.ts +2 -0
- package/dist/payments/sendBsvHandle.test.d.ts.map +1 -0
- package/dist/payments/sendBsvHandle.test.js +478 -0
- package/dist/payments/sendBsvHandle.test.js.map +1 -0
- package/package.json +7 -7
- package/dist/mandala/envelope.test.d.ts.map +0 -1
- /package/dist/{mandala → metanet}/brc78.d.ts +0 -0
- /package/dist/{mandala → metanet}/brc78.js +0 -0
- /package/dist/{mandala → metanet}/envelope.d.ts +0 -0
- /package/dist/{mandala → metanet}/envelope.js +0 -0
- /package/dist/{mandala → metanet}/envelope.test.d.ts +0 -0
- /package/dist/{mandala → metanet}/envelope.test.js +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send a signed BRC-169 §7.3 envelope (DAG-CBOR, BRC-231 body over BRC-104)
|
|
3
|
+
* to a resolved handle's messagebox.
|
|
4
|
+
*
|
|
5
|
+
* `content` is BRC-78 encryption (via `wallet.encrypt`) of the given MIME
|
|
6
|
+
* plaintext to the recipient's identity key; `contentHash` is the SHA-256 of
|
|
7
|
+
* that plaintext; the signature is per §7.2 item 3.
|
|
8
|
+
*/
|
|
9
|
+
import type { HandleResolution } from '@1sat/client';
|
|
10
|
+
import { type WalletInterface } from '@bsv/sdk';
|
|
11
|
+
import { type EnvelopePayment } from './envelope.js';
|
|
12
|
+
/** A fresh random 16-byte value, base64: a BRC-29 derivation prefix/suffix or key ID half. */
|
|
13
|
+
export declare function randomBase64(): string;
|
|
14
|
+
export declare function sendEnvelope(wallet: WalletInterface, resolution: HandleResolution, p: {
|
|
15
|
+
/** Our identity key, hex */
|
|
16
|
+
senderIdentityKey: string;
|
|
17
|
+
/** The MIME entity `content` encrypts */
|
|
18
|
+
plaintext: number[];
|
|
19
|
+
payment: EnvelopePayment | null;
|
|
20
|
+
/** Messagebox box name */
|
|
21
|
+
messageBox: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
status: string;
|
|
24
|
+
messageId: string;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=deliver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliver.d.ts","sourceRoot":"","sources":["../../src/metanet/deliver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAA;AAE5D,OAAO,EAAE,KAAK,eAAe,EAAgB,MAAM,eAAe,CAAA;AAGlE,8FAA8F;AAC9F,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAsB,YAAY,CACjC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,gBAAgB,EAC5B,CAAC,EAAE;IACF,4BAA4B;IAC5B,iBAAiB,EAAE,MAAM,CAAA;IACzB,yCAAyC;IACzC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,0BAA0B;IAC1B,UAAU,EAAE,MAAM,CAAA;CAClB,GACC,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA8BhD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send a signed BRC-169 §7.3 envelope (DAG-CBOR, BRC-231 body over BRC-104)
|
|
3
|
+
* to a resolved handle's messagebox.
|
|
4
|
+
*
|
|
5
|
+
* `content` is BRC-78 encryption (via `wallet.encrypt`) of the given MIME
|
|
6
|
+
* plaintext to the recipient's identity key; `contentHash` is the SHA-256 of
|
|
7
|
+
* that plaintext; the signature is per §7.2 item 3.
|
|
8
|
+
*/
|
|
9
|
+
import { Hash, Utils } from '@bsv/sdk';
|
|
10
|
+
import { encryptBrc78 } from './brc78.js';
|
|
11
|
+
import { signEnvelope } from './envelope.js';
|
|
12
|
+
import { messageRelay } from './relay.js';
|
|
13
|
+
/** A fresh random 16-byte value, base64: a BRC-29 derivation prefix/suffix or key ID half. */
|
|
14
|
+
export function randomBase64() {
|
|
15
|
+
return Utils.toBase64(Array.from(crypto.getRandomValues(new Uint8Array(16))));
|
|
16
|
+
}
|
|
17
|
+
export async function sendEnvelope(wallet, resolution, p) {
|
|
18
|
+
const content = await encryptBrc78(wallet, p.plaintext, resolution.identityKey);
|
|
19
|
+
const bytes = (a) => Uint8Array.from(a);
|
|
20
|
+
const { envelope } = await signEnvelope(wallet, {
|
|
21
|
+
metanetHandles: '1.0',
|
|
22
|
+
recipient: {
|
|
23
|
+
handle: resolution.handle,
|
|
24
|
+
tag: resolution.tag,
|
|
25
|
+
domain: resolution.domain,
|
|
26
|
+
},
|
|
27
|
+
sender: { identityKey: bytes(Utils.toArray(p.senderIdentityKey, 'hex')) },
|
|
28
|
+
created: new Date().toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
|
29
|
+
payment: p.payment,
|
|
30
|
+
contentHash: bytes(Hash.sha256(p.plaintext)),
|
|
31
|
+
}, bytes(content));
|
|
32
|
+
return messageRelay.sendCborMessage(wallet, resolution.messagebox, resolution.identityKey, p.messageBox, envelope);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=deliver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliver.js","sourceRoot":"","sources":["../../src/metanet/deliver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;A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AU,EACrB,UAAU,CAAC,WAAW,EACtB,CAAC,CAAC,UAAU,EACZ,QAAQ,CACR,CAAA;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/metanet/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,UAAU,CAAA;AAMjB,mCAAmC;AACnC,eAAO,MAAM,2BAA2B,EAAE,cAGzC,CAAA;AACD,iCAAiC;AACjC,eAAO,MAAM,yBAAyB,SAAS,CAAA;AAE/C,4BAA4B;AAC5B,MAAM,WAAW,eAAe;IAC/B,gBAAgB,EAAE,UAAU,CAAA;IAC5B,gBAAgB,EAAE,UAAU,CAAA;IAC5B,8CAA8C;IAC9C,QAAQ,EAAE,UAAU,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,kBAAkB;IAClB,IAAI,EAAE,UAAU,CAAA;CAChB;AAED,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAChC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3D,kDAAkD;IAClD,MAAM,EAAE;QAAE,WAAW,EAAE,UAAU,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrE,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,WAAW,CAAC,EAAE,UAAU,CAAA;CACxB;AAiBD,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,CAEzE;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CACjC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,EAChD,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC,CAY1D;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACzD,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;CACrB;AAED,uCAAuC;AACvC,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,CAYlE;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAe5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/metanet/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,WAAW,EACX,KAAK,GAGL,MAAM,UAAU,CAAA;AACjB,OAAO,EACN,MAAM,IAAI,aAAa,EACvB,MAAM,IAAI,aAAa,GACvB,MAAM,gBAAgB,CAAA;AAEvB,mCAAmC;AACnC,MAAM,CAAC,MAAM,2BAA2B,GAAmB;IAC1D,CAAC;IACD,0BAA0B;CAC1B,CAAA;AACD,iCAAiC;AACjC,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AA0B/C,2DAA2D;AAC3D,SAAS,OAAO,CAAmB,GAAM;IACxC,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,C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AAC,OAAO,YAAY,UAAU,CAAC;QACpC,CAAC,CAAC,GAAG,CAAC,SAAS,YAAY,UAAU,CAAC,EACrC,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAqB;IACzD,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,GAAG,GAAG,CAAA;IACnD,IAAI,CAAC;QACJ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC;YACjE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YACnD,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAChC,UAAU,EAAE,2BAA2B;YACvC,KAAK,EAAE,yBAAyB;YAChC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC7D,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACR,8CAA8C;QAC9C,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.test.d.ts","sourceRoot":"","sources":["../../src/metanet/envelope.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.test.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"envelope.test.js","sourceRoot":"","sources":["../../src/metanet/envelope.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACjD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AE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1B,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAuB,CAAC;YAC9C,UAAU,EAAE,2BAA2B;YACvC,KAAK,EAAE,yBAAyB;YAChC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7C,CAAC,CAAA;QACF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messagebox steps shared by the BRC-169 inbox syncs (`mandala_inbox`,
|
|
3
|
+
* `metanet_inbox`): list a box (BRC-231 over BRC-104), decode each §7.3
|
|
4
|
+
* DAG-CBOR envelope, verify its §7.2 signature against `sender.identityKey`,
|
|
5
|
+
* decrypt the BRC-78 `content` with `wallet.decrypt`, check `contentHash`,
|
|
6
|
+
* parse the MIME entity, hand it to the box's handler, and acknowledge only
|
|
7
|
+
* the messages whose handler succeeded. A message whose handler throws is
|
|
8
|
+
* left in the box and reported with the reason.
|
|
9
|
+
*/
|
|
10
|
+
import { type MimeEntity } from '@1sat/utils';
|
|
11
|
+
import { type WalletInterface } from '@bsv/sdk';
|
|
12
|
+
import { type ReceivedEnvelope } from './envelope.js';
|
|
13
|
+
import { type CborMessage } from './relay.js';
|
|
14
|
+
/** Default messagebox when the caller names none. */
|
|
15
|
+
export declare const DEFAULT_MESSAGEBOX_URL = "https://messagebox.1sat.app";
|
|
16
|
+
/** A message left in the box, and why. */
|
|
17
|
+
export interface InboxSkip {
|
|
18
|
+
messageId: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
}
|
|
21
|
+
/** Thrown to leave a message unacknowledged with a reason. */
|
|
22
|
+
export declare class InboxSkipError extends Error {
|
|
23
|
+
}
|
|
24
|
+
/** Hex of a byte string of the given length, or InboxSkipError. */
|
|
25
|
+
export declare function bytesHex(b: unknown, length: number, what: string): string;
|
|
26
|
+
/** A verified, decrypted envelope. */
|
|
27
|
+
export interface OpenedEnvelope {
|
|
28
|
+
env: ReceivedEnvelope;
|
|
29
|
+
/** `sender.identityKey`, hex */
|
|
30
|
+
sender: string;
|
|
31
|
+
/** The decrypted `content` */
|
|
32
|
+
plaintext: number[];
|
|
33
|
+
entity: MimeEntity;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Decode, verify, decrypt and parse one envelope addressed to this wallet.
|
|
37
|
+
*
|
|
38
|
+
* @throws InboxSkipError when it is not a DAG-CBOR envelope, the signature
|
|
39
|
+
* does not verify, or `contentHash` does not match
|
|
40
|
+
*/
|
|
41
|
+
export declare function openEnvelope(wallet: Pick<WalletInterface, 'decrypt'>, body: Uint8Array): Promise<OpenedEnvelope>;
|
|
42
|
+
/**
|
|
43
|
+
* List `messageBox`, open each envelope and run `handle` on it; acknowledge
|
|
44
|
+
* the messages `handle` returned for.
|
|
45
|
+
*/
|
|
46
|
+
export declare function processInbox<R>(wallet: WalletInterface, messageboxUrl: string | undefined, messageBox: string, handle: (opened: OpenedEnvelope, msg: CborMessage) => Promise<R>): Promise<{
|
|
47
|
+
received: R[];
|
|
48
|
+
skipped: InboxSkip[];
|
|
49
|
+
error?: string;
|
|
50
|
+
}>;
|
|
51
|
+
//# sourceMappingURL=inbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../src/metanet/inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAA;AAE5D,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,YAAY,CAAA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4
|
+
* DAG-CBOR envelope, verify its §7.2 signature against `sender.identityKey`,
|
|
5
|
+
* decrypt the BRC-78 `content` with `wallet.decrypt`, check `contentHash`,
|
|
6
|
+
* parse the MIME entity, hand it to the box's handler, and acknowledge only
|
|
7
|
+
* the messages whose handler succeeded. A message whose handler throws is
|
|
8
|
+
* left in the box and reported with the reason.
|
|
9
|
+
*/
|
|
10
|
+
import { parseMimeEntity } from '@1sat/utils';
|
|
11
|
+
import { Hash, Utils } from '@bsv/sdk';
|
|
12
|
+
import { decryptBrc78 } from './brc78.js';
|
|
13
|
+
import { decodeEnvelope, verifyEnvelope, } from './envelope.js';
|
|
14
|
+
import { messageRelay } from './relay.js';
|
|
15
|
+
/** Default messagebox when the caller names none. */
|
|
16
|
+
export const DEFAULT_MESSAGEBOX_URL = 'https://messagebox.1sat.app';
|
|
17
|
+
/** Thrown to leave a message unacknowledged with a reason. */
|
|
18
|
+
export class InboxSkipError extends Error {
|
|
19
|
+
}
|
|
20
|
+
/** Hex of a byte string of the given length, or InboxSkipError. */
|
|
21
|
+
export function bytesHex(b, length, what) {
|
|
22
|
+
if (!(b instanceof Uint8Array) || b.length !== length) {
|
|
23
|
+
throw new InboxSkipError(`${what} must be ${length} bytes`);
|
|
24
|
+
}
|
|
25
|
+
return Utils.toHex(Array.from(b));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Decode, verify, decrypt and parse one envelope addressed to this wallet.
|
|
29
|
+
*
|
|
30
|
+
* @throws InboxSkipError when it is not a DAG-CBOR envelope, the signature
|
|
31
|
+
* does not verify, or `contentHash` does not match
|
|
32
|
+
*/
|
|
33
|
+
export async function openEnvelope(wallet, body) {
|
|
34
|
+
let env;
|
|
35
|
+
try {
|
|
36
|
+
env = decodeEnvelope(body);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new InboxSkipError('not a DAG-CBOR BRC-169 envelope');
|
|
40
|
+
}
|
|
41
|
+
if (!(await verifyEnvelope(env))) {
|
|
42
|
+
throw new InboxSkipError('envelope signature does not verify');
|
|
43
|
+
}
|
|
44
|
+
const sender = bytesHex(env.sender.identityKey, 33, 'sender');
|
|
45
|
+
const plaintext = await decryptBrc78(wallet, env.content, sender);
|
|
46
|
+
if (env.contentHash !== undefined &&
|
|
47
|
+
Utils.toHex(Hash.sha256(plaintext)) !==
|
|
48
|
+
Utils.toHex(Array.from(env.contentHash))) {
|
|
49
|
+
throw new InboxSkipError('contentHash does not match the content');
|
|
50
|
+
}
|
|
51
|
+
return { env, sender, plaintext, entity: parseMimeEntity(plaintext) };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* List `messageBox`, open each envelope and run `handle` on it; acknowledge
|
|
55
|
+
* the messages `handle` returned for.
|
|
56
|
+
*/
|
|
57
|
+
export async function processInbox(wallet, messageboxUrl, messageBox, handle) {
|
|
58
|
+
const messagebox = messageboxUrl?.replace(/\/+$/, '') || DEFAULT_MESSAGEBOX_URL;
|
|
59
|
+
const received = [];
|
|
60
|
+
const skipped = [];
|
|
61
|
+
const acknowledged = [];
|
|
62
|
+
let messages;
|
|
63
|
+
try {
|
|
64
|
+
messages = await messageRelay.listCborMessages(wallet, messagebox, messageBox);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
received,
|
|
69
|
+
skipped,
|
|
70
|
+
error: error instanceof Error ? error.message : String(error),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
for (const msg of messages) {
|
|
74
|
+
try {
|
|
75
|
+
const opened = await openEnvelope(wallet, msg.body);
|
|
76
|
+
received.push(await handle(opened, msg));
|
|
77
|
+
acknowledged.push(msg.messageId);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
skipped.push({
|
|
81
|
+
messageId: msg.messageId,
|
|
82
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (acknowledged.length > 0) {
|
|
87
|
+
try {
|
|
88
|
+
await messageRelay.acknowledgeCborMessages(wallet, messagebox, acknowledged);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return {
|
|
92
|
+
received,
|
|
93
|
+
skipped,
|
|
94
|
+
error: `acknowledge-failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { received, skipped };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=inbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox.js","sourceRoot":"","sources":["../../src/metanet/inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAmB,eAAe,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAEN,cAAc,EACd,cAAc,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAoB,YAAY,EAAE,MAAM,YAAY,CAAA;AAE3D,qDAAqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,CAAA;AAQnE,8DAA8D;AAC9D,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAG;AAE5C,mEAAmE;AACnE,MAAM,UAAU,QAAQ,CAAC,CAAU,EAAE,MAAc,EAAE,IAAY;IAChE,IAAI,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACvD,MAAM,IAAI,cAAc,CAAC,GAAG,IAAI,YAAY,MAAM,QAAQ,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC;AAYD;;;;;GAKG;AACH,MAAM,CAAC,KAA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K,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACtF,CAAA;QACF,CAAC;IACF,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BRC-169 envelope plumbing shared by the handle-addressed actions (Mandala
|
|
3
|
+
* sends, `sendBsv` to a handle) and the `metanet_inbox` sync.
|
|
4
|
+
*/
|
|
5
|
+
export * from './envelope.js';
|
|
6
|
+
export * from './receive.js';
|
|
7
|
+
export declare const metanetActions: import("../types.js").Action<import("./receive.js").SyncMetanetInboxInput, import("./receive.js").SyncMetanetInboxResult>[];
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metanet/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAE5B,eAAO,MAAM,cAAc,6HAAqB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BRC-169 envelope plumbing shared by the handle-addressed actions (Mandala
|
|
3
|
+
* sends, `sendBsv` to a handle) and the `metanet_inbox` sync.
|
|
4
|
+
*/
|
|
5
|
+
import { syncMetanetInbox } from './receive.js';
|
|
6
|
+
export * from './envelope.js';
|
|
7
|
+
export * from './receive.js';
|
|
8
|
+
export const metanetActions = [syncMetanetInbox];
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metanet/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAE5B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect BRC-169 payments from the wallet's `metanet_inbox`.
|
|
3
|
+
*
|
|
4
|
+
* For each message listed (BRC-231 over BRC-104) the shared inbox steps
|
|
5
|
+
* decode the §7.3 DAG-CBOR envelope, verify its §7.2 signature against
|
|
6
|
+
* `sender.identityKey`, decrypt the BRC-78 `content`, check `contentHash`
|
|
7
|
+
* and parse the MIME entity (see `processInbox`). Then:
|
|
8
|
+
*
|
|
9
|
+
* - `payment` set (BRC-169 §6.1): internalize its Atomic BEEF as a BRC-29
|
|
10
|
+
* `wallet payment` of output 0, remittance `{ derivationPrefix,
|
|
11
|
+
* derivationSuffix, senderIdentityKey: sender.identityKey }`, label
|
|
12
|
+
* `metanet payment`, the memo in the description when `content` is
|
|
13
|
+
* `text/plain`;
|
|
14
|
+
* - `payment` null and `content` a BRC-232 transaction delivery: processed as
|
|
15
|
+
* `syncMandalaInbox` processes it.
|
|
16
|
+
*
|
|
17
|
+
* A message is acknowledged only after its internalize succeeds. Anything
|
|
18
|
+
* else (JSON envelopes, a bad signature or hash, a payment protocol other
|
|
19
|
+
* than BRC-29, a payment whose content is a transaction delivery, a message
|
|
20
|
+
* with nothing to internalize) is left unacknowledged and reported.
|
|
21
|
+
*/
|
|
22
|
+
import type { Action } from '../types.js';
|
|
23
|
+
import { type InboxSkip } from './inbox.js';
|
|
24
|
+
/** Label on internalized handle payments */
|
|
25
|
+
export declare const METANET_PAYMENT_LABEL = "metanet payment";
|
|
26
|
+
export interface SyncMetanetInboxInput {
|
|
27
|
+
/** MessageBox server URL (default: "https://messagebox.1sat.app") */
|
|
28
|
+
messageboxUrl?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A message internalized and acknowledged. */
|
|
31
|
+
export interface MetanetInboxReceipt {
|
|
32
|
+
messageId: string;
|
|
33
|
+
txid: string;
|
|
34
|
+
/** Sender identity key, hex */
|
|
35
|
+
sender: string;
|
|
36
|
+
/** `payment.satoshis` as the envelope states it (payments only) */
|
|
37
|
+
satoshis?: number;
|
|
38
|
+
/** The `text/plain` content (payments only) */
|
|
39
|
+
memo?: string;
|
|
40
|
+
/** Mandala tokens received (BRC-232 deliveries only) */
|
|
41
|
+
tokenIds: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface SyncMetanetInboxResult {
|
|
44
|
+
received: MetanetInboxReceipt[];
|
|
45
|
+
/** Messages left unacknowledged */
|
|
46
|
+
skipped: InboxSkip[];
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare const syncMetanetInbox: Action<SyncMetanetInboxInput, SyncMetanetInboxResult>;
|
|
50
|
+
//# sourceMappingURL=receive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receive.d.ts","sourceRoot":"","sources":["../../src/metanet/receive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,YAAY,CAAA;AAEzE,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,oBAAoB,CAAA;AAEtD,MAAM,WAAW,qBAAqB;IACrC,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,mCAAmC;IACnC,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAqDD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACpC,qBAAqB,EACrB,sBAAsB,CAiEtB,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect BRC-169 payments from the wallet's `metanet_inbox`.
|
|
3
|
+
*
|
|
4
|
+
* For each message listed (BRC-231 over BRC-104) the shared inbox steps
|
|
5
|
+
* decode the §7.3 DAG-CBOR envelope, verify its §7.2 signature against
|
|
6
|
+
* `sender.identityKey`, decrypt the BRC-78 `content`, check `contentHash`
|
|
7
|
+
* and parse the MIME entity (see `processInbox`). Then:
|
|
8
|
+
*
|
|
9
|
+
* - `payment` set (BRC-169 §6.1): internalize its Atomic BEEF as a BRC-29
|
|
10
|
+
* `wallet payment` of output 0, remittance `{ derivationPrefix,
|
|
11
|
+
* derivationSuffix, senderIdentityKey: sender.identityKey }`, label
|
|
12
|
+
* `metanet payment`, the memo in the description when `content` is
|
|
13
|
+
* `text/plain`;
|
|
14
|
+
* - `payment` null and `content` a BRC-232 transaction delivery: processed as
|
|
15
|
+
* `syncMandalaInbox` processes it.
|
|
16
|
+
*
|
|
17
|
+
* A message is acknowledged only after its internalize succeeds. Anything
|
|
18
|
+
* else (JSON envelopes, a bad signature or hash, a payment protocol other
|
|
19
|
+
* than BRC-29, a payment whose content is a transaction delivery, a message
|
|
20
|
+
* with nothing to internalize) is left unacknowledged and reported.
|
|
21
|
+
*/
|
|
22
|
+
import { BRC29_PROTOCOL_ID, METANET_INBOX } from '@1sat/types';
|
|
23
|
+
import { TRANSACTION_CBOR_CONTENT_TYPE, mediaType } from '@1sat/utils';
|
|
24
|
+
import { Beef, Utils } from '@bsv/sdk';
|
|
25
|
+
import { internalizeTransactionDelivery } from '../mandala/receive.js';
|
|
26
|
+
import { InboxSkipError, processInbox } from './inbox.js';
|
|
27
|
+
/** Label on internalized handle payments */
|
|
28
|
+
export const METANET_PAYMENT_LABEL = 'metanet payment';
|
|
29
|
+
const BRC29_PROTOCOL = BRC29_PROTOCOL_ID[1];
|
|
30
|
+
/** Internalize a §7.3 `payment` as a BRC-29 wallet payment of output 0. */
|
|
31
|
+
async function internalizeEnvelopePayment(wallet, payment, sender, memo) {
|
|
32
|
+
if (!(payment.protocol instanceof Uint8Array) ||
|
|
33
|
+
Utils.toUTF8(Array.from(payment.protocol)) !== BRC29_PROTOCOL) {
|
|
34
|
+
throw new InboxSkipError('payment protocol is not BRC-29');
|
|
35
|
+
}
|
|
36
|
+
if (!(payment.derivationPrefix instanceof Uint8Array) ||
|
|
37
|
+
!(payment.derivationSuffix instanceof Uint8Array) ||
|
|
38
|
+
!(payment.beef instanceof Uint8Array)) {
|
|
39
|
+
throw new InboxSkipError('malformed payment');
|
|
40
|
+
}
|
|
41
|
+
const beef = Beef.fromBinary(Array.from(payment.beef));
|
|
42
|
+
const txid = beef.atomicTxid ?? beef.txs[beef.txs.length - 1]?.tx?.id('hex');
|
|
43
|
+
if (!txid)
|
|
44
|
+
throw new InboxSkipError('payment beef has no transaction');
|
|
45
|
+
await wallet.internalizeAction({
|
|
46
|
+
tx: beef.toBinaryAtomic(txid),
|
|
47
|
+
outputs: [
|
|
48
|
+
{
|
|
49
|
+
outputIndex: 0,
|
|
50
|
+
protocol: 'wallet payment',
|
|
51
|
+
paymentRemittance: {
|
|
52
|
+
derivationPrefix: Utils.toBase64(Array.from(payment.derivationPrefix)),
|
|
53
|
+
derivationSuffix: Utils.toBase64(Array.from(payment.derivationSuffix)),
|
|
54
|
+
senderIdentityKey: sender,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
labels: [METANET_PAYMENT_LABEL],
|
|
59
|
+
description: (memo ? `Metanet payment: ${memo}` : 'Metanet payment').slice(0, 50),
|
|
60
|
+
});
|
|
61
|
+
return txid;
|
|
62
|
+
}
|
|
63
|
+
export const syncMetanetInbox = {
|
|
64
|
+
meta: {
|
|
65
|
+
name: 'syncMetanetInbox',
|
|
66
|
+
description: 'Collect BRC-169 handle payments (and BRC-232 deliveries) from the metanet_inbox message box and internalize them',
|
|
67
|
+
category: 'sync',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
messageboxUrl: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'MessageBox server URL (default: "https://messagebox.1sat.app")',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
requiresServices: false,
|
|
78
|
+
},
|
|
79
|
+
async execute(ctx, input) {
|
|
80
|
+
return processInbox(ctx.wallet, input.messageboxUrl, METANET_INBOX, async ({ env, sender, entity }, msg) => {
|
|
81
|
+
const type = mediaType(entity.contentType);
|
|
82
|
+
if (env.payment) {
|
|
83
|
+
if (type === TRANSACTION_CBOR_CONTENT_TYPE) {
|
|
84
|
+
throw new InboxSkipError('a payment with transaction-delivery content is not supported');
|
|
85
|
+
}
|
|
86
|
+
const memo = type === 'text/plain'
|
|
87
|
+
? Utils.toUTF8(Array.from(entity.body))
|
|
88
|
+
: undefined;
|
|
89
|
+
const txid = await internalizeEnvelopePayment(ctx.wallet, env.payment, sender, memo);
|
|
90
|
+
return {
|
|
91
|
+
messageId: msg.messageId,
|
|
92
|
+
txid,
|
|
93
|
+
sender,
|
|
94
|
+
satoshis: env.payment.satoshis,
|
|
95
|
+
memo,
|
|
96
|
+
tokenIds: [],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (type === TRANSACTION_CBOR_CONTENT_TYPE) {
|
|
100
|
+
const { txid, tokenIds } = await internalizeTransactionDelivery(ctx.wallet, entity.body);
|
|
101
|
+
return { messageId: msg.messageId, txid, sender, tokenIds };
|
|
102
|
+
}
|
|
103
|
+
throw new InboxSkipError(`nothing to internalize: no payment, content type ${entity.contentType}`);
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=receive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receive.js","sourceRoot":"","sources":["../../src/metanet/receive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AAGtE,OAAO,EAAkB,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAA;AA4BtD,MAAM,cAAc,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAE3C,2EAA2E;AAC3E,KAAK,UAAU,0BAA0B,CACxC,MAAkD,EAClD,OAAwB,EACxB,MAAc,EACd,IAAwB;IAExB,IACC,CAAC,CAAC,OAAO,CAAC,QAAQ,YAAY,UAAU,CAAC;QACzC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,cAAc,EAC5D,CAAC;QACF,MAAM,IAAI,cAAc,CAAC,gCAAgC,CAAC,CAAA;IAC3D,CAAC;IACD,IACC,CAAC,CAAC,OAAO,CAAC,gBAAgB,YAAY,UAAU,CAAC;QACjD,CAAC,CAAC,OAAO,CAAC,gBAAgB,YAAY,UAAU,CAAC;QACjD,CAAC,CAAC,OAAO,CAAC,IAAI,YAAY,UAAU,CAAC,EACpC,CAAC;QACF,MAAM,IAAI,cAAc,CAAC,mBAAmB,CAAC,CAAA;IAC9C,CAAC;IACD,MAAM,IAAI,GAA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EAAE,QAAQ,EAAE,CAAA;YAC5D,CAAC;YACD,MAAM,IAAI,cAAc,CACvB,oDAAoD,MAAM,CAAC,WAAW,EAAE,CACxE,CAAA;QACF,CAAC,CACD,CAAA;IACF,CAAC;CACD,CAAA"}
|
|
@@ -25,8 +25,9 @@ export declare function acknowledgeCborMessages(wallet: WalletInterface, message
|
|
|
25
25
|
status: string;
|
|
26
26
|
}>;
|
|
27
27
|
/**
|
|
28
|
-
* The relay calls the
|
|
29
|
-
* or a test can
|
|
28
|
+
* The relay calls the BRC-169 envelope actions make (Mandala sends, handle
|
|
29
|
+
* payments, inbox syncs), gathered in one object so a host or a test can
|
|
30
|
+
* substitute the transport.
|
|
30
31
|
*/
|
|
31
32
|
export declare const messageRelay: {
|
|
32
33
|
sendCborMessage: typeof sendCborMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/metanet/relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAA;AAMjE,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,UAAU,CAAA;CAClB;AAsBD,wBAAsB,eAAe,CACpC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAQhD;AAED,wBAAsB,gBAAgB,CACrC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,EAAE,CAAC,CAQxB;AAED,wBAAsB,uBAAuB,CAC5C,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAE7B;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAA"}
|
|
@@ -39,8 +39,9 @@ export async function acknowledgeCborMessages(wallet, messagebox, messageIds) {
|
|
|
39
39
|
return postCbor(wallet, messagebox, '/acknowledgeMessage', { messageIds });
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* The relay calls the
|
|
43
|
-
* or a test can
|
|
42
|
+
* The relay calls the BRC-169 envelope actions make (Mandala sends, handle
|
|
43
|
+
* payments, inbox syncs), gathered in one object so a host or a test can
|
|
44
|
+
* substitute the transport.
|
|
44
45
|
*/
|
|
45
46
|
export const messageRelay = {
|
|
46
47
|
sendCborMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/metanet/relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAA;AACjE,OAAO,EACN,MAAM,IAAI,aAAa,EACvB,MAAM,IAAI,aAAa,GACvB,MAAM,gBAAgB,CAAA;AASvB,KAAK,UAAU,QAAQ,CACtB,MAAuB,EACvB,UAAkB,EAClB,IAAY,EACZ,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,CAC5C,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAC1C;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EA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ED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Actions for sending BSV payments.
|
|
5
5
|
*/
|
|
6
|
+
import { type HandleResolution } from '@1sat/client';
|
|
6
7
|
import { type CreateActionArgs } from '@bsv/sdk';
|
|
7
8
|
import type { FundingProvider } from '../funding/index.js';
|
|
8
9
|
import type { Action, ActionOptions } from '../types.js';
|
|
@@ -21,8 +22,26 @@ export declare function dispatchPlainPayment(wallet: import('@bsv/sdk').WalletIn
|
|
|
21
22
|
export interface SendBsvRequest extends ActionOptions {
|
|
22
23
|
/** Destination address (P2PKH) */
|
|
23
24
|
address?: string;
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Destination paymail. Tried as a BRC-169 handle first: when the domain's
|
|
27
|
+
* `manifest.json` carries `metanet.handles` the payment goes to the handle
|
|
28
|
+
* (see {@link SendBsvRequest.handle}), otherwise by paymail as before.
|
|
29
|
+
*
|
|
30
|
+
* @deprecated Paymail is to be deprecated; use `handle`.
|
|
31
|
+
*/
|
|
25
32
|
paymail?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Destination BRC-169 handle. `@handle@domain` (optional `+tag`) is
|
|
35
|
+
* BRC-169 only. A bare `handle@domain` is BRC-169 when
|
|
36
|
+
* `https://<domain>/manifest.json` carries `metanet.handles`, and paymail
|
|
37
|
+
* otherwise. A handle payment is a BRC-29 output in a protected `noSend`
|
|
38
|
+
* action (BRC-177), delivered in a signed envelope to the handle's
|
|
39
|
+
* `metanet_inbox`; the recipient broadcasts it. It must be the only
|
|
40
|
+
* request.
|
|
41
|
+
*/
|
|
42
|
+
handle?: string;
|
|
43
|
+
/** Memo for a handle payment, sent as the envelope's `text/plain` content */
|
|
44
|
+
memo?: string;
|
|
26
45
|
/** Amount in satoshis */
|
|
27
46
|
satoshis: number;
|
|
28
47
|
/** Custom locking script (hex) */
|
|
@@ -39,8 +58,20 @@ export interface SendBsvRequest extends ActionOptions {
|
|
|
39
58
|
export interface SendBsvResponse {
|
|
40
59
|
txid?: string;
|
|
41
60
|
tx?: number[];
|
|
61
|
+
/** `envelope`: a handle payment, delivered to the handle's messagebox, not broadcast */
|
|
62
|
+
delivered?: 'envelope';
|
|
63
|
+
/** Messagebox message id of a handle payment's envelope */
|
|
64
|
+
messageId?: string;
|
|
42
65
|
error?: string;
|
|
43
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a payment recipient as a BRC-169 handle, or return undefined when
|
|
69
|
+
* it is paymail. `@handle@domain` is always a handle (resolution errors
|
|
70
|
+
* throw, no fallback); a bare `handle@domain` is a handle when
|
|
71
|
+
* `https://<domain>/manifest.json` carries `metanet.handles`, and paymail
|
|
72
|
+
* otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolvePaymentHandle(recipient: string): Promise<HandleResolution | undefined>;
|
|
44
75
|
/** Input for sendBsv action */
|
|
45
76
|
export interface SendBsvInput extends ActionOptions {
|
|
46
77
|
requests: SendBsvRequest[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,cAAc,CAAA;AAUrB,OAAO,EAGN,KAAK,gBAAgB,EAUrB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAO1D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,OAAO,UAAU,EAAE,eAAe,EAC1C,IAAI,EAAE,gBAAgB,EACtB,eAAe,CAAC,EAAE,eAAe,GAC/B,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE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