@1sat/wallet-server 0.0.28 → 0.0.31

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 (49) hide show
  1. package/dist/createHostServer.d.ts +44 -0
  2. package/dist/createHostServer.d.ts.map +1 -0
  3. package/dist/createHostServer.js +187 -0
  4. package/dist/createHostServer.js.map +1 -0
  5. package/dist/createWalletServer.d.ts +15 -1
  6. package/dist/createWalletServer.d.ts.map +1 -1
  7. package/dist/createWalletServer.js +28 -6
  8. package/dist/createWalletServer.js.map +1 -1
  9. package/dist/hosting/client.d.ts +31 -0
  10. package/dist/hosting/client.d.ts.map +1 -0
  11. package/dist/hosting/client.js +45 -0
  12. package/dist/hosting/client.js.map +1 -0
  13. package/dist/hosting/routes.d.ts +25 -0
  14. package/dist/hosting/routes.d.ts.map +1 -0
  15. package/dist/hosting/routes.js +238 -0
  16. package/dist/hosting/routes.js.map +1 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +6 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/paymail/destination.d.ts +14 -0
  22. package/dist/paymail/destination.d.ts.map +1 -0
  23. package/dist/paymail/destination.js +48 -0
  24. package/dist/paymail/destination.js.map +1 -0
  25. package/dist/paymail/entitlement.d.ts +15 -0
  26. package/dist/paymail/entitlement.d.ts.map +1 -0
  27. package/dist/paymail/entitlement.js +30 -0
  28. package/dist/paymail/entitlement.js.map +1 -0
  29. package/dist/paymail/messagebox.d.ts +25 -0
  30. package/dist/paymail/messagebox.d.ts.map +1 -0
  31. package/dist/paymail/messagebox.js +55 -0
  32. package/dist/paymail/messagebox.js.map +1 -0
  33. package/dist/paymail/pending.d.ts +19 -0
  34. package/dist/paymail/pending.d.ts.map +1 -0
  35. package/dist/paymail/pending.js +90 -0
  36. package/dist/paymail/pending.js.map +1 -0
  37. package/dist/paymail/resolve.d.ts +12 -0
  38. package/dist/paymail/resolve.d.ts.map +1 -0
  39. package/dist/paymail/resolve.js +72 -0
  40. package/dist/paymail/resolve.js.map +1 -0
  41. package/dist/paymail/routes.d.ts +8 -0
  42. package/dist/paymail/routes.d.ts.map +1 -0
  43. package/dist/paymail/routes.js +152 -0
  44. package/dist/paymail/routes.js.map +1 -0
  45. package/dist/paymail/types.d.ts +48 -0
  46. package/dist/paymail/types.d.ts.map +1 -0
  47. package/dist/paymail/types.js +2 -0
  48. package/dist/paymail/types.js.map +1 -0
  49. package/package.json +61 -57
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Resolve OpNS alias → identity via tip UTXO PushDrop bind.
3
+ */
4
+ import { OneSatServices } from '@1sat/client';
5
+ import { LockingScript, Transaction } from '@bsv/sdk';
6
+ import type { ResolvedBind } from './types';
7
+ /**
8
+ * Load tip locking script for alias, verify PushDrop bind, return identity key.
9
+ */
10
+ export declare function resolvePaymailBind(services: OneSatServices, alias: string): Promise<ResolvedBind>;
11
+ export declare function verifyPushDropBind(tx: Transaction, vout: number, lockingScript: LockingScript): Promise<string>;
12
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/paymail/resolve.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EACN,aAAa,EAGb,WAAW,EAEX,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAY3C;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,CAavB;AAED,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,aAAa,GAC1B,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Resolve OpNS alias → identity via tip UTXO PushDrop bind.
3
+ */
4
+ import { P1SAT_PROTOCOL, opnsRegisterKeyId } from '@1sat/types';
5
+ import { ProtoWallet, PushDrop, Transaction, Utils, } from '@bsv/sdk';
6
+ function parseOutpoint(outpoint) {
7
+ const normalized = outpoint.replace('_', '.');
8
+ const [txid, voutStr] = normalized.split('.');
9
+ const vout = Number(voutStr);
10
+ if (!txid || !Number.isFinite(vout)) {
11
+ throw new Error(`invalid outpoint: ${outpoint}`);
12
+ }
13
+ return { txid, vout };
14
+ }
15
+ /**
16
+ * Load tip locking script for alias, verify PushDrop bind, return identity key.
17
+ */
18
+ export async function resolvePaymailBind(services, alias) {
19
+ const { outpoint } = await services.opns.getOrigin(alias);
20
+ const { txid, vout } = parseOutpoint(outpoint);
21
+ const beefBytes = await services.beef.getBeef(txid);
22
+ const tx = Transaction.fromBEEF(Array.from(beefBytes));
23
+ const output = tx.outputs[vout];
24
+ if (!output?.lockingScript) {
25
+ throw new Error(`no output at ${outpoint}`);
26
+ }
27
+ const identityKey = await verifyPushDropBind(tx, vout, output.lockingScript);
28
+ return { identityKey, outpoint: `${txid}.${vout}` };
29
+ }
30
+ export async function verifyPushDropBind(tx, vout, lockingScript) {
31
+ const decoded = PushDrop.decode(lockingScript);
32
+ if (decoded.fields.length < 2) {
33
+ throw new Error('not a signed PushDrop bind');
34
+ }
35
+ const fields = decoded.fields.map((f) => [...f]);
36
+ const signature = fields.pop();
37
+ const idKeyBytes = fields[0];
38
+ if (!idKeyBytes?.length) {
39
+ throw new Error('missing identity field');
40
+ }
41
+ const identityKey = Utils.toHex(idKeyBytes);
42
+ const input = tx.inputs[0];
43
+ const sourceTxid = input.sourceTXID ?? input.sourceTransaction?.id('hex') ?? '';
44
+ const sourceVout = input.sourceOutputIndex;
45
+ if (!sourceTxid) {
46
+ throw new Error('missing creation input outpoint');
47
+ }
48
+ const keyID = opnsRegisterKeyId(`${sourceTxid}.${sourceVout}`);
49
+ const anyone = new ProtoWallet('anyone');
50
+ const { publicKey: expectedLockPub } = await anyone.getPublicKey({
51
+ protocolID: P1SAT_PROTOCOL,
52
+ keyID,
53
+ counterparty: identityKey,
54
+ forSelf: true,
55
+ });
56
+ if (expectedLockPub !== decoded.lockingPublicKey.toString()) {
57
+ throw new Error('lock pubkey does not match bind derivation');
58
+ }
59
+ const data = fields.reduce((a, e) => [...a, ...e], []);
60
+ const { valid } = await anyone.verifySignature({
61
+ data,
62
+ signature,
63
+ protocolID: P1SAT_PROTOCOL,
64
+ keyID,
65
+ counterparty: identityKey,
66
+ });
67
+ if (!valid) {
68
+ throw new Error('invalid PushDrop field signature');
69
+ }
70
+ return identityKey;
71
+ }
72
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/paymail/resolve.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAEN,WAAW,EACX,QAAQ,EACR,WAAW,EACX,KAAK,GACL,MAAM,UAAU,CAAA;AAGjB,SAAS,aAAa,CAAC,QAAgB;IACtC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC5B,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,Q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AAe,CAAC;QAC9C,IAAI;QACJ,SAAS;QACT,UAAU,EAAE,cAAc;QAC1B,KAAK;QACL,YAAY,EAAE,WAAW;KACzB,CAAC,CAAA;IACF,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,WAAW,CAAA;AACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Mount bsvalias surface on the host app using @bsv/paymail PaymailRouter.
3
+ * Public routes — no BRC-100 auth. Mounted before auth-scoped surfaces.
4
+ */
5
+ import type { Express } from 'express';
6
+ import type { PaymailDeps } from './types';
7
+ export declare function mountPaymailRoutes(app: Express, deps: PaymailDeps): Promise<void>;
8
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/paymail/routes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAA;AAS1D,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAkJf"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Mount bsvalias surface on the host app using @bsv/paymail PaymailRouter.
3
+ * Public routes — no BRC-100 auth. Mounted before auth-scoped surfaces.
4
+ */
5
+ import { OneSatServices } from '@1sat/client';
6
+ import { PaymailRouter, PublicKeyInfrastructureRoute, PublicProfileRoute, P2pPaymentDestinationRoute, ReceiveBeefTransactionRoute, ReceiveTransactionRoute, PaymailClient, } from '@bsv/paymail';
7
+ import { Transaction, Utils } from '@bsv/sdk';
8
+ import { createPaymentDestination, verifyPaymentOutputs } from './destination';
9
+ import { checkHostingEntitlement } from './entitlement';
10
+ import { MessageBoxClient } from './messagebox';
11
+ import { resolvePaymailBind } from './resolve';
12
+ class NotFoundError extends Error {
13
+ constructor(message = 'paymail not found') {
14
+ super(message);
15
+ this.name = 'NotFoundError';
16
+ }
17
+ }
18
+ export async function mountPaymailRoutes(app, deps) {
19
+ const services = new OneSatServices('main', deps.stackUrl);
20
+ const gateOn = deps.requireEntitlement === true && deps.hostWallet != null;
21
+ const messageBox = deps.messageboxUrl && deps.hostPrivateKey
22
+ ? MessageBoxClient.fromPrivateKey(deps.messageboxUrl, deps.hostPrivateKey)
23
+ : null;
24
+ if (deps.messageboxUrl && !deps.hostPrivateKey) {
25
+ console.warn('[paymail] messageboxUrl set without hostPrivateKey — inbox delivery disabled');
26
+ }
27
+ async function resolveAndAuthorize(alias) {
28
+ try {
29
+ const bind = await resolvePaymailBind(services, alias);
30
+ if (gateOn && deps.hostWallet) {
31
+ const ent = await checkHostingEntitlement(deps.hostWallet, bind.identityKey);
32
+ if (!ent.active)
33
+ throw new NotFoundError();
34
+ }
35
+ return bind;
36
+ }
37
+ catch (err) {
38
+ if (err instanceof NotFoundError)
39
+ throw err;
40
+ throw new NotFoundError();
41
+ }
42
+ }
43
+ const paymailClient = new PaymailClient();
44
+ const router = new PaymailRouter({
45
+ baseUrl: deps.baseUrl,
46
+ basePath: '/bsvalias',
47
+ routes: [
48
+ new PublicKeyInfrastructureRoute({
49
+ domainLogicHandler: async (params) => {
50
+ const { name, domain } = PublicKeyInfrastructureRoute.getNameAndDomain(params);
51
+ const bind = await resolveAndAuthorize(name);
52
+ return {
53
+ bsvalias: '1.0',
54
+ handle: `${name}@${domain}`,
55
+ pubkey: bind.identityKey,
56
+ };
57
+ },
58
+ }),
59
+ new PublicProfileRoute({
60
+ domainLogicHandler: async (params) => {
61
+ const { name } = PublicProfileRoute.getNameAndDomain(params);
62
+ return { name, avatar: '' };
63
+ },
64
+ }),
65
+ new P2pPaymentDestinationRoute({
66
+ domainLogicHandler: async (params, body) => {
67
+ const { name, domain } = P2pPaymentDestinationRoute.getNameAndDomain(params);
68
+ const bind = await resolveAndAuthorize(name);
69
+ const pending = await createPaymentDestination(deps.pendingStore, {
70
+ alias: name,
71
+ domain,
72
+ identityPubKey: bind.identityKey,
73
+ satoshis: Number(body.satoshis ?? 0),
74
+ ttlMs: deps.pendingTtlMs,
75
+ });
76
+ return {
77
+ reference: pending.reference,
78
+ outputs: [
79
+ { satoshis: pending.satoshis, script: pending.outputScript },
80
+ ],
81
+ };
82
+ },
83
+ }),
84
+ new ReceiveBeefTransactionRoute({
85
+ verifySignature: false,
86
+ paymailClient,
87
+ domainLogicHandler: async (params, body) => {
88
+ const beefBytes = Utils.toArray(body.beef, 'hex');
89
+ const tx = Transaction.fromAtomicBEEF(beefBytes);
90
+ return finishReceive(tx, beefBytes, body.reference);
91
+ },
92
+ }),
93
+ new ReceiveTransactionRoute({
94
+ verifySignature: false,
95
+ paymailClient,
96
+ domainLogicHandler: async (params, body) => {
97
+ const tx = Transaction.fromHex(body.hex);
98
+ await populateAncestors(tx);
99
+ const beefBytes = tx.toAtomicBEEF();
100
+ return finishReceive(tx, beefBytes, body.reference);
101
+ },
102
+ }),
103
+ ],
104
+ errorHandler: (err, _req, res, next) => {
105
+ if (err instanceof NotFoundError) {
106
+ return res.status(404).json({ error: 'paymail not found' });
107
+ }
108
+ next(err);
109
+ },
110
+ });
111
+ async function populateAncestors(tx) {
112
+ for (const input of tx.inputs) {
113
+ if (input.sourceTransaction)
114
+ continue;
115
+ const sourceTxid = input.sourceTXID;
116
+ if (!sourceTxid)
117
+ throw new Error('input missing sourceTXID');
118
+ const beefBytes = await services.beef.getBeef(sourceTxid);
119
+ input.sourceTransaction = Transaction.fromBEEF(Array.from(beefBytes));
120
+ }
121
+ }
122
+ async function finishReceive(tx, beefBytes, reference) {
123
+ const pending = await deps.pendingStore.get(reference);
124
+ if (!pending)
125
+ throw new NotFoundError('destination not found or expired');
126
+ const scripts = tx.outputs.map((o) => o.lockingScript.toHex());
127
+ const sats = tx.outputs.map((o) => o.satoshis ?? 0);
128
+ const outputIndex = verifyPaymentOutputs(scripts, sats, pending);
129
+ const status = await services.submitToStack(new Uint8Array(beefBytes));
130
+ if (isRejected(status.txStatus)) {
131
+ throw new Error('transaction rejected by network');
132
+ }
133
+ const txid = status.txid || tx.id('hex');
134
+ pending.txid = txid;
135
+ await deps.pendingStore.update(pending);
136
+ if (messageBox) {
137
+ try {
138
+ await messageBox.deliverPayment(Utils.toHex(beefBytes), outputIndex, pending);
139
+ }
140
+ catch (err) {
141
+ console.error('[paymail] messagebox delivery failed', err);
142
+ throw new Error('failed to process payment');
143
+ }
144
+ }
145
+ return { txid, note: 'Payment received' };
146
+ }
147
+ app.use(router.getRouter());
148
+ }
149
+ function isRejected(txStatus) {
150
+ return ['REJECTED', 'INVALID', 'DOUBLE_SPEND_ATTEMPTED'].includes(txStatus?.toUpperCase?.() ?? '');
151
+ }
152
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/paymail/routes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EACN,aAAa,EACb,4BAA4B,EAC5B,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,GACb,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAE7C,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAG9C,MAAM,aAAc,SAAQ,KAAK;IAChC,YAAY,OAAO,GAAG,mBAAmB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,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QAAQ,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;QACtE,IAAI,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACnD,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;QACxC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;QACnB,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAEvC,IAAI,UAAU,EAAE,CAAC;YAChB,IAAI,CAAC;gBACJ,MAAM,UAAU,CAAC,cAAc,CAC9B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EACtB,WAAW,EACX,OAAO,CACP,CAAA;YACF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAA;gBAC1D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;YAC7C,CAAC;QACF,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAA;IAC1C,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;AAC5B,CAAC;AAED,SAAS,UAAU,CAAC,QAA4B;IAC/C,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,CAAC,CAAC,QAAQ,CAChE,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,CAC/B,CAAA;AACF,CAAC"}
@@ -0,0 +1,48 @@
1
+ export interface PendingPayment {
2
+ reference: string;
3
+ alias: string;
4
+ domain: string;
5
+ identityPubKey: string;
6
+ derivationPrefix: string;
7
+ derivationSuffix: string;
8
+ satoshis: number;
9
+ outputScript: string;
10
+ txid?: string;
11
+ createdAt: Date;
12
+ expiresAt: Date;
13
+ }
14
+ export interface PendingStore {
15
+ create(p: PendingPayment): Promise<void>;
16
+ get(reference: string): Promise<PendingPayment | null>;
17
+ update(p: PendingPayment): Promise<void>;
18
+ delete(reference: string): Promise<void>;
19
+ }
20
+ export interface ResolvedBind {
21
+ identityKey: string;
22
+ outpoint: string;
23
+ }
24
+ export interface PaymailDeps {
25
+ /** Public base URL for capability document (e.g. https://1sat.app) */
26
+ baseUrl: string;
27
+ /** Stack root URL (OpNS, beef, tx broadcast) */
28
+ stackUrl: string;
29
+ /** In-flight payment refs store */
30
+ pendingStore: PendingStore;
31
+ /** Pending TTL ms (default 15m) */
32
+ pendingTtlMs?: number;
33
+ /**
34
+ * Host wallet for subscription receipt checks + messagebox AuthFetch.
35
+ * Gate is on when requireEntitlement is true.
36
+ */
37
+ hostWallet?: import('@bsv/sdk').WalletInterface;
38
+ requireEntitlement?: boolean;
39
+ /**
40
+ * Messagebox URL for payment_inbox delivery after receive.
41
+ * When unified with messagebox on the same app, point at this server's
42
+ * own public (or loopback) URL. Unset = skip delivery.
43
+ */
44
+ messageboxUrl?: string;
45
+ /** Host private key for messagebox AuthFetch (required if messageboxUrl set) */
46
+ hostPrivateKey?: import('@bsv/sdk').PrivateKey;
47
+ }
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paymail/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACtD,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxC;AAED,MAAM,WAAW,YAAY;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC3B,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAA;IACf,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,YAAY,EAAE,YAAY,CAAA;IAC1B,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,UAAU,EAAE,eAAe,CAAA;IAC/C,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gFAAgF;IAChF,cAAc,CAAC,EAAE,OAAO,UAAU,EAAE,UAAU,CAAA;CAC9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paymail/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,59 +1,63 @@
1
1
  {
2
- "name": "@1sat/wallet-server",
3
- "version": "0.0.28",
4
- "description": "BRC-100 wallet storage RPC server for 1Sat Ordinals SDK",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
13
- },
14
- "files": [
15
- "dist"
16
- ],
17
- "scripts": {
18
- "build": "tsc",
19
- "dev": "tsc --watch",
20
- "clean": "rm -rf dist",
21
- "test": "bun test"
22
- },
23
- "keywords": [
24
- "1sat",
25
- "bsv",
26
- "ordinals",
27
- "wallet",
28
- "server",
29
- "rpc",
30
- "brc-100"
31
- ],
32
- "license": "MIT",
33
- "dependencies": {
34
- "@1sat/client": "0.0.43",
35
- "@1sat/wallet": "0.0.93",
36
- "evlog": "^2.13.0",
37
- "express": "^4.21.2"
38
- },
39
- "peerDependencies": {
40
- "@bsv/auth-express-middleware": "^2.0.4",
41
- "@bsv/sdk": "^2.1.6",
42
- "@bsv/wallet-toolbox": "2.1.24",
43
- "knex": "^3.1.0"
44
- },
45
- "peerDependenciesMeta": {
46
- "pg": {
47
- "optional": true
48
- }
49
- },
50
- "devDependencies": {
51
- "@bsv/auth-express-middleware": "^2.0.4",
52
- "@bsv/sdk": "^2.1.6",
53
- "@bsv/wallet-toolbox": "2.1.24",
54
- "@types/bun": "^1.3.10",
55
- "@types/express": "^4.17.21",
56
- "knex": "^3.1.0",
57
- "typescript": "^5.9.3"
58
- }
2
+ "name": "@1sat/wallet-server",
3
+ "version": "0.0.31",
4
+ "description": "BRC-100 wallet storage RPC server for 1Sat Ordinals SDK",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "clean": "rm -rf dist",
21
+ "test": "bun test"
22
+ },
23
+ "keywords": [
24
+ "1sat",
25
+ "bsv",
26
+ "ordinals",
27
+ "wallet",
28
+ "server",
29
+ "rpc",
30
+ "brc-100"
31
+ ],
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@1sat/client": "0.0.45",
35
+ "@1sat/types": "0.0.36",
36
+ "@1sat/wallet": "0.0.96",
37
+ "evlog": "^2.13.0",
38
+ "express": "^4.21.2",
39
+ "@bopen-io/messagebox-server": "^1.3.2"
40
+ },
41
+ "peerDependencies": {
42
+ "@bsv/auth-express-middleware": "^2.0.4",
43
+ "@bsv/sdk": "^2.1.6",
44
+ "@bsv/wallet-toolbox": "2.1.24",
45
+ "knex": "^3.1.0",
46
+ "@bsv/paymail": "^2.4.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "pg": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "devDependencies": {
54
+ "@bsv/auth-express-middleware": "^2.0.4",
55
+ "@bsv/sdk": "^2.1.6",
56
+ "@bsv/wallet-toolbox": "2.1.24",
57
+ "@types/bun": "^1.3.10",
58
+ "@types/express": "^4.17.21",
59
+ "knex": "^3.1.0",
60
+ "typescript": "^5.9.3",
61
+ "@bsv/paymail": "^2.4.0"
62
+ }
59
63
  }