@cardanowall/sdk-ts 0.2.0 → 0.4.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/client/index.cjs +2566 -1706
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +42 -5
- package/dist/client/index.d.ts +42 -5
- package/dist/client/index.js +2564 -1708
- package/dist/client/index.js.map +1 -1
- package/dist/conformance/cli.cjs +5978 -3438
- package/dist/conformance/cli.cjs.map +1 -1
- package/dist/conformance/cli.js +5978 -3438
- package/dist/conformance/cli.js.map +1 -1
- package/dist/fetch/index.cjs +33 -14
- package/dist/fetch/index.cjs.map +1 -1
- package/dist/fetch/index.d.cts +2 -2
- package/dist/fetch/index.d.ts +2 -2
- package/dist/fetch/index.js +32 -15
- package/dist/fetch/index.js.map +1 -1
- package/dist/{fetch-outbound-BT5-NiYN.d.cts → fetch-outbound-dOK3ZxYa.d.cts} +7 -3
- package/dist/{fetch-outbound-BT5-NiYN.d.ts → fetch-outbound-dOK3ZxYa.d.ts} +7 -3
- package/dist/hash/index.cjs +1 -1
- package/dist/hash/index.cjs.map +1 -1
- package/dist/hash/index.js +1 -1
- package/dist/hash/index.js.map +1 -1
- package/dist/identity/index.cjs +460 -219
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.d.cts +3 -2
- package/dist/identity/index.d.ts +3 -2
- package/dist/identity/index.js +460 -219
- package/dist/identity/index.js.map +1 -1
- package/dist/index.cjs +6912 -3678
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6890 -3672
- package/dist/index.js.map +1 -1
- package/dist/merkle/index.cjs +1 -1
- package/dist/merkle/index.js +1 -1
- package/dist/types-Cexm4VH9.d.cts +119 -0
- package/dist/types-CgoBub9J.d.ts +119 -0
- package/dist/{types-DGsZTMuZ.d.cts → types-Dp4wUSFI.d.cts} +220 -1
- package/dist/{types-DGsZTMuZ.d.ts → types-Dp4wUSFI.d.ts} +220 -1
- package/dist/verifier/index.cjs +5738 -3205
- package/dist/verifier/index.cjs.map +1 -1
- package/dist/verifier/index.d.cts +159 -111
- package/dist/verifier/index.d.ts +159 -111
- package/dist/verifier/index.js +5726 -3201
- package/dist/verifier/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/types-B8Q3gW54.d.ts +0 -123
- package/dist/types-CLXdbjqr.d.cts +0 -123
package/dist/merkle/index.cjs
CHANGED
package/dist/merkle/index.js
CHANGED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ValidationIssue, PoeRecord } from '@cardanowall/poe-standard';
|
|
2
|
+
import { H as HttpCallRecord, F as FetchOutbound } from './fetch-outbound-dOK3ZxYa.cjs';
|
|
3
|
+
|
|
4
|
+
type Verdict = 'valid' | 'pending' | 'unverifiable' | 'failed';
|
|
5
|
+
type ExitCode = 0 | 1 | 2 | 3;
|
|
6
|
+
declare const EXIT_CODE_FOR_VERDICT: Readonly<Record<Verdict, ExitCode>>;
|
|
7
|
+
type Profile = 'core' | 'signed' | 'sealed' | 'recipient-sealed';
|
|
8
|
+
declare const PROFILE_RANK: Readonly<Record<Profile, number>>;
|
|
9
|
+
|
|
10
|
+
type DecryptionCredential = {
|
|
11
|
+
readonly recipientSecretKey: Uint8Array;
|
|
12
|
+
} | {
|
|
13
|
+
readonly passphrase: string;
|
|
14
|
+
};
|
|
15
|
+
interface VerifyTxInput {
|
|
16
|
+
readonly txHash: string;
|
|
17
|
+
readonly profile?: Profile;
|
|
18
|
+
readonly cardanoGatewayChain?: ReadonlyArray<string>;
|
|
19
|
+
readonly blockfrostProjectId?: string;
|
|
20
|
+
readonly arweaveGatewayChain?: ReadonlyArray<string>;
|
|
21
|
+
readonly ipfsGatewayChain?: ReadonlyArray<string>;
|
|
22
|
+
readonly confirmationDepthThreshold?: number;
|
|
23
|
+
readonly denyHosts?: ReadonlyArray<string>;
|
|
24
|
+
readonly fetchContent?: boolean;
|
|
25
|
+
readonly maxFetchBytes?: number;
|
|
26
|
+
readonly decryption?: ReadonlyArray<DecryptionCredential>;
|
|
27
|
+
readonly ciphertextBytes?: Readonly<Record<number, Uint8Array>>;
|
|
28
|
+
readonly merkleLeaves?: Readonly<Record<number, Uint8Array>>;
|
|
29
|
+
readonly cardanoNetwork?: 'mainnet' | 'preprod';
|
|
30
|
+
readonly fetchOutbound?: FetchOutbound;
|
|
31
|
+
}
|
|
32
|
+
interface VerifyResolvedInput {
|
|
33
|
+
readonly txHash: string;
|
|
34
|
+
readonly metadataCbor: Uint8Array;
|
|
35
|
+
readonly confirmationDepth: number;
|
|
36
|
+
readonly blockTime: number;
|
|
37
|
+
readonly blockSlot?: number;
|
|
38
|
+
readonly txCbor?: Uint8Array;
|
|
39
|
+
readonly network?: string;
|
|
40
|
+
readonly cardanoNetwork?: 'mainnet' | 'preprod';
|
|
41
|
+
readonly profile?: Profile;
|
|
42
|
+
readonly confirmationDepthThreshold?: number;
|
|
43
|
+
readonly arweaveGatewayChain?: ReadonlyArray<string>;
|
|
44
|
+
readonly ipfsGatewayChain?: ReadonlyArray<string>;
|
|
45
|
+
readonly fetchOutbound?: FetchOutbound;
|
|
46
|
+
readonly denyHosts?: ReadonlyArray<string>;
|
|
47
|
+
readonly fetchContent?: boolean;
|
|
48
|
+
readonly maxFetchBytes?: number;
|
|
49
|
+
readonly decryption?: ReadonlyArray<DecryptionCredential>;
|
|
50
|
+
readonly ciphertextBytes?: Readonly<Record<number, Uint8Array>>;
|
|
51
|
+
readonly merkleLeaves?: Readonly<Record<number, Uint8Array>>;
|
|
52
|
+
}
|
|
53
|
+
type ContentCheck = 'checked' | 'mismatched' | 'not_checked';
|
|
54
|
+
interface DecryptionOutcome {
|
|
55
|
+
readonly decrypted: boolean;
|
|
56
|
+
readonly plaintextHashOk?: boolean;
|
|
57
|
+
readonly code?: string;
|
|
58
|
+
}
|
|
59
|
+
interface ItemReportEntry {
|
|
60
|
+
readonly contentCheck: ContentCheck;
|
|
61
|
+
readonly decryption?: DecryptionOutcome;
|
|
62
|
+
}
|
|
63
|
+
interface MerkleReportEntry {
|
|
64
|
+
readonly contentCheck: ContentCheck;
|
|
65
|
+
}
|
|
66
|
+
type SignatureVerdict = 'valid' | 'invalid' | 'unsupported' | 'unresolved';
|
|
67
|
+
type SignatureFailureReason = 'MALFORMED_SIG_COSE_SIGN1' | 'SIGNATURE_UNSUPPORTED' | 'SIGNER_KEY_UNRESOLVED' | 'SIGNATURE_INVALID' | 'WALLET_ADDRESS_MISMATCH';
|
|
68
|
+
type SignerType = 'in-signature-kid' | 'wallet-inline-key';
|
|
69
|
+
interface VerifyRecordSignature {
|
|
70
|
+
readonly index: number;
|
|
71
|
+
readonly verdict: SignatureVerdict;
|
|
72
|
+
readonly signerPub?: string;
|
|
73
|
+
readonly signerType?: SignerType;
|
|
74
|
+
readonly reason?: SignatureFailureReason;
|
|
75
|
+
}
|
|
76
|
+
interface VerifyTxWitness {
|
|
77
|
+
readonly type: 'vkey';
|
|
78
|
+
readonly vkey: string;
|
|
79
|
+
readonly key_hash: string;
|
|
80
|
+
readonly signature_valid: boolean;
|
|
81
|
+
}
|
|
82
|
+
interface VerifyTxOutput {
|
|
83
|
+
readonly address: string;
|
|
84
|
+
readonly lovelace: string;
|
|
85
|
+
}
|
|
86
|
+
interface VerifyTxSummary {
|
|
87
|
+
readonly fee_lovelace: string;
|
|
88
|
+
readonly input_count: number;
|
|
89
|
+
readonly output_count: number;
|
|
90
|
+
readonly outputs: ReadonlyArray<VerifyTxOutput>;
|
|
91
|
+
readonly total_output_lovelace: string;
|
|
92
|
+
readonly script_witness_count: number;
|
|
93
|
+
readonly invalid_before?: number;
|
|
94
|
+
readonly invalid_hereafter?: number;
|
|
95
|
+
readonly required_signer_key_hashes?: ReadonlyArray<string>;
|
|
96
|
+
readonly network_id?: number;
|
|
97
|
+
}
|
|
98
|
+
interface VerifyReport {
|
|
99
|
+
readonly verdict: Verdict;
|
|
100
|
+
readonly exitCode: ExitCode;
|
|
101
|
+
readonly issues: ReadonlyArray<ValidationIssue>;
|
|
102
|
+
readonly items: ReadonlyArray<ItemReportEntry>;
|
|
103
|
+
readonly merkle: ReadonlyArray<MerkleReportEntry>;
|
|
104
|
+
readonly auditTrail: ReadonlyArray<HttpCallRecord>;
|
|
105
|
+
readonly network: string;
|
|
106
|
+
readonly confirmationDepth?: number;
|
|
107
|
+
readonly confirmationThreshold?: number;
|
|
108
|
+
readonly block_time?: number;
|
|
109
|
+
readonly block_slot?: number;
|
|
110
|
+
readonly txHash: string;
|
|
111
|
+
readonly profile: Profile;
|
|
112
|
+
readonly record?: PoeRecord;
|
|
113
|
+
readonly signatures?: ReadonlyArray<VerifyRecordSignature>;
|
|
114
|
+
readonly txWitnesses?: ReadonlyArray<VerifyTxWitness>;
|
|
115
|
+
readonly txSummary?: VerifyTxSummary;
|
|
116
|
+
readonly metadataLabels?: ReadonlyArray<number>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { type ContentCheck as C, type DecryptionCredential as D, EXIT_CODE_FOR_VERDICT as E, type ItemReportEntry as I, type MerkleReportEntry as M, PROFILE_RANK as P, type SignatureFailureReason as S, type Verdict as V, type DecryptionOutcome as a, type ExitCode as b, type Profile as c, type SignatureVerdict as d, type SignerType as e, type VerifyRecordSignature as f, type VerifyReport as g, type VerifyResolvedInput as h, type VerifyTxInput as i, type VerifyTxOutput as j, type VerifyTxSummary as k, type VerifyTxWitness as l };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ValidationIssue, PoeRecord } from '@cardanowall/poe-standard';
|
|
2
|
+
import { H as HttpCallRecord, F as FetchOutbound } from './fetch-outbound-dOK3ZxYa.js';
|
|
3
|
+
|
|
4
|
+
type Verdict = 'valid' | 'pending' | 'unverifiable' | 'failed';
|
|
5
|
+
type ExitCode = 0 | 1 | 2 | 3;
|
|
6
|
+
declare const EXIT_CODE_FOR_VERDICT: Readonly<Record<Verdict, ExitCode>>;
|
|
7
|
+
type Profile = 'core' | 'signed' | 'sealed' | 'recipient-sealed';
|
|
8
|
+
declare const PROFILE_RANK: Readonly<Record<Profile, number>>;
|
|
9
|
+
|
|
10
|
+
type DecryptionCredential = {
|
|
11
|
+
readonly recipientSecretKey: Uint8Array;
|
|
12
|
+
} | {
|
|
13
|
+
readonly passphrase: string;
|
|
14
|
+
};
|
|
15
|
+
interface VerifyTxInput {
|
|
16
|
+
readonly txHash: string;
|
|
17
|
+
readonly profile?: Profile;
|
|
18
|
+
readonly cardanoGatewayChain?: ReadonlyArray<string>;
|
|
19
|
+
readonly blockfrostProjectId?: string;
|
|
20
|
+
readonly arweaveGatewayChain?: ReadonlyArray<string>;
|
|
21
|
+
readonly ipfsGatewayChain?: ReadonlyArray<string>;
|
|
22
|
+
readonly confirmationDepthThreshold?: number;
|
|
23
|
+
readonly denyHosts?: ReadonlyArray<string>;
|
|
24
|
+
readonly fetchContent?: boolean;
|
|
25
|
+
readonly maxFetchBytes?: number;
|
|
26
|
+
readonly decryption?: ReadonlyArray<DecryptionCredential>;
|
|
27
|
+
readonly ciphertextBytes?: Readonly<Record<number, Uint8Array>>;
|
|
28
|
+
readonly merkleLeaves?: Readonly<Record<number, Uint8Array>>;
|
|
29
|
+
readonly cardanoNetwork?: 'mainnet' | 'preprod';
|
|
30
|
+
readonly fetchOutbound?: FetchOutbound;
|
|
31
|
+
}
|
|
32
|
+
interface VerifyResolvedInput {
|
|
33
|
+
readonly txHash: string;
|
|
34
|
+
readonly metadataCbor: Uint8Array;
|
|
35
|
+
readonly confirmationDepth: number;
|
|
36
|
+
readonly blockTime: number;
|
|
37
|
+
readonly blockSlot?: number;
|
|
38
|
+
readonly txCbor?: Uint8Array;
|
|
39
|
+
readonly network?: string;
|
|
40
|
+
readonly cardanoNetwork?: 'mainnet' | 'preprod';
|
|
41
|
+
readonly profile?: Profile;
|
|
42
|
+
readonly confirmationDepthThreshold?: number;
|
|
43
|
+
readonly arweaveGatewayChain?: ReadonlyArray<string>;
|
|
44
|
+
readonly ipfsGatewayChain?: ReadonlyArray<string>;
|
|
45
|
+
readonly fetchOutbound?: FetchOutbound;
|
|
46
|
+
readonly denyHosts?: ReadonlyArray<string>;
|
|
47
|
+
readonly fetchContent?: boolean;
|
|
48
|
+
readonly maxFetchBytes?: number;
|
|
49
|
+
readonly decryption?: ReadonlyArray<DecryptionCredential>;
|
|
50
|
+
readonly ciphertextBytes?: Readonly<Record<number, Uint8Array>>;
|
|
51
|
+
readonly merkleLeaves?: Readonly<Record<number, Uint8Array>>;
|
|
52
|
+
}
|
|
53
|
+
type ContentCheck = 'checked' | 'mismatched' | 'not_checked';
|
|
54
|
+
interface DecryptionOutcome {
|
|
55
|
+
readonly decrypted: boolean;
|
|
56
|
+
readonly plaintextHashOk?: boolean;
|
|
57
|
+
readonly code?: string;
|
|
58
|
+
}
|
|
59
|
+
interface ItemReportEntry {
|
|
60
|
+
readonly contentCheck: ContentCheck;
|
|
61
|
+
readonly decryption?: DecryptionOutcome;
|
|
62
|
+
}
|
|
63
|
+
interface MerkleReportEntry {
|
|
64
|
+
readonly contentCheck: ContentCheck;
|
|
65
|
+
}
|
|
66
|
+
type SignatureVerdict = 'valid' | 'invalid' | 'unsupported' | 'unresolved';
|
|
67
|
+
type SignatureFailureReason = 'MALFORMED_SIG_COSE_SIGN1' | 'SIGNATURE_UNSUPPORTED' | 'SIGNER_KEY_UNRESOLVED' | 'SIGNATURE_INVALID' | 'WALLET_ADDRESS_MISMATCH';
|
|
68
|
+
type SignerType = 'in-signature-kid' | 'wallet-inline-key';
|
|
69
|
+
interface VerifyRecordSignature {
|
|
70
|
+
readonly index: number;
|
|
71
|
+
readonly verdict: SignatureVerdict;
|
|
72
|
+
readonly signerPub?: string;
|
|
73
|
+
readonly signerType?: SignerType;
|
|
74
|
+
readonly reason?: SignatureFailureReason;
|
|
75
|
+
}
|
|
76
|
+
interface VerifyTxWitness {
|
|
77
|
+
readonly type: 'vkey';
|
|
78
|
+
readonly vkey: string;
|
|
79
|
+
readonly key_hash: string;
|
|
80
|
+
readonly signature_valid: boolean;
|
|
81
|
+
}
|
|
82
|
+
interface VerifyTxOutput {
|
|
83
|
+
readonly address: string;
|
|
84
|
+
readonly lovelace: string;
|
|
85
|
+
}
|
|
86
|
+
interface VerifyTxSummary {
|
|
87
|
+
readonly fee_lovelace: string;
|
|
88
|
+
readonly input_count: number;
|
|
89
|
+
readonly output_count: number;
|
|
90
|
+
readonly outputs: ReadonlyArray<VerifyTxOutput>;
|
|
91
|
+
readonly total_output_lovelace: string;
|
|
92
|
+
readonly script_witness_count: number;
|
|
93
|
+
readonly invalid_before?: number;
|
|
94
|
+
readonly invalid_hereafter?: number;
|
|
95
|
+
readonly required_signer_key_hashes?: ReadonlyArray<string>;
|
|
96
|
+
readonly network_id?: number;
|
|
97
|
+
}
|
|
98
|
+
interface VerifyReport {
|
|
99
|
+
readonly verdict: Verdict;
|
|
100
|
+
readonly exitCode: ExitCode;
|
|
101
|
+
readonly issues: ReadonlyArray<ValidationIssue>;
|
|
102
|
+
readonly items: ReadonlyArray<ItemReportEntry>;
|
|
103
|
+
readonly merkle: ReadonlyArray<MerkleReportEntry>;
|
|
104
|
+
readonly auditTrail: ReadonlyArray<HttpCallRecord>;
|
|
105
|
+
readonly network: string;
|
|
106
|
+
readonly confirmationDepth?: number;
|
|
107
|
+
readonly confirmationThreshold?: number;
|
|
108
|
+
readonly block_time?: number;
|
|
109
|
+
readonly block_slot?: number;
|
|
110
|
+
readonly txHash: string;
|
|
111
|
+
readonly profile: Profile;
|
|
112
|
+
readonly record?: PoeRecord;
|
|
113
|
+
readonly signatures?: ReadonlyArray<VerifyRecordSignature>;
|
|
114
|
+
readonly txWitnesses?: ReadonlyArray<VerifyTxWitness>;
|
|
115
|
+
readonly txSummary?: VerifyTxSummary;
|
|
116
|
+
readonly metadataLabels?: ReadonlyArray<number>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { type ContentCheck as C, type DecryptionCredential as D, EXIT_CODE_FOR_VERDICT as E, type ItemReportEntry as I, type MerkleReportEntry as M, PROFILE_RANK as P, type SignatureFailureReason as S, type Verdict as V, type DecryptionOutcome as a, type ExitCode as b, type Profile as c, type SignatureVerdict as d, type SignerType as e, type VerifyRecordSignature as f, type VerifyReport as g, type VerifyResolvedInput as h, type VerifyTxInput as i, type VerifyTxOutput as j, type VerifyTxSummary as k, type VerifyTxWitness as l };
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/** The runtime-neutral source contract the resumable uploader drives. */
|
|
2
|
+
interface ResumableSource {
|
|
3
|
+
/** Total number of bytes in the input. */
|
|
4
|
+
readonly size: number;
|
|
5
|
+
/**
|
|
6
|
+
* Read the half-open byte range `[start, end)`. May resolve synchronously or
|
|
7
|
+
* asynchronously; callers always `await` the result. The returned array owns
|
|
8
|
+
* its bytes (callers may transfer it into a request body).
|
|
9
|
+
*/
|
|
10
|
+
slice(start: number, end: number): Uint8Array | Promise<Uint8Array>;
|
|
11
|
+
/**
|
|
12
|
+
* An ordered async stream over the whole input, used once to compute the
|
|
13
|
+
* whole-file digest. Implementations stream in bounded chunks so a multi-GB
|
|
14
|
+
* input is never materialised in full.
|
|
15
|
+
*/
|
|
16
|
+
stream(): AsyncIterable<Uint8Array>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Any value `toResumableSource` knows how to adapt:
|
|
20
|
+
* - a `ResumableSource` (passed through),
|
|
21
|
+
* - a browser `Blob`/`File` (uses native `.slice()`/`.stream()`),
|
|
22
|
+
* - a `Uint8Array`/`Buffer` (in-memory bytes),
|
|
23
|
+
* - a filesystem path string (read in bounded slices, never fully buffered).
|
|
24
|
+
*/
|
|
25
|
+
type ResumableSourceInput = ResumableSource | Blob | Uint8Array | string;
|
|
26
|
+
/**
|
|
27
|
+
* Adapt any supported input to the runtime-neutral {@link ResumableSource}
|
|
28
|
+
* contract. Returns a promise because a filesystem-path source must stat the
|
|
29
|
+
* file before its size is known. Throws `TypeError` for unsupported inputs.
|
|
30
|
+
*
|
|
31
|
+
* The path branch is the only one that touches `node:fs`; a browser caller
|
|
32
|
+
* passes a `Blob`/`File` or `Uint8Array` and never reaches it.
|
|
33
|
+
*/
|
|
34
|
+
declare function toResumableSource(input: ResumableSourceInput): Promise<ResumableSource>;
|
|
35
|
+
|
|
1
36
|
type FetchImpl = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
2
37
|
interface Label309ClientConfig {
|
|
3
38
|
/**
|
|
@@ -44,6 +79,190 @@ type UploadEntry = UploadSuccessEntry | UploadFailureEntry;
|
|
|
44
79
|
interface UploadsResponse {
|
|
45
80
|
readonly uploads: ReadonlyArray<UploadEntry>;
|
|
46
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Body of `POST /api/v1/poe/uploads/sessions`. `sha256` is the lowercase-hex
|
|
84
|
+
* digest of the WHOLE file; `chunk_bytes` is the client's requested chunk size,
|
|
85
|
+
* which the server clamps to `max_chunk_bytes` and echoes back authoritatively.
|
|
86
|
+
*/
|
|
87
|
+
interface UploadSessionCreateRequest {
|
|
88
|
+
readonly target: StorageTarget;
|
|
89
|
+
readonly sha256: string;
|
|
90
|
+
readonly total_bytes: number;
|
|
91
|
+
readonly chunk_bytes: number;
|
|
92
|
+
readonly content_type?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* `201 Created` from session create. `chunk_bytes` is AUTHORITATIVE — the
|
|
96
|
+
* client recomputes its chunk grid from this value, not from what it requested.
|
|
97
|
+
*/
|
|
98
|
+
interface UploadSessionCreateResponse {
|
|
99
|
+
readonly session_id: string;
|
|
100
|
+
readonly chunk_bytes: number;
|
|
101
|
+
readonly chunk_count: number;
|
|
102
|
+
readonly received: ReadonlyArray<number>;
|
|
103
|
+
readonly expires_at: string;
|
|
104
|
+
readonly max_chunk_bytes: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* `200 OK` short-circuit returned by session create when the declared
|
|
108
|
+
* `(account, backend, sha256)` already has a committed receipt: the existing
|
|
109
|
+
* URI is returned and no bytes are uploaded.
|
|
110
|
+
*
|
|
111
|
+
* `charged_usd_micros` is a JSON number and is always `0` on this path (the
|
|
112
|
+
* bytes were already stored, so nothing is charged).
|
|
113
|
+
*/
|
|
114
|
+
interface UploadSessionDeduplicatedResponse {
|
|
115
|
+
readonly deduplicated: true;
|
|
116
|
+
readonly uri: string;
|
|
117
|
+
readonly sha256: string;
|
|
118
|
+
readonly bytes: number;
|
|
119
|
+
readonly charged_usd_micros: number;
|
|
120
|
+
}
|
|
121
|
+
/** `200 OK` from a chunk PUT — the running received-set after this chunk. */
|
|
122
|
+
interface UploadSessionChunkResponse {
|
|
123
|
+
readonly index: number;
|
|
124
|
+
readonly received: ReadonlyArray<number>;
|
|
125
|
+
readonly remaining: number;
|
|
126
|
+
readonly complete: boolean;
|
|
127
|
+
}
|
|
128
|
+
type UploadSessionState = 'open' | 'assembling' | 'completed' | 'failed' | 'expired';
|
|
129
|
+
/**
|
|
130
|
+
* `GET /api/v1/poe/uploads/sessions/{sid}` — the resume contract. A
|
|
131
|
+
* reconnecting client reads `missing` and re-PUTs only those indices.
|
|
132
|
+
*/
|
|
133
|
+
interface UploadSessionStatus {
|
|
134
|
+
readonly session_id: string;
|
|
135
|
+
readonly state: UploadSessionState;
|
|
136
|
+
readonly sha256: string;
|
|
137
|
+
readonly total_bytes: number;
|
|
138
|
+
readonly chunk_bytes: number;
|
|
139
|
+
readonly chunk_count: number;
|
|
140
|
+
readonly received: ReadonlyArray<number>;
|
|
141
|
+
readonly missing: ReadonlyArray<number>;
|
|
142
|
+
readonly expires_at: string;
|
|
143
|
+
readonly attempt_id: string | null;
|
|
144
|
+
readonly uri: string | null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* `POST /api/v1/poe/uploads/sessions/{sid}/complete`. Either the terminal
|
|
148
|
+
* committed/dedup outcome (`ok`), or `accepted` with an `attempt_id` to poll via
|
|
149
|
+
* `GET /api/v1/poe/uploads/attempts/{attempt_id}`.
|
|
150
|
+
*/
|
|
151
|
+
interface UploadSessionCompletedResponse {
|
|
152
|
+
readonly ok: true;
|
|
153
|
+
readonly uri: string;
|
|
154
|
+
readonly sha256: string;
|
|
155
|
+
readonly bytes: number;
|
|
156
|
+
/**
|
|
157
|
+
* Storage USD (micro-USD) applied at completion, a JSON number: the number
|
|
158
|
+
* `0` on a free-window or deduped-on-commit completion, the charge otherwise.
|
|
159
|
+
*/
|
|
160
|
+
readonly charged_usd_micros: number;
|
|
161
|
+
}
|
|
162
|
+
interface UploadSessionAcceptedResponse {
|
|
163
|
+
readonly accepted: true;
|
|
164
|
+
readonly attempt_id: string;
|
|
165
|
+
}
|
|
166
|
+
type UploadSessionCompleteResponse = UploadSessionCompletedResponse | UploadSessionAcceptedResponse;
|
|
167
|
+
/**
|
|
168
|
+
* `GET /api/v1/poe/uploads/attempts/{attempt_id}` — the terminal poll target
|
|
169
|
+
* shared with the single-shot path.
|
|
170
|
+
*
|
|
171
|
+
* - `reserved` — still in flight; keep polling.
|
|
172
|
+
* - `committed` — terminal success; carries `uri` and `charged_usd_micros`.
|
|
173
|
+
* - `released` — terminal failure; carries `reason`.
|
|
174
|
+
*
|
|
175
|
+
* `attempt_id`, `sha256`, `bytes`, and `backend` are present in every state;
|
|
176
|
+
* `uri` / `charged_usd_micros` appear only on `committed`, `reason` only on
|
|
177
|
+
* `released`. `bytes` and `charged_usd_micros` are JSON numbers. Modelled as a
|
|
178
|
+
* discriminated union on `state` so a consumer that narrows on `state` sees
|
|
179
|
+
* exactly the fields that state carries.
|
|
180
|
+
*/
|
|
181
|
+
type UploadAttemptState = 'reserved' | 'committed' | 'released';
|
|
182
|
+
type UploadAttemptReleaseReason = 'provider_rejected' | 'unrecoverable_staged_content_lost';
|
|
183
|
+
interface UploadAttemptCommon {
|
|
184
|
+
readonly attempt_id: string;
|
|
185
|
+
readonly sha256: string;
|
|
186
|
+
readonly bytes: number;
|
|
187
|
+
readonly backend: string;
|
|
188
|
+
}
|
|
189
|
+
interface UploadAttemptReserved extends UploadAttemptCommon {
|
|
190
|
+
readonly state: 'reserved';
|
|
191
|
+
}
|
|
192
|
+
interface UploadAttemptCommitted extends UploadAttemptCommon {
|
|
193
|
+
readonly state: 'committed';
|
|
194
|
+
readonly uri: string;
|
|
195
|
+
readonly charged_usd_micros: number;
|
|
196
|
+
}
|
|
197
|
+
interface UploadAttemptReleased extends UploadAttemptCommon {
|
|
198
|
+
readonly state: 'released';
|
|
199
|
+
/**
|
|
200
|
+
* Why the attempt failed. The gateway emits a closed set today
|
|
201
|
+
* (`provider_rejected` — retry; `unrecoverable_staged_content_lost` —
|
|
202
|
+
* re-upload), but a forward-compatible consumer should treat the value as an
|
|
203
|
+
* opaque string.
|
|
204
|
+
*/
|
|
205
|
+
readonly reason: UploadAttemptReleaseReason | (string & {});
|
|
206
|
+
}
|
|
207
|
+
type UploadAttemptStatus = UploadAttemptReserved | UploadAttemptCommitted | UploadAttemptReleased;
|
|
208
|
+
/**
|
|
209
|
+
* Input to `uploadResumable()`. The `source` works in both runtimes: a
|
|
210
|
+
* `Blob`/`File` in the browser, a `Uint8Array`, a filesystem path string, or a
|
|
211
|
+
* pre-adapted `ResumableSource` on the server. The helper uploads at most one
|
|
212
|
+
* file and returns its `ar://` URI.
|
|
213
|
+
*/
|
|
214
|
+
interface UploadResumableInput {
|
|
215
|
+
readonly target?: StorageTarget;
|
|
216
|
+
/**
|
|
217
|
+
* Bytes to upload: a browser `Blob`/`File` (sliced + streamed from disk), a
|
|
218
|
+
* `Uint8Array`, a server filesystem path, or a `ResumableSource`.
|
|
219
|
+
*/
|
|
220
|
+
readonly source: ResumableSourceInput;
|
|
221
|
+
/**
|
|
222
|
+
* Files at or below this size use the single-shot `uploads()` path unchanged;
|
|
223
|
+
* larger files use the session flow. Defaults to ~48 MiB so an upload clears
|
|
224
|
+
* common CDN/proxy single-request body caps below 100 MB.
|
|
225
|
+
*/
|
|
226
|
+
readonly threshold?: number;
|
|
227
|
+
/**
|
|
228
|
+
* Requested chunk size for the session. The server clamps it to its
|
|
229
|
+
* `max_chunk_bytes` and the helper honours the returned authoritative value.
|
|
230
|
+
* Defaults to ~48 MiB.
|
|
231
|
+
*/
|
|
232
|
+
readonly chunkBytes?: number;
|
|
233
|
+
/** Number of chunk PUTs in flight at once (default 4). */
|
|
234
|
+
readonly parallelism?: number;
|
|
235
|
+
/** Per-chunk retry attempts on a transient PUT failure (default 4). */
|
|
236
|
+
readonly maxChunkRetries?: number;
|
|
237
|
+
/**
|
|
238
|
+
* Stable key for `POST .../complete` replay. When omitted the helper derives
|
|
239
|
+
* one deterministically from the declared digest so a re-invocation replays
|
|
240
|
+
* the same terminal result rather than racing a second completion.
|
|
241
|
+
*/
|
|
242
|
+
readonly idempotencyKey?: string;
|
|
243
|
+
/** MIME type recorded for the assembled data item. */
|
|
244
|
+
readonly contentType?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Resume an interrupted upload: pass a `session_id` from a prior attempt and
|
|
247
|
+
* the helper GETs its status and uploads only the missing indices.
|
|
248
|
+
*/
|
|
249
|
+
readonly sessionId?: string;
|
|
250
|
+
/** Abort signal forwarded to every underlying request. */
|
|
251
|
+
readonly signal?: AbortSignal;
|
|
252
|
+
}
|
|
253
|
+
/** Result of `uploadResumable()` — the committed storage location. */
|
|
254
|
+
interface UploadResumableResult {
|
|
255
|
+
/** Canonical `ar://<tx>` URI of the stored content. */
|
|
256
|
+
readonly uri: string;
|
|
257
|
+
/** Whole-file SHA-256, lowercase hex. */
|
|
258
|
+
readonly sha256: string;
|
|
259
|
+
/** Stored byte count. */
|
|
260
|
+
readonly bytes: number;
|
|
261
|
+
/** `true` when the bytes were already stored (create-time or commit-time dedup). */
|
|
262
|
+
readonly deduplicated: boolean;
|
|
263
|
+
/** Which ingress path carried the bytes. */
|
|
264
|
+
readonly mode: 'single-shot' | 'chunked';
|
|
265
|
+
}
|
|
47
266
|
interface QuoteInput {
|
|
48
267
|
/** Canonical-CBOR record length in bytes (header + items). */
|
|
49
268
|
readonly recordBytes: number;
|
|
@@ -318,4 +537,4 @@ interface PublishMerkleResponse {
|
|
|
318
537
|
readonly balance_after_usd_micros: string;
|
|
319
538
|
}
|
|
320
539
|
|
|
321
|
-
export type
|
|
540
|
+
export { type UploadSuccessEntry as $, type AccountBalance as A, type UploadAttemptReleaseReason as B, type ConformanceProfile as C, type UploadAttemptReleased as D, type UploadAttemptReserved as E, type FetchImpl as F, type UploadAttemptState as G, type UploadAttemptStatus as H, type UploadEntry as I, type UploadFailureEntry as J, type UploadResumableInput as K, type Label309ClientConfig as L, type UploadResumableResult as M, type UploadSessionAcceptedResponse as N, type UploadSessionChunkResponse as O, type PoeItemResponse as P, type QuoteInput as Q, type RecordResource as R, type Signer as S, type UploadSessionCompleteResponse as T, type UploadAttemptCommitted as U, type UploadSessionCompletedResponse as V, type UploadSessionCreateRequest as W, type UploadSessionCreateResponse as X, type UploadSessionDeduplicatedResponse as Y, type UploadSessionState as Z, type UploadSessionStatus as _, type PoeStatus as a, type UploadsInput as a0, type UploadsResponse as a1, toResumableSource as a2, type PoeVerifyInput as b, type PublishBatchEntry as c, type PublishBatchFailureEntry as d, type PublishBatchFailureError as e, type PublishBatchInput as f, type PublishBatchResponse as g, type PublishBatchResultEntry as h, type PublishBatchSuccessEntry as i, type PublishContentInput as j, type PublishInput as k, type PublishMerkleInput as l, type PublishMerkleResponse as m, type PublishPrehashedInput as n, type PublishResponse as o, type PublishSealedInput as p, type QuoteResponse as q, type RecordScheme as r, type RecordSignature as s, type RecordStatus as t, type RecordsListInput as u, type RecordsListResponse as v, type ResumableSource as w, type ResumableSourceInput as x, type StorageTarget as y, type SupportedHashAlg as z };
|