@defdone/annon 0.0.0-stage → 0.1.0-alpha.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/CHANGELOG.md +56 -0
- package/CLI.md +378 -0
- package/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +581 -2
- package/dist/api/annon-types.d.ts +108 -0
- package/dist/api/annon-types.js +2 -0
- package/dist/api/annon.d.ts +117 -0
- package/dist/api/annon.js +1152 -0
- package/dist/api/hosted-record.d.ts +13 -0
- package/dist/api/hosted-record.js +149 -0
- package/dist/api/sharing-types.d.ts +109 -0
- package/dist/api/sharing-types.js +1 -0
- package/dist/api/sharing.d.ts +36 -0
- package/dist/api/sharing.js +879 -0
- package/dist/browser/download.d.ts +19 -0
- package/dist/browser/download.js +52 -0
- package/dist/browser/index.d.ts +23 -0
- package/dist/browser/index.js +22 -0
- package/dist/browser/login-bundle.js +116 -0
- package/dist/browser/login.d.ts +1 -0
- package/dist/browser/login.js +177 -0
- package/dist/browser/purchase-bundle.js +84 -0
- package/dist/browser/purchases.d.ts +98 -0
- package/dist/browser/purchases.js +735 -0
- package/dist/browser/record.d.ts +55 -0
- package/dist/browser/record.js +16 -0
- package/dist/browser/selling.d.ts +146 -0
- package/dist/browser/selling.js +418 -0
- package/dist/browser/wallets.d.ts +53 -0
- package/dist/browser/wallets.js +286 -0
- package/dist/bytes.d.ts +4 -0
- package/dist/bytes.js +16 -0
- package/dist/download/download.d.ts +59 -0
- package/dist/download/download.js +384 -0
- package/dist/download/host.d.ts +56 -0
- package/dist/download/host.js +161 -0
- package/dist/download/http.d.ts +23 -0
- package/dist/download/http.js +87 -0
- package/dist/download/proof.d.ts +20 -0
- package/dist/download/proof.js +79 -0
- package/dist/download/upload.d.ts +130 -0
- package/dist/download/upload.js +408 -0
- package/dist/envelope/evm.d.ts +4 -0
- package/dist/envelope/evm.js +32 -0
- package/dist/envelope/pay2.d.ts +176 -0
- package/dist/envelope/pay2.js +541 -0
- package/dist/envelope/replay.d.ts +45 -0
- package/dist/envelope/replay.js +186 -0
- package/dist/envelope/stream.d.ts +78 -0
- package/dist/envelope/stream.js +372 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +300 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +23 -0
- package/dist/keys/near-ckd.d.ts +47 -0
- package/dist/keys/near-ckd.js +96 -0
- package/dist/limits.d.ts +4 -0
- package/dist/limits.js +4 -0
- package/dist/near/nep413.d.ts +22 -0
- package/dist/near/nep413.js +39 -0
- package/dist/near/rpc.d.ts +170 -0
- package/dist/near/rpc.js +423 -0
- package/dist/near/texts.d.ts +39 -0
- package/dist/near/texts.js +60 -0
- package/dist/net/ip.d.ts +7 -0
- package/dist/net/ip.js +62 -0
- package/dist/net/retry.d.ts +3 -0
- package/dist/net/retry.js +31 -0
- package/dist/node/adapter-checks.d.ts +6 -0
- package/dist/node/adapter-checks.js +13 -0
- package/dist/node/adapter.d.ts +8 -0
- package/dist/node/adapter.js +99 -0
- package/dist/node/agent.d.ts +49 -0
- package/dist/node/agent.js +266 -0
- package/dist/node/amounts.d.ts +2 -0
- package/dist/node/amounts.js +20 -0
- package/dist/node/browser-login.d.ts +18 -0
- package/dist/node/browser-login.js +212 -0
- package/dist/node/budget.d.ts +24 -0
- package/dist/node/budget.js +59 -0
- package/dist/node/buy-commands.d.ts +24 -0
- package/dist/node/buy-commands.js +301 -0
- package/dist/node/cli.d.ts +60 -0
- package/dist/node/cli.js +201 -0
- package/dist/node/command-context.d.ts +82 -0
- package/dist/node/command-context.js +77 -0
- package/dist/node/config.d.ts +37 -0
- package/dist/node/config.js +189 -0
- package/dist/node/core-adapter.d.ts +43 -0
- package/dist/node/core-adapter.js +122 -0
- package/dist/node/errors.d.ts +8 -0
- package/dist/node/errors.js +12 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.js +5 -0
- package/dist/node/io.d.ts +13 -0
- package/dist/node/io.js +112 -0
- package/dist/node/keychain.d.ts +10 -0
- package/dist/node/keychain.js +67 -0
- package/dist/node/main.d.ts +2 -0
- package/dist/node/main.js +21 -0
- package/dist/node/offers.d.ts +16 -0
- package/dist/node/offers.js +91 -0
- package/dist/node/origin.d.ts +11 -0
- package/dist/node/origin.js +80 -0
- package/dist/node/paths.d.ts +3 -0
- package/dist/node/paths.js +71 -0
- package/dist/node/payment-terms.d.ts +26 -0
- package/dist/node/payment-terms.js +127 -0
- package/dist/node/purchase-commands.d.ts +16 -0
- package/dist/node/purchase-commands.js +237 -0
- package/dist/node/purchase-guard.d.ts +19 -0
- package/dist/node/purchase-guard.js +53 -0
- package/dist/node/relay-transport.d.ts +6 -0
- package/dist/node/relay-transport.js +173 -0
- package/dist/node/resources.d.ts +2 -0
- package/dist/node/resources.js +26 -0
- package/dist/node/retry-gate.d.ts +15 -0
- package/dist/node/retry-gate.js +53 -0
- package/dist/node/seller-commands.d.ts +12 -0
- package/dist/node/seller-commands.js +207 -0
- package/dist/node/sharing.d.ts +3 -0
- package/dist/node/sharing.js +28 -0
- package/dist/node/shops.d.ts +17 -0
- package/dist/node/shops.js +74 -0
- package/dist/node/signer-mock.d.ts +11 -0
- package/dist/node/signer-mock.js +79 -0
- package/dist/node/signer-wallet.d.ts +8 -0
- package/dist/node/signer-wallet.js +147 -0
- package/dist/node/signing.d.ts +29 -0
- package/dist/node/signing.js +200 -0
- package/dist/node/storage-commands.d.ts +11 -0
- package/dist/node/storage-commands.js +50 -0
- package/dist/node/sync-dir.d.ts +1 -0
- package/dist/node/sync-dir.js +11 -0
- package/dist/node/wallets.d.ts +13 -0
- package/dist/node/wallets.js +146 -0
- package/dist/oneclick/oneclick.d.ts +132 -0
- package/dist/oneclick/oneclick.js +342 -0
- package/dist/pay/backup.d.ts +70 -0
- package/dist/pay/backup.js +402 -0
- package/dist/pay/base.d.ts +135 -0
- package/dist/pay/base.js +393 -0
- package/dist/pay/eip3009.d.ts +59 -0
- package/dist/pay/eip3009.js +72 -0
- package/dist/pay/pay.d.ts +86 -0
- package/dist/pay/pay.js +297 -0
- package/dist/pay/purchase.d.ts +103 -0
- package/dist/pay/purchase.js +20 -0
- package/dist/pay/recover.d.ts +31 -0
- package/dist/pay/recover.js +34 -0
- package/dist/pay/seller.d.ts +130 -0
- package/dist/pay/seller.js +444 -0
- package/dist/pay/settle.d.ts +96 -0
- package/dist/pay/settle.js +308 -0
- package/dist/pay/split.d.ts +115 -0
- package/dist/pay/split.js +256 -0
- package/dist/pay/store-node.d.ts +8 -0
- package/dist/pay/store-node.js +224 -0
- package/dist/pay/store.d.ts +54 -0
- package/dist/pay/store.js +135 -0
- package/dist/pay/x402.d.ts +95 -0
- package/dist/pay/x402.js +136 -0
- package/dist/relay/admission.d.ts +8 -0
- package/dist/relay/admission.js +58 -0
- package/dist/relay/capabilities.d.ts +36 -0
- package/dist/relay/capabilities.js +232 -0
- package/dist/relay/fees.d.ts +17 -0
- package/dist/relay/fees.js +105 -0
- package/dist/relay/index.d.ts +10 -0
- package/dist/relay/index.js +8 -0
- package/dist/relay/keeper-balance.d.ts +17 -0
- package/dist/relay/keeper-balance.js +46 -0
- package/dist/relay/keeper-runner.d.ts +114 -0
- package/dist/relay/keeper-runner.js +703 -0
- package/dist/relay/keeper.d.ts +38 -0
- package/dist/relay/keeper.js +73 -0
- package/dist/relay/ledger.d.ts +155 -0
- package/dist/relay/ledger.js +392 -0
- package/dist/relay/relay-checks.d.ts +3 -0
- package/dist/relay/relay-checks.js +244 -0
- package/dist/relay/relay-reconciliation.d.ts +15 -0
- package/dist/relay/relay-reconciliation.js +293 -0
- package/dist/relay/relay-request.d.ts +6 -0
- package/dist/relay/relay-request.js +139 -0
- package/dist/relay/relay-transactions.d.ts +23 -0
- package/dist/relay/relay-transactions.js +182 -0
- package/dist/relay/relay-types.d.ts +128 -0
- package/dist/relay/relay-types.js +17 -0
- package/dist/relay/relay.d.ts +102 -0
- package/dist/relay/relay.js +426 -0
- package/dist/relay/reservation.d.ts +29 -0
- package/dist/relay/reservation.js +132 -0
- package/dist/relay/sponsorship.d.ts +42 -0
- package/dist/relay/sponsorship.js +184 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +1 -0
- package/dist/settle-near/codec.d.ts +17 -0
- package/dist/settle-near/codec.js +86 -0
- package/dist/settle-near/identity.d.ts +27 -0
- package/dist/settle-near/identity.js +80 -0
- package/dist/settle-near/purchase.d.ts +40 -0
- package/dist/settle-near/purchase.js +153 -0
- package/dist/settle-near/terms.d.ts +37 -0
- package/dist/settle-near/terms.js +89 -0
- package/dist/shops/discovery.d.ts +95 -0
- package/dist/shops/discovery.js +384 -0
- package/dist/wallet/account-only.d.ts +11 -0
- package/dist/wallet/account-only.js +6 -0
- package/dist/wallet/uncertain.d.ts +8 -0
- package/dist/wallet/uncertain.js +13 -0
- package/dist/wallet/wallet.d.ts +100 -0
- package/dist/wallet/wallet.js +204 -0
- package/package.json +135 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SellRecord } from '../pay/backup.js';
|
|
2
|
+
import { type Identity } from '../settle-near/identity.js';
|
|
3
|
+
import { type Terms } from '../settle-near/terms.js';
|
|
4
|
+
import type { ShareStep } from './sharing-types.js';
|
|
5
|
+
declare const assets: (t: Terms) => {
|
|
6
|
+
baseUsdc?: string;
|
|
7
|
+
nearUsdc: string;
|
|
8
|
+
};
|
|
9
|
+
declare const salt: string;
|
|
10
|
+
export declare function shareSteps(seller: Identity): ShareStep[];
|
|
11
|
+
/** Validate before any nested access by callers. Encryption authenticates the whole revision. */
|
|
12
|
+
export declare function validateHostedRecord(job: SellRecord): void;
|
|
13
|
+
export { assets, salt };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** The share steps per seller kind and the validation of a saved hosted sell record. */
|
|
2
|
+
import { parseUpload, uploadOrigin } from '../download/upload.js';
|
|
3
|
+
import { checkProtocolFee } from '../relay/fees.js';
|
|
4
|
+
import { parseReservation } from '../relay/reservation.js';
|
|
5
|
+
import { bytes } from '../settle-near/codec.js';
|
|
6
|
+
import { identityJson } from '../settle-near/identity.js';
|
|
7
|
+
import { termsHash } from '../settle-near/terms.js';
|
|
8
|
+
const assets = (t) => ({
|
|
9
|
+
nearUsdc: t.near.token,
|
|
10
|
+
...(t.base ? { baseUsdc: t.base.usdc } : {}),
|
|
11
|
+
});
|
|
12
|
+
const salt = `0x${'00'.repeat(32)}`;
|
|
13
|
+
export function shareSteps(seller) {
|
|
14
|
+
return seller.kind === 'near'
|
|
15
|
+
? ['stage', 'deposit', 'register', 'fund', 'publish']
|
|
16
|
+
: seller.kind === 'evm'
|
|
17
|
+
? ['stage', 'split', 'register', 'publish']
|
|
18
|
+
: ['stage', 'register', 'publish'];
|
|
19
|
+
}
|
|
20
|
+
/** Validate before any nested access by callers. Encryption authenticates the whole revision. */
|
|
21
|
+
export function validateHostedRecord(job) {
|
|
22
|
+
const h = job.hosting;
|
|
23
|
+
if (!h)
|
|
24
|
+
return;
|
|
25
|
+
const t = job.terms;
|
|
26
|
+
termsHash(t, assets(t));
|
|
27
|
+
if (!h ||
|
|
28
|
+
typeof h !== 'object' ||
|
|
29
|
+
h.origin !== uploadOrigin(h.origin) ||
|
|
30
|
+
!Array.isArray(h.steps) ||
|
|
31
|
+
!Array.isArray(h.completed) ||
|
|
32
|
+
JSON.stringify(h.steps) !== JSON.stringify(shareSteps(t.seller)) ||
|
|
33
|
+
h.completed.some((s, i) => s !== h.steps[i]) ||
|
|
34
|
+
h.completed.length > h.steps.length ||
|
|
35
|
+
typeof h.backupConfirmed !== 'boolean')
|
|
36
|
+
throw new Error('Invalid hosted record.');
|
|
37
|
+
if (t.seller.kind === 'evm' &&
|
|
38
|
+
(!t.base ||
|
|
39
|
+
!job.baseSplit ||
|
|
40
|
+
job.baseSplit.kind !== 'push' ||
|
|
41
|
+
job.baseSplit.salt !== salt ||
|
|
42
|
+
job.baseSplit.address !== t.base.pay_to))
|
|
43
|
+
throw new Error('Invalid Base terms.');
|
|
44
|
+
if (t.seller.kind === 'near' && h.fee !== null)
|
|
45
|
+
throw new Error('Invalid direct fee.');
|
|
46
|
+
if (h.fee !== null && h.fee === undefined)
|
|
47
|
+
throw new Error('Missing fee.');
|
|
48
|
+
if (h.fee)
|
|
49
|
+
checkProtocolFee(t, h.fee);
|
|
50
|
+
if (t.seller.kind !== 'evm' && (t.base !== null || job.baseSplit !== null))
|
|
51
|
+
throw new Error('Invalid seller routes.');
|
|
52
|
+
if (h.pending !== null &&
|
|
53
|
+
(!h.pending ||
|
|
54
|
+
h.pending.step !== h.steps[h.completed.length] ||
|
|
55
|
+
typeof h.pending.token !== 'string'))
|
|
56
|
+
throw new Error('Invalid pending operation.');
|
|
57
|
+
if (h.pending?.operation && ['deposit', 'fund'].includes(h.pending.step)) {
|
|
58
|
+
const { snapshot, validUntil } = h.pending;
|
|
59
|
+
if ((h.pending.step === 'deposit' && typeof h.pending.storageAccountExisted !== 'boolean') ||
|
|
60
|
+
typeof snapshot !== 'string' ||
|
|
61
|
+
!/^(0|[1-9][0-9]*)$/.test(snapshot) ||
|
|
62
|
+
BigInt(snapshot) >= 2n ** 128n ||
|
|
63
|
+
!Number.isSafeInteger(validUntil) ||
|
|
64
|
+
(validUntil ?? -1) < 0)
|
|
65
|
+
throw new Error('Invalid funding snapshot.');
|
|
66
|
+
}
|
|
67
|
+
if (h.pending?.startedAt !== undefined &&
|
|
68
|
+
(!Number.isSafeInteger(h.pending.startedAt) || h.pending.startedAt < 0))
|
|
69
|
+
throw new Error('Invalid operation checkpoint.');
|
|
70
|
+
if (h.lease !== null &&
|
|
71
|
+
(!h.lease || typeof h.lease.owner !== 'string' || !Number.isSafeInteger(h.lease.until)))
|
|
72
|
+
throw new Error('Invalid lease.');
|
|
73
|
+
if (h.completed.length && !h.backupConfirmed)
|
|
74
|
+
throw new Error('Missing backup confirmation.');
|
|
75
|
+
if (h.uploadId !== null && !/^[0-9a-f]{64}$/.test(h.uploadId))
|
|
76
|
+
throw new Error('Invalid upload.');
|
|
77
|
+
const request = parseUpload({
|
|
78
|
+
intent: h.intent,
|
|
79
|
+
manifest: h.manifest,
|
|
80
|
+
terms: t,
|
|
81
|
+
metadata: h.metadata,
|
|
82
|
+
auth: h.authorization?.auth ??
|
|
83
|
+
(t.seller.kind === 'near'
|
|
84
|
+
? { kind: 'near', accountId: t.seller.id, publicKey: '', signature: '' }
|
|
85
|
+
: { kind: t.seller.kind, sig: `0x${'00'.repeat(t.seller.kind === 'evm' ? 65 : 64)}` }),
|
|
86
|
+
});
|
|
87
|
+
if (request.intent.termsHash !== termsHash(t, assets(t)) ||
|
|
88
|
+
request.intent.fileId !== t.file_id ||
|
|
89
|
+
request.intent.cipherHash !== t.cipher_hash ||
|
|
90
|
+
request.intent.hostOrigin !== h.origin ||
|
|
91
|
+
identityJson(request.intent.seller) !== identityJson(t.seller))
|
|
92
|
+
throw new Error('Invalid hosted binding.');
|
|
93
|
+
if (h.authorization && JSON.stringify(h.authorization.intent) !== JSON.stringify(h.intent))
|
|
94
|
+
throw new Error('Invalid authorization binding.');
|
|
95
|
+
if (t.seller.kind === 'near' &&
|
|
96
|
+
(!h.listingStorage ||
|
|
97
|
+
!job.storageBudget ||
|
|
98
|
+
!/^[1-9][0-9]*$/.test(h.listingStorage) ||
|
|
99
|
+
BigInt(h.listingStorage) >= 2n ** 128n))
|
|
100
|
+
throw new Error('Missing approved funding.');
|
|
101
|
+
if (h.reservation) {
|
|
102
|
+
const r = parseReservation(h.reservation);
|
|
103
|
+
for (const k of [
|
|
104
|
+
'fileId',
|
|
105
|
+
'termsHash',
|
|
106
|
+
'cipherHash',
|
|
107
|
+
'metadataHash',
|
|
108
|
+
'hostOrigin',
|
|
109
|
+
'byteSize',
|
|
110
|
+
'plaintextSize',
|
|
111
|
+
'headerSize',
|
|
112
|
+
'network',
|
|
113
|
+
'contract',
|
|
114
|
+
])
|
|
115
|
+
if (r[k] !== h.intent[k])
|
|
116
|
+
throw new Error('Invalid reservation binding.');
|
|
117
|
+
if (r.uploadId !== h.uploadId || identityJson(r.seller) !== identityJson(t.seller))
|
|
118
|
+
throw new Error('Invalid reservation.');
|
|
119
|
+
}
|
|
120
|
+
if (h.split !== null &&
|
|
121
|
+
(!h.split ||
|
|
122
|
+
t.seller.kind !== 'evm' ||
|
|
123
|
+
!['pending', 'ready'].includes(h.split.state) ||
|
|
124
|
+
h.split.address.toLowerCase() !== t.base?.pay_to ||
|
|
125
|
+
h.split.kind !== 'push' ||
|
|
126
|
+
h.split.salt !== salt ||
|
|
127
|
+
!(h.split.txHash === null || typeof h.split.txHash === 'string')))
|
|
128
|
+
throw new Error('Invalid split checkpoint.');
|
|
129
|
+
if (h.completed.includes('split') && h.split?.state !== 'ready')
|
|
130
|
+
throw new Error('Missing split confirmation.');
|
|
131
|
+
if (h.result !== null) {
|
|
132
|
+
const r = h.result;
|
|
133
|
+
const url = `${h.origin}/f/${t.file_id.slice(2)}`;
|
|
134
|
+
if (!r ||
|
|
135
|
+
r.fileId !== t.file_id ||
|
|
136
|
+
r.url !== url ||
|
|
137
|
+
r.header !== `${url}/header` ||
|
|
138
|
+
(r.expiresAt !== null && (!Number.isSafeInteger(r.expiresAt) || r.expiresAt <= 0)) ||
|
|
139
|
+
h.completed.at(-1) !== 'publish' ||
|
|
140
|
+
!h.header ||
|
|
141
|
+
!job.published)
|
|
142
|
+
throw new Error('Invalid publication.');
|
|
143
|
+
}
|
|
144
|
+
if (!!job.published !== (h.result !== null))
|
|
145
|
+
throw new Error('Invalid completion.');
|
|
146
|
+
if (h.header !== null)
|
|
147
|
+
bytes(h.header, (h.header.length - 2) / 2);
|
|
148
|
+
}
|
|
149
|
+
export { assets, salt };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** Types of hosted selling: share options, quotes, steps and the durable hosted checkpoint. */
|
|
2
|
+
import type { UploadAuth, UploadAuthorization, UploadBaseSplit, UploadIntent, UploadManifest, UploadMetadata, UploadPublished } from '../download/upload.js';
|
|
3
|
+
import type { SellData, Spool } from '../envelope/replay.js';
|
|
4
|
+
import type { FileInfo } from '../near/rpc.js';
|
|
5
|
+
import type { SellRecord } from '../pay/backup.js';
|
|
6
|
+
import type { ProtocolFee } from '../relay/fees.js';
|
|
7
|
+
import type { HostingReservation } from '../relay/reservation.js';
|
|
8
|
+
import type { Identity } from '../settle-near/identity.js';
|
|
9
|
+
import type { Terms } from '../settle-near/terms.js';
|
|
10
|
+
import type { IdentityWallet } from '../wallet/wallet.js';
|
|
11
|
+
export type ShareStep = 'stage' | 'split' | 'deposit' | 'register' | 'fund' | 'publish';
|
|
12
|
+
export interface ShareHosting {
|
|
13
|
+
origin: string;
|
|
14
|
+
/** Required only for a NEAR seller; signs the exact upload-specific NEP-413 payload. */
|
|
15
|
+
signUpload?: (intent: UploadIntent) => Promise<UploadAuth>;
|
|
16
|
+
/** Browsers supply a ciphertext Blob spool; Node supplies a disk spool. */
|
|
17
|
+
spool?: Spool;
|
|
18
|
+
body?: (source: import('../envelope/replay.js').ReplayableSource) => Promise<Blob | ReadableStream<Uint8Array>>;
|
|
19
|
+
}
|
|
20
|
+
export interface ShareOptions {
|
|
21
|
+
data: SellData;
|
|
22
|
+
name: string;
|
|
23
|
+
mime: string;
|
|
24
|
+
seller: IdentityWallet;
|
|
25
|
+
/** USDC base units. The default split pays this seller. */
|
|
26
|
+
price: string;
|
|
27
|
+
near?: {
|
|
28
|
+
recipients: {
|
|
29
|
+
identity: Identity;
|
|
30
|
+
bps: number;
|
|
31
|
+
}[];
|
|
32
|
+
remainder: Identity;
|
|
33
|
+
};
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
hosting: ShareHosting;
|
|
37
|
+
listingStorage?: bigint;
|
|
38
|
+
storageBudget?: bigint;
|
|
39
|
+
onSplit?: (near: Terms['near'], fee?: ProtocolFee, aboveMaximum?: boolean) => Promise<void> | void;
|
|
40
|
+
/** Resolves only after the pending encrypted backup and separate secret are saved. */
|
|
41
|
+
confirmBackup?: (backup: {
|
|
42
|
+
fileId: string;
|
|
43
|
+
text: string;
|
|
44
|
+
}) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface ShareQuote {
|
|
47
|
+
quoteId: string;
|
|
48
|
+
fileId: string;
|
|
49
|
+
terms: Terms;
|
|
50
|
+
fee: ProtocolFee | null;
|
|
51
|
+
steps: ShareStep[];
|
|
52
|
+
metadata: UploadMetadata;
|
|
53
|
+
listingStorage: string | null;
|
|
54
|
+
storageBudget: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface Shared extends UploadPublished {
|
|
57
|
+
/** Hosting expiry in Unix seconds as stated by the shop, or null for no planned expiry. */
|
|
58
|
+
expiresAt: number | null;
|
|
59
|
+
}
|
|
60
|
+
export interface HostedCheckpoint {
|
|
61
|
+
origin: string;
|
|
62
|
+
metadata: UploadMetadata;
|
|
63
|
+
fee: ProtocolFee | null;
|
|
64
|
+
intent: UploadIntent;
|
|
65
|
+
manifest: UploadManifest;
|
|
66
|
+
authorization: UploadAuthorization | null;
|
|
67
|
+
uploadId: string | null;
|
|
68
|
+
reservation: HostingReservation | null;
|
|
69
|
+
split: UploadBaseSplit | null;
|
|
70
|
+
steps: ShareStep[];
|
|
71
|
+
completed: ShareStep[];
|
|
72
|
+
pending: {
|
|
73
|
+
step: ShareStep;
|
|
74
|
+
token: string;
|
|
75
|
+
txHash?: string;
|
|
76
|
+
snapshot?: string;
|
|
77
|
+
storageAccountExisted?: boolean;
|
|
78
|
+
validUntil?: number;
|
|
79
|
+
startedAt?: number;
|
|
80
|
+
operation?: {
|
|
81
|
+
method: string;
|
|
82
|
+
args: object;
|
|
83
|
+
deposit: string;
|
|
84
|
+
};
|
|
85
|
+
auth?: import('../settle-near/identity.js').Authorization;
|
|
86
|
+
} | null;
|
|
87
|
+
lease: {
|
|
88
|
+
owner: string;
|
|
89
|
+
until: number;
|
|
90
|
+
} | null;
|
|
91
|
+
backupConfirmed: boolean;
|
|
92
|
+
listingStorage: string | null;
|
|
93
|
+
header: string | null;
|
|
94
|
+
result: Shared | null;
|
|
95
|
+
}
|
|
96
|
+
export type HostedSellRecord = SellRecord & {
|
|
97
|
+
hosting: HostedCheckpoint;
|
|
98
|
+
};
|
|
99
|
+
export interface ShareContext {
|
|
100
|
+
config(): Promise<{
|
|
101
|
+
network: string;
|
|
102
|
+
nearUsdc: string;
|
|
103
|
+
usdc: string;
|
|
104
|
+
}>;
|
|
105
|
+
file(fileId: string): Promise<FileInfo | null>;
|
|
106
|
+
call(method: string, args: object, wallet: IdentityWallet): Promise<unknown>;
|
|
107
|
+
answer(value: unknown, secret: Uint8Array, fileId: string): Promise<Uint8Array>;
|
|
108
|
+
reopen(fileId: string, seller: IdentityWallet): Promise<Uint8Array>;
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type SellData } from '../envelope/replay.js';
|
|
2
|
+
import { type SellRecord } from '../pay/backup.js';
|
|
3
|
+
import '../relay/reservation.js';
|
|
4
|
+
import type { AnnonOptions } from './annon.js';
|
|
5
|
+
import type { HostedSellRecord, ShareContext, ShareOptions, ShareQuote } from './sharing-types.js';
|
|
6
|
+
export { shareSteps, validateHostedRecord } from './hosted-record.js';
|
|
7
|
+
export type { HostedCheckpoint, HostedSellRecord, ShareContext, Shared, ShareHosting, ShareOptions, ShareQuote, ShareStep, } from './sharing-types.js';
|
|
8
|
+
export declare function shareSize(data: SellData): number;
|
|
9
|
+
export declare class HostedSelling {
|
|
10
|
+
private readonly o;
|
|
11
|
+
private readonly context;
|
|
12
|
+
private readonly store;
|
|
13
|
+
private readonly quotes;
|
|
14
|
+
constructor(o: AnnonOptions, context: ShareContext);
|
|
15
|
+
private direct;
|
|
16
|
+
private fundingBalance;
|
|
17
|
+
private now;
|
|
18
|
+
private key;
|
|
19
|
+
load(id: string): Promise<HostedSellRecord>;
|
|
20
|
+
private save;
|
|
21
|
+
quote(input: ShareOptions): Promise<ShareQuote>;
|
|
22
|
+
begin(quoteId: string): Promise<SellRecord>;
|
|
23
|
+
confirmBackup(id: string): Promise<SellRecord>;
|
|
24
|
+
discard(id: string): Promise<void>;
|
|
25
|
+
backup(id: string): Promise<string>;
|
|
26
|
+
private prepared;
|
|
27
|
+
verifySource(id: string, data: SellData): Promise<void>;
|
|
28
|
+
next(id: string, input: Pick<ShareOptions, 'data' | 'seller' | 'hosting'> & {
|
|
29
|
+
expectedRevision?: number;
|
|
30
|
+
txHash?: string;
|
|
31
|
+
}): Promise<HostedSellRecord>;
|
|
32
|
+
private advance;
|
|
33
|
+
private checkSplit;
|
|
34
|
+
private live;
|
|
35
|
+
private finishPublication;
|
|
36
|
+
}
|