@1sat/actions 0.0.229 → 0.0.231

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 (94) hide show
  1. package/dist/apply/opnsRegister.d.ts +12 -5
  2. package/dist/apply/opnsRegister.d.ts.map +1 -1
  3. package/dist/apply/opnsRegister.js +68 -10
  4. package/dist/apply/opnsRegister.js.map +1 -1
  5. package/dist/funding/index.d.ts +1 -0
  6. package/dist/funding/index.d.ts.map +1 -1
  7. package/dist/funding/index.js +1 -1
  8. package/dist/funding/index.js.map +1 -1
  9. package/dist/funding/walletFunding.d.ts +47 -0
  10. package/dist/funding/walletFunding.d.ts.map +1 -0
  11. package/dist/funding/walletFunding.js +162 -0
  12. package/dist/funding/walletFunding.js.map +1 -0
  13. package/dist/funding/walletFunding.test.d.ts +2 -0
  14. package/dist/funding/walletFunding.test.d.ts.map +1 -0
  15. package/dist/funding/walletFunding.test.js +225 -0
  16. package/dist/funding/walletFunding.test.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/mandala/brc78.d.ts +29 -0
  22. package/dist/mandala/brc78.d.ts.map +1 -0
  23. package/dist/mandala/brc78.js +60 -0
  24. package/dist/mandala/brc78.js.map +1 -0
  25. package/dist/mandala/deploy.d.ts +89 -0
  26. package/dist/mandala/deploy.d.ts.map +1 -0
  27. package/dist/mandala/deploy.js +226 -0
  28. package/dist/mandala/deploy.js.map +1 -0
  29. package/dist/mandala/deploy.test.d.ts +2 -0
  30. package/dist/mandala/deploy.test.d.ts.map +1 -0
  31. package/dist/mandala/deploy.test.js +281 -0
  32. package/dist/mandala/deploy.test.js.map +1 -0
  33. package/dist/mandala/envelope.d.ts +69 -0
  34. package/dist/mandala/envelope.d.ts.map +1 -0
  35. package/dist/mandala/envelope.js +86 -0
  36. package/dist/mandala/envelope.js.map +1 -0
  37. package/dist/mandala/envelope.test.d.ts +2 -0
  38. package/dist/mandala/envelope.test.d.ts.map +1 -0
  39. package/dist/mandala/envelope.test.js +106 -0
  40. package/dist/mandala/envelope.test.js.map +1 -0
  41. package/dist/mandala/index.d.ts +10 -0
  42. package/dist/mandala/index.d.ts.map +1 -0
  43. package/dist/mandala/index.js +18 -0
  44. package/dist/mandala/index.js.map +1 -0
  45. package/dist/mandala/receive.d.ts +46 -0
  46. package/dist/mandala/receive.d.ts.map +1 -0
  47. package/dist/mandala/receive.js +218 -0
  48. package/dist/mandala/receive.js.map +1 -0
  49. package/dist/mandala/relay.d.ts +36 -0
  50. package/dist/mandala/relay.d.ts.map +1 -0
  51. package/dist/mandala/relay.js +50 -0
  52. package/dist/mandala/relay.js.map +1 -0
  53. package/dist/mandala/send.d.ts +74 -0
  54. package/dist/mandala/send.d.ts.map +1 -0
  55. package/dist/mandala/send.js +327 -0
  56. package/dist/mandala/send.js.map +1 -0
  57. package/dist/mandala/send.test.d.ts +2 -0
  58. package/dist/mandala/send.test.d.ts.map +1 -0
  59. package/dist/mandala/send.test.js +515 -0
  60. package/dist/mandala/send.test.js.map +1 -0
  61. package/dist/mandala/tokenId.d.ts +21 -0
  62. package/dist/mandala/tokenId.d.ts.map +1 -0
  63. package/dist/mandala/tokenId.js +29 -0
  64. package/dist/mandala/tokenId.js.map +1 -0
  65. package/dist/opns/index.d.ts +65 -4
  66. package/dist/opns/index.d.ts.map +1 -1
  67. package/dist/opns/index.js +93 -34
  68. package/dist/opns/index.js.map +1 -1
  69. package/dist/opns/registerOpns.test.d.ts +2 -0
  70. package/dist/opns/registerOpns.test.d.ts.map +1 -0
  71. package/dist/opns/registerOpns.test.js +186 -0
  72. package/dist/opns/registerOpns.test.js.map +1 -0
  73. package/dist/payments/index.d.ts +14 -0
  74. package/dist/payments/index.d.ts.map +1 -1
  75. package/dist/payments/index.js +1 -1
  76. package/dist/payments/index.js.map +1 -1
  77. package/dist/sweep/index.d.ts.map +1 -1
  78. package/dist/sweep/index.js +13 -9
  79. package/dist/sweep/index.js.map +1 -1
  80. package/dist/sweep/sweepBsv21.test.d.ts +2 -0
  81. package/dist/sweep/sweepBsv21.test.d.ts.map +1 -0
  82. package/dist/sweep/sweepBsv21.test.js +46 -0
  83. package/dist/sweep/sweepBsv21.test.js.map +1 -0
  84. package/dist/sweep/types.d.ts +2 -0
  85. package/dist/sweep/types.d.ts.map +1 -1
  86. package/dist/tokens/index.d.ts +15 -1
  87. package/dist/tokens/index.d.ts.map +1 -1
  88. package/dist/tokens/index.js +100 -17
  89. package/dist/tokens/index.js.map +1 -1
  90. package/dist/tokens/overlayFunding.test.d.ts +2 -0
  91. package/dist/tokens/overlayFunding.test.d.ts.map +1 -0
  92. package/dist/tokens/overlayFunding.test.js +116 -0
  93. package/dist/tokens/overlayFunding.test.js.map +1 -0
  94. package/package.json +8 -7
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Collect BRC-232 transaction deliveries from the wallet's `mandala_inbox`.
3
+ *
4
+ * For each message listed (BRC-231 over BRC-104): decode the BRC-169 §7.3
5
+ * DAG-CBOR envelope, verify its §7.2 signature against `sender.identityKey`,
6
+ * decrypt the BRC-78 `content` with `wallet.decrypt`, check `contentHash`,
7
+ * parse the MIME entity, require `application/vnd.metanet.transaction+cbor`,
8
+ * decode the DAG-CBOR body and internalize its outputs:
9
+ *
10
+ * - `wallet payment` → `paymentRemittance { derivationPrefix,
11
+ * derivationSuffix, senderIdentityKey }`;
12
+ * - `basket insertion` under a `mandala <txid> <vout>` protocol → basket
13
+ * `mandala <txid> <vout>`, customInstructions = the derivation triple as given,
14
+ * labels `mandala` and `mandala <txid> <vout>`, after checking that the output's
15
+ * script names that token.
16
+ *
17
+ * A message is internalized whole or not at all, and acknowledged only after
18
+ * its internalize succeeds. Anything else (an unknown content type or
19
+ * protocolID, a token id mismatch, a bad signature, …) leaves the message
20
+ * unacknowledged and is reported. SPV is `internalizeAction`'s.
21
+ */
22
+ import type { Action } from '../types.js';
23
+ export interface SyncMandalaInboxInput {
24
+ /** MessageBox server URL (default: "https://messagebox.1sat.app") */
25
+ messageboxUrl?: string;
26
+ }
27
+ /** A message left in the box, and why. */
28
+ export interface MandalaInboxSkip {
29
+ messageId: string;
30
+ reason: string;
31
+ }
32
+ /** A message internalized and acknowledged. */
33
+ export interface MandalaInboxReceipt {
34
+ messageId: string;
35
+ txid: string;
36
+ /** Tokens (BRC-36 deploy outpoints `<txid>.<vout>`) of the Mandala outputs received */
37
+ tokenIds: string[];
38
+ }
39
+ export interface SyncMandalaInboxResult {
40
+ received: MandalaInboxReceipt[];
41
+ /** Messages left unacknowledged */
42
+ skipped: MandalaInboxSkip[];
43
+ error?: string;
44
+ }
45
+ export declare const syncMandalaInbox: Action<SyncMandalaInboxInput, SyncMandalaInboxResult>;
46
+ //# sourceMappingURL=receive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive.d.ts","sourceRoot":"","sources":["../../src/mandala/receive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAuBH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMzC,MAAM,WAAW,qBAAqB;IACrC,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACd;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,uFAAuF;IACvF,QAAQ,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,mCAAmC;IACnC,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAkID,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACpC,qBAAqB,EACrB,sBAAsB,CA0GtB,CAAA"}
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Collect BRC-232 transaction deliveries from the wallet's `mandala_inbox`.
3
+ *
4
+ * For each message listed (BRC-231 over BRC-104): decode the BRC-169 §7.3
5
+ * DAG-CBOR envelope, verify its §7.2 signature against `sender.identityKey`,
6
+ * decrypt the BRC-78 `content` with `wallet.decrypt`, check `contentHash`,
7
+ * parse the MIME entity, require `application/vnd.metanet.transaction+cbor`,
8
+ * decode the DAG-CBOR body and internalize its outputs:
9
+ *
10
+ * - `wallet payment` → `paymentRemittance { derivationPrefix,
11
+ * derivationSuffix, senderIdentityKey }`;
12
+ * - `basket insertion` under a `mandala <txid> <vout>` protocol → basket
13
+ * `mandala <txid> <vout>`, customInstructions = the derivation triple as given,
14
+ * labels `mandala` and `mandala <txid> <vout>`, after checking that the output's
15
+ * script names that token.
16
+ *
17
+ * A message is internalized whole or not at all, and acknowledged only after
18
+ * its internalize succeeds. Anything else (an unknown content type or
19
+ * protocolID, a token id mismatch, a bad signature, …) leaves the message
20
+ * unacknowledged and is reported. SPV is `internalizeAction`'s.
21
+ */
22
+ import { Mandala } from '@1sat/templates';
23
+ import { MANDALA_INBOX, MANDALA_LABEL, mandalaTokenBasket, mandalaTokenLabel, parseMandalaName, } from '@1sat/types';
24
+ import { TRANSACTION_CBOR_CONTENT_TYPE, mediaType, parseMimeEntity, } from '@1sat/utils';
25
+ import { Beef, Hash, Utils, } from '@bsv/sdk';
26
+ import { decode as dagCborDecode } from '@ipld/dag-cbor';
27
+ import { decryptBrc78 } from './brc78.js';
28
+ import { decodeEnvelope, verifyEnvelope } from './envelope.js';
29
+ import { messageRelay } from './relay.js';
30
+ import { mandalaTokenOf } from './tokenId.js';
31
+ const MANDALA_PREFIX = 'mandala ';
32
+ class Skip extends Error {
33
+ }
34
+ function bytesHex(b, length, what) {
35
+ if (!(b instanceof Uint8Array) || b.length !== length) {
36
+ throw new Skip(`${what} must be ${length} bytes`);
37
+ }
38
+ return Utils.toHex(Array.from(b));
39
+ }
40
+ /** Build the internalize outputs and labels for one delivery, or throw Skip. */
41
+ function planInternalize(body) {
42
+ const txid = bytesHex(body.txid, 32, 'txid');
43
+ if (!(body.beef instanceof Uint8Array))
44
+ throw new Skip('beef must be bytes');
45
+ if (!Array.isArray(body.outputs) || body.outputs.length === 0) {
46
+ throw new Skip('outputs must be a non-empty array');
47
+ }
48
+ const beef = Beef.fromBinary(Array.from(body.beef));
49
+ const subject = beef.findTxid(txid)?.tx;
50
+ if (!subject)
51
+ throw new Skip(`beef does not contain ${txid}`);
52
+ const outputs = [];
53
+ const tokenIds = [];
54
+ const seen = new Set();
55
+ for (const entry of body.outputs) {
56
+ const outputIndex = entry.outputIndex;
57
+ if (typeof outputIndex !== 'number' ||
58
+ !subject.outputs[outputIndex] ||
59
+ seen.has(outputIndex)) {
60
+ throw new Skip(`bad outputIndex ${String(outputIndex)}`);
61
+ }
62
+ seen.add(outputIndex);
63
+ if (entry.protocol === 'wallet payment') {
64
+ if (typeof entry.derivationPrefix !== 'string' ||
65
+ typeof entry.derivationSuffix !== 'string') {
66
+ throw new Skip(`output ${outputIndex}: bad payment remittance`);
67
+ }
68
+ outputs.push({
69
+ outputIndex,
70
+ protocol: 'wallet payment',
71
+ paymentRemittance: {
72
+ derivationPrefix: entry.derivationPrefix,
73
+ derivationSuffix: entry.derivationSuffix,
74
+ senderIdentityKey: bytesHex(entry.senderIdentityKey, 33, 'senderIdentityKey'),
75
+ },
76
+ });
77
+ continue;
78
+ }
79
+ if (entry.protocol !== 'basket insertion') {
80
+ throw new Skip(`output ${outputIndex}: unknown protocol ${String(entry.protocol)}`);
81
+ }
82
+ const protocolID = entry.protocolID;
83
+ const name = Array.isArray(protocolID) ? protocolID[1] : undefined;
84
+ if (typeof name !== 'string' || !name.startsWith(MANDALA_PREFIX)) {
85
+ throw new Skip(`output ${outputIndex}: unknown protocolID ${JSON.stringify(protocolID)}`);
86
+ }
87
+ if (typeof entry.keyID !== 'string') {
88
+ throw new Skip(`output ${outputIndex}: keyID must be a string`);
89
+ }
90
+ const counterparty = bytesHex(entry.counterparty, 33, 'counterparty');
91
+ // The protocol names the token by its deploy outpoint; the script's
92
+ // BRC-162 id must name the same outpoint.
93
+ const named = parseMandalaName(name);
94
+ if (!named) {
95
+ throw new Skip(`output ${outputIndex}: malformed Mandala protocol ${name}`);
96
+ }
97
+ const tokenId = `${named.txid}.${named.vout}`;
98
+ const token = Mandala.decode(subject.outputs[outputIndex].lockingScript);
99
+ const scriptTokenId = token
100
+ ? mandalaTokenOf(token, txid, outputIndex)
101
+ : undefined;
102
+ if (scriptTokenId === undefined || scriptTokenId !== tokenId) {
103
+ throw new Skip(`output ${outputIndex}: token mismatch (protocolID ${tokenId}, script ${scriptTokenId ?? 'none'})`);
104
+ }
105
+ outputs.push({
106
+ outputIndex,
107
+ protocol: 'basket insertion',
108
+ insertionRemittance: {
109
+ basket: mandalaTokenBasket(tokenId),
110
+ customInstructions: JSON.stringify({
111
+ protocolID,
112
+ keyID: entry.keyID,
113
+ counterparty,
114
+ }),
115
+ },
116
+ });
117
+ if (!tokenIds.includes(tokenId))
118
+ tokenIds.push(tokenId);
119
+ }
120
+ const labels = tokenIds.length
121
+ ? [MANDALA_LABEL, ...tokenIds.map(mandalaTokenLabel)]
122
+ : [];
123
+ return { txid, tx: beef.toBinaryAtomic(txid), outputs, labels, tokenIds };
124
+ }
125
+ export const syncMandalaInbox = {
126
+ meta: {
127
+ name: 'syncMandalaInbox',
128
+ description: 'Collect BRC-232 transaction deliveries (Mandala tokens, BRC-29 payments) from the mandala_inbox message box and internalize them',
129
+ category: 'sync',
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ messageboxUrl: {
134
+ type: 'string',
135
+ description: 'MessageBox server URL (default: "https://messagebox.1sat.app")',
136
+ },
137
+ },
138
+ },
139
+ requiresServices: false,
140
+ },
141
+ async execute(ctx, input) {
142
+ const messagebox = input.messageboxUrl?.replace(/\/+$/, '') || 'https://messagebox.1sat.app';
143
+ const received = [];
144
+ const skipped = [];
145
+ const acknowledged = [];
146
+ let messages;
147
+ try {
148
+ messages = await messageRelay.listCborMessages(ctx.wallet, messagebox, MANDALA_INBOX);
149
+ }
150
+ catch (error) {
151
+ return {
152
+ received,
153
+ skipped,
154
+ error: error instanceof Error ? error.message : String(error),
155
+ };
156
+ }
157
+ for (const msg of messages) {
158
+ try {
159
+ let env;
160
+ try {
161
+ env = decodeEnvelope(msg.body);
162
+ }
163
+ catch {
164
+ throw new Skip('not a DAG-CBOR BRC-169 envelope');
165
+ }
166
+ if (!(await verifyEnvelope(env))) {
167
+ throw new Skip('envelope signature does not verify');
168
+ }
169
+ const sender = bytesHex(env.sender.identityKey, 33, 'sender');
170
+ const plaintext = await decryptBrc78(ctx.wallet, env.content, sender);
171
+ if (env.contentHash !== undefined &&
172
+ Utils.toHex(Hash.sha256(plaintext)) !==
173
+ Utils.toHex(Array.from(env.contentHash))) {
174
+ throw new Skip('contentHash does not match the content');
175
+ }
176
+ const entity = parseMimeEntity(plaintext);
177
+ if (mediaType(entity.contentType) !== TRANSACTION_CBOR_CONTENT_TYPE) {
178
+ throw new Skip(`unsupported content type ${entity.contentType}`);
179
+ }
180
+ const plan = planInternalize(dagCborDecode(entity.body));
181
+ await ctx.wallet.internalizeAction({
182
+ tx: plan.tx,
183
+ outputs: plan.outputs,
184
+ ...(plan.labels.length && { labels: plan.labels }),
185
+ description: plan.tokenIds.length
186
+ ? 'Receive Mandala tokens'
187
+ : 'Receive delivered outputs',
188
+ });
189
+ acknowledged.push(msg.messageId);
190
+ received.push({
191
+ messageId: msg.messageId,
192
+ txid: plan.txid,
193
+ tokenIds: plan.tokenIds,
194
+ });
195
+ }
196
+ catch (error) {
197
+ skipped.push({
198
+ messageId: msg.messageId,
199
+ reason: error instanceof Error ? error.message : String(error),
200
+ });
201
+ }
202
+ }
203
+ if (acknowledged.length > 0) {
204
+ try {
205
+ await messageRelay.acknowledgeCborMessages(ctx.wallet, messagebox, acknowledged);
206
+ }
207
+ catch (error) {
208
+ return {
209
+ received,
210
+ skipped,
211
+ error: `acknowledge-failed: ${error instanceof Error ? error.message : String(error)}`,
212
+ };
213
+ }
214
+ }
215
+ return { received, skipped };
216
+ },
217
+ };
218
+ //# sourceMappingURL=receive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive.js","sourceRoot":"","sources":["../../src/mandala/receive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EACN,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,6BAA6B,EAC7B,SAAS,EACT,eAAe,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,IAAI,EACJ,IAAI,EAEJ,KAAK,GAEL,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAoB,YAAY,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAoC7C,MAAM,cAAc,GAAG,UAAU,CAAA;AAEjC,MAAM,IAAK,SAAQ,KAAK;CAAG;AAE3B,SAAS,QAAQ,CAAC,CAAU,EAAE,MAAc,EAAE,IAAY;IACzD,IAAI,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACvD,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,YAAY,MAAM,QAAQ,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,KAAK,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AAC,KAAK,CAAC,EAAE;iBACtF,CAAA;YACF,CAAC;QACF,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;IAC7B,CAAC;CACD,CAAA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * BRC-33 message relay in the BRC-231 binary encoding, over BRC-104
3
+ * (AuthFetch): requests and responses are DAG-CBOR, the message body and
4
+ * identity keys are byte strings.
5
+ *
6
+ * - `POST /sendMessage` `{ message: { recipient: bstr(33), messageBox, body: bstr } }`
7
+ * → `{ status, messageId }`
8
+ * - `POST /listMessages` `{ messageBox }`
9
+ * → `{ status, messages: [ { messageId, body: bstr, sender: bstr(33) } ] }`
10
+ * - `POST /acknowledgeMessage` `{ messageIds }` → `{ status }`
11
+ */
12
+ import { type WalletInterface } from '@bsv/sdk';
13
+ /** A listed BRC-231 message. */
14
+ export interface CborMessage {
15
+ messageId: string;
16
+ body: Uint8Array;
17
+ sender: Uint8Array;
18
+ }
19
+ export declare function sendCborMessage(wallet: WalletInterface, messagebox: string, recipient: string, messageBox: string, body: Uint8Array): Promise<{
20
+ status: string;
21
+ messageId: string;
22
+ }>;
23
+ export declare function listCborMessages(wallet: WalletInterface, messagebox: string, messageBox: string): Promise<CborMessage[]>;
24
+ export declare function acknowledgeCborMessages(wallet: WalletInterface, messagebox: string, messageIds: string[]): Promise<{
25
+ status: string;
26
+ }>;
27
+ /**
28
+ * The relay calls the Mandala actions make, gathered in one object so a host
29
+ * or a test can substitute the transport.
30
+ */
31
+ export declare const messageRelay: {
32
+ sendCborMessage: typeof sendCborMessage;
33
+ listCborMessages: typeof listCborMessages;
34
+ acknowledgeCborMessages: typeof acknowledgeCborMessages;
35
+ };
36
+ //# sourceMappingURL=relay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/mandala/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;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAA"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * BRC-33 message relay in the BRC-231 binary encoding, over BRC-104
3
+ * (AuthFetch): requests and responses are DAG-CBOR, the message body and
4
+ * identity keys are byte strings.
5
+ *
6
+ * - `POST /sendMessage` `{ message: { recipient: bstr(33), messageBox, body: bstr } }`
7
+ * → `{ status, messageId }`
8
+ * - `POST /listMessages` `{ messageBox }`
9
+ * → `{ status, messages: [ { messageId, body: bstr, sender: bstr(33) } ] }`
10
+ * - `POST /acknowledgeMessage` `{ messageIds }` → `{ status }`
11
+ */
12
+ import { AuthFetch, Utils } from '@bsv/sdk';
13
+ import { decode as dagCborDecode, encode as dagCborEncode, } from '@ipld/dag-cbor';
14
+ async function postCbor(wallet, messagebox, path, request) {
15
+ const res = await new AuthFetch(wallet).fetch(`${messagebox.replace(/\/+$/, '')}${path}`, {
16
+ method: 'POST',
17
+ headers: { 'Content-Type': 'application/cbor' },
18
+ body: dagCborEncode(request),
19
+ });
20
+ if (!res.ok) {
21
+ throw new Error(`${path.slice(1)} ${res.status}`);
22
+ }
23
+ return dagCborDecode(new Uint8Array(await res.arrayBuffer()));
24
+ }
25
+ export async function sendCborMessage(wallet, messagebox, recipient, messageBox, body) {
26
+ return postCbor(wallet, messagebox, '/sendMessage', {
27
+ message: {
28
+ recipient: Uint8Array.from(Utils.toArray(recipient, 'hex')),
29
+ messageBox,
30
+ body,
31
+ },
32
+ });
33
+ }
34
+ export async function listCborMessages(wallet, messagebox, messageBox) {
35
+ const res = await postCbor(wallet, messagebox, '/listMessages', { messageBox });
36
+ return res.messages ?? [];
37
+ }
38
+ export async function acknowledgeCborMessages(wallet, messagebox, messageIds) {
39
+ return postCbor(wallet, messagebox, '/acknowledgeMessage', { messageIds });
40
+ }
41
+ /**
42
+ * The relay calls the Mandala actions make, gathered in one object so a host
43
+ * or a test can substitute the transport.
44
+ */
45
+ export const messageRelay = {
46
+ sendCborMessage,
47
+ listCborMessages,
48
+ acknowledgeCborMessages,
49
+ };
50
+ //# sourceMappingURL=relay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/mandala/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,EA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AC,MAAM,YAAY,GAAG;IAC3B,eAAe;IACf,gBAAgB;IAChB,uBAAuB;CACvB,CAAA"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Mandala (BRC-162) send to a BRC-169 handle, delivered per BRC-232.
3
+ *
4
+ * 1. Resolve the handle (`resolveHandle`): identity key + messagebox.
5
+ * 2. When no single token output in `mandala <txid> <vout>` holds exactly `amount`,
6
+ * split first: an ordinary, broadcast action spending token outputs into
7
+ * an exact-`amount` output and a remainder, both back to the wallet under
8
+ * `mandalaProtocol(tokenId)` in the token's basket.
9
+ * 3. The protected send: one `createAction` spending only the exact output,
10
+ * with one output, the recipient's token output, locked to the key
11
+ * derived under `mandalaProtocol(tokenId)` with keyID
12
+ * `<derivationPrefix> <derivationSuffix>` (fresh random base64) and
13
+ * counterparty = the recipient. `noSend`, labels `mandala`,
14
+ * `mandala <txid> <vout>` and `p nosend expiry seconds <n>` (BRC-177; the wallet
15
+ * funds it). It is not broadcast: the recipient broadcasts by
16
+ * internalizing (BRC-169 §6.1, BRC-232 rule 4).
17
+ * 4. Delivery: a signed BRC-169 §7.3 envelope (DAG-CBOR, BRC-231 body over
18
+ * BRC-104) to the resolved messagebox, box `mandala_inbox`, `payment:
19
+ * null`. `content` is BRC-78 encryption (via `wallet.encrypt`) of a MIME
20
+ * entity of type `application/vnd.metanet.transaction+cbor` whose DAG-CBOR
21
+ * body is the BRC-232 delivery `{ txid, beef, outputs: [ basket insertion
22
+ * ] }`; `contentHash` is the SHA-256 of the MIME bytes.
23
+ *
24
+ * When delivery fails the result carries the error with `txid` and `tx`, so
25
+ * the caller can retry delivery or `abortAction` the send.
26
+ */
27
+ import { type WalletProtocol } from '@bsv/sdk';
28
+ import type { Action } from '../types.js';
29
+ export interface SendMandalaInput {
30
+ /** Token: the deploy outpoint, BRC-36 `<txid>.<vout>` (`<txid>_<vout>` accepted) */
31
+ tokenId: string;
32
+ /** Amount in raw units */
33
+ amount: bigint | string;
34
+ /** BRC-169 handle: `@handle@domain` or `handle@domain` */
35
+ destination: {
36
+ handle: string;
37
+ };
38
+ /**
39
+ * BRC-177 `nosend expiry seconds` for the protected send (default
40
+ * {@link MANDALA_SEND_EXPIRY_SECONDS}, one year).
41
+ */
42
+ expirySeconds?: number;
43
+ /** Optional free text carried as the BRC-232 `memo` */
44
+ memo?: string;
45
+ }
46
+ export interface SendMandalaResult {
47
+ txid?: string;
48
+ /** Atomic BEEF of the send */
49
+ tx?: number[];
50
+ /** `envelope`: BRC-169 envelope to the handle's messagebox, not broadcast */
51
+ delivered?: 'envelope';
52
+ /** Messagebox message id */
53
+ messageId?: string;
54
+ error?: string;
55
+ }
56
+ /** A BRC-232 `basket insertion` output entry. */
57
+ export interface MandalaDeliveryOutput {
58
+ outputIndex: number;
59
+ protocol: 'basket insertion';
60
+ protocolID: WalletProtocol;
61
+ keyID: string;
62
+ /** bstr(33): the key the recipient derives against (the sender's identity) */
63
+ counterparty: Uint8Array;
64
+ }
65
+ /** The BRC-232 DAG-CBOR body a Mandala send delivers. */
66
+ export interface MandalaDeliveryBody {
67
+ memo?: string;
68
+ /** bstr(32), display byte order (as in the BRC-95 Atomic BEEF header) */
69
+ txid: Uint8Array;
70
+ beef: Uint8Array;
71
+ outputs: MandalaDeliveryOutput[];
72
+ }
73
+ export declare const sendMandala: Action<SendMandalaInput, SendMandalaResult>;
74
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/mandala/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAaH,OAAO,EAQN,KAAK,cAAc,EACnB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAA;AAYxD,MAAM,WAAW,gBAAgB;IAChC,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAA;IACf,0BAA0B;IAC1B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB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