@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,84 @@
|
|
|
1
|
+
import { BaseRecord, TagsBase } from "@credo-ts/core";
|
|
2
|
+
|
|
3
|
+
//#region src/repository/CounterRecord.d.ts
|
|
4
|
+
interface CounterRecordProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
deviceId: string;
|
|
7
|
+
currentCounter: number;
|
|
8
|
+
usedCounters?: number[];
|
|
9
|
+
createdAt?: Date;
|
|
10
|
+
updatedAt?: Date;
|
|
11
|
+
tags?: CustomCounterTags;
|
|
12
|
+
}
|
|
13
|
+
type CustomCounterTags = TagsBase & {
|
|
14
|
+
deviceId: string;
|
|
15
|
+
};
|
|
16
|
+
type DefaultCounterTags = {
|
|
17
|
+
deviceId: string;
|
|
18
|
+
currentCounter: string;
|
|
19
|
+
};
|
|
20
|
+
declare class CounterRecord extends BaseRecord<DefaultCounterTags, CustomCounterTags> {
|
|
21
|
+
static readonly type = "CounterRecord";
|
|
22
|
+
readonly type = "CounterRecord";
|
|
23
|
+
/**
|
|
24
|
+
* Device identifier (DID or key identifier)
|
|
25
|
+
* @example "did:ex:alice#device1" or "z6Mkk..."
|
|
26
|
+
*/
|
|
27
|
+
deviceId: string;
|
|
28
|
+
/**
|
|
29
|
+
* Current counter value
|
|
30
|
+
*
|
|
31
|
+
* This is the highest counter value that has been seen and persisted.
|
|
32
|
+
* Next valid counter must be > currentCounter.
|
|
33
|
+
*/
|
|
34
|
+
currentCounter: number;
|
|
35
|
+
/**
|
|
36
|
+
* Set of used counter values for additional replay protection
|
|
37
|
+
*
|
|
38
|
+
* While currentCounter provides the main replay protection,
|
|
39
|
+
* this set tracks all used counters to detect any replay attempts.
|
|
40
|
+
*
|
|
41
|
+
* Note: This may grow large over time. Consider pruning old values
|
|
42
|
+
* that are < currentCounter - window_size.
|
|
43
|
+
*/
|
|
44
|
+
usedCounters: Set<number>;
|
|
45
|
+
/**
|
|
46
|
+
* Last update timestamp
|
|
47
|
+
*/
|
|
48
|
+
updatedAt: Date;
|
|
49
|
+
constructor(props: CounterRecordProps);
|
|
50
|
+
/**
|
|
51
|
+
* Get default tags for indexing
|
|
52
|
+
*/
|
|
53
|
+
getTags(): {
|
|
54
|
+
deviceId: string;
|
|
55
|
+
currentCounter: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Check if a counter value has been used
|
|
59
|
+
*/
|
|
60
|
+
isCounterUsed(ctr: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Update counter to a new value
|
|
63
|
+
*
|
|
64
|
+
* CRITICAL: This should only be called BEFORE consuming the token.
|
|
65
|
+
* If token consumption fails, counter should be rolled back.
|
|
66
|
+
*/
|
|
67
|
+
updateCounter(newCounter: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Prune old used counters to prevent unbounded growth
|
|
70
|
+
*
|
|
71
|
+
* Removes counters that are more than `windowSize` behind current counter.
|
|
72
|
+
* These are guaranteed to be rejected anyway since they're <= currentCounter.
|
|
73
|
+
*
|
|
74
|
+
* @param windowSize - How many old counters to keep (default 100)
|
|
75
|
+
*/
|
|
76
|
+
pruneOldCounters(windowSize?: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Serialize used counters for storage
|
|
79
|
+
*/
|
|
80
|
+
toJSON(): Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { CounterRecord, CounterRecordProps, CustomCounterTags, DefaultCounterTags };
|
|
84
|
+
//# sourceMappingURL=CounterRecord.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterRecord.d.mts","names":[],"sources":["../../src/repository/CounterRecord.ts"],"mappings":";;;UAgBiB,kBAAA;EACf,EAAA;EACA,QAAA;EACA,cAAA;EACA,YAAA;EACA,SAAA,GAAY,IAAA;EACZ,SAAA,GAAY,IAAA;EACZ,IAAA,GAAO,iBAAA;AAAA;AAAA,KAGG,iBAAA,GAAoB,QAAA;EAC9B,QAAA;AAAA;AAAA,KAGU,kBAAA;EACV,QAAA;EACA,cAAA;AAAA;AAAA,cAGW,aAAA,SAAsB,UAAA,CAAW,kBAAA,EAAoB,iBAAA;EAAA,gBACzC,IAAA;EAAA,SACP,IAAA;EAFL;;;;EAQJ,QAAA;EAmBc;;;;;;EAXd,cAAA;EAhB0B;;;;;;;;;EA2B1B,YAAA,EAAc,GAAA;EAKF;;;EAAZ,SAAA,EAAY,IAAA;cAEA,KAAA,EAAO,kBAAA;;;;EAsBnB,OAAA,CAAA;;;;EA8CiB;;;EAnCjB,aAAA,CAAc,GAAA;EA+CE;;;;;;EArChB,aAAA,CAAc,UAAA;;;;;;;;;EAyBd,gBAAA,CAAiB,UAAA;;;;EAYjB,MAAA,CAAA,GAAU,MAAA;AAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BaseRecord, utils } from "@credo-ts/core";
|
|
2
|
+
|
|
3
|
+
//#region src/repository/CounterRecord.ts
|
|
4
|
+
var CounterRecord = class CounterRecord extends BaseRecord {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super();
|
|
7
|
+
this.type = CounterRecord.type;
|
|
8
|
+
this.usedCounters = /* @__PURE__ */ new Set();
|
|
9
|
+
if (props) {
|
|
10
|
+
this.id = props.id ?? utils.uuid();
|
|
11
|
+
this.deviceId = props.deviceId;
|
|
12
|
+
this.currentCounter = props.currentCounter;
|
|
13
|
+
if (props.usedCounters) this.usedCounters = Array.isArray(props.usedCounters) ? new Set(props.usedCounters) : /* @__PURE__ */ new Set();
|
|
14
|
+
else this.usedCounters = /* @__PURE__ */ new Set();
|
|
15
|
+
this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
|
|
16
|
+
this.updatedAt = props.updatedAt ?? /* @__PURE__ */ new Date();
|
|
17
|
+
this._tags = props.tags ?? { deviceId: this.deviceId };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get default tags for indexing
|
|
22
|
+
*/
|
|
23
|
+
getTags() {
|
|
24
|
+
return {
|
|
25
|
+
...this._tags,
|
|
26
|
+
deviceId: this.deviceId,
|
|
27
|
+
currentCounter: this.currentCounter.toString()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a counter value has been used
|
|
32
|
+
*/
|
|
33
|
+
isCounterUsed(ctr) {
|
|
34
|
+
return ctr <= this.currentCounter || this.usedCounters.has(ctr);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Update counter to a new value
|
|
38
|
+
*
|
|
39
|
+
* CRITICAL: This should only be called BEFORE consuming the token.
|
|
40
|
+
* If token consumption fails, counter should be rolled back.
|
|
41
|
+
*/
|
|
42
|
+
updateCounter(newCounter) {
|
|
43
|
+
if (newCounter <= this.currentCounter) throw new Error(`Counter must be strictly increasing: ${newCounter} <= ${this.currentCounter}`);
|
|
44
|
+
if (!this.usedCounters || !(this.usedCounters instanceof Set)) this.usedCounters = new Set(this.usedCounters || []);
|
|
45
|
+
this.usedCounters.add(newCounter);
|
|
46
|
+
this.currentCounter = newCounter;
|
|
47
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Prune old used counters to prevent unbounded growth
|
|
51
|
+
*
|
|
52
|
+
* Removes counters that are more than `windowSize` behind current counter.
|
|
53
|
+
* These are guaranteed to be rejected anyway since they're <= currentCounter.
|
|
54
|
+
*
|
|
55
|
+
* @param windowSize - How many old counters to keep (default 100)
|
|
56
|
+
*/
|
|
57
|
+
pruneOldCounters(windowSize = 100) {
|
|
58
|
+
const minCounter = this.currentCounter - windowSize;
|
|
59
|
+
this.usedCounters.forEach((ctr) => {
|
|
60
|
+
if (ctr < minCounter) this.usedCounters.delete(ctr);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Serialize used counters for storage
|
|
65
|
+
*/
|
|
66
|
+
toJSON() {
|
|
67
|
+
return {
|
|
68
|
+
id: this.id,
|
|
69
|
+
deviceId: this.deviceId,
|
|
70
|
+
currentCounter: this.currentCounter,
|
|
71
|
+
usedCounters: Array.from(this.usedCounters),
|
|
72
|
+
createdAt: this.createdAt.toISOString(),
|
|
73
|
+
updatedAt: this.updatedAt.toISOString(),
|
|
74
|
+
tags: this._tags
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
CounterRecord.type = "CounterRecord";
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { CounterRecord };
|
|
82
|
+
//# sourceMappingURL=CounterRecord.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterRecord.mjs","names":[],"sources":["../../src/repository/CounterRecord.ts"],"sourcesContent":["/**\n * Counter Record for Replay Protection\n *\n * Tracks monotonic counters per device to prevent replay attacks on join tokens.\n * Each device has its own counter that must strictly increase with each token use.\n *\n * Security Requirements (from Signing Protocol spec):\n * - Counters MUST be strictly monotonically increasing per device\n * - Tokens with ctr <= last_seen_ctr MUST be rejected\n * - Counter MUST be persisted BEFORE token consumption\n * - Used counters MUST be tracked to detect replays\n */\n\nimport type { TagsBase } from '@credo-ts/core'\nimport { BaseRecord, utils } from '@credo-ts/core'\n\nexport interface CounterRecordProps {\n id?: string\n deviceId: string\n currentCounter: number\n usedCounters?: number[]\n createdAt?: Date\n updatedAt?: Date\n tags?: CustomCounterTags\n}\n\nexport type CustomCounterTags = TagsBase & {\n deviceId: string\n}\n\nexport type DefaultCounterTags = {\n deviceId: string\n currentCounter: string\n}\n\nexport class CounterRecord extends BaseRecord<DefaultCounterTags, CustomCounterTags> {\n public static readonly type = 'CounterRecord'\n public readonly type = CounterRecord.type\n\n /**\n * Device identifier (DID or key identifier)\n * @example \"did:ex:alice#device1\" or \"z6Mkk...\"\n */\n public deviceId!: string\n\n /**\n * Current counter value\n *\n * This is the highest counter value that has been seen and persisted.\n * Next valid counter must be > currentCounter.\n */\n public currentCounter!: number\n\n /**\n * Set of used counter values for additional replay protection\n *\n * While currentCounter provides the main replay protection,\n * this set tracks all used counters to detect any replay attempts.\n *\n * Note: This may grow large over time. Consider pruning old values\n * that are < currentCounter - window_size.\n */\n public usedCounters: Set<number> = new Set()\n\n /**\n * Last update timestamp\n */\n public updatedAt!: Date\n\n public constructor(props: CounterRecordProps) {\n super()\n\n if (props) {\n this.id = props.id ?? utils.uuid()\n this.deviceId = props.deviceId\n this.currentCounter = props.currentCounter\n // Ensure usedCounters is always a Set, even if loaded from storage as array\n if (props.usedCounters) {\n this.usedCounters = Array.isArray(props.usedCounters) ? new Set(props.usedCounters) : new Set()\n } else {\n this.usedCounters = new Set()\n }\n this.createdAt = props.createdAt ?? new Date()\n this.updatedAt = props.updatedAt ?? new Date()\n this._tags = props.tags ?? { deviceId: this.deviceId }\n }\n }\n\n /**\n * Get default tags for indexing\n */\n public getTags() {\n return {\n ...this._tags,\n deviceId: this.deviceId,\n currentCounter: this.currentCounter.toString(),\n }\n }\n\n /**\n * Check if a counter value has been used\n */\n public isCounterUsed(ctr: number): boolean {\n return ctr <= this.currentCounter || this.usedCounters.has(ctr)\n }\n\n /**\n * Update counter to a new value\n *\n * CRITICAL: This should only be called BEFORE consuming the token.\n * If token consumption fails, counter should be rolled back.\n */\n public updateCounter(newCounter: number): void {\n if (newCounter <= this.currentCounter) {\n throw new Error(\n `Counter must be strictly increasing: ${newCounter} <= ${this.currentCounter}`\n )\n }\n\n // Ensure usedCounters is a Set (in case it was deserialized as an array)\n if (!this.usedCounters || !(this.usedCounters instanceof Set)) {\n this.usedCounters = new Set(this.usedCounters || [])\n }\n\n this.usedCounters.add(newCounter)\n this.currentCounter = newCounter\n this.updatedAt = new Date()\n }\n\n /**\n * Prune old used counters to prevent unbounded growth\n *\n * Removes counters that are more than `windowSize` behind current counter.\n * These are guaranteed to be rejected anyway since they're <= currentCounter.\n *\n * @param windowSize - How many old counters to keep (default 100)\n */\n public pruneOldCounters(windowSize = 100): void {\n const minCounter = this.currentCounter - windowSize\n this.usedCounters.forEach((ctr) => {\n if (ctr < minCounter) {\n this.usedCounters.delete(ctr)\n }\n })\n }\n\n /**\n * Serialize used counters for storage\n */\n public toJSON(): Record<string, unknown> {\n return {\n id: this.id,\n deviceId: this.deviceId,\n currentCounter: this.currentCounter,\n usedCounters: Array.from(this.usedCounters),\n createdAt: this.createdAt.toISOString(),\n updatedAt: this.updatedAt.toISOString(),\n tags: this._tags,\n }\n }\n}\n"],"mappings":";;;AAmCA,IAAa,gBAAb,MAAa,sBAAsB,WAAkD;CAkCnF,AAAO,YAAY,OAA2B;AAC5C,SAAO;OAjCO,OAAO,cAAc;OAyB9B,+BAA4B,IAAI,KAAK;AAU1C,MAAI,OAAO;AACT,QAAK,KAAK,MAAM,MAAM,MAAM,MAAM;AAClC,QAAK,WAAW,MAAM;AACtB,QAAK,iBAAiB,MAAM;AAE5B,OAAI,MAAM,aACR,MAAK,eAAe,MAAM,QAAQ,MAAM,aAAa,GAAG,IAAI,IAAI,MAAM,aAAa,mBAAG,IAAI,KAAK;OAE/F,MAAK,+BAAe,IAAI,KAAK;AAE/B,QAAK,YAAY,MAAM,6BAAa,IAAI,MAAM;AAC9C,QAAK,YAAY,MAAM,6BAAa,IAAI,MAAM;AAC9C,QAAK,QAAQ,MAAM,QAAQ,EAAE,UAAU,KAAK,UAAU;;;;;;CAO1D,AAAO,UAAU;AACf,SAAO;GACL,GAAG,KAAK;GACR,UAAU,KAAK;GACf,gBAAgB,KAAK,eAAe,UAAU;GAC/C;;;;;CAMH,AAAO,cAAc,KAAsB;AACzC,SAAO,OAAO,KAAK,kBAAkB,KAAK,aAAa,IAAI,IAAI;;;;;;;;CASjE,AAAO,cAAc,YAA0B;AAC7C,MAAI,cAAc,KAAK,eACrB,OAAM,IAAI,MACR,wCAAwC,WAAW,MAAM,KAAK,iBAC/D;AAIH,MAAI,CAAC,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,KACvD,MAAK,eAAe,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;AAGtD,OAAK,aAAa,IAAI,WAAW;AACjC,OAAK,iBAAiB;AACtB,OAAK,4BAAY,IAAI,MAAM;;;;;;;;;;CAW7B,AAAO,iBAAiB,aAAa,KAAW;EAC9C,MAAM,aAAa,KAAK,iBAAiB;AACzC,OAAK,aAAa,SAAS,QAAQ;AACjC,OAAI,MAAM,WACR,MAAK,aAAa,OAAO,IAAI;IAE/B;;;;;CAMJ,AAAO,SAAkC;AACvC,SAAO;GACL,IAAI,KAAK;GACT,UAAU,KAAK;GACf,gBAAgB,KAAK;GACrB,cAAc,MAAM,KAAK,KAAK,aAAa;GAC3C,WAAW,KAAK,UAAU,aAAa;GACvC,WAAW,KAAK,UAAU,aAAa;GACvC,MAAM,KAAK;GACZ;;;cA1HoB,OAAO"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CounterRecord } from "./CounterRecord.mjs";
|
|
2
|
+
import { AgentContext, EventEmitter, Repository, StorageService } from "@credo-ts/core";
|
|
3
|
+
|
|
4
|
+
//#region src/repository/CounterRepository.d.ts
|
|
5
|
+
declare class CounterRepository extends Repository<CounterRecord> {
|
|
6
|
+
constructor(storageService: StorageService<CounterRecord>, eventEmitter: EventEmitter);
|
|
7
|
+
/**
|
|
8
|
+
* Find counter record by device ID
|
|
9
|
+
*/
|
|
10
|
+
findByDeviceId(agentContext: AgentContext, deviceId: string): Promise<CounterRecord | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Get counter record by device ID (throws if not found)
|
|
13
|
+
*/
|
|
14
|
+
getByDeviceId(agentContext: AgentContext, deviceId: string): Promise<CounterRecord>;
|
|
15
|
+
/**
|
|
16
|
+
* Get or create counter record for a device
|
|
17
|
+
*/
|
|
18
|
+
getOrCreate(agentContext: AgentContext, deviceId: string): Promise<CounterRecord>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CounterRepository };
|
|
22
|
+
//# sourceMappingURL=CounterRepository.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterRepository.d.mts","names":[],"sources":["../../src/repository/CounterRepository.ts"],"mappings":";;;;cAWa,iBAAA,SAA0B,UAAA,CAAW,aAAA;cAEL,cAAA,EAAgB,cAAA,CAAe,aAAA,GACxE,YAAA,EAAc,YAAA;EAAA;;;EAQH,cAAA,CAAe,YAAA,EAAc,YAAA,EAAc,QAAA,WAAmB,OAAA,CAAQ,aAAA;EAW1C;;;EAA5B,aAAA,CAAc,YAAA,EAAc,YAAA,EAAc,QAAA,WAAmB,OAAA,CAAQ,aAAA;EAaF;;;EAAnE,WAAA,CAAY,YAAA,EAAc,YAAA,EAAc,QAAA,WAAmB,OAAA,CAAQ,aAAA;AAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
|
|
3
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
4
|
+
import { CounterRecord } from "./CounterRecord.mjs";
|
|
5
|
+
import { EventEmitter, InjectionSymbols, Repository, inject, injectable } from "@credo-ts/core";
|
|
6
|
+
|
|
7
|
+
//#region src/repository/CounterRepository.ts
|
|
8
|
+
var _ref;
|
|
9
|
+
let CounterRepository = class CounterRepository extends Repository {
|
|
10
|
+
constructor(storageService, eventEmitter) {
|
|
11
|
+
super(CounterRecord, storageService, eventEmitter);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Find counter record by device ID
|
|
15
|
+
*/
|
|
16
|
+
async findByDeviceId(agentContext, deviceId) {
|
|
17
|
+
const records = await this.findByQuery(agentContext, { deviceId });
|
|
18
|
+
return records.length > 0 ? records[0] : null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get counter record by device ID (throws if not found)
|
|
22
|
+
*/
|
|
23
|
+
async getByDeviceId(agentContext, deviceId) {
|
|
24
|
+
const record = await this.findByDeviceId(agentContext, deviceId);
|
|
25
|
+
if (!record) throw new Error(`Counter record not found for device: ${deviceId}`);
|
|
26
|
+
return record;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get or create counter record for a device
|
|
30
|
+
*/
|
|
31
|
+
async getOrCreate(agentContext, deviceId) {
|
|
32
|
+
const existing = await this.findByDeviceId(agentContext, deviceId);
|
|
33
|
+
if (existing) return existing;
|
|
34
|
+
const record = new CounterRecord({
|
|
35
|
+
deviceId,
|
|
36
|
+
currentCounter: 0,
|
|
37
|
+
usedCounters: []
|
|
38
|
+
});
|
|
39
|
+
await this.save(agentContext, record);
|
|
40
|
+
return record;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
CounterRepository = __decorate([
|
|
44
|
+
injectable(),
|
|
45
|
+
__decorateParam(0, inject(InjectionSymbols.StorageService)),
|
|
46
|
+
__decorateMetadata("design:paramtypes", [Object, EventEmitter])
|
|
47
|
+
], CounterRepository);
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CounterRepository };
|
|
51
|
+
//# sourceMappingURL=CounterRepository.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CounterRepository.mjs","names":[],"sources":["../../src/repository/CounterRepository.ts"],"sourcesContent":["/**\n * Counter Repository\n *\n * Manages persistence of counter records for replay protection.\n */\n\nimport type { AgentContext, StorageService } from '@credo-ts/core'\nimport { EventEmitter, inject, injectable, InjectionSymbols, Repository } from '@credo-ts/core'\nimport { CounterRecord } from './CounterRecord'\n\n@injectable()\nexport class CounterRepository extends Repository<CounterRecord> {\n public constructor(\n @inject(InjectionSymbols.StorageService) storageService: StorageService<CounterRecord>,\n eventEmitter: EventEmitter\n ) {\n super(CounterRecord, storageService, eventEmitter)\n }\n\n /**\n * Find counter record by device ID\n */\n public async findByDeviceId(agentContext: AgentContext, deviceId: string): Promise<CounterRecord | null> {\n const records = await this.findByQuery(agentContext, {\n deviceId,\n })\n\n return records.length > 0 ? records[0] : null\n }\n\n /**\n * Get counter record by device ID (throws if not found)\n */\n public async getByDeviceId(agentContext: AgentContext, deviceId: string): Promise<CounterRecord> {\n const record = await this.findByDeviceId(agentContext, deviceId)\n\n if (!record) {\n throw new Error(`Counter record not found for device: ${deviceId}`)\n }\n\n return record\n }\n\n /**\n * Get or create counter record for a device\n */\n public async getOrCreate(agentContext: AgentContext, deviceId: string): Promise<CounterRecord> {\n const existing = await this.findByDeviceId(agentContext, deviceId)\n\n if (existing) {\n return existing\n }\n\n // Create new counter record starting at 0\n const record = new CounterRecord({\n deviceId,\n currentCounter: 0,\n usedCounters: [],\n })\n\n await this.save(agentContext, record)\n\n return record\n }\n}\n"],"mappings":";;;;;;;;AAWO,8BAAM,0BAA0B,WAA0B;CAC/D,AAAO,YACL,AAAyC,gBACzC,cACA;AACA,QAAM,eAAe,gBAAgB,aAAa;;;;;CAMpD,MAAa,eAAe,cAA4B,UAAiD;EACvG,MAAM,UAAU,MAAM,KAAK,YAAY,cAAc,EACnD,UACD,CAAC;AAEF,SAAO,QAAQ,SAAS,IAAI,QAAQ,KAAK;;;;;CAM3C,MAAa,cAAc,cAA4B,UAA0C;EAC/F,MAAM,SAAS,MAAM,KAAK,eAAe,cAAc,SAAS;AAEhE,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wCAAwC,WAAW;AAGrE,SAAO;;;;;CAMT,MAAa,YAAY,cAA4B,UAA0C;EAC7F,MAAM,WAAW,MAAM,KAAK,eAAe,cAAc,SAAS;AAElE,MAAI,SACF,QAAO;EAIT,MAAM,SAAS,IAAI,cAAc;GAC/B;GACA,gBAAgB;GAChB,cAAc,EAAE;GACjB,CAAC;AAEF,QAAM,KAAK,KAAK,cAAc,OAAO;AAErC,SAAO;;;;CApDV,YAAY;oBAGR,OAAO,iBAAiB,eAAe"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { SigningRole } from "../SigningRole.mjs";
|
|
2
|
+
import { SigningState } from "../models/SigningState.mjs";
|
|
3
|
+
import { SignableObject } from "../models/SignableObject.mjs";
|
|
4
|
+
import { SessionMode, ThresholdConfig } from "../models/Session.mjs";
|
|
5
|
+
import { SuiteConfig } from "../models/Suite.mjs";
|
|
6
|
+
import { ConsentData, PartialSignature } from "../models/PartialSignature.mjs";
|
|
7
|
+
import { AggregationResult, ArtifactData, ArtifactReference } from "../models/AggregationResult.mjs";
|
|
8
|
+
import "../models/index.mjs";
|
|
9
|
+
import { BaseRecord, RecordTags, TagsBase } from "@credo-ts/core";
|
|
10
|
+
|
|
11
|
+
//#region src/repository/SigningSessionRecord.d.ts
|
|
12
|
+
type CustomSigningSessionTags = TagsBase;
|
|
13
|
+
type DefaultSigningSessionTags = {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
connectionId?: string;
|
|
16
|
+
role: SigningRole;
|
|
17
|
+
state: SigningState;
|
|
18
|
+
threadId: string;
|
|
19
|
+
};
|
|
20
|
+
type SigningSessionTags = RecordTags<SigningSessionRecord>;
|
|
21
|
+
interface SigningSessionStorageProps {
|
|
22
|
+
id?: string;
|
|
23
|
+
createdAt?: Date;
|
|
24
|
+
updatedAt?: Date;
|
|
25
|
+
tags?: CustomSigningSessionTags;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
connectionId?: string;
|
|
28
|
+
threadId: string;
|
|
29
|
+
role: SigningRole;
|
|
30
|
+
state: SigningState;
|
|
31
|
+
mode?: SessionMode;
|
|
32
|
+
object?: SignableObject;
|
|
33
|
+
suite?: SuiteConfig;
|
|
34
|
+
threshold?: ThresholdConfig;
|
|
35
|
+
partialSignatures?: PartialSignature[];
|
|
36
|
+
consentMessages?: ConsentData[];
|
|
37
|
+
aggregationResult?: AggregationResult;
|
|
38
|
+
artifacts?: ArtifactData[];
|
|
39
|
+
artifactReferences?: ArtifactReference[];
|
|
40
|
+
idempotencyKey?: string;
|
|
41
|
+
errorMessage?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Database record for a signing session
|
|
45
|
+
*/
|
|
46
|
+
declare class SigningSessionRecord extends BaseRecord<DefaultSigningSessionTags, CustomSigningSessionTags> {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
connectionId?: string;
|
|
49
|
+
threadId: string;
|
|
50
|
+
role: SigningRole;
|
|
51
|
+
state: SigningState;
|
|
52
|
+
mode?: SessionMode;
|
|
53
|
+
object?: SignableObject;
|
|
54
|
+
suite?: SuiteConfig;
|
|
55
|
+
threshold?: ThresholdConfig;
|
|
56
|
+
partialSignatures: PartialSignature[];
|
|
57
|
+
consentMessages: ConsentData[];
|
|
58
|
+
aggregationResult?: AggregationResult;
|
|
59
|
+
artifacts: ArtifactData[];
|
|
60
|
+
artifactReferences: ArtifactReference[];
|
|
61
|
+
idempotencyKey?: string;
|
|
62
|
+
errorMessage?: string;
|
|
63
|
+
static readonly type = "SigningSessionRecord";
|
|
64
|
+
readonly type = "SigningSessionRecord";
|
|
65
|
+
constructor(props: SigningSessionStorageProps);
|
|
66
|
+
getTags(): {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
connectionId: string | undefined;
|
|
69
|
+
role: SigningRole;
|
|
70
|
+
state: SigningState;
|
|
71
|
+
threadId: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Assert that the record is in a specific role
|
|
75
|
+
* @throws {InvalidStateError} if role doesn't match
|
|
76
|
+
*/
|
|
77
|
+
assertRole(expectedRole: SigningRole): void;
|
|
78
|
+
/**
|
|
79
|
+
* Assert that the record is in a specific state
|
|
80
|
+
* @throws {InvalidStateError} if state doesn't match
|
|
81
|
+
*/
|
|
82
|
+
assertState(expectedState: SigningState | SigningState[]): void;
|
|
83
|
+
/**
|
|
84
|
+
* Check if threshold is met (for multi-sig sessions)
|
|
85
|
+
*/
|
|
86
|
+
get isThresholdMet(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Check if session has consent from a specific signer
|
|
89
|
+
*/
|
|
90
|
+
hasConsentFrom(signerDid: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Get partial signature from a specific signer
|
|
93
|
+
*/
|
|
94
|
+
getPartialSignatureFrom(signerDid: string): PartialSignature | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Check if we have a partial signature from a specific signer
|
|
97
|
+
*/
|
|
98
|
+
hasPartialSignatureFrom(signerDid: string): boolean;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { CustomSigningSessionTags, DefaultSigningSessionTags, SigningSessionRecord, SigningSessionStorageProps, SigningSessionTags };
|
|
102
|
+
//# sourceMappingURL=SigningSessionRecord.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigningSessionRecord.d.mts","names":[],"sources":["../../src/repository/SigningSessionRecord.ts"],"mappings":";;;;;;;;;;;KAmBY,wBAAA,GAA2B,QAAA;AAAA,KAE3B,yBAAA;EACV,SAAA;EACA,YAAA;EACA,IAAA,EAAM,WAAA;EACN,KAAA,EAAO,YAAA;EACP,QAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,UAAA,CAAW,oBAAA;AAAA,UAE3B,0BAAA;EACf,EAAA;EACA,SAAA,GAAY,IAAA;EACZ,SAAA,GAAY,IAAA;EACZ,IAAA,GAAO,wBAAA;EAGP,SAAA;EACA,YAAA;EACA,QAAA;EAGA,IAAA,EAAM,WAAA;EACN,KAAA,EAAO,YAAA;EAGP,IAAA,GAAO,WAAA;EACP,MAAA,GAAS,cAAA;EACT,KAAA,GAAQ,WAAA;EACR,SAAA,GAAY,eAAA;EAGZ,iBAAA,GAAoB,gBAAA;EACpB,eAAA,GAAkB,WAAA;EAClB,iBAAA,GAAoB,iBAAA;EACpB,SAAA,GAAY,YAAA;EACZ,kBAAA,GAAqB,iBAAA;EAGrB,cAAA;EACA,YAAA;AAAA;;;;cAMW,oBAAA,SAA6B,UAAA,CAAW,yBAAA,EAA2B,wBAAA;EACvE,SAAA;EACA,YAAA;EACA,QAAA;EAEA,IAAA,EAAO,WAAA;EACP,KAAA,EAAQ,YAAA;EAER,IAAA,GAAO,WAAA;EACP,MAAA,GAAS,cAAA;EACT,KAAA,GAAQ,WAAA;EACR,SAAA,GAAY,eAAA;EAEZ,iBAAA,EAAmB,gBAAA;EACnB,eAAA,EAAiB,WAAA;EACjB,iBAAA,GAAoB,iBAAA;EACpB,SAAA,EAAW,YAAA;EACX,kBAAA,EAAoB,iBAAA;EAEpB,cAAA;EACA,YAAA;EAAA,gBAEgB,IAAA;EAAA,SACP,IAAA;cAEG,KAAA,EAAO,0BAAA;EAiCnB,OAAA,CAAA;;;;;;;EAjFP;;;;EAgGO,UAAA,CAAW,YAAA,EAAc,WAAA;EA5FvB;;;;EA0GF,WAAA,CAAY,aAAA,EAAe,YAAA,GAAe,YAAA;EArGjD;;;EAAA,IAgHW,cAAA,CAAA;EA9GX;;;EA+HO,cAAA,CAAe,SAAA;EA7HtB;;;EAoIO,uBAAA,CAAwB,SAAA,WAAoB,gBAAA;EAhIvC;;AAMd;EAiIS,uBAAA,CAAwB,SAAA;AAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { InvalidStateError } from "../errors/InvalidStateError.mjs";
|
|
2
|
+
import "../errors/index.mjs";
|
|
3
|
+
import { BaseRecord, utils } from "@credo-ts/core";
|
|
4
|
+
|
|
5
|
+
//#region src/repository/SigningSessionRecord.ts
|
|
6
|
+
/**
|
|
7
|
+
* Database record for a signing session
|
|
8
|
+
*/
|
|
9
|
+
var SigningSessionRecord = class SigningSessionRecord extends BaseRecord {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super();
|
|
12
|
+
this.partialSignatures = [];
|
|
13
|
+
this.consentMessages = [];
|
|
14
|
+
this.artifacts = [];
|
|
15
|
+
this.artifactReferences = [];
|
|
16
|
+
this.type = SigningSessionRecord.type;
|
|
17
|
+
if (props) {
|
|
18
|
+
this.id = props.id ?? utils.uuid();
|
|
19
|
+
this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
|
|
20
|
+
this.updatedAt = props.updatedAt;
|
|
21
|
+
this.sessionId = props.sessionId;
|
|
22
|
+
this.connectionId = props.connectionId;
|
|
23
|
+
this.threadId = props.threadId;
|
|
24
|
+
this.role = props.role;
|
|
25
|
+
this.state = props.state;
|
|
26
|
+
this.mode = props.mode;
|
|
27
|
+
this.object = props.object;
|
|
28
|
+
this.suite = props.suite;
|
|
29
|
+
this.threshold = props.threshold;
|
|
30
|
+
this.partialSignatures = props.partialSignatures ?? [];
|
|
31
|
+
this.consentMessages = props.consentMessages ?? [];
|
|
32
|
+
this.aggregationResult = props.aggregationResult;
|
|
33
|
+
this.artifacts = props.artifacts ?? [];
|
|
34
|
+
this.artifactReferences = props.artifactReferences ?? [];
|
|
35
|
+
this.idempotencyKey = props.idempotencyKey;
|
|
36
|
+
this.errorMessage = props.errorMessage;
|
|
37
|
+
this._tags = props.tags ?? {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getTags() {
|
|
41
|
+
return {
|
|
42
|
+
...this._tags,
|
|
43
|
+
sessionId: this.sessionId,
|
|
44
|
+
connectionId: this.connectionId,
|
|
45
|
+
role: this.role,
|
|
46
|
+
state: this.state,
|
|
47
|
+
threadId: this.threadId
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Assert that the record is in a specific role
|
|
52
|
+
* @throws {InvalidStateError} if role doesn't match
|
|
53
|
+
*/
|
|
54
|
+
assertRole(expectedRole) {
|
|
55
|
+
if (this.role !== expectedRole) throw new InvalidStateError(this.state, this.state, `perform operation as ${expectedRole} (current role: ${this.role})`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Assert that the record is in a specific state
|
|
59
|
+
* @throws {InvalidStateError} if state doesn't match
|
|
60
|
+
*/
|
|
61
|
+
assertState(expectedState) {
|
|
62
|
+
const expectedStates = Array.isArray(expectedState) ? expectedState : [expectedState];
|
|
63
|
+
if (!expectedStates.includes(this.state)) throw new InvalidStateError(this.state, expectedStates, "perform this operation");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if threshold is met (for multi-sig sessions)
|
|
67
|
+
*/
|
|
68
|
+
get isThresholdMet() {
|
|
69
|
+
if (this.mode === "single") return this.partialSignatures.length >= 1;
|
|
70
|
+
if (!this.threshold) return false;
|
|
71
|
+
return this.partialSignatures.length >= this.threshold.n;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if session has consent from a specific signer
|
|
75
|
+
*/
|
|
76
|
+
hasConsentFrom(signerDid) {
|
|
77
|
+
return this.consentMessages.some((consent) => consent.signer === signerDid);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get partial signature from a specific signer
|
|
81
|
+
*/
|
|
82
|
+
getPartialSignatureFrom(signerDid) {
|
|
83
|
+
return this.partialSignatures.find((sig) => sig.signer === signerDid);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if we have a partial signature from a specific signer
|
|
87
|
+
*/
|
|
88
|
+
hasPartialSignatureFrom(signerDid) {
|
|
89
|
+
return this.partialSignatures.some((sig) => sig.signer === signerDid);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
SigningSessionRecord.type = "SigningSessionRecord";
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { SigningSessionRecord };
|
|
96
|
+
//# sourceMappingURL=SigningSessionRecord.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigningSessionRecord.mjs","names":[],"sources":["../../src/repository/SigningSessionRecord.ts"],"sourcesContent":["import type { TagsBase, RecordTags } from '@credo-ts/core'\nimport type { SigningRole } from '../SigningRole'\nimport type {\n SigningState,\n SignableObject,\n Session,\n SuiteConfig,\n ThresholdConfig,\n SessionMode,\n PartialSignature,\n ConsentData,\n AggregationResult,\n ArtifactData,\n ArtifactReference,\n} from '../models'\n\nimport { BaseRecord, utils } from '@credo-ts/core'\nimport { InvalidStateError } from '../errors'\n\nexport type CustomSigningSessionTags = TagsBase\n\nexport type DefaultSigningSessionTags = {\n sessionId: string\n connectionId?: string\n role: SigningRole\n state: SigningState\n threadId: string\n}\n\nexport type SigningSessionTags = RecordTags<SigningSessionRecord>\n\nexport interface SigningSessionStorageProps {\n id?: string\n createdAt?: Date\n updatedAt?: Date\n tags?: CustomSigningSessionTags\n\n // Core identifiers\n sessionId: string\n connectionId?: string\n threadId: string\n\n // Role and state\n role: SigningRole\n state: SigningState\n\n // Session configuration\n mode?: SessionMode\n object?: SignableObject\n suite?: SuiteConfig\n threshold?: ThresholdConfig\n\n // Signing data\n partialSignatures?: PartialSignature[]\n consentMessages?: ConsentData[]\n aggregationResult?: AggregationResult\n artifacts?: ArtifactData[]\n artifactReferences?: ArtifactReference[]\n\n // Metadata\n idempotencyKey?: string\n errorMessage?: string\n}\n\n/**\n * Database record for a signing session\n */\nexport class SigningSessionRecord extends BaseRecord<DefaultSigningSessionTags, CustomSigningSessionTags> {\n public sessionId!: string\n public connectionId?: string\n public threadId!: string\n\n public role!: SigningRole\n public state!: SigningState\n\n public mode?: SessionMode\n public object?: SignableObject\n public suite?: SuiteConfig\n public threshold?: ThresholdConfig\n\n public partialSignatures: PartialSignature[] = []\n public consentMessages: ConsentData[] = []\n public aggregationResult?: AggregationResult\n public artifacts: ArtifactData[] = []\n public artifactReferences: ArtifactReference[] = []\n\n public idempotencyKey?: string\n public errorMessage?: string\n\n public static readonly type = 'SigningSessionRecord'\n public readonly type = SigningSessionRecord.type\n\n public constructor(props: SigningSessionStorageProps) {\n super()\n\n if (props) {\n this.id = props.id ?? utils.uuid()\n this.createdAt = props.createdAt ?? new Date()\n this.updatedAt = props.updatedAt\n\n this.sessionId = props.sessionId\n this.connectionId = props.connectionId\n this.threadId = props.threadId\n\n this.role = props.role\n this.state = props.state\n\n this.mode = props.mode\n this.object = props.object\n this.suite = props.suite\n this.threshold = props.threshold\n\n this.partialSignatures = props.partialSignatures ?? []\n this.consentMessages = props.consentMessages ?? []\n this.aggregationResult = props.aggregationResult\n this.artifacts = props.artifacts ?? []\n this.artifactReferences = props.artifactReferences ?? []\n\n this.idempotencyKey = props.idempotencyKey\n this.errorMessage = props.errorMessage\n\n this._tags = props.tags ?? {}\n }\n }\n\n public getTags() {\n return {\n ...this._tags,\n sessionId: this.sessionId,\n connectionId: this.connectionId,\n role: this.role,\n state: this.state,\n threadId: this.threadId,\n }\n }\n\n /**\n * Assert that the record is in a specific role\n * @throws {InvalidStateError} if role doesn't match\n */\n public assertRole(expectedRole: SigningRole): void {\n if (this.role !== expectedRole) {\n throw new InvalidStateError(\n this.state,\n this.state,\n `perform operation as ${expectedRole} (current role: ${this.role})`\n )\n }\n }\n\n /**\n * Assert that the record is in a specific state\n * @throws {InvalidStateError} if state doesn't match\n */\n public assertState(expectedState: SigningState | SigningState[]): void {\n const expectedStates = Array.isArray(expectedState) ? expectedState : [expectedState]\n\n if (!expectedStates.includes(this.state)) {\n throw new InvalidStateError(this.state, expectedStates, 'perform this operation')\n }\n }\n\n /**\n * Check if threshold is met (for multi-sig sessions)\n */\n public get isThresholdMet(): boolean {\n // Single signer - always \"met\"\n if (this.mode === 'single') {\n return this.partialSignatures.length >= 1\n }\n\n // Threshold mode - check if we have enough signatures\n if (!this.threshold) {\n return false\n }\n\n return this.partialSignatures.length >= this.threshold.n\n }\n\n /**\n * Check if session has consent from a specific signer\n */\n public hasConsentFrom(signerDid: string): boolean {\n return this.consentMessages.some((consent) => consent.signer === signerDid)\n }\n\n /**\n * Get partial signature from a specific signer\n */\n public getPartialSignatureFrom(signerDid: string): PartialSignature | undefined {\n return this.partialSignatures.find((sig) => sig.signer === signerDid)\n }\n\n /**\n * Check if we have a partial signature from a specific signer\n */\n public hasPartialSignatureFrom(signerDid: string): boolean {\n return this.partialSignatures.some((sig) => sig.signer === signerDid)\n }\n}\n"],"mappings":";;;;;;;;AAmEA,IAAa,uBAAb,MAAa,6BAA6B,WAAgE;CAyBxG,AAAO,YAAY,OAAmC;AACpD,SAAO;OAbF,oBAAwC,EAAE;OAC1C,kBAAiC,EAAE;OAEnC,YAA4B,EAAE;OAC9B,qBAA0C,EAAE;OAMnC,OAAO,qBAAqB;AAK1C,MAAI,OAAO;AACT,QAAK,KAAK,MAAM,MAAM,MAAM,MAAM;AAClC,QAAK,YAAY,MAAM,6BAAa,IAAI,MAAM;AAC9C,QAAK,YAAY,MAAM;AAEvB,QAAK,YAAY,MAAM;AACvB,QAAK,eAAe,MAAM;AAC1B,QAAK,WAAW,MAAM;AAEtB,QAAK,OAAO,MAAM;AAClB,QAAK,QAAQ,MAAM;AAEnB,QAAK,OAAO,MAAM;AAClB,QAAK,SAAS,MAAM;AACpB,QAAK,QAAQ,MAAM;AACnB,QAAK,YAAY,MAAM;AAEvB,QAAK,oBAAoB,MAAM,qBAAqB,EAAE;AACtD,QAAK,kBAAkB,MAAM,mBAAmB,EAAE;AAClD,QAAK,oBAAoB,MAAM;AAC/B,QAAK,YAAY,MAAM,aAAa,EAAE;AACtC,QAAK,qBAAqB,MAAM,sBAAsB,EAAE;AAExD,QAAK,iBAAiB,MAAM;AAC5B,QAAK,eAAe,MAAM;AAE1B,QAAK,QAAQ,MAAM,QAAQ,EAAE;;;CAIjC,AAAO,UAAU;AACf,SAAO;GACL,GAAG,KAAK;GACR,WAAW,KAAK;GAChB,cAAc,KAAK;GACnB,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,UAAU,KAAK;GAChB;;;;;;CAOH,AAAO,WAAW,cAAiC;AACjD,MAAI,KAAK,SAAS,aAChB,OAAM,IAAI,kBACR,KAAK,OACL,KAAK,OACL,wBAAwB,aAAa,kBAAkB,KAAK,KAAK,GAClE;;;;;;CAQL,AAAO,YAAY,eAAoD;EACrE,MAAM,iBAAiB,MAAM,QAAQ,cAAc,GAAG,gBAAgB,CAAC,cAAc;AAErF,MAAI,CAAC,eAAe,SAAS,KAAK,MAAM,CACtC,OAAM,IAAI,kBAAkB,KAAK,OAAO,gBAAgB,yBAAyB;;;;;CAOrF,IAAW,iBAA0B;AAEnC,MAAI,KAAK,SAAS,SAChB,QAAO,KAAK,kBAAkB,UAAU;AAI1C,MAAI,CAAC,KAAK,UACR,QAAO;AAGT,SAAO,KAAK,kBAAkB,UAAU,KAAK,UAAU;;;;;CAMzD,AAAO,eAAe,WAA4B;AAChD,SAAO,KAAK,gBAAgB,MAAM,YAAY,QAAQ,WAAW,UAAU;;;;;CAM7E,AAAO,wBAAwB,WAAiD;AAC9E,SAAO,KAAK,kBAAkB,MAAM,QAAQ,IAAI,WAAW,UAAU;;;;;CAMvE,AAAO,wBAAwB,WAA4B;AACzD,SAAO,KAAK,kBAAkB,MAAM,QAAQ,IAAI,WAAW,UAAU;;;qBA5GhD,OAAO"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SigningSessionRecord } from "./SigningSessionRecord.mjs";
|
|
2
|
+
import { AgentContext, EventEmitter, Repository, StorageService } from "@credo-ts/core";
|
|
3
|
+
|
|
4
|
+
//#region src/repository/SigningSessionRepository.d.ts
|
|
5
|
+
declare class SigningSessionRepository extends Repository<SigningSessionRecord> {
|
|
6
|
+
constructor(storageService: StorageService<SigningSessionRecord>, eventEmitter: EventEmitter);
|
|
7
|
+
/**
|
|
8
|
+
* Find session by session ID
|
|
9
|
+
*/
|
|
10
|
+
findBySessionId(agentContext: AgentContext, sessionId: string): Promise<SigningSessionRecord | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Get session by session ID (throws if not found)
|
|
13
|
+
*/
|
|
14
|
+
getBySessionId(agentContext: AgentContext, sessionId: string): Promise<SigningSessionRecord>;
|
|
15
|
+
/**
|
|
16
|
+
* Find session by thread ID
|
|
17
|
+
*/
|
|
18
|
+
findByThreadId(agentContext: AgentContext, threadId: string): Promise<SigningSessionRecord | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Find all sessions for a connection
|
|
21
|
+
*/
|
|
22
|
+
findByConnectionId(agentContext: AgentContext, connectionId: string): Promise<SigningSessionRecord[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Find session by idempotency key
|
|
25
|
+
*/
|
|
26
|
+
findByIdempotencyKey(agentContext: AgentContext, idempotencyKey: string): Promise<SigningSessionRecord | null>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { SigningSessionRepository };
|
|
30
|
+
//# sourceMappingURL=SigningSessionRepository.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigningSessionRepository.d.mts","names":[],"sources":["../../src/repository/SigningSessionRepository.ts"],"mappings":";;;;cAOa,wBAAA,SAAiC,UAAA,CAAW,oBAAA;cAEZ,cAAA,EAAgB,cAAA,CAAe,oBAAA,GACxE,YAAA,EAAc,YAAA;EAHoB;;;EAWvB,eAAA,CAAgB,YAAA,EAAc,YAAA,EAAc,SAAA,WAAoB,OAAA,CAAQ,oBAAA;EAT1B;;;EAgB9C,cAAA,CAAe,YAAA,EAAc,YAAA,EAAc,SAAA,WAAoB,OAAA,CAAQ,oBAAA;EAPP;;;EAchE,cAAA,CAAe,YAAA,EAAc,YAAA,EAAc,QAAA,WAAmB,OAAA,CAAQ,oBAAA;EAAzC;;;EAO7B,kBAAA,CAAmB,YAAA,EAAc,YAAA,EAAc,YAAA,WAAuB,OAAA,CAAQ,oBAAA;EAAA;;;EAO9E,oBAAA,CACX,YAAA,EAAc,YAAA,EACd,cAAA,WACC,OAAA,CAAQ,oBAAA;AAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SigningSessionRecord } from "./SigningSessionRecord.mjs";
|
|
2
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
3
|
+
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
|
|
4
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
5
|
+
import { EventEmitter, InjectionSymbols, Repository, inject, injectable } from "@credo-ts/core";
|
|
6
|
+
|
|
7
|
+
//#region src/repository/SigningSessionRepository.ts
|
|
8
|
+
var _ref;
|
|
9
|
+
let SigningSessionRepository = class SigningSessionRepository extends Repository {
|
|
10
|
+
constructor(storageService, eventEmitter) {
|
|
11
|
+
super(SigningSessionRecord, storageService, eventEmitter);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Find session by session ID
|
|
15
|
+
*/
|
|
16
|
+
async findBySessionId(agentContext, sessionId) {
|
|
17
|
+
return this.findSingleByQuery(agentContext, { sessionId });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get session by session ID (throws if not found)
|
|
21
|
+
*/
|
|
22
|
+
async getBySessionId(agentContext, sessionId) {
|
|
23
|
+
return this.getSingleByQuery(agentContext, { sessionId });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Find session by thread ID
|
|
27
|
+
*/
|
|
28
|
+
async findByThreadId(agentContext, threadId) {
|
|
29
|
+
return this.findSingleByQuery(agentContext, { threadId });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Find all sessions for a connection
|
|
33
|
+
*/
|
|
34
|
+
async findByConnectionId(agentContext, connectionId) {
|
|
35
|
+
return this.findByQuery(agentContext, { connectionId });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Find session by idempotency key
|
|
39
|
+
*/
|
|
40
|
+
async findByIdempotencyKey(agentContext, idempotencyKey) {
|
|
41
|
+
return (await this.getAll(agentContext)).find((session) => session.idempotencyKey === idempotencyKey) ?? null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
SigningSessionRepository = __decorate([
|
|
45
|
+
injectable(),
|
|
46
|
+
__decorateParam(0, inject(InjectionSymbols.StorageService)),
|
|
47
|
+
__decorateMetadata("design:paramtypes", [Object, EventEmitter])
|
|
48
|
+
], SigningSessionRepository);
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { SigningSessionRepository };
|
|
52
|
+
//# sourceMappingURL=SigningSessionRepository.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigningSessionRepository.mjs","names":[],"sources":["../../src/repository/SigningSessionRepository.ts"],"sourcesContent":["import type { AgentContext, StorageService } from '@credo-ts/core'\n\nimport { EventEmitter, inject, injectable, InjectionSymbols, Repository } from '@credo-ts/core'\n\nimport { SigningSessionRecord } from './SigningSessionRecord'\n\n@injectable()\nexport class SigningSessionRepository extends Repository<SigningSessionRecord> {\n public constructor(\n @inject(InjectionSymbols.StorageService) storageService: StorageService<SigningSessionRecord>,\n eventEmitter: EventEmitter\n ) {\n super(SigningSessionRecord, storageService, eventEmitter)\n }\n\n /**\n * Find session by session ID\n */\n public async findBySessionId(agentContext: AgentContext, sessionId: string): Promise<SigningSessionRecord | null> {\n return this.findSingleByQuery(agentContext, { sessionId })\n }\n\n /**\n * Get session by session ID (throws if not found)\n */\n public async getBySessionId(agentContext: AgentContext, sessionId: string): Promise<SigningSessionRecord> {\n return this.getSingleByQuery(agentContext, { sessionId })\n }\n\n /**\n * Find session by thread ID\n */\n public async findByThreadId(agentContext: AgentContext, threadId: string): Promise<SigningSessionRecord | null> {\n return this.findSingleByQuery(agentContext, { threadId })\n }\n\n /**\n * Find all sessions for a connection\n */\n public async findByConnectionId(agentContext: AgentContext, connectionId: string): Promise<SigningSessionRecord[]> {\n return this.findByQuery(agentContext, { connectionId })\n }\n\n /**\n * Find session by idempotency key\n */\n public async findByIdempotencyKey(\n agentContext: AgentContext,\n idempotencyKey: string\n ): Promise<SigningSessionRecord | null> {\n // Note: idempotencyKey is not a tag, so we need to fetch and filter\n const allSessions = await this.getAll(agentContext)\n return allSessions.find((session) => session.idempotencyKey === idempotencyKey) ?? null\n }\n}\n"],"mappings":";;;;;;;;AAOO,qCAAM,iCAAiC,WAAiC;CAC7E,AAAO,YACL,AAAyC,gBACzC,cACA;AACA,QAAM,sBAAsB,gBAAgB,aAAa;;;;;CAM3D,MAAa,gBAAgB,cAA4B,WAAyD;AAChH,SAAO,KAAK,kBAAkB,cAAc,EAAE,WAAW,CAAC;;;;;CAM5D,MAAa,eAAe,cAA4B,WAAkD;AACxG,SAAO,KAAK,iBAAiB,cAAc,EAAE,WAAW,CAAC;;;;;CAM3D,MAAa,eAAe,cAA4B,UAAwD;AAC9G,SAAO,KAAK,kBAAkB,cAAc,EAAE,UAAU,CAAC;;;;;CAM3D,MAAa,mBAAmB,cAA4B,cAAuD;AACjH,SAAO,KAAK,YAAY,cAAc,EAAE,cAAc,CAAC;;;;;CAMzD,MAAa,qBACX,cACA,gBACsC;AAGtC,UADoB,MAAM,KAAK,OAAO,aAAa,EAChC,MAAM,YAAY,QAAQ,mBAAmB,eAAe,IAAI;;;;CA9CtF,YAAY;oBAGR,OAAO,iBAAiB,eAAe"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CustomSigningSessionTags, DefaultSigningSessionTags, SigningSessionRecord, SigningSessionStorageProps, SigningSessionTags } from "./SigningSessionRecord.mjs";
|
|
2
|
+
import { SigningSessionRepository } from "./SigningSessionRepository.mjs";
|
|
3
|
+
import { CounterRecord, CounterRecordProps, CustomCounterTags, DefaultCounterTags } from "./CounterRecord.mjs";
|
|
4
|
+
import { CounterRepository } from "./CounterRepository.mjs";
|