@veridid/signing 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +39 -2
- package/build/SigningApi.d.mts +368 -0
- package/build/SigningApi.d.mts.map +1 -0
- package/build/SigningApi.mjs +516 -0
- package/build/SigningApi.mjs.map +1 -0
- package/build/SigningEvents.d.mts +71 -0
- package/build/SigningEvents.d.mts.map +1 -0
- package/build/SigningEvents.mjs +16 -0
- package/build/SigningEvents.mjs.map +1 -0
- package/build/SigningModule.d.mts +42 -0
- package/build/SigningModule.d.mts.map +1 -0
- package/build/SigningModule.mjs +91 -0
- package/build/SigningModule.mjs.map +1 -0
- package/build/SigningRole.d.mts +25 -0
- package/build/SigningRole.d.mts.map +1 -0
- package/build/SigningRole.mjs +27 -0
- package/build/SigningRole.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +9 -0
- package/build/compat.d.mts +24 -0
- package/build/compat.d.mts.map +1 -0
- package/build/compat.mjs +26 -0
- package/build/compat.mjs.map +1 -0
- package/build/delivery/ArtifactDeliveryStrategy.d.mts +74 -0
- package/build/delivery/ArtifactDeliveryStrategy.d.mts.map +1 -0
- package/build/delivery/InlineBase64Strategy.d.mts +50 -0
- package/build/delivery/InlineBase64Strategy.d.mts.map +1 -0
- package/build/delivery/InlineBase64Strategy.mjs +80 -0
- package/build/delivery/InlineBase64Strategy.mjs.map +1 -0
- package/build/delivery/index.mjs +1 -0
- package/build/errors/ArtifactTooLargeError.d.mts +12 -0
- package/build/errors/ArtifactTooLargeError.d.mts.map +1 -0
- package/build/errors/ArtifactTooLargeError.mjs +15 -0
- package/build/errors/ArtifactTooLargeError.mjs.map +1 -0
- package/build/errors/DigestMismatchError.d.mts +12 -0
- package/build/errors/DigestMismatchError.d.mts.map +1 -0
- package/build/errors/DigestMismatchError.mjs +15 -0
- package/build/errors/DigestMismatchError.mjs.map +1 -0
- package/build/errors/IdempotencyConflictError.d.mts +12 -0
- package/build/errors/IdempotencyConflictError.d.mts.map +1 -0
- package/build/errors/IdempotencyConflictError.mjs +15 -0
- package/build/errors/IdempotencyConflictError.mjs.map +1 -0
- package/build/errors/InvalidStateError.d.mts +14 -0
- package/build/errors/InvalidStateError.d.mts.map +1 -0
- package/build/errors/InvalidStateError.mjs +16 -0
- package/build/errors/InvalidStateError.mjs.map +1 -0
- package/build/errors/PolicyEnforcementError.d.mts +12 -0
- package/build/errors/PolicyEnforcementError.d.mts.map +1 -0
- package/build/errors/PolicyEnforcementError.mjs +15 -0
- package/build/errors/PolicyEnforcementError.mjs.map +1 -0
- package/build/errors/SigningError.d.mts +16 -0
- package/build/errors/SigningError.d.mts.map +1 -0
- package/build/errors/SigningError.mjs +16 -0
- package/build/errors/SigningError.mjs.map +1 -0
- package/build/errors/ThresholdNotMetError.d.mts +12 -0
- package/build/errors/ThresholdNotMetError.d.mts.map +1 -0
- package/build/errors/ThresholdNotMetError.mjs +15 -0
- package/build/errors/ThresholdNotMetError.mjs.map +1 -0
- package/build/errors/UnsupportedCanonicalizerError.d.mts +12 -0
- package/build/errors/UnsupportedCanonicalizerError.d.mts.map +1 -0
- package/build/errors/UnsupportedCanonicalizerError.mjs +16 -0
- package/build/errors/UnsupportedCanonicalizerError.mjs.map +1 -0
- package/build/errors/UnsupportedSuiteError.d.mts +12 -0
- package/build/errors/UnsupportedSuiteError.d.mts.map +1 -0
- package/build/errors/UnsupportedSuiteError.mjs +16 -0
- package/build/errors/UnsupportedSuiteError.mjs.map +1 -0
- package/build/errors/index.d.mts +9 -0
- package/build/errors/index.mjs +9 -0
- package/build/handlers/CombineMessageHandler.d.mts +22 -0
- package/build/handlers/CombineMessageHandler.d.mts.map +1 -0
- package/build/handlers/CombineMessageHandler.mjs +25 -0
- package/build/handlers/CombineMessageHandler.mjs.map +1 -0
- package/build/handlers/ConsentMessageHandler.d.mts +19 -0
- package/build/handlers/ConsentMessageHandler.d.mts.map +1 -0
- package/build/handlers/ConsentMessageHandler.mjs +21 -0
- package/build/handlers/ConsentMessageHandler.mjs.map +1 -0
- package/build/handlers/DeclineMessageHandler.d.mts +19 -0
- package/build/handlers/DeclineMessageHandler.d.mts.map +1 -0
- package/build/handlers/DeclineMessageHandler.mjs +21 -0
- package/build/handlers/DeclineMessageHandler.mjs.map +1 -0
- package/build/handlers/PartialSignatureMessageHandler.d.mts +19 -0
- package/build/handlers/PartialSignatureMessageHandler.d.mts.map +1 -0
- package/build/handlers/PartialSignatureMessageHandler.mjs +21 -0
- package/build/handlers/PartialSignatureMessageHandler.mjs.map +1 -0
- package/build/handlers/ProposeSigningMessageHandler.d.mts +19 -0
- package/build/handlers/ProposeSigningMessageHandler.d.mts.map +1 -0
- package/build/handlers/ProposeSigningMessageHandler.mjs +21 -0
- package/build/handlers/ProposeSigningMessageHandler.mjs.map +1 -0
- package/build/handlers/ProvideArtifactsMessageHandler.d.mts +19 -0
- package/build/handlers/ProvideArtifactsMessageHandler.d.mts.map +1 -0
- package/build/handlers/ProvideArtifactsMessageHandler.mjs +21 -0
- package/build/handlers/ProvideArtifactsMessageHandler.mjs.map +1 -0
- package/build/handlers/RequestSigningMessageHandler.d.mts +19 -0
- package/build/handlers/RequestSigningMessageHandler.d.mts.map +1 -0
- package/build/handlers/RequestSigningMessageHandler.mjs +21 -0
- package/build/handlers/RequestSigningMessageHandler.mjs.map +1 -0
- package/build/handlers/SigningAckMessageHandler.d.mts +22 -0
- package/build/handlers/SigningAckMessageHandler.d.mts.map +1 -0
- package/build/handlers/SigningAckMessageHandler.mjs +25 -0
- package/build/handlers/SigningAckMessageHandler.mjs.map +1 -0
- package/build/handlers/SigningProblemReportMessageHandler.d.mts +19 -0
- package/build/handlers/SigningProblemReportMessageHandler.d.mts.map +1 -0
- package/build/handlers/SigningProblemReportMessageHandler.mjs +21 -0
- package/build/handlers/SigningProblemReportMessageHandler.mjs.map +1 -0
- package/build/handlers/index.d.mts +9 -0
- package/build/handlers/index.mjs +9 -0
- package/build/index.d.mts +75 -0
- package/build/index.mjs +63 -0
- package/build/messages/CombineMessage.d.mts +32 -0
- package/build/messages/CombineMessage.d.mts.map +1 -0
- package/build/messages/CombineMessage.mjs +47 -0
- package/build/messages/CombineMessage.mjs.map +1 -0
- package/build/messages/ConsentMessage.d.mts +32 -0
- package/build/messages/ConsentMessage.d.mts.map +1 -0
- package/build/messages/ConsentMessage.mjs +46 -0
- package/build/messages/ConsentMessage.mjs.map +1 -0
- package/build/messages/DeclineMessage.d.mts +26 -0
- package/build/messages/DeclineMessage.d.mts.map +1 -0
- package/build/messages/DeclineMessage.mjs +47 -0
- package/build/messages/DeclineMessage.mjs.map +1 -0
- package/build/messages/PartialSignatureMessage.d.mts +36 -0
- package/build/messages/PartialSignatureMessage.d.mts.map +1 -0
- package/build/messages/PartialSignatureMessage.mjs +72 -0
- package/build/messages/PartialSignatureMessage.mjs.map +1 -0
- package/build/messages/ProposeSigningMessage.d.mts +27 -0
- package/build/messages/ProposeSigningMessage.d.mts.map +1 -0
- package/build/messages/ProposeSigningMessage.mjs +41 -0
- package/build/messages/ProposeSigningMessage.mjs.map +1 -0
- package/build/messages/ProvideArtifactsMessage.d.mts +62 -0
- package/build/messages/ProvideArtifactsMessage.d.mts.map +1 -0
- package/build/messages/ProvideArtifactsMessage.mjs +40 -0
- package/build/messages/ProvideArtifactsMessage.mjs.map +1 -0
- package/build/messages/RequestSigningMessage.d.mts +38 -0
- package/build/messages/RequestSigningMessage.d.mts.map +1 -0
- package/build/messages/RequestSigningMessage.mjs +62 -0
- package/build/messages/RequestSigningMessage.mjs.map +1 -0
- package/build/messages/SigningAckMessage.d.mts +26 -0
- package/build/messages/SigningAckMessage.d.mts.map +1 -0
- package/build/messages/SigningAckMessage.mjs +46 -0
- package/build/messages/SigningAckMessage.mjs.map +1 -0
- package/build/messages/SigningProblemReportMessage.d.mts +44 -0
- package/build/messages/SigningProblemReportMessage.d.mts.map +1 -0
- package/build/messages/SigningProblemReportMessage.mjs +65 -0
- package/build/messages/SigningProblemReportMessage.mjs.map +1 -0
- package/build/messages/index.d.mts +9 -0
- package/build/messages/index.mjs +9 -0
- package/build/models/AggregationResult.d.mts +85 -0
- package/build/models/AggregationResult.d.mts.map +1 -0
- package/build/models/ArtifactMetadata.d.mts +37 -0
- package/build/models/ArtifactMetadata.d.mts.map +1 -0
- package/build/models/AuthzArtifact.d.mts +178 -0
- package/build/models/AuthzArtifact.d.mts.map +1 -0
- package/build/models/Capabilities.d.mts +109 -0
- package/build/models/Capabilities.d.mts.map +1 -0
- package/build/models/JoinToken.d.mts +344 -0
- package/build/models/JoinToken.d.mts.map +1 -0
- package/build/models/JoinToken.mjs +14 -0
- package/build/models/JoinToken.mjs.map +1 -0
- package/build/models/PartialSignature.d.mts +82 -0
- package/build/models/PartialSignature.d.mts.map +1 -0
- package/build/models/PolicyContext.d.mts +55 -0
- package/build/models/PolicyContext.d.mts.map +1 -0
- package/build/models/RouterAttestation.d.mts +186 -0
- package/build/models/RouterAttestation.d.mts.map +1 -0
- package/build/models/Session.d.mts +62 -0
- package/build/models/Session.d.mts.map +1 -0
- package/build/models/Session.mjs +19 -0
- package/build/models/Session.mjs.map +1 -0
- package/build/models/SignableObject.d.mts +71 -0
- package/build/models/SignableObject.d.mts.map +1 -0
- package/build/models/SigningState.d.mts +21 -0
- package/build/models/SigningState.d.mts.map +1 -0
- package/build/models/SigningState.mjs +23 -0
- package/build/models/SigningState.mjs.map +1 -0
- package/build/models/Suite.d.mts +59 -0
- package/build/models/Suite.d.mts.map +1 -0
- package/build/models/index.d.mts +12 -0
- package/build/pdf/PdfUtils.d.mts +160 -0
- package/build/pdf/PdfUtils.d.mts.map +1 -0
- package/build/pdf/PdfUtils.mjs +283 -0
- package/build/pdf/PdfUtils.mjs.map +1 -0
- package/build/pdf/index.mjs +1 -0
- package/build/registry/aggregators/Aggregator.d.mts +85 -0
- package/build/registry/aggregators/Aggregator.d.mts.map +1 -0
- package/build/registry/aggregators/AggregatorRegistry.d.mts +55 -0
- package/build/registry/aggregators/AggregatorRegistry.d.mts.map +1 -0
- package/build/registry/aggregators/AggregatorRegistry.mjs +76 -0
- package/build/registry/aggregators/AggregatorRegistry.mjs.map +1 -0
- package/build/registry/aggregators/BundleNoneAggregator.d.mts +43 -0
- package/build/registry/aggregators/BundleNoneAggregator.d.mts.map +1 -0
- package/build/registry/aggregators/BundleNoneAggregator.mjs +65 -0
- package/build/registry/aggregators/BundleNoneAggregator.mjs.map +1 -0
- package/build/registry/aggregators/index.d.mts +3 -0
- package/build/registry/aggregators/index.mjs +2 -0
- package/build/registry/canonicalizers/Canonicalizer.d.mts +67 -0
- package/build/registry/canonicalizers/Canonicalizer.d.mts.map +1 -0
- package/build/registry/canonicalizers/CanonicalizerRegistry.d.mts +55 -0
- package/build/registry/canonicalizers/CanonicalizerRegistry.d.mts.map +1 -0
- package/build/registry/canonicalizers/CanonicalizerRegistry.mjs +78 -0
- package/build/registry/canonicalizers/CanonicalizerRegistry.mjs.map +1 -0
- package/build/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.d.mts +126 -0
- package/build/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.d.mts.map +1 -0
- package/build/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.mjs +143 -0
- package/build/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.mjs.map +1 -0
- package/build/registry/canonicalizers/RawBytesCanonicalizer.d.mts +34 -0
- package/build/registry/canonicalizers/RawBytesCanonicalizer.d.mts.map +1 -0
- package/build/registry/canonicalizers/RawBytesCanonicalizer.mjs +55 -0
- package/build/registry/canonicalizers/RawBytesCanonicalizer.mjs.map +1 -0
- package/build/registry/canonicalizers/index.d.mts +4 -0
- package/build/registry/canonicalizers/index.mjs +3 -0
- package/build/registry/index.d.mts +18 -0
- package/build/registry/index.mjs +14 -0
- package/build/registry/policies/Policy.d.mts +62 -0
- package/build/registry/policies/Policy.d.mts.map +1 -0
- package/build/registry/policies/PolicyRegistry.d.mts +54 -0
- package/build/registry/policies/PolicyRegistry.d.mts.map +1 -0
- package/build/registry/policies/PolicyRegistry.mjs +73 -0
- package/build/registry/policies/PolicyRegistry.mjs.map +1 -0
- package/build/registry/policies/TimeWindowPolicy.d.mts +85 -0
- package/build/registry/policies/TimeWindowPolicy.d.mts.map +1 -0
- package/build/registry/policies/TimeWindowPolicy.mjs +111 -0
- package/build/registry/policies/TimeWindowPolicy.mjs.map +1 -0
- package/build/registry/policies/index.d.mts +3 -0
- package/build/registry/policies/index.mjs +2 -0
- package/build/registry/suites/JwsEd25519Suite.d.mts +47 -0
- package/build/registry/suites/JwsEd25519Suite.d.mts.map +1 -0
- package/build/registry/suites/JwsEd25519Suite.mjs +101 -0
- package/build/registry/suites/JwsEd25519Suite.mjs.map +1 -0
- package/build/registry/suites/PadesBLtaSuite.d.mts +106 -0
- package/build/registry/suites/PadesBLtaSuite.d.mts.map +1 -0
- package/build/registry/suites/PadesBLtaSuite.mjs +122 -0
- package/build/registry/suites/PadesBLtaSuite.mjs.map +1 -0
- package/build/registry/suites/SignatureSuite.d.mts +128 -0
- package/build/registry/suites/SignatureSuite.d.mts.map +1 -0
- package/build/registry/suites/SignatureSuiteRegistry.d.mts +62 -0
- package/build/registry/suites/SignatureSuiteRegistry.d.mts.map +1 -0
- package/build/registry/suites/SignatureSuiteRegistry.mjs +87 -0
- package/build/registry/suites/SignatureSuiteRegistry.mjs.map +1 -0
- package/build/registry/suites/index.d.mts +4 -0
- package/build/registry/suites/index.mjs +3 -0
- package/build/repository/CounterRecord.d.mts +84 -0
- package/build/repository/CounterRecord.d.mts.map +1 -0
- package/build/repository/CounterRecord.mjs +82 -0
- package/build/repository/CounterRecord.mjs.map +1 -0
- package/build/repository/CounterRepository.d.mts +22 -0
- package/build/repository/CounterRepository.d.mts.map +1 -0
- package/build/repository/CounterRepository.mjs +51 -0
- package/build/repository/CounterRepository.mjs.map +1 -0
- package/build/repository/SigningSessionRecord.d.mts +102 -0
- package/build/repository/SigningSessionRecord.d.mts.map +1 -0
- package/build/repository/SigningSessionRecord.mjs +96 -0
- package/build/repository/SigningSessionRecord.mjs.map +1 -0
- package/build/repository/SigningSessionRepository.d.mts +30 -0
- package/build/repository/SigningSessionRepository.d.mts.map +1 -0
- package/build/repository/SigningSessionRepository.mjs +52 -0
- package/build/repository/SigningSessionRepository.mjs.map +1 -0
- package/build/repository/index.d.mts +4 -0
- package/build/repository/index.mjs +4 -0
- package/build/services/CounterService.d.mts +121 -0
- package/build/services/CounterService.d.mts.map +1 -0
- package/build/services/CounterService.mjs +176 -0
- package/build/services/CounterService.mjs.map +1 -0
- package/build/services/HPKEService.d.mts +174 -0
- package/build/services/HPKEService.d.mts.map +1 -0
- package/build/services/HPKEService.mjs +195 -0
- package/build/services/HPKEService.mjs.map +1 -0
- package/build/services/SigningService.d.mts +387 -0
- package/build/services/SigningService.d.mts.map +1 -0
- package/build/services/SigningService.mjs +1104 -0
- package/build/services/SigningService.mjs.map +1 -0
- package/build/services/index.d.mts +3 -0
- package/build/services/index.mjs +3 -0
- package/package.json +44 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
2
|
+
import { CredoError, injectable } from "@credo-ts/core";
|
|
3
|
+
|
|
4
|
+
//#region src/registry/aggregators/BundleNoneAggregator.ts
|
|
5
|
+
let BundleNoneAggregator = class BundleNoneAggregator {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.id = "bundle-none@1";
|
|
8
|
+
this.version = 1;
|
|
9
|
+
this.name = "bundle-none";
|
|
10
|
+
this.aggregationType = "bundle";
|
|
11
|
+
this.supportedSuites = ["*"];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Aggregate signatures by bundling them into an array
|
|
15
|
+
*/
|
|
16
|
+
async aggregate(_agentContext, input) {
|
|
17
|
+
if (input.partialSignatures.length === 0) throw new CredoError("Cannot aggregate empty signature array");
|
|
18
|
+
const bundle = input.partialSignatures.map((sig) => ({
|
|
19
|
+
signer: sig.signer,
|
|
20
|
+
suite: sig.suite,
|
|
21
|
+
signature: sig.signature,
|
|
22
|
+
timestamp: sig.timestamp
|
|
23
|
+
}));
|
|
24
|
+
return {
|
|
25
|
+
type: "bundle",
|
|
26
|
+
finalSignature: JSON.stringify(bundle),
|
|
27
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if aggregation can be performed
|
|
32
|
+
*/
|
|
33
|
+
async canAggregate(partialSignatures, _session) {
|
|
34
|
+
return partialSignatures.length > 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Verify aggregated signature by checking each individual signature
|
|
38
|
+
*/
|
|
39
|
+
async verify(data, aggregatedSignature, verifier, _parameters) {
|
|
40
|
+
try {
|
|
41
|
+
const bundle = JSON.parse(aggregatedSignature);
|
|
42
|
+
if (!Array.isArray(bundle) || bundle.length === 0) return false;
|
|
43
|
+
return (await Promise.all(bundle.map(async (sig) => {
|
|
44
|
+
try {
|
|
45
|
+
return await verifier(data, sig.signature, sig.keyId);
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}))).every((result) => result === true);
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if aggregation method is supported
|
|
56
|
+
*/
|
|
57
|
+
supportsMethod(method) {
|
|
58
|
+
return method === this.aggregationType;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
BundleNoneAggregator = __decorate([injectable()], BundleNoneAggregator);
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { BundleNoneAggregator };
|
|
65
|
+
//# sourceMappingURL=BundleNoneAggregator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleNoneAggregator.mjs","names":[],"sources":["../../../src/registry/aggregators/BundleNoneAggregator.ts"],"sourcesContent":["import type { Aggregator, AggregateInput } from './Aggregator'\nimport type { AgentContext } from '@credo-ts/core'\nimport type { AggregationResult } from '../../models'\n\nimport { CredoError, injectable } from '@credo-ts/core'\n\n/**\n * Bundle-None Aggregator\n *\n * Simple aggregator that bundles multiple signatures without cryptographic aggregation.\n * Each signature is independently verifiable. This is the simplest multi-signature approach.\n *\n * Use cases:\n * - Multiple independent signers\n * - No cryptographic aggregation needed\n * - Each signature must be individually verifiable\n */\n@injectable()\nexport class BundleNoneAggregator implements Aggregator {\n public readonly id = 'bundle-none@1'\n public readonly version = 1\n public readonly name = 'bundle-none'\n public readonly aggregationType = 'bundle' as const\n public readonly supportedSuites: string[] = ['*'] // Supports all suites\n\n /**\n * Aggregate signatures by bundling them into an array\n */\n public async aggregate(_agentContext: AgentContext, input: AggregateInput): Promise<AggregationResult> {\n if (input.partialSignatures.length === 0) {\n throw new CredoError('Cannot aggregate empty signature array')\n }\n\n // Bundle signatures into JSON array\n const bundle = input.partialSignatures.map((sig) => ({\n signer: sig.signer,\n suite: sig.suite,\n signature: sig.signature,\n timestamp: sig.timestamp,\n }))\n\n return {\n type: 'bundle',\n finalSignature: JSON.stringify(bundle),\n timestamp: new Date(),\n }\n }\n\n /**\n * Check if aggregation can be performed\n */\n public async canAggregate(partialSignatures: any[], _session: any): Promise<boolean> {\n return partialSignatures.length > 0\n }\n\n /**\n * Verify aggregated signature by checking each individual signature\n */\n public async verify(\n data: Uint8Array,\n aggregatedSignature: string,\n verifier: (data: Uint8Array, signature: string, keyId: string) => Promise<boolean>,\n _parameters?: Record<string, unknown>\n ): Promise<boolean> {\n try {\n // Parse bundle\n const bundle = JSON.parse(aggregatedSignature) as Array<{\n signature: string\n keyId: string\n metadata?: Record<string, unknown>\n }>\n\n if (!Array.isArray(bundle) || bundle.length === 0) {\n return false\n }\n\n // Verify each signature independently\n const verificationResults = await Promise.all(\n bundle.map(async (sig) => {\n try {\n return await verifier(data, sig.signature, sig.keyId)\n } catch {\n return false\n }\n })\n )\n\n // All signatures must be valid\n return verificationResults.every((result) => result === true)\n } catch {\n // JSON parsing or other errors\n return false\n }\n }\n\n /**\n * Check if aggregation method is supported\n */\n public supportsMethod(method: string): boolean {\n return method === this.aggregationType\n }\n}\n"],"mappings":";;;;AAkBO,iCAAM,qBAA2C;;OACtC,KAAK;OACL,UAAU;OACV,OAAO;OACP,kBAAkB;OAClB,kBAA4B,CAAC,IAAI;;;;;CAKjD,MAAa,UAAU,eAA6B,OAAmD;AACrG,MAAI,MAAM,kBAAkB,WAAW,EACrC,OAAM,IAAI,WAAW,yCAAyC;EAIhE,MAAM,SAAS,MAAM,kBAAkB,KAAK,SAAS;GACnD,QAAQ,IAAI;GACZ,OAAO,IAAI;GACX,WAAW,IAAI;GACf,WAAW,IAAI;GAChB,EAAE;AAEH,SAAO;GACL,MAAM;GACN,gBAAgB,KAAK,UAAU,OAAO;GACtC,2BAAW,IAAI,MAAM;GACtB;;;;;CAMH,MAAa,aAAa,mBAA0B,UAAiC;AACnF,SAAO,kBAAkB,SAAS;;;;;CAMpC,MAAa,OACX,MACA,qBACA,UACA,aACkB;AAClB,MAAI;GAEF,MAAM,SAAS,KAAK,MAAM,oBAAoB;AAM9C,OAAI,CAAC,MAAM,QAAQ,OAAO,IAAI,OAAO,WAAW,EAC9C,QAAO;AAeT,WAX4B,MAAM,QAAQ,IACxC,OAAO,IAAI,OAAO,QAAQ;AACxB,QAAI;AACF,YAAO,MAAM,SAAS,MAAM,IAAI,WAAW,IAAI,MAAM;YAC/C;AACN,YAAO;;KAET,CACH,EAG0B,OAAO,WAAW,WAAW,KAAK;UACvD;AAEN,UAAO;;;;;;CAOX,AAAO,eAAe,QAAyB;AAC7C,SAAO,WAAW,KAAK;;;mCAlF1B,YAAY"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region src/registry/canonicalizers/Canonicalizer.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for a canonicalizer module
|
|
4
|
+
*/
|
|
5
|
+
interface CanonicalizerMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier with version
|
|
8
|
+
* @example "eip-712@1"
|
|
9
|
+
*/
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Version number
|
|
13
|
+
*/
|
|
14
|
+
readonly version: number;
|
|
15
|
+
/**
|
|
16
|
+
* Canonicalizer name
|
|
17
|
+
* @example "eip-712"
|
|
18
|
+
*/
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Supported media types
|
|
22
|
+
* @example ["application/eip-712"]
|
|
23
|
+
*/
|
|
24
|
+
readonly mediaTypes: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Supported hash algorithms
|
|
27
|
+
* @example ["sha-256", "keccak-256"]
|
|
28
|
+
*/
|
|
29
|
+
readonly supportedAlgorithms: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Canonicalizer interface - converts input to canonical bytes
|
|
33
|
+
*
|
|
34
|
+
* Canonicalizers prepare data for signing by converting it to a
|
|
35
|
+
* standard format. This ensures WYSIWYS (What You See Is What You Sign).
|
|
36
|
+
*/
|
|
37
|
+
interface Canonicalizer extends CanonicalizerMetadata {
|
|
38
|
+
/**
|
|
39
|
+
* Convert input to canonical bytes
|
|
40
|
+
*
|
|
41
|
+
* @param input - The input data to canonicalize
|
|
42
|
+
* @param parameters - Method-specific parameters
|
|
43
|
+
* @returns Canonical bytes ready for signing
|
|
44
|
+
*/
|
|
45
|
+
canonicalize(input: unknown, parameters?: Record<string, unknown>): Promise<Uint8Array>;
|
|
46
|
+
/**
|
|
47
|
+
* Compute cryptographic digest over canonical bytes
|
|
48
|
+
*
|
|
49
|
+
* @param canonical - Canonical bytes
|
|
50
|
+
* @param algorithm - Hash algorithm to use
|
|
51
|
+
* @returns Digest with algorithm and value
|
|
52
|
+
*/
|
|
53
|
+
computeDigest(canonical: Uint8Array, algorithm: string): Promise<{
|
|
54
|
+
alg: string;
|
|
55
|
+
value: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Check if this canonicalizer supports a media type
|
|
59
|
+
*
|
|
60
|
+
* @param mediaType - Media type to check
|
|
61
|
+
* @returns True if supported
|
|
62
|
+
*/
|
|
63
|
+
supportsMediaType(mediaType: string): boolean;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { Canonicalizer, CanonicalizerMetadata };
|
|
67
|
+
//# sourceMappingURL=Canonicalizer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canonicalizer.d.mts","names":[],"sources":["../../../src/registry/canonicalizers/Canonicalizer.ts"],"mappings":";;AAGA;;UAAiB,qBAAA;EAAqB;;;;EAAA,SAK3B,EAAA;EAuBA;;;EAAA,SAlBA,OAAA;EA2BoB;;;;EAAA,SArBpB,IAAA;EAsCgB;;;;EAAA,SAhChB,UAAA;EAe4B;;;;EAAA,SAT5B,mBAAA;AAAA;;;;;;;UASM,aAAA,SAAsB,qBAAA;EAiB2C;;;;;;;EAThF,YAAA,CAAa,KAAA,WAAgB,UAAA,GAAa,MAAA,oBAA0B,OAAA,CAAQ,UAAA;;;;;;;;EAS5E,aAAA,CAAc,SAAA,EAAW,UAAA,EAAY,SAAA,WAAoB,OAAA;IAAU,GAAA;IAAa,KAAA;EAAA;;;;;;;EAQhF,iBAAA,CAAkB,SAAA;AAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CanonicalizerCapability } from "../../models/Capabilities.mjs";
|
|
2
|
+
import "../../models/index.mjs";
|
|
3
|
+
import { Canonicalizer } from "./Canonicalizer.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/registry/canonicalizers/CanonicalizerRegistry.d.ts
|
|
6
|
+
declare const CanonicalizerToken: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Registry for canonicalizer modules
|
|
9
|
+
*
|
|
10
|
+
* Uses dependency injection to allow pluggable canonicalizers.
|
|
11
|
+
* Canonicalizers can be registered by adding them to the module config.
|
|
12
|
+
*/
|
|
13
|
+
declare class CanonicalizerRegistry {
|
|
14
|
+
private canonicalizers;
|
|
15
|
+
constructor(canonicalizers: Array<Canonicalizer | 'default'>);
|
|
16
|
+
/**
|
|
17
|
+
* Get canonicalizer by ID
|
|
18
|
+
*
|
|
19
|
+
* @param id - Canonicalizer ID (e.g., "eip-712@1")
|
|
20
|
+
* @throws {UnsupportedCanonicalizerError} if not found
|
|
21
|
+
*/
|
|
22
|
+
getById(id: string): Canonicalizer;
|
|
23
|
+
/**
|
|
24
|
+
* Get all canonicalizers that support a media type
|
|
25
|
+
*
|
|
26
|
+
* @param mediaType - Media type to search for
|
|
27
|
+
* @returns Array of matching canonicalizers
|
|
28
|
+
*/
|
|
29
|
+
getByMediaType(mediaType: string): Canonicalizer[];
|
|
30
|
+
/**
|
|
31
|
+
* Get all canonicalizers with a specific name (different versions)
|
|
32
|
+
*
|
|
33
|
+
* @param name - Canonicalizer name (e.g., "eip-712")
|
|
34
|
+
* @returns Array of canonicalizers
|
|
35
|
+
*/
|
|
36
|
+
getAllByName(name: string): Canonicalizer[];
|
|
37
|
+
/**
|
|
38
|
+
* Check if a canonicalizer is supported
|
|
39
|
+
*
|
|
40
|
+
* @param id - Canonicalizer ID
|
|
41
|
+
* @returns True if supported
|
|
42
|
+
*/
|
|
43
|
+
isSupported(id: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get all supported canonicalizer IDs
|
|
46
|
+
*/
|
|
47
|
+
get supportedIds(): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Get capabilities for proposal/negotiation
|
|
50
|
+
*/
|
|
51
|
+
get capabilities(): CanonicalizerCapability[];
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CanonicalizerRegistry, CanonicalizerToken };
|
|
55
|
+
//# sourceMappingURL=CanonicalizerRegistry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanonicalizerRegistry.d.mts","names":[],"sources":["../../../src/registry/canonicalizers/CanonicalizerRegistry.ts"],"mappings":";;;;;cAMa,kBAAA;;;AAAb;;;;cASa,qBAAA;EAAA,QACH,cAAA;cAE0C,cAAA,EAAgB,KAAA,CAAM,aAAA;;;;;;;EAWjE,OAAA,CAAQ,EAAA,WAAa,aAAA;EAkDsB;;;;;;EAlC3C,cAAA,CAAe,SAAA,WAAoB,aAAA;EAhBnC;;;;;;EA0BA,YAAA,CAAa,IAAA,WAAe,aAAA;EAAf;;;;;;EAUb,WAAA,CAAY,EAAA;EAc+B;;;EAAA,IAPvC,YAAA,CAAA;;;;MAOA,YAAA,CAAA,GAAgB,uBAAA;AAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { UnsupportedCanonicalizerError } from "../../errors/UnsupportedCanonicalizerError.mjs";
|
|
2
|
+
import "../../errors/index.mjs";
|
|
3
|
+
import { __decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
4
|
+
import { __decorateParam } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
|
|
5
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
6
|
+
import { injectAll, injectable } from "@credo-ts/core";
|
|
7
|
+
|
|
8
|
+
//#region src/registry/canonicalizers/CanonicalizerRegistry.ts
|
|
9
|
+
var _ref;
|
|
10
|
+
const CanonicalizerToken = Symbol("CanonicalizerToken");
|
|
11
|
+
let CanonicalizerRegistry = class CanonicalizerRegistry {
|
|
12
|
+
constructor(canonicalizers) {
|
|
13
|
+
this.canonicalizers = canonicalizers.filter((c) => c !== "default");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get canonicalizer by ID
|
|
17
|
+
*
|
|
18
|
+
* @param id - Canonicalizer ID (e.g., "eip-712@1")
|
|
19
|
+
* @throws {UnsupportedCanonicalizerError} if not found
|
|
20
|
+
*/
|
|
21
|
+
getById(id) {
|
|
22
|
+
const canonicalizer = this.canonicalizers.find((c) => c.id === id);
|
|
23
|
+
if (!canonicalizer) throw new UnsupportedCanonicalizerError(id, this.supportedIds);
|
|
24
|
+
return canonicalizer;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get all canonicalizers that support a media type
|
|
28
|
+
*
|
|
29
|
+
* @param mediaType - Media type to search for
|
|
30
|
+
* @returns Array of matching canonicalizers
|
|
31
|
+
*/
|
|
32
|
+
getByMediaType(mediaType) {
|
|
33
|
+
return this.canonicalizers.filter((c) => c.supportsMediaType(mediaType));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get all canonicalizers with a specific name (different versions)
|
|
37
|
+
*
|
|
38
|
+
* @param name - Canonicalizer name (e.g., "eip-712")
|
|
39
|
+
* @returns Array of canonicalizers
|
|
40
|
+
*/
|
|
41
|
+
getAllByName(name) {
|
|
42
|
+
return this.canonicalizers.filter((c) => c.name === name);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a canonicalizer is supported
|
|
46
|
+
*
|
|
47
|
+
* @param id - Canonicalizer ID
|
|
48
|
+
* @returns True if supported
|
|
49
|
+
*/
|
|
50
|
+
isSupported(id) {
|
|
51
|
+
return this.canonicalizers.some((c) => c.id === id);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get all supported canonicalizer IDs
|
|
55
|
+
*/
|
|
56
|
+
get supportedIds() {
|
|
57
|
+
return this.canonicalizers.map((c) => c.id);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get capabilities for proposal/negotiation
|
|
61
|
+
*/
|
|
62
|
+
get capabilities() {
|
|
63
|
+
return this.canonicalizers.map((c) => ({
|
|
64
|
+
id: c.id,
|
|
65
|
+
mediaTypes: c.mediaTypes,
|
|
66
|
+
algorithms: c.supportedAlgorithms
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
CanonicalizerRegistry = __decorate([
|
|
71
|
+
injectable(),
|
|
72
|
+
__decorateParam(0, injectAll(CanonicalizerToken)),
|
|
73
|
+
__decorateMetadata("design:paramtypes", [Array])
|
|
74
|
+
], CanonicalizerRegistry);
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { CanonicalizerRegistry, CanonicalizerToken };
|
|
78
|
+
//# sourceMappingURL=CanonicalizerRegistry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanonicalizerRegistry.mjs","names":[],"sources":["../../../src/registry/canonicalizers/CanonicalizerRegistry.ts"],"sourcesContent":["import type { Canonicalizer } from './Canonicalizer'\nimport type { CanonicalizerCapability } from '../../models'\n\nimport { injectable, injectAll } from '@credo-ts/core'\nimport { UnsupportedCanonicalizerError } from '../../errors'\n\nexport const CanonicalizerToken = Symbol('CanonicalizerToken')\n\n/**\n * Registry for canonicalizer modules\n *\n * Uses dependency injection to allow pluggable canonicalizers.\n * Canonicalizers can be registered by adding them to the module config.\n */\n@injectable()\nexport class CanonicalizerRegistry {\n private canonicalizers: Canonicalizer[]\n\n public constructor(@injectAll(CanonicalizerToken) canonicalizers: Array<Canonicalizer | 'default'>) {\n // Filter out the 'default' placeholder used for tsyringe\n this.canonicalizers = canonicalizers.filter((c): c is Canonicalizer => c !== 'default')\n }\n\n /**\n * Get canonicalizer by ID\n *\n * @param id - Canonicalizer ID (e.g., \"eip-712@1\")\n * @throws {UnsupportedCanonicalizerError} if not found\n */\n public getById(id: string): Canonicalizer {\n const canonicalizer = this.canonicalizers.find((c) => c.id === id)\n\n if (!canonicalizer) {\n throw new UnsupportedCanonicalizerError(id, this.supportedIds)\n }\n\n return canonicalizer\n }\n\n /**\n * Get all canonicalizers that support a media type\n *\n * @param mediaType - Media type to search for\n * @returns Array of matching canonicalizers\n */\n public getByMediaType(mediaType: string): Canonicalizer[] {\n return this.canonicalizers.filter((c) => c.supportsMediaType(mediaType))\n }\n\n /**\n * Get all canonicalizers with a specific name (different versions)\n *\n * @param name - Canonicalizer name (e.g., \"eip-712\")\n * @returns Array of canonicalizers\n */\n public getAllByName(name: string): Canonicalizer[] {\n return this.canonicalizers.filter((c) => c.name === name)\n }\n\n /**\n * Check if a canonicalizer is supported\n *\n * @param id - Canonicalizer ID\n * @returns True if supported\n */\n public isSupported(id: string): boolean {\n return this.canonicalizers.some((c) => c.id === id)\n }\n\n /**\n * Get all supported canonicalizer IDs\n */\n public get supportedIds(): string[] {\n return this.canonicalizers.map((c) => c.id)\n }\n\n /**\n * Get capabilities for proposal/negotiation\n */\n public get capabilities(): CanonicalizerCapability[] {\n return this.canonicalizers.map((c) => ({\n id: c.id,\n mediaTypes: c.mediaTypes,\n algorithms: c.supportedAlgorithms,\n }))\n }\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,qBAAqB,OAAO,qBAAqB;AASvD,kCAAM,sBAAsB;CAGjC,AAAO,YAAY,AAA+B,gBAAkD;AAElG,OAAK,iBAAiB,eAAe,QAAQ,MAA0B,MAAM,UAAU;;;;;;;;CASzF,AAAO,QAAQ,IAA2B;EACxC,MAAM,gBAAgB,KAAK,eAAe,MAAM,MAAM,EAAE,OAAO,GAAG;AAElE,MAAI,CAAC,cACH,OAAM,IAAI,8BAA8B,IAAI,KAAK,aAAa;AAGhE,SAAO;;;;;;;;CAST,AAAO,eAAe,WAAoC;AACxD,SAAO,KAAK,eAAe,QAAQ,MAAM,EAAE,kBAAkB,UAAU,CAAC;;;;;;;;CAS1E,AAAO,aAAa,MAA+B;AACjD,SAAO,KAAK,eAAe,QAAQ,MAAM,EAAE,SAAS,KAAK;;;;;;;;CAS3D,AAAO,YAAY,IAAqB;AACtC,SAAO,KAAK,eAAe,MAAM,MAAM,EAAE,OAAO,GAAG;;;;;CAMrD,IAAW,eAAyB;AAClC,SAAO,KAAK,eAAe,KAAK,MAAM,EAAE,GAAG;;;;;CAM7C,IAAW,eAA0C;AACnD,SAAO,KAAK,eAAe,KAAK,OAAO;GACrC,IAAI,EAAE;GACN,YAAY,EAAE;GACd,YAAY,EAAE;GACf,EAAE;;;;CAtEN,YAAY;oBAIS,UAAU,mBAAmB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Canonicalizer } from "./Canonicalizer.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for PDF canonicalization
|
|
6
|
+
*/
|
|
7
|
+
interface PdfCanonicalizationParameters {
|
|
8
|
+
/**
|
|
9
|
+
* Byte range specifying which parts of the PDF to sign
|
|
10
|
+
* Format: [start1, length1, start2, length2]
|
|
11
|
+
*
|
|
12
|
+
* The gap between the two ranges is where the signature is placed.
|
|
13
|
+
* If not provided, the canonicalizer will prepare the PDF and return
|
|
14
|
+
* the byte range as part of the result.
|
|
15
|
+
*/
|
|
16
|
+
byteRange?: [number, number, number, number];
|
|
17
|
+
/**
|
|
18
|
+
* If true, prepare the PDF for signing (add signature placeholder)
|
|
19
|
+
* Returns prepared PDF bytes instead of bytes to sign
|
|
20
|
+
*/
|
|
21
|
+
prepareForSigning?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Signature placeholder options (used when prepareForSigning is true)
|
|
24
|
+
*/
|
|
25
|
+
signaturePlaceholder?: {
|
|
26
|
+
reason?: string;
|
|
27
|
+
location?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
contactInfo?: string;
|
|
30
|
+
signatureSize?: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result when preparing PDF for signing
|
|
35
|
+
*/
|
|
36
|
+
interface PreparedPdfCanonicalization {
|
|
37
|
+
/** PDF bytes with signature placeholder */
|
|
38
|
+
preparedPdf: Uint8Array;
|
|
39
|
+
/** Byte range for signing */
|
|
40
|
+
byteRange: [number, number, number, number];
|
|
41
|
+
/** Offset where signature should be embedded */
|
|
42
|
+
signatureOffset: number;
|
|
43
|
+
/** Length of signature placeholder */
|
|
44
|
+
signatureLength: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* PDF Incremental Update Canonicalizer
|
|
48
|
+
*
|
|
49
|
+
* Implements the canonicalizer interface for PDF documents.
|
|
50
|
+
*/
|
|
51
|
+
declare class PdfIncrementalUpdateCanonicalizer implements Canonicalizer {
|
|
52
|
+
readonly id = "pdf-incremental-update@1";
|
|
53
|
+
readonly version = 1;
|
|
54
|
+
readonly name = "pdf-incremental-update";
|
|
55
|
+
readonly mediaTypes: string[];
|
|
56
|
+
readonly supportedAlgorithms: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Store for prepared PDF metadata (keyed by hash of prepared PDF)
|
|
59
|
+
* This allows retrieval of byteRange info after canonicalization
|
|
60
|
+
*/
|
|
61
|
+
private preparedPdfMetadata;
|
|
62
|
+
/**
|
|
63
|
+
* Canonicalize PDF for signing
|
|
64
|
+
*
|
|
65
|
+
* Two modes:
|
|
66
|
+
* 1. If prepareForSigning=true: Adds signature placeholder and returns prepared PDF
|
|
67
|
+
* 2. If byteRange provided: Extracts bytes to sign from existing prepared PDF
|
|
68
|
+
*
|
|
69
|
+
* @param input - PDF bytes (Uint8Array or Buffer)
|
|
70
|
+
* @param parameters - Canonicalization parameters
|
|
71
|
+
* @returns Canonical bytes (either prepared PDF or bytes to sign)
|
|
72
|
+
*/
|
|
73
|
+
canonicalize(input: unknown, parameters?: Record<string, unknown>): Promise<Uint8Array>;
|
|
74
|
+
/**
|
|
75
|
+
* Compute cryptographic digest over canonical PDF bytes
|
|
76
|
+
*
|
|
77
|
+
* @param canonical - Canonical bytes from canonicalize()
|
|
78
|
+
* @param algorithm - Hash algorithm (sha-256, sha-384, sha-512)
|
|
79
|
+
* @returns Digest with algorithm and base64-encoded value
|
|
80
|
+
*/
|
|
81
|
+
computeDigest(canonical: Uint8Array, algorithm: string): Promise<{
|
|
82
|
+
alg: string;
|
|
83
|
+
value: string;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Check if this canonicalizer supports the given media type
|
|
87
|
+
*
|
|
88
|
+
* @param mediaType - Media type to check
|
|
89
|
+
* @returns True if media type is application/pdf
|
|
90
|
+
*/
|
|
91
|
+
supportsMediaType(mediaType: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Prepare PDF for signing
|
|
94
|
+
*
|
|
95
|
+
* Adds a signature placeholder to the PDF and stores metadata
|
|
96
|
+
* for later retrieval.
|
|
97
|
+
*
|
|
98
|
+
* @param pdfBytes - Original PDF bytes
|
|
99
|
+
* @param options - Signature placeholder options
|
|
100
|
+
* @returns Prepared PDF bytes
|
|
101
|
+
*/
|
|
102
|
+
private preparePdfForSigning;
|
|
103
|
+
/**
|
|
104
|
+
* Get preparation metadata for a prepared PDF
|
|
105
|
+
*
|
|
106
|
+
* @param preparedPdfBytes - Prepared PDF bytes
|
|
107
|
+
* @returns Preparation metadata or undefined
|
|
108
|
+
*/
|
|
109
|
+
getPreparationMetadata(preparedPdfBytes: Uint8Array): PreparedPdfCanonicalization | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Clear stored preparation metadata
|
|
112
|
+
* Call this after signing is complete to free memory
|
|
113
|
+
*/
|
|
114
|
+
clearMetadata(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Validate that input is PDF bytes
|
|
117
|
+
*/
|
|
118
|
+
private validateInput;
|
|
119
|
+
/**
|
|
120
|
+
* Simple hash for caching (not cryptographic)
|
|
121
|
+
*/
|
|
122
|
+
private hashBytes;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { PdfCanonicalizationParameters, PdfIncrementalUpdateCanonicalizer, PreparedPdfCanonicalization };
|
|
126
|
+
//# sourceMappingURL=PdfIncrementalUpdateCanonicalizer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdfIncrementalUpdateCanonicalizer.d.mts","names":[],"sources":["../../../src/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.ts"],"mappings":";;;AA2DA;;;AAAA,UAhCiB,6BAAA;EAkCf;;;;;;;AAcF;EAvCE,SAAA;;;;;EAMA,iBAAA;EA4FG;;;EAvFH,oBAAA;IACE,MAAA;IACA,QAAA;IACA,IAAA;IACA,WAAA;IACA,aAAA;EAAA;AAAA;;;;UAOa,2BAAA;EAwCwC;EAtCvD,WAAA,EAAa,UAAA;EAsCoE;EApCjF,SAAA;EAoEa;EAlEb,eAAA;EAmEE;EAjEF,eAAA;AAAA;;;;;;cAQW,iCAAA,YAA6C,aAAA;EAAA,SACxC,EAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA;EAAA,SACA,mBAAA;EA0KR;;;;EAAA,QApKA,mBAAA;;;;;;;;;;;;EAaK,YAAA,CAAa,KAAA,WAAgB,UAAA,GAAa,MAAA,oBAA0B,OAAA,CAAQ,UAAA;;;;;;;;EAgC5E,aAAA,CACX,SAAA,EAAW,UAAA,EACX,SAAA,WACC,OAAA;IAAU,GAAA;IAAa,KAAA;EAAA;;;;;;;EAkCnB,iBAAA,CAAkB,SAAA;;;;;;;;;;;UAcX,oBAAA;;;;;;;EAwBP,sBAAA,CAAuB,gBAAA,EAAkB,UAAA,GAAa,2BAAA;;;;;EAStD,aAAA,CAAA;;;;UAOC,aAAA;;;;UA4BA,SAAA;AAAA"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { PdfUtils } from "../../pdf/PdfUtils.mjs";
|
|
2
|
+
import { CredoError } from "@credo-ts/core";
|
|
3
|
+
import { webcrypto } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.ts
|
|
6
|
+
/**
|
|
7
|
+
* PDF Incremental Update Canonicalizer
|
|
8
|
+
*
|
|
9
|
+
* Implements the canonicalizer interface for PDF documents.
|
|
10
|
+
*/
|
|
11
|
+
var PdfIncrementalUpdateCanonicalizer = class {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.id = "pdf-incremental-update@1";
|
|
14
|
+
this.version = 1;
|
|
15
|
+
this.name = "pdf-incremental-update";
|
|
16
|
+
this.mediaTypes = ["application/pdf"];
|
|
17
|
+
this.supportedAlgorithms = [
|
|
18
|
+
"sha-256",
|
|
19
|
+
"sha-384",
|
|
20
|
+
"sha-512"
|
|
21
|
+
];
|
|
22
|
+
this.preparedPdfMetadata = /* @__PURE__ */ new Map();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Canonicalize PDF for signing
|
|
26
|
+
*
|
|
27
|
+
* Two modes:
|
|
28
|
+
* 1. If prepareForSigning=true: Adds signature placeholder and returns prepared PDF
|
|
29
|
+
* 2. If byteRange provided: Extracts bytes to sign from existing prepared PDF
|
|
30
|
+
*
|
|
31
|
+
* @param input - PDF bytes (Uint8Array or Buffer)
|
|
32
|
+
* @param parameters - Canonicalization parameters
|
|
33
|
+
* @returns Canonical bytes (either prepared PDF or bytes to sign)
|
|
34
|
+
*/
|
|
35
|
+
async canonicalize(input, parameters) {
|
|
36
|
+
const pdfBytes = this.validateInput(input);
|
|
37
|
+
const params = parameters;
|
|
38
|
+
if (params?.prepareForSigning) return this.preparePdfForSigning(pdfBytes, params.signaturePlaceholder);
|
|
39
|
+
if (params?.byteRange) return PdfUtils.getBytesToSign(pdfBytes, params.byteRange);
|
|
40
|
+
const sigInfo = await PdfUtils.extractSignatureInfo(pdfBytes);
|
|
41
|
+
if (sigInfo.hasSig && sigInfo.byteRange) return PdfUtils.getBytesToSign(pdfBytes, sigInfo.byteRange);
|
|
42
|
+
return pdfBytes;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compute cryptographic digest over canonical PDF bytes
|
|
46
|
+
*
|
|
47
|
+
* @param canonical - Canonical bytes from canonicalize()
|
|
48
|
+
* @param algorithm - Hash algorithm (sha-256, sha-384, sha-512)
|
|
49
|
+
* @returns Digest with algorithm and base64-encoded value
|
|
50
|
+
*/
|
|
51
|
+
async computeDigest(canonical, algorithm) {
|
|
52
|
+
if (!this.supportedAlgorithms.includes(algorithm)) throw new CredoError(`Unsupported hash algorithm: ${algorithm}. Supported: ${this.supportedAlgorithms.join(", ")}`);
|
|
53
|
+
const cryptoAlg = {
|
|
54
|
+
"sha-256": "SHA-256",
|
|
55
|
+
"sha-384": "SHA-384",
|
|
56
|
+
"sha-512": "SHA-512"
|
|
57
|
+
}[algorithm];
|
|
58
|
+
const hashBuffer = await webcrypto.subtle.digest(cryptoAlg, canonical);
|
|
59
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
60
|
+
return {
|
|
61
|
+
alg: algorithm,
|
|
62
|
+
value: Buffer.from(hashArray).toString("base64")
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if this canonicalizer supports the given media type
|
|
67
|
+
*
|
|
68
|
+
* @param mediaType - Media type to check
|
|
69
|
+
* @returns True if media type is application/pdf
|
|
70
|
+
*/
|
|
71
|
+
supportsMediaType(mediaType) {
|
|
72
|
+
return this.mediaTypes.includes(mediaType.toLowerCase());
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Prepare PDF for signing
|
|
76
|
+
*
|
|
77
|
+
* Adds a signature placeholder to the PDF and stores metadata
|
|
78
|
+
* for later retrieval.
|
|
79
|
+
*
|
|
80
|
+
* @param pdfBytes - Original PDF bytes
|
|
81
|
+
* @param options - Signature placeholder options
|
|
82
|
+
* @returns Prepared PDF bytes
|
|
83
|
+
*/
|
|
84
|
+
async preparePdfForSigning(pdfBytes, options) {
|
|
85
|
+
const prepared = await PdfUtils.preparePdfForSigning(pdfBytes, options);
|
|
86
|
+
const key = this.hashBytes(prepared.pdfBytes);
|
|
87
|
+
this.preparedPdfMetadata.set(key, {
|
|
88
|
+
preparedPdf: prepared.pdfBytes,
|
|
89
|
+
byteRange: prepared.byteRange,
|
|
90
|
+
signatureOffset: prepared.signatureOffset,
|
|
91
|
+
signatureLength: prepared.signatureLength
|
|
92
|
+
});
|
|
93
|
+
return prepared.pdfBytes;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get preparation metadata for a prepared PDF
|
|
97
|
+
*
|
|
98
|
+
* @param preparedPdfBytes - Prepared PDF bytes
|
|
99
|
+
* @returns Preparation metadata or undefined
|
|
100
|
+
*/
|
|
101
|
+
getPreparationMetadata(preparedPdfBytes) {
|
|
102
|
+
const key = this.hashBytes(preparedPdfBytes);
|
|
103
|
+
return this.preparedPdfMetadata.get(key);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Clear stored preparation metadata
|
|
107
|
+
* Call this after signing is complete to free memory
|
|
108
|
+
*/
|
|
109
|
+
clearMetadata() {
|
|
110
|
+
this.preparedPdfMetadata.clear();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validate that input is PDF bytes
|
|
114
|
+
*/
|
|
115
|
+
validateInput(input) {
|
|
116
|
+
if (input instanceof Uint8Array) return input;
|
|
117
|
+
if (Buffer.isBuffer(input)) return Uint8Array.from(input);
|
|
118
|
+
if (typeof input === "string") {
|
|
119
|
+
try {
|
|
120
|
+
const decoded = Buffer.from(input, "base64");
|
|
121
|
+
if (decoded.slice(0, 5).toString() === "%PDF-") return Uint8Array.from(decoded);
|
|
122
|
+
} catch {}
|
|
123
|
+
throw new CredoError("PDF input must be Uint8Array or Buffer, not string");
|
|
124
|
+
}
|
|
125
|
+
throw new CredoError(`Cannot canonicalize input of type ${typeof input}. Expected PDF bytes.`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Simple hash for caching (not cryptographic)
|
|
129
|
+
*/
|
|
130
|
+
hashBytes(bytes) {
|
|
131
|
+
const head = bytes.slice(0, 100);
|
|
132
|
+
const tail = bytes.slice(-100);
|
|
133
|
+
return [
|
|
134
|
+
bytes.length.toString(),
|
|
135
|
+
Buffer.from(head).toString("hex"),
|
|
136
|
+
Buffer.from(tail).toString("hex")
|
|
137
|
+
].join(":");
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
export { PdfIncrementalUpdateCanonicalizer };
|
|
143
|
+
//# sourceMappingURL=PdfIncrementalUpdateCanonicalizer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdfIncrementalUpdateCanonicalizer.mjs","names":[],"sources":["../../../src/registry/canonicalizers/PdfIncrementalUpdateCanonicalizer.ts"],"sourcesContent":["/**\n * PDF Incremental Update Canonicalizer\n *\n * Canonicalizes PDF documents for digital signing using incremental updates.\n * This is the standard method for adding signatures to PDF documents without\n * invalidating existing signatures.\n *\n * PDF signatures work by:\n * 1. Appending a signature dictionary as an incremental update\n * 2. Specifying a ByteRange that excludes the signature value itself\n * 3. Computing a hash over the ByteRange portions\n * 4. Embedding the signature in the excluded portion\n *\n * @see ISO 32000-2 (PDF 2.0) Section 12.8 - Digital Signatures\n * @see ETSI EN 319 142-1 - PAdES Digital Signatures\n */\n\nimport type { Canonicalizer } from './Canonicalizer'\n\nimport { CredoError } from '@credo-ts/core'\nimport { webcrypto } from 'node:crypto'\n\nimport { PdfUtils } from '../../pdf/PdfUtils'\n\n/**\n * Parameters for PDF canonicalization\n */\nexport interface PdfCanonicalizationParameters {\n /**\n * Byte range specifying which parts of the PDF to sign\n * Format: [start1, length1, start2, length2]\n *\n * The gap between the two ranges is where the signature is placed.\n * If not provided, the canonicalizer will prepare the PDF and return\n * the byte range as part of the result.\n */\n byteRange?: [number, number, number, number]\n\n /**\n * If true, prepare the PDF for signing (add signature placeholder)\n * Returns prepared PDF bytes instead of bytes to sign\n */\n prepareForSigning?: boolean\n\n /**\n * Signature placeholder options (used when prepareForSigning is true)\n */\n signaturePlaceholder?: {\n reason?: string\n location?: string\n name?: string\n contactInfo?: string\n signatureSize?: number\n }\n}\n\n/**\n * Result when preparing PDF for signing\n */\nexport interface PreparedPdfCanonicalization {\n /** PDF bytes with signature placeholder */\n preparedPdf: Uint8Array\n /** Byte range for signing */\n byteRange: [number, number, number, number]\n /** Offset where signature should be embedded */\n signatureOffset: number\n /** Length of signature placeholder */\n signatureLength: number\n}\n\n/**\n * PDF Incremental Update Canonicalizer\n *\n * Implements the canonicalizer interface for PDF documents.\n */\nexport class PdfIncrementalUpdateCanonicalizer implements Canonicalizer {\n public readonly id = 'pdf-incremental-update@1'\n public readonly version = 1\n public readonly name = 'pdf-incremental-update'\n public readonly mediaTypes = ['application/pdf']\n public readonly supportedAlgorithms = ['sha-256', 'sha-384', 'sha-512']\n\n /**\n * Store for prepared PDF metadata (keyed by hash of prepared PDF)\n * This allows retrieval of byteRange info after canonicalization\n */\n private preparedPdfMetadata: Map<string, PreparedPdfCanonicalization> = new Map()\n\n /**\n * Canonicalize PDF for signing\n *\n * Two modes:\n * 1. If prepareForSigning=true: Adds signature placeholder and returns prepared PDF\n * 2. If byteRange provided: Extracts bytes to sign from existing prepared PDF\n *\n * @param input - PDF bytes (Uint8Array or Buffer)\n * @param parameters - Canonicalization parameters\n * @returns Canonical bytes (either prepared PDF or bytes to sign)\n */\n public async canonicalize(input: unknown, parameters?: Record<string, unknown>): Promise<Uint8Array> {\n // Validate input is PDF bytes\n const pdfBytes = this.validateInput(input)\n const params = parameters as PdfCanonicalizationParameters | undefined\n\n // Mode 1: Prepare PDF for signing\n if (params?.prepareForSigning) {\n return this.preparePdfForSigning(pdfBytes, params.signaturePlaceholder)\n }\n\n // Mode 2: Extract bytes to sign using provided byte range\n if (params?.byteRange) {\n return PdfUtils.getBytesToSign(pdfBytes, params.byteRange)\n }\n\n // Mode 3: Check if this is an already-prepared PDF with signature placeholder\n const sigInfo = await PdfUtils.extractSignatureInfo(pdfBytes)\n if (sigInfo.hasSig && sigInfo.byteRange) {\n return PdfUtils.getBytesToSign(pdfBytes, sigInfo.byteRange)\n }\n\n // Default: Return PDF bytes as-is (for raw signing, not recommended)\n return pdfBytes\n }\n\n /**\n * Compute cryptographic digest over canonical PDF bytes\n *\n * @param canonical - Canonical bytes from canonicalize()\n * @param algorithm - Hash algorithm (sha-256, sha-384, sha-512)\n * @returns Digest with algorithm and base64-encoded value\n */\n public async computeDigest(\n canonical: Uint8Array,\n algorithm: string\n ): Promise<{ alg: string; value: string }> {\n if (!this.supportedAlgorithms.includes(algorithm)) {\n throw new CredoError(\n `Unsupported hash algorithm: ${algorithm}. Supported: ${this.supportedAlgorithms.join(', ')}`\n )\n }\n\n // Map to WebCrypto algorithm names\n const cryptoAlgMap: Record<string, string> = {\n 'sha-256': 'SHA-256',\n 'sha-384': 'SHA-384',\n 'sha-512': 'SHA-512',\n }\n const cryptoAlg = cryptoAlgMap[algorithm]\n\n // Compute hash using WebCrypto API\n const hashBuffer = await webcrypto.subtle.digest(cryptoAlg, canonical)\n\n // Convert to base64\n const hashArray = new Uint8Array(hashBuffer)\n const base64 = Buffer.from(hashArray).toString('base64')\n\n return {\n alg: algorithm,\n value: base64,\n }\n }\n\n /**\n * Check if this canonicalizer supports the given media type\n *\n * @param mediaType - Media type to check\n * @returns True if media type is application/pdf\n */\n public supportsMediaType(mediaType: string): boolean {\n return this.mediaTypes.includes(mediaType.toLowerCase())\n }\n\n /**\n * Prepare PDF for signing\n *\n * Adds a signature placeholder to the PDF and stores metadata\n * for later retrieval.\n *\n * @param pdfBytes - Original PDF bytes\n * @param options - Signature placeholder options\n * @returns Prepared PDF bytes\n */\n private async preparePdfForSigning(\n pdfBytes: Uint8Array,\n options?: PdfCanonicalizationParameters['signaturePlaceholder']\n ): Promise<Uint8Array> {\n const prepared = await PdfUtils.preparePdfForSigning(pdfBytes, options)\n\n // Store metadata for later retrieval\n const key = this.hashBytes(prepared.pdfBytes)\n this.preparedPdfMetadata.set(key, {\n preparedPdf: prepared.pdfBytes,\n byteRange: prepared.byteRange,\n signatureOffset: prepared.signatureOffset,\n signatureLength: prepared.signatureLength,\n })\n\n return prepared.pdfBytes\n }\n\n /**\n * Get preparation metadata for a prepared PDF\n *\n * @param preparedPdfBytes - Prepared PDF bytes\n * @returns Preparation metadata or undefined\n */\n public getPreparationMetadata(preparedPdfBytes: Uint8Array): PreparedPdfCanonicalization | undefined {\n const key = this.hashBytes(preparedPdfBytes)\n return this.preparedPdfMetadata.get(key)\n }\n\n /**\n * Clear stored preparation metadata\n * Call this after signing is complete to free memory\n */\n public clearMetadata(): void {\n this.preparedPdfMetadata.clear()\n }\n\n /**\n * Validate that input is PDF bytes\n */\n private validateInput(input: unknown): Uint8Array {\n if (input instanceof Uint8Array) {\n return input\n }\n\n if (Buffer.isBuffer(input)) {\n return Uint8Array.from(input)\n }\n\n if (typeof input === 'string') {\n // Check if it's base64-encoded PDF\n try {\n const decoded = Buffer.from(input, 'base64')\n if (decoded.slice(0, 5).toString() === '%PDF-') {\n return Uint8Array.from(decoded)\n }\n } catch {\n // Not base64\n }\n throw new CredoError('PDF input must be Uint8Array or Buffer, not string')\n }\n\n throw new CredoError(`Cannot canonicalize input of type ${typeof input}. Expected PDF bytes.`)\n }\n\n /**\n * Simple hash for caching (not cryptographic)\n */\n private hashBytes(bytes: Uint8Array): string {\n // Use first and last 100 bytes + length as key\n const head = bytes.slice(0, 100)\n const tail = bytes.slice(-100)\n const parts = [bytes.length.toString(), Buffer.from(head).toString('hex'), Buffer.from(tail).toString('hex')]\n return parts.join(':')\n }\n}\n"],"mappings":";;;;;;;;;;AA2EA,IAAa,oCAAb,MAAwE;;OACtD,KAAK;OACL,UAAU;OACV,OAAO;OACP,aAAa,CAAC,kBAAkB;OAChC,sBAAsB;GAAC;GAAW;GAAW;GAAU;OAM/D,sCAAgE,IAAI,KAAK;;;;;;;;;;;;;CAajF,MAAa,aAAa,OAAgB,YAA2D;EAEnG,MAAM,WAAW,KAAK,cAAc,MAAM;EAC1C,MAAM,SAAS;AAGf,MAAI,QAAQ,kBACV,QAAO,KAAK,qBAAqB,UAAU,OAAO,qBAAqB;AAIzE,MAAI,QAAQ,UACV,QAAO,SAAS,eAAe,UAAU,OAAO,UAAU;EAI5D,MAAM,UAAU,MAAM,SAAS,qBAAqB,SAAS;AAC7D,MAAI,QAAQ,UAAU,QAAQ,UAC5B,QAAO,SAAS,eAAe,UAAU,QAAQ,UAAU;AAI7D,SAAO;;;;;;;;;CAUT,MAAa,cACX,WACA,WACyC;AACzC,MAAI,CAAC,KAAK,oBAAoB,SAAS,UAAU,CAC/C,OAAM,IAAI,WACR,+BAA+B,UAAU,eAAe,KAAK,oBAAoB,KAAK,KAAK,GAC5F;EASH,MAAM,YALuC;GAC3C,WAAW;GACX,WAAW;GACX,WAAW;GACZ,CAC8B;EAG/B,MAAM,aAAa,MAAM,UAAU,OAAO,OAAO,WAAW,UAAU;EAGtE,MAAM,YAAY,IAAI,WAAW,WAAW;AAG5C,SAAO;GACL,KAAK;GACL,OAJa,OAAO,KAAK,UAAU,CAAC,SAAS,SAAS;GAKvD;;;;;;;;CASH,AAAO,kBAAkB,WAA4B;AACnD,SAAO,KAAK,WAAW,SAAS,UAAU,aAAa,CAAC;;;;;;;;;;;;CAa1D,MAAc,qBACZ,UACA,SACqB;EACrB,MAAM,WAAW,MAAM,SAAS,qBAAqB,UAAU,QAAQ;EAGvE,MAAM,MAAM,KAAK,UAAU,SAAS,SAAS;AAC7C,OAAK,oBAAoB,IAAI,KAAK;GAChC,aAAa,SAAS;GACtB,WAAW,SAAS;GACpB,iBAAiB,SAAS;GAC1B,iBAAiB,SAAS;GAC3B,CAAC;AAEF,SAAO,SAAS;;;;;;;;CASlB,AAAO,uBAAuB,kBAAuE;EACnG,MAAM,MAAM,KAAK,UAAU,iBAAiB;AAC5C,SAAO,KAAK,oBAAoB,IAAI,IAAI;;;;;;CAO1C,AAAO,gBAAsB;AAC3B,OAAK,oBAAoB,OAAO;;;;;CAMlC,AAAQ,cAAc,OAA4B;AAChD,MAAI,iBAAiB,WACnB,QAAO;AAGT,MAAI,OAAO,SAAS,MAAM,CACxB,QAAO,WAAW,KAAK,MAAM;AAG/B,MAAI,OAAO,UAAU,UAAU;AAE7B,OAAI;IACF,MAAM,UAAU,OAAO,KAAK,OAAO,SAAS;AAC5C,QAAI,QAAQ,MAAM,GAAG,EAAE,CAAC,UAAU,KAAK,QACrC,QAAO,WAAW,KAAK,QAAQ;WAE3B;AAGR,SAAM,IAAI,WAAW,qDAAqD;;AAG5E,QAAM,IAAI,WAAW,qCAAqC,OAAO,MAAM,uBAAuB;;;;;CAMhG,AAAQ,UAAU,OAA2B;EAE3C,MAAM,OAAO,MAAM,MAAM,GAAG,IAAI;EAChC,MAAM,OAAO,MAAM,MAAM,KAAK;AAE9B,SADc;GAAC,MAAM,OAAO,UAAU;GAAE,OAAO,KAAK,KAAK,CAAC,SAAS,MAAM;GAAE,OAAO,KAAK,KAAK,CAAC,SAAS,MAAM;GAAC,CAChG,KAAK,IAAI"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Canonicalizer } from "./Canonicalizer.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/registry/canonicalizers/RawBytesCanonicalizer.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Raw bytes canonicalizer - identity canonicalization
|
|
6
|
+
*
|
|
7
|
+
* This is the simplest canonicalizer that just converts input to bytes
|
|
8
|
+
* without any transformation. Useful for data that's already canonical.
|
|
9
|
+
*/
|
|
10
|
+
declare class RawBytesCanonicalizer implements Canonicalizer {
|
|
11
|
+
readonly id = "raw-bytes@1";
|
|
12
|
+
readonly version = 1;
|
|
13
|
+
readonly name = "raw-bytes";
|
|
14
|
+
readonly mediaTypes: string[];
|
|
15
|
+
readonly supportedAlgorithms: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Convert input to bytes (identity transformation)
|
|
18
|
+
*/
|
|
19
|
+
canonicalize(input: unknown, _parameters?: Record<string, unknown>): Promise<Uint8Array>;
|
|
20
|
+
/**
|
|
21
|
+
* Compute cryptographic digest
|
|
22
|
+
*/
|
|
23
|
+
computeDigest(canonical: Uint8Array, algorithm: string): Promise<{
|
|
24
|
+
alg: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if media type is supported (supports all)
|
|
29
|
+
*/
|
|
30
|
+
supportsMediaType(_mediaType: string): boolean;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { RawBytesCanonicalizer };
|
|
34
|
+
//# sourceMappingURL=RawBytesCanonicalizer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawBytesCanonicalizer.d.mts","names":[],"sources":["../../../src/registry/canonicalizers/RawBytesCanonicalizer.ts"],"mappings":";;;;;AAWA;;;;cAAa,qBAAA,YAAiC,aAAA;EAAA,SAC5B,EAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA;EAAA,SACA,mBAAA;EALyC;;;EAU5C,YAAA,CAAa,KAAA,WAAgB,WAAA,GAAc,MAAA,oBAA0B,OAAA,CAAQ,UAAA;EAP1E;;;EAmCH,aAAA,CACX,SAAA,EAAW,UAAA,EACX,SAAA,WACC,OAAA;IAAU,GAAA;IAAa,KAAA;EAAA;EA/BwD;;;EAyD3E,iBAAA,CAAkB,UAAA;AAAA"}
|