fix: bind DOC0 upload receipts to original request
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 3s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 5s
CI (SIAX Cloud) / security (push) Successful in 22s
Security Scan (SIAX Cloud) / security (push) Successful in 22s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 25s
CI (SIAX Cloud) / integration (pull_request) Successful in 32s
CI (SIAX Cloud) / security (pull_request) Successful in 35s
CI (SIAX Cloud) / quality (push) Successful in 47s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m18s
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 3s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 5s
CI (SIAX Cloud) / security (push) Successful in 22s
Security Scan (SIAX Cloud) / security (push) Successful in 22s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 25s
CI (SIAX Cloud) / integration (pull_request) Successful in 32s
CI (SIAX Cloud) / security (pull_request) Successful in 35s
CI (SIAX Cloud) / quality (push) Successful in 47s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m18s
This commit is contained in:
@@ -142,11 +142,18 @@ export class Doc0UploadClient {
|
||||
) {
|
||||
throw new Error('A trusted HTTPS DOC0 endpoint, service credential and valid upload limits are required');
|
||||
}
|
||||
// Keep the validated values even if the caller later changes its options object.
|
||||
this.options = { ...options };
|
||||
this.baseUrl = url.toString().replace(/\/+$/, '');
|
||||
this.fetchImpl = options.fetchImpl ?? fetch;
|
||||
}
|
||||
|
||||
async upload(input: Doc0UploadInput): Promise<Doc0UploadReceipt> {
|
||||
if (!(input.bytes instanceof Uint8Array) || input.bytes.byteLength > this.options.maxBytes) {
|
||||
throw new Error('Invalid DOC0 upload input');
|
||||
}
|
||||
// Bind the outbound request and receipt to the same immutable-by-caller input.
|
||||
input = { ...input, bytes: new Uint8Array(input.bytes) };
|
||||
const identity = prepareDoc0UploadIdentity(input);
|
||||
if (identity.sourceSizeBytes > this.options.maxBytes) throw new Error('Invalid DOC0 upload input');
|
||||
const expectedHash = identity.sourceSha256;
|
||||
|
||||
Reference in New Issue
Block a user