@attocash/cli 0.6.0 → 0.7.0
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/application/app.d.ts +3 -1
- package/dist/application/app.js +23 -19
- package/dist/application/operations.d.ts +0 -1
- package/dist/application/operations.js +1 -7
- package/dist/cli/cli.js +4 -21
- package/dist/internal-marketplace.d.ts +2 -11
- package/dist/internal-marketplace.js +6 -13
- package/dist/marketplace/approval-preview.js +5 -20
- package/dist/marketplace/connection.d.ts +43 -0
- package/dist/marketplace/{topups.js → connection.js} +18 -213
- package/dist/marketplace/proof-approval.d.ts +1 -1
- package/dist/marketplace/proof-approval.js +10 -119
- package/dist/marketplace/relay.d.ts +58 -0
- package/dist/marketplace/relay.js +122 -0
- package/dist/marketplace/strict-json.d.ts +2 -0
- package/dist/marketplace/strict-json.js +96 -0
- package/dist/spending/atto-x402.d.ts +2 -0
- package/dist/spending/atto-x402.js +1 -1
- package/dist/spending/journal.d.ts +9 -0
- package/dist/spending/journal.js +11 -0
- package/dist/spending/ledger.d.ts +11 -3
- package/dist/spending/ledger.js +42 -7
- package/dist/spending/payments.d.ts +9 -36
- package/dist/spending/payments.js +253 -817
- package/dist/wallet/signing.d.ts +3 -1
- package/dist/wallet/signing.js +25 -17
- package/package.json +1 -1
- package/dist/marketplace/topups.d.ts +0 -82
|
@@ -24,7 +24,7 @@ export declare class AttoApplication {
|
|
|
24
24
|
private preparation?;
|
|
25
25
|
private readonly preparationAbort;
|
|
26
26
|
private readonly payments;
|
|
27
|
-
private readonly
|
|
27
|
+
private readonly marketplaceConnection;
|
|
28
28
|
private watchManager?;
|
|
29
29
|
private watchConfiguration;
|
|
30
30
|
private watchQueue;
|
|
@@ -148,6 +148,8 @@ export declare class AttoApplication {
|
|
|
148
148
|
private withWatches;
|
|
149
149
|
private invoke;
|
|
150
150
|
call(name: string, input?: Record<string, unknown>): Promise<unknown>;
|
|
151
|
+
/** Private installed Marketplace adapter; absent from the public CLI/MCP operation catalog. */
|
|
152
|
+
marketplaceRelay(name: string, input: Record<string, unknown>): Promise<unknown>;
|
|
151
153
|
/** Terminal-only Marketplace controller connection; session tokens remain in memory. */
|
|
152
154
|
connectMarketplace(input: {
|
|
153
155
|
apiUrl: string;
|
package/dist/application/app.js
CHANGED
|
@@ -25,7 +25,7 @@ import { MarketData } from '../pricing/market.js';
|
|
|
25
25
|
import { marketTerms } from '../pricing/terms.js';
|
|
26
26
|
import { runDoctor } from '../doctor/doctor.js';
|
|
27
27
|
import { validateMarketplaceUserProofApproval, createMarketplaceProofApprovalResponse } from '../marketplace/proof-approval.js';
|
|
28
|
-
import {
|
|
28
|
+
import { MarketplaceConnectionClient } from '../marketplace/connection.js';
|
|
29
29
|
const RESET_KEY = 'wallet.reset';
|
|
30
30
|
function signedMessageBytes(args) {
|
|
31
31
|
const bytes = args.messageHex !== undefined
|
|
@@ -48,7 +48,7 @@ export class AttoApplication {
|
|
|
48
48
|
preparation;
|
|
49
49
|
preparationAbort = new AbortController();
|
|
50
50
|
payments;
|
|
51
|
-
|
|
51
|
+
marketplaceConnection;
|
|
52
52
|
watchManager;
|
|
53
53
|
watchConfiguration = '';
|
|
54
54
|
watchQueue = Promise.resolve();
|
|
@@ -82,7 +82,7 @@ export class AttoApplication {
|
|
|
82
82
|
this.work = new WalletWork(this.store, () => this.settings(), options.workExecution);
|
|
83
83
|
this.background = new BackgroundReceiver(this.store);
|
|
84
84
|
this.receivingAllowed = options.receivingAllowed ?? (() => true);
|
|
85
|
-
this.
|
|
85
|
+
this.marketplaceConnection = new MarketplaceConnectionClient(this.store, {
|
|
86
86
|
settings: () => this.settings(), addresses: () => this.addresses(), seed: () => this.seed(), mcp: this.mcp,
|
|
87
87
|
});
|
|
88
88
|
this.receiver = new WalletReceiver({
|
|
@@ -95,7 +95,7 @@ export class AttoApplication {
|
|
|
95
95
|
settings: () => this.settings(), addresses: () => this.addresses(), seed: () => this.seed(),
|
|
96
96
|
requireWrite: () => this.requireMcpWrite(), mcp: this.mcp,
|
|
97
97
|
...(this.internalMarketplaceReceiveSafety ? { requireAccountsAvailable: (indexes) => this.receiver.requireReceivesResolved(indexes) } : {}),
|
|
98
|
-
}, this.market, this.work, options.sendRetry, options.onDestination
|
|
98
|
+
}, this.market, this.work, options.sendRetry, options.onDestination);
|
|
99
99
|
this.auto = new AutoReceiver(() => ({
|
|
100
100
|
settings: !this.receivingAllowed() || (this.mcp && this.ledger.mcpAccess() !== 'spend') ? { ...this.settings(), autoReceive: false } : this.settings(),
|
|
101
101
|
addresses: this.addresses(),
|
|
@@ -522,18 +522,6 @@ export class AttoApplication {
|
|
|
522
522
|
case 'send': return this.payments.send({ ...args,
|
|
523
523
|
destination: args.destinationIndex !== undefined ? this.address(args.destinationIndex).address : args.destination,
|
|
524
524
|
});
|
|
525
|
-
case 'marketplace_topup': return this.payments.marketplaceTopUp(args);
|
|
526
|
-
case 'marketplace_topup_status': return this.payments.marketplaceTopUpStatus(args.requestId);
|
|
527
|
-
case 'marketplace_pay_intent': {
|
|
528
|
-
if (!this.internalMarketplacePayment)
|
|
529
|
-
throw new AttoError('INTERNAL_ONLY', 'This operation is available only to the configured private Marketplace wallet child.');
|
|
530
|
-
return this.payments.marketplacePayIntent(args);
|
|
531
|
-
}
|
|
532
|
-
case 'marketplace_pay_intent_status': {
|
|
533
|
-
if (!this.internalMarketplacePayment)
|
|
534
|
-
throw new AttoError('INTERNAL_ONLY', 'This operation is available only to the configured private Marketplace wallet child.');
|
|
535
|
-
return this.payments.marketplacePayIntentStatus(args.requestId);
|
|
536
|
-
}
|
|
537
525
|
case 'receive': return this.receiver.receive(args);
|
|
538
526
|
case 'receive_all': return this.receiver.receiveAll(args);
|
|
539
527
|
case 'representative_change': return this.changeRepresentative(args.index, args.representative);
|
|
@@ -608,21 +596,37 @@ export class AttoApplication {
|
|
|
608
596
|
this.calls.delete(call);
|
|
609
597
|
}
|
|
610
598
|
}
|
|
599
|
+
/** Private installed Marketplace adapter; absent from the public CLI/MCP operation catalog. */
|
|
600
|
+
async marketplaceRelay(name, input) {
|
|
601
|
+
this.requireReady();
|
|
602
|
+
if (!this.internalMarketplaceAuthorizeWrite)
|
|
603
|
+
throw new AttoError('UNKNOWN_OPERATION', 'Private wallet operation unavailable.');
|
|
604
|
+
const call = name === 'payment_prepare' ? this.payments.prepareRelay(input)
|
|
605
|
+
: name === 'payment_authorize' ? this.payments.authorizeRelay(input)
|
|
606
|
+
: name === 'payment_status' ? this.payments.relayStatus(input) : Promise.reject(new AttoError('UNKNOWN_OPERATION', 'Unknown private wallet operation.'));
|
|
607
|
+
this.calls.add(call);
|
|
608
|
+
try {
|
|
609
|
+
return await call;
|
|
610
|
+
}
|
|
611
|
+
finally {
|
|
612
|
+
this.calls.delete(call);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
611
615
|
/** Terminal-only Marketplace controller connection; session tokens remain in memory. */
|
|
612
616
|
async connectMarketplace(input) {
|
|
613
617
|
this.requireReady();
|
|
614
|
-
const connection = await this.store.withWalletLock(() => this.
|
|
618
|
+
const connection = await this.store.withWalletLock(() => this.marketplaceConnection.connect(input));
|
|
615
619
|
return { connected: true, apiUrl: connection.apiUrl, audience: connection.audience,
|
|
616
620
|
controllerIndex: connection.controllerIndex, accountId: connection.accountId, identityId: connection.identityId,
|
|
617
621
|
...(connection.browserOrigins ? { browserOrigins: connection.browserOrigins } : {}) };
|
|
618
622
|
}
|
|
619
623
|
inspectMarketplaceProofApproval(input) {
|
|
620
624
|
this.requireReady();
|
|
621
|
-
return this.
|
|
625
|
+
return this.marketplaceConnection.inspectProofApproval(input);
|
|
622
626
|
}
|
|
623
627
|
async approveMarketplaceProof(input) {
|
|
624
628
|
this.requireReady();
|
|
625
|
-
return this.store.withWalletLock(() => this.
|
|
629
|
+
return this.store.withWalletLock(() => this.marketplaceConnection.signProofApproval(input));
|
|
626
630
|
}
|
|
627
631
|
/** Private Marketplace terminal signing: no standalone connection is read or changed. */
|
|
628
632
|
async approveMarketplaceOwnedProof(input) {
|
|
@@ -7,6 +7,5 @@ export interface Operation {
|
|
|
7
7
|
internalOnly?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare const operations: readonly Operation[];
|
|
10
|
-
export declare const internalOperations: readonly Operation[];
|
|
11
10
|
export declare function operationFor(name: string): Operation | undefined;
|
|
12
11
|
export declare function parseOperation(name: string, input?: unknown): Record<string, unknown>;
|
|
@@ -73,8 +73,6 @@ export const operations = [
|
|
|
73
73
|
{ name: 'history_list', description: 'Read action-oriented entries by default; use event=transaction for raw signed protocol records and receive sendHash linkage. Entries expose owner address, subjectAddress, subjectRole and exact transfer amount. Supply up to 100 addresses together for batched reads, or index for one saved account; defaults to active accounts. Results follow address order and ascending height. Limit is at most 1000 records. Reuse nextCursor with the same filters to continue frozen account heights without rescanning earlier pages; timedOut may return a partial page.', schema: z.strictObject({ event: z.enum(['transaction', 'entry']).default('entry'), ...accountFields, fromHeight: integer.optional(), toHeight: integer.optional(), ...listFields }).refine(singleSelection, 'Choose an index or addresses.'), readOnly: true },
|
|
74
74
|
{ name: 'receivables_list', description: 'Scan pending incoming payments, defaulting to active wallet addresses. Select a saved index or explicit addresses, including foreign accounts. This is a bounded scan, without continuation cursors; timedOut means the scan window ended and more payments may exist.', schema: z.strictObject({ ...accountFields, minAmountRaw: integer.optional(), limit: limit.optional(), timeoutMs: timeoutMs.optional() }).refine(singleSelection, 'Choose an index or addresses.'), readOnly: true },
|
|
75
75
|
{ name: 'send', description: 'Send funds to exactly one destination address, saved destinationIndex, or personal destinationLabel, subject to shared spending limits. Omit index to select an account from the approved pool. Explicit MCP indexes must belong to that pool and hold the full amount. Approved consolidation may combine pool funds only when index is omitted. Metadata is optional local journal data (up to 4096 UTF-8 bytes) and is never published on the network. USD uses an indicative price and requires accepted terms. Reuse requestId for retries; the original account, metadata, and USD conversion are preserved. Omit metadata to retain it; changed metadata is rejected.', schema: z.strictObject({ index: index.optional(), destination: address.optional(), destinationLabel: personalNameSchema.optional().describe('Exact personal name; global-only names fail locally. The original label and resolved address are pinned per request ID before network access.'), destinationIndex: index.optional().describe('Existing saved destination account index, instead of destination.'), amount: decimal, unit: z.enum(['ATTO', 'RAW', 'USD']).default('ATTO'), requestId: z.string().min(1).max(128), metadata: paymentMetadataSchema.optional() }).refine(value => [value.destination, value.destinationIndex, value.destinationLabel].filter(value => value !== undefined).length === 1, 'Choose exactly one destination address, destination index, or personal label.'), readOnly: false },
|
|
76
|
-
{ name: 'marketplace_topup', description: 'Fund only the configured Marketplace ATTO account using a bounded native x402 exact payment. Uses this wallet’s approved spend policy and pool; no tasks or hiring actions are available. Reuse requestId to recover the same intent and exact signed payment after uncertainty. Amount is an exact ATTO or RAW decimal string.', schema: z.strictObject({ amount: decimal, unit: unit.default('ATTO'), requestId: z.string().min(1).max(128), index: index.optional() }), readOnly: false },
|
|
77
|
-
{ name: 'marketplace_topup_status', description: 'Read the current Marketplace account top-up status by its original requestId and reconcile the same native payment. Does not create or replace a payment.', schema: z.strictObject({ requestId: z.string().min(1).max(128) }), readOnly: true },
|
|
78
76
|
{ name: 'pool_get', description: 'Read the approved send pool, its account balances, and readiness for payments. Does not reserve an account or move funds.', schema: z.strictObject({}), readOnly: true },
|
|
79
77
|
{ name: 'journal_list', description: 'List local payment journal records, newest first, with an optional status filter. Includes caller metadata and recorded payment progress; metadata is not an authenticated statement from the network.', schema: z.strictObject({ limit: z.number().int().min(1).max(100).default(50), cursor: cursor.optional(), status: z.enum(['reserved', 'signed', 'published', 'unknown', 'failed']).optional() }), readOnly: true },
|
|
80
78
|
{ name: 'journal_get', description: 'Read a local payment journal record by its request ID, including caller metadata and recorded payment progress.', schema: z.strictObject({ requestId: z.string().min(1).max(128) }), readOnly: true },
|
|
@@ -92,12 +90,8 @@ export const operations = [
|
|
|
92
90
|
{ name: 'watch_read', description: 'Read buffered events after an optional numeric cursor. Gaps are reported if bounded event retention was exceeded.', schema: z.strictObject({ id: z.string().min(1).max(128), cursor: z.number().int().nonnegative().optional(), limit: limit.optional() }), readOnly: true },
|
|
93
91
|
{ name: 'watch_stop', description: 'Stop a watch owned by this process and cancel its network subscription.', schema: z.strictObject({ id: z.string().min(1).max(128) }), readOnly: false },
|
|
94
92
|
];
|
|
95
|
-
export const internalOperations = [
|
|
96
|
-
{ name: 'marketplace_pay_intent', description: 'Private Marketplace-child operation. Sign one existing exact ATTO x402 intent supplied by the configured Marketplace process. Requires the matching locally configured API origin/audience/network and approved wallet spend access and pool. Persists the exact challenge and signature for same-request recovery. Never creates an intent or submits the payment.', schema: z.strictObject({ requestId: z.string().regex(/^[A-Za-z0-9_-]{16,128}$/), intentId: z.string().uuid(), amountAtomic: integer, paymentIdentifier: z.string().regex(/^[A-Za-z0-9_-]{16,128}$/), paymentRequired: z.string().min(1).max(90_000), apiUrl: z.string().min(1).max(2048), audience: z.string().min(1).max(255), resourceUrl: z.string().min(1).max(2048), expiresAt: z.string().min(1).max(128), index: index.optional() }), readOnly: false, internalOnly: true },
|
|
97
|
-
{ name: 'marketplace_pay_intent_status', description: 'Private Marketplace-child operation. Reconcile the saved block against the configured native chain and return its binding. Recover the exact saved signature while unresolved or published; native rejection returns terminal FAILED without a signature. Never re-sign or replace the saved challenge.', schema: z.strictObject({ requestId: z.string().regex(/^[A-Za-z0-9_-]{16,128}$/) }), readOnly: true, internalOnly: true },
|
|
98
|
-
];
|
|
99
93
|
export function operationFor(name) {
|
|
100
|
-
return
|
|
94
|
+
return operations.find(operation => operation.name === name);
|
|
101
95
|
}
|
|
102
96
|
export function parseOperation(name, input = {}) {
|
|
103
97
|
const operation = operationFor(name);
|
package/dist/cli/cli.js
CHANGED
|
@@ -272,9 +272,9 @@ export async function runCli(argv = process.argv) {
|
|
|
272
272
|
});
|
|
273
273
|
});
|
|
274
274
|
program.command('metrics').description('Read public Atto market metrics').action(() => call('metrics_get'));
|
|
275
|
-
const marketplace = program.command('marketplace').description('
|
|
275
|
+
const marketplace = program.command('marketplace').description('Connect and approve Marketplace identity requests');
|
|
276
276
|
marketplace.command('connect').description('Connect this wallet to Marketplace in a local terminal')
|
|
277
|
-
.requiredOption('--api-url <url>', 'Marketplace /v1/agent/
|
|
277
|
+
.requiredOption('--api-url <url>', 'Marketplace /v1/agent/payments URL')
|
|
278
278
|
.requiredOption('--audience <audience>', 'Exact Marketplace controller-proof audience')
|
|
279
279
|
.option('--browser-origin <origin>', 'Allow this exact browser origin for typed proof approvals (repeatable)', (origin, previous) => [...previous, origin], [])
|
|
280
280
|
.option('--controller-index <index>', 'Saved wallet controller account index (default: 0)', number, 0)
|
|
@@ -284,21 +284,6 @@ export async function runCli(argv = process.argv) {
|
|
|
284
284
|
controllerIndex: options.controllerIndex, ...(options.browserOrigin?.length ? { browserOrigins: options.browserOrigin } : {}) });
|
|
285
285
|
output(result, 'marketplace_connect');
|
|
286
286
|
});
|
|
287
|
-
marketplace.command('topup <amount>').description('Fund the configured Marketplace ATTO account under wallet spending limits')
|
|
288
|
-
.option('--unit <unit>', 'ATTO (default) or RAW')
|
|
289
|
-
.option('--request-id <id>', 'Payment ID (generated if omitted); reuse it after uncertainty')
|
|
290
|
-
.option('--index <index>', 'Source account index (defaults to the approved pool)', number)
|
|
291
|
-
.action(async (amount, options) => {
|
|
292
|
-
const requestId = options.requestId ?? randomUUID();
|
|
293
|
-
const input = compact({ amount, unit: options.unit, requestId, index: options.index });
|
|
294
|
-
parseOperation('marketplace_topup', input);
|
|
295
|
-
sendRequestId = requestId;
|
|
296
|
-
process.stderr.write(program.opts().json ? `${JSON.stringify({ progress: { requestId } })}\n`
|
|
297
|
-
: `Marketplace top-up request ID: ${requestId}\n`);
|
|
298
|
-
await call('marketplace_topup', input);
|
|
299
|
-
});
|
|
300
|
-
marketplace.command('status <request-id>').description('Read and reconcile a Marketplace top-up by its original request ID')
|
|
301
|
-
.action(requestId => call('marketplace_topup_status', { requestId }));
|
|
302
287
|
marketplace.command('approve <request-file>').description('Review and sign one exact typed Marketplace controller-proof request')
|
|
303
288
|
.action(async (requestFile) => {
|
|
304
289
|
requireTerminal();
|
|
@@ -491,10 +476,8 @@ export async function runCli(argv = process.argv) {
|
|
|
491
476
|
'atto message sign': 'atto message sign --index 0 --text "exact challenge"',
|
|
492
477
|
'atto message verify': 'atto message verify --public-key <hex> --signature <hex> --text "exact challenge"',
|
|
493
478
|
'atto send': 'atto send <address> 1\n atto send --to-index 1 --amount 1\n atto send --to-label "Savings" --amount 1\n atto send <address> --usd 1',
|
|
494
|
-
'atto marketplace': 'atto marketplace connect --api-url https://marketplace.example/v1/agent/
|
|
495
|
-
'atto marketplace connect': 'atto marketplace connect --api-url https://marketplace.example/v1/agent/
|
|
496
|
-
'atto marketplace topup': 'atto marketplace topup 1 --request-id marketplace-funding-001',
|
|
497
|
-
'atto marketplace status': 'atto marketplace status marketplace-funding-001',
|
|
479
|
+
'atto marketplace': 'atto marketplace connect --api-url https://marketplace.example/v1/agent/payments --audience marketplace --controller-index 0 --browser-origin https://site.example\n atto marketplace approve ./marketplace-approval-request.json',
|
|
480
|
+
'atto marketplace connect': 'atto marketplace connect --api-url https://marketplace.example/v1/agent/payments --audience marketplace --controller-index 0 --browser-origin https://site.example',
|
|
498
481
|
'atto marketplace approve': 'atto marketplace approve ./marketplace-approval-request.json',
|
|
499
482
|
'atto metrics': 'atto metrics', 'atto quote': 'atto quote --usd 1',
|
|
500
483
|
'atto terms': 'atto terms show', 'atto terms show': 'atto terms show',
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import { internalOperations } from './application/operations.js';
|
|
2
1
|
import type { ApplicationSession } from './core.js';
|
|
3
|
-
import type { InternalMarketplacePaymentConfig } from './spending/payments.js';
|
|
4
|
-
export { internalOperations };
|
|
5
|
-
export type { InternalMarketplacePaymentConfig };
|
|
6
|
-
export type { MarketplaceIntentPayment, MarketplaceIntentPaymentFailure, MarketplaceIntentPendingSignature, MarketplaceIntentPaymentStatus } from './spending/payments.js';
|
|
7
2
|
/** Narrow private child facade. Additional authority can only restrict the normal MCP grants. */
|
|
8
3
|
export declare function createInternalMarketplaceWalletApplication(options: {
|
|
9
4
|
directory?: string;
|
|
10
5
|
authorizeWrite: (status: unknown) => void;
|
|
11
|
-
internalMarketplacePayment?: InternalMarketplacePaymentConfig;
|
|
12
|
-
}): ApplicationSession;
|
|
13
|
-
/** Runtime facade reserved for the configured Marketplace MCP private stdio child. */
|
|
14
|
-
export declare function createInternalMarketplacePaymentApplication(options: {
|
|
15
|
-
directory?: string;
|
|
16
|
-
internalMarketplacePayment: InternalMarketplacePaymentConfig;
|
|
17
6
|
}): ApplicationSession;
|
|
18
7
|
export { withMarketplaceRecoverySeed, initializeMarketplaceRecoveryWallet, type MarketplaceRecoverySource } from './storage/recovery-seed.js';
|
|
19
8
|
export { validateMarketplaceUserProofApproval, type MarketplaceUserProofApprovalRequest } from './marketplace/proof-approval.js';
|
|
@@ -25,3 +14,5 @@ export declare function signMarketplaceAttoController(options: {
|
|
|
25
14
|
}): Promise<import("./marketplace/proof-approval.js").MarketplaceProofApprovalResponse>;
|
|
26
15
|
export { inspectMarketplaceWalletSetup, withUnchangedMarketplaceWalletSetup, type MarketplaceWalletSetupSnapshot } from './marketplace/wallet-setup.js';
|
|
27
16
|
export { assertPrivatePermissions, assertPrivatePermissionsBatch, securePrivatePermissions, syncPrivateDirectory, type PrivatePath } from './storage/private-permissions.js';
|
|
17
|
+
export { parseRelayOffer, decodePaymentHeader, relayPaymentPayload, relayProofFromHeader, relayEvidenceBinding, validateRelayProof, validateRelayOfferRefresh, MARKETPLACE_BINDING, type RelayRequest, type RelayTerms, type RelayProof, type RelayRecord } from './marketplace/relay.js';
|
|
18
|
+
export { parseJsonObject } from './marketplace/strict-json.js';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AttoApplication } from './application/app.js';
|
|
2
2
|
import { AttoError } from './domain/errors.js';
|
|
3
|
-
import { internalOperations } from './application/operations.js';
|
|
4
|
-
export { internalOperations };
|
|
5
3
|
const marketplaceWalletOperations = new Set([
|
|
6
4
|
'wallet_status', 'balances_get', 'receivables_list', 'send', 'journal_get', 'limits_get', 'receive',
|
|
7
|
-
'
|
|
5
|
+
'message_sign',
|
|
6
|
+
'payment_prepare', 'payment_authorize', 'payment_status',
|
|
8
7
|
]);
|
|
9
8
|
/** Narrow private child facade. Additional authority can only restrict the normal MCP grants. */
|
|
10
9
|
export function createInternalMarketplaceWalletApplication(options) {
|
|
@@ -13,27 +12,19 @@ export function createInternalMarketplaceWalletApplication(options) {
|
|
|
13
12
|
const application = new AttoApplication({
|
|
14
13
|
directory: options.directory, access: 'mcp', internalMarketplaceReceiveSafety: true, receivingAllowed: () => false,
|
|
15
14
|
internalMarketplaceAuthorizeWrite: options.authorizeWrite,
|
|
16
|
-
...(options.internalMarketplacePayment ? { internalMarketplacePayment: options.internalMarketplacePayment } : {}),
|
|
17
15
|
});
|
|
18
16
|
return {
|
|
19
17
|
async call(name, input) {
|
|
20
18
|
if (!marketplaceWalletOperations.has(name))
|
|
21
19
|
throw new AttoError('UNKNOWN_OPERATION', 'Unknown private Marketplace wallet operation.');
|
|
20
|
+
if (name.startsWith('payment_'))
|
|
21
|
+
return application.marketplaceRelay(name, input ?? {});
|
|
22
22
|
return application.call(name, input);
|
|
23
23
|
},
|
|
24
24
|
start: application.start.bind(application),
|
|
25
25
|
close: application.close.bind(application),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
/** Runtime facade reserved for the configured Marketplace MCP private stdio child. */
|
|
29
|
-
export function createInternalMarketplacePaymentApplication(options) {
|
|
30
|
-
const application = new AttoApplication({ ...options, access: 'mcp' });
|
|
31
|
-
return {
|
|
32
|
-
call: application.call.bind(application),
|
|
33
|
-
start: application.start.bind(application),
|
|
34
|
-
close: application.close.bind(application),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
28
|
export { withMarketplaceRecoverySeed, initializeMarketplaceRecoveryWallet } from './storage/recovery-seed.js';
|
|
38
29
|
export { validateMarketplaceUserProofApproval } from './marketplace/proof-approval.js';
|
|
39
30
|
/** Private, terminal-only typed signer. Public CLI/MCP operations remain unchanged. */
|
|
@@ -50,3 +41,5 @@ export async function signMarketplaceAttoController(options) {
|
|
|
50
41
|
}
|
|
51
42
|
export { inspectMarketplaceWalletSetup, withUnchangedMarketplaceWalletSetup } from './marketplace/wallet-setup.js';
|
|
52
43
|
export { assertPrivatePermissions, assertPrivatePermissionsBatch, securePrivatePermissions, syncPrivateDirectory } from './storage/private-permissions.js';
|
|
44
|
+
export { parseRelayOffer, decodePaymentHeader, relayPaymentPayload, relayProofFromHeader, relayEvidenceBinding, validateRelayProof, validateRelayOfferRefresh, MARKETPLACE_BINDING } from './marketplace/relay.js';
|
|
45
|
+
export { parseJsonObject } from './marketplace/strict-json.js';
|
|
@@ -13,29 +13,16 @@ export function formatMarketplaceApprovalPreview(preview) {
|
|
|
13
13
|
`Challenge: ${preview.challengeId}`,
|
|
14
14
|
`Expires: ${preview.expiresAt}`,
|
|
15
15
|
];
|
|
16
|
-
if (action.kind === '
|
|
17
|
-
fields.push(`Action: withdraw ${String(command.atomicAmount)} ${String(command.asset)} on ${String(action.network)}`, `Destination: ${String(action.destinationAddress)} (${String(command.destinationId)})`);
|
|
18
|
-
}
|
|
19
|
-
else if (action.kind === 'productPurchase') {
|
|
20
|
-
fields.push('Action: purchase digital product release', `Client-provided seller (not verified by this proof): ${String(action.sellerAgentId)}`, `Proof-bound release ID: ${String(action.releaseId)}`, `Proof-bound release SHA-256: ${String(action.expectedReleaseHash)}`, `Proof-bound asset: ${String(action.asset)}`, `Proof-bound gross: ${String(action.grossAtomic)} atomic`, `Client-provided fee (not verified by this proof): ${String(action.feeAtomic)} atomic`, `Client-provided net (not verified by this proof): ${String(action.netAtomic)} atomic`, `Proof-bound idempotency key: ${String(action.idempotencyKey)}`);
|
|
21
|
-
}
|
|
22
|
-
else if (action.kind === 'productRefund') {
|
|
23
|
-
const authority = String(action.authority);
|
|
24
|
-
fields.push(`Action: ${authority === 'ADMIN' ? 'administrator refund compensation' : 'seller refund'}`, `Proof-bound authority: ${authority}`, `Client-provided buyer (not verified by this proof): ${String(action.buyerAgentId)}`, `Client-provided seller (not verified by this proof): ${String(action.sellerAgentId)}`, `Proof-bound purchase ID: ${String(action.purchaseId)}`, `Proof-bound original purchase receipt SHA-256: ${String(action.originalPurchaseReceiptHash)}`, `Proof-bound expected purchase version: ${String(action.expectedPurchaseVersion)}`, `Proof-bound asset: ${String(action.asset)}`, `Proof-bound gross: ${String(action.grossAtomic)} atomic`, `Client-provided fee (not verified by this proof): ${String(action.feeAtomic)} atomic`, `Client-provided net (not verified by this proof): ${String(action.netAtomic)} atomic`, `Proof-bound idempotency key: ${String(action.idempotencyKey)}`);
|
|
25
|
-
}
|
|
26
|
-
else if (action.kind === 'payout-address') {
|
|
27
|
-
fields.push(`Action: ${String(command.action)} ${String(command.asset)} payout address on ${String(action.network)}`, `Destination: ${String(action.canonicalTargetAddress)}`);
|
|
28
|
-
}
|
|
29
|
-
else if (action.kind === 'credential') {
|
|
16
|
+
if (action.kind === 'credential') {
|
|
30
17
|
const credential = command.credential && typeof command.credential === 'object' ? command.credential : {};
|
|
31
18
|
fields.push(`Action: ${String(command.operation)} scoped credential`, ...(typeof credential.name === 'string' ? [`Name: ${credential.name.trim()}`] : []), ...(Array.isArray(credential.scopes) ? [`Scopes: ${credential.scopes.join(', ')}`] : []), ...(typeof command.targetApiKeyId === 'string' ? [`Credential ID: ${command.targetApiKeyId}`] : []));
|
|
32
|
-
for (const [name, label] of [['publishAttoLimit', 'ATTO publish ceiling'], ['publishXnoLimit', 'XNO publish ceiling']
|
|
19
|
+
for (const [name, label] of [['publishAttoLimit', 'ATTO publish ceiling'], ['publishXnoLimit', 'XNO publish ceiling']]) {
|
|
33
20
|
if (typeof credential[name] === 'string')
|
|
34
21
|
fields.push(`${label}: ${String(credential[name])} atomic units`);
|
|
35
22
|
}
|
|
36
23
|
if (Array.isArray(credential.scopes) && credential.scopes.includes('products:publish')) {
|
|
37
|
-
for (const [name, label] of [['productPublishAttoLimit', 'ATTO product publication
|
|
38
|
-
['productPublishXnoLimit', 'XNO product publication
|
|
24
|
+
for (const [name, label] of [['productPublishAttoLimit', 'ATTO product publication basis ceiling'],
|
|
25
|
+
['productPublishXnoLimit', 'XNO product publication basis ceiling']]) {
|
|
39
26
|
fields.push(`${label}: ${typeof credential[name] === 'string' ? `${String(credential[name])} atomic units` : 'denied'}`);
|
|
40
27
|
}
|
|
41
28
|
}
|
|
@@ -66,9 +53,7 @@ export function formatMarketplaceApprovalPreview(preview) {
|
|
|
66
53
|
else if (action.kind === 'login') {
|
|
67
54
|
fields.push(`Action: create a controller session for ${String(action.address)}`);
|
|
68
55
|
}
|
|
69
|
-
const heading =
|
|
70
|
-
? 'Review this Marketplace challenge before signing. Items marked client-provided are not verified by this proof:'
|
|
71
|
-
: 'Review this server-authored Marketplace wallet proof before signing:';
|
|
56
|
+
const heading = 'Review this server-authored Marketplace wallet proof before signing:';
|
|
72
57
|
return `${heading}\n${fields.map(field => ` ${escapeTerminalControls(field)}`).join('\n')}`;
|
|
73
58
|
}
|
|
74
59
|
function terminalSafeValue(value) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WalletAddress, WalletSettings } from '../wallet/types.js';
|
|
2
|
+
import type { StateStore } from '../storage/state.js';
|
|
3
|
+
import type { AttoSeed } from '@attocash/commons-core';
|
|
4
|
+
import { type MarketplaceProofApprovalResponse } from './proof-approval.js';
|
|
5
|
+
export interface MarketplaceConnection {
|
|
6
|
+
version: 1;
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
audience: string;
|
|
9
|
+
controllerIndex: number;
|
|
10
|
+
controllerAddress: string;
|
|
11
|
+
accountId: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
identityId: string;
|
|
14
|
+
walletFingerprint: string;
|
|
15
|
+
browserOrigins?: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface MarketplaceWalletAccess {
|
|
18
|
+
settings(): WalletSettings;
|
|
19
|
+
addresses(): WalletAddress[];
|
|
20
|
+
seed(): Promise<AttoSeed>;
|
|
21
|
+
mcp: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function validateMarketplaceApiUrl(value: string, network: WalletSettings['network']): string;
|
|
24
|
+
export declare class MarketplaceConnectionClient {
|
|
25
|
+
private readonly store;
|
|
26
|
+
private readonly wallet;
|
|
27
|
+
constructor(store: StateStore, wallet: MarketplaceWalletAccess);
|
|
28
|
+
connect(input: {
|
|
29
|
+
apiUrl: string;
|
|
30
|
+
audience: string;
|
|
31
|
+
controllerIndex: number;
|
|
32
|
+
browserOrigins?: string[];
|
|
33
|
+
}): Promise<MarketplaceConnection>;
|
|
34
|
+
connection(): MarketplaceConnection;
|
|
35
|
+
inspectProofApproval(input: unknown): {
|
|
36
|
+
request: import("./proof-approval.js").MarketplaceProofApprovalRequest;
|
|
37
|
+
preview: import("./proof-approval.js").MarketplaceProofApprovalPreview;
|
|
38
|
+
};
|
|
39
|
+
signProofApproval(input: unknown): Promise<MarketplaceProofApprovalResponse>;
|
|
40
|
+
private login;
|
|
41
|
+
private postAuth;
|
|
42
|
+
private httpFailure;
|
|
43
|
+
}
|