@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,98 @@
|
|
|
1
|
+
/** Durable SDK orchestration. Storage belongs to the embedding origin; no UI or wallet connector. */
|
|
2
|
+
import { Annon, type AnnonOptions, type BuyOptions, type BuyRoute } from '../api/annon.js';
|
|
3
|
+
import { AnnonError } from '../errors.js';
|
|
4
|
+
import { type Deposit, OneClick, type PollOptions } from '../oneclick/oneclick.js';
|
|
5
|
+
import { type EncryptedRecord, type RecoveryRecord } from '../pay/backup.js';
|
|
6
|
+
import { type PurchaseRecord } from '../pay/purchase.js';
|
|
7
|
+
import { type Store } from '../pay/store.js';
|
|
8
|
+
import type { IdentityWallet } from '../wallet/wallet.js';
|
|
9
|
+
import { type BrowserDownloadOptions } from './download.js';
|
|
10
|
+
import type { BrowserPurchaseRecord, BrowserPurchaseState } from './record.js';
|
|
11
|
+
export type { BrowserPurchaseRecord, BrowserPurchaseState } from './record.js';
|
|
12
|
+
export type PurchaseSdk = Pick<Annon, 'buy' | 'accept' | 'open' | 'recover' | 'proveRecovery'>;
|
|
13
|
+
export interface BrowserPurchaseStorage {
|
|
14
|
+
rawStore: Store<EncryptedRecord>;
|
|
15
|
+
backupSecret: Uint8Array;
|
|
16
|
+
writeBackup(name: string, encryptedFile: string): Promise<void>;
|
|
17
|
+
load(id: string): Promise<BrowserPurchaseRecord | null>;
|
|
18
|
+
save(expected: BrowserPurchaseRecord | null, next: BrowserPurchaseRecord): Promise<void>;
|
|
19
|
+
restorePurchase(record: PurchaseRecord): Promise<PurchaseRecord>;
|
|
20
|
+
list(): Promise<Pick<BrowserPurchaseRecord, 'id' | 'fileId' | 'route' | 'state'>[]>;
|
|
21
|
+
exportReceipt(id: string, secret: Uint8Array): Promise<string>;
|
|
22
|
+
importReceipt(file: string, secret: Uint8Array): Promise<string>;
|
|
23
|
+
recoveryArchives(purchaseId: string): Promise<RecoveryRecord[]>;
|
|
24
|
+
}
|
|
25
|
+
/** Local secret is random, persisted once with CAS. Clearing site storage removes local recovery. */
|
|
26
|
+
export declare function browserPurchaseStorage(options?: {
|
|
27
|
+
name?: string;
|
|
28
|
+
factory?: IDBFactory;
|
|
29
|
+
}): Promise<BrowserPurchaseStorage>;
|
|
30
|
+
export interface PurchaseProgress {
|
|
31
|
+
id: string;
|
|
32
|
+
state: BrowserPurchaseState;
|
|
33
|
+
revision: number;
|
|
34
|
+
/** A safe status code; raw upstream details stay in the encrypted record. */
|
|
35
|
+
swapStatus?: string;
|
|
36
|
+
/** Unix seconds when another tab or a crashed owner releases this checkout. */
|
|
37
|
+
leaseWaitUntil?: number;
|
|
38
|
+
}
|
|
39
|
+
export type BrowserOpenOptions = Pick<BrowserDownloadOptions, 'fetch' | 'signal' | 'size' | 'onProgress' | 'retries' | 'settleTries' | 'wait'>;
|
|
40
|
+
export interface ControllerOptions {
|
|
41
|
+
storage: BrowserPurchaseStorage;
|
|
42
|
+
sdk: PurchaseSdk;
|
|
43
|
+
id: string;
|
|
44
|
+
now?: () => number;
|
|
45
|
+
}
|
|
46
|
+
export interface PurchaseTermsReview {
|
|
47
|
+
/** Caller-chosen stable checkout id deduplicates double clicks and tabs. */
|
|
48
|
+
id: string;
|
|
49
|
+
fileId: string;
|
|
50
|
+
header: Uint8Array;
|
|
51
|
+
resourceUrl: string;
|
|
52
|
+
route: BuyRoute;
|
|
53
|
+
maxPrice: bigint;
|
|
54
|
+
}
|
|
55
|
+
/** Build the real SDK using the same encrypted storage and durable internal backups. */
|
|
56
|
+
export declare function browserAnnon(storage: BrowserPurchaseStorage, options: Omit<AnnonOptions, 'rawStore' | 'backupSecret' | 'writeBackup'>): Annon;
|
|
57
|
+
export declare class PurchaseLeaseBusy extends AnnonError {
|
|
58
|
+
readonly waitUntil: number;
|
|
59
|
+
readonly code = "lease_busy";
|
|
60
|
+
constructor(waitUntil: number);
|
|
61
|
+
}
|
|
62
|
+
export declare class BrowserPurchaseController {
|
|
63
|
+
private readonly options;
|
|
64
|
+
readonly storage: BrowserPurchaseStorage;
|
|
65
|
+
private readonly owner;
|
|
66
|
+
private readonly listeners;
|
|
67
|
+
constructor(options: ControllerOptions);
|
|
68
|
+
static create(options: Omit<ControllerOptions, 'id'>, terms: PurchaseTermsReview): Promise<BrowserPurchaseController>;
|
|
69
|
+
subscribe(listener: (event: PurchaseProgress) => void): () => void;
|
|
70
|
+
private read;
|
|
71
|
+
/** Safe to render. Full records are available only through the persistence adapter. */
|
|
72
|
+
snapshot(): Promise<PurchaseProgress & {
|
|
73
|
+
fileId: string;
|
|
74
|
+
route: BuyRoute;
|
|
75
|
+
resourceUrl: string;
|
|
76
|
+
}>;
|
|
77
|
+
private now;
|
|
78
|
+
private waiting;
|
|
79
|
+
private emit;
|
|
80
|
+
private busy;
|
|
81
|
+
/** Every asynchronous operation owns a renewable lease, with revision CAS on every write. */
|
|
82
|
+
private withLease;
|
|
83
|
+
private change;
|
|
84
|
+
start(options: Omit<BuyOptions, 'fileId' | 'header' | 'url' | 'route' | 'maxPrice' | 'onSaved' | 'beforeSave' | 'beforePayment' | 'onQuote'>): Promise<void>;
|
|
85
|
+
private deposit;
|
|
86
|
+
instructions(): Promise<Deposit | null>;
|
|
87
|
+
resume(options?: {
|
|
88
|
+
recovery?: IdentityWallet;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
/** Polling remains available after the deposit cutoff to track late deposits and refunds. */
|
|
91
|
+
poll(options?: Omit<PollOptions, 'checkpoint' | 'memo' | 'onProgress'> & {
|
|
92
|
+
oneClick?: Pick<OneClick, 'poll'>;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
recover(wallet: IdentityWallet): Promise<void>;
|
|
95
|
+
/** Open supplied ciphertext, or download with the saved grant. Returns plaintext only in memory. */
|
|
96
|
+
open(input?: Uint8Array | BrowserOpenOptions): ReturnType<Annon['open']>;
|
|
97
|
+
exportReceipt(secret: Uint8Array): Promise<string>;
|
|
98
|
+
}
|