@xyo-network/event-kit-protocol 0.0.1 → 0.1.1

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.
Files changed (31) hide show
  1. package/LICENSE +310 -0
  2. package/README.md +17 -2
  3. package/dist/neutral/canonicalJson.d.ts +5 -0
  4. package/dist/neutral/canonicalJson.d.ts.map +1 -0
  5. package/dist/neutral/endpointChallenge.d.ts +36 -0
  6. package/dist/neutral/endpointChallenge.d.ts.map +1 -0
  7. package/dist/neutral/handshakeConstruction.d.ts +91 -0
  8. package/dist/neutral/handshakeConstruction.d.ts.map +1 -0
  9. package/dist/neutral/index.d.ts +13 -0
  10. package/dist/neutral/index.d.ts.map +1 -1
  11. package/dist/neutral/index.mjs +1067 -47
  12. package/dist/neutral/index.mjs.map +4 -4
  13. package/dist/neutral/lifecycleSelection.d.ts +105 -0
  14. package/dist/neutral/lifecycleSelection.d.ts.map +1 -0
  15. package/dist/neutral/memoryStatementGrantGraph.d.ts +4 -0
  16. package/dist/neutral/memoryStatementGrantGraph.d.ts.map +1 -1
  17. package/dist/neutral/memoryWakeInbox.d.ts +3 -2
  18. package/dist/neutral/memoryWakeInbox.d.ts.map +1 -1
  19. package/dist/neutral/publisherHandshakeStores.d.ts +97 -0
  20. package/dist/neutral/publisherHandshakeStores.d.ts.map +1 -0
  21. package/dist/neutral/publisherSubscription.d.ts +127 -0
  22. package/dist/neutral/publisherSubscription.d.ts.map +1 -0
  23. package/dist/neutral/statementGraphPorts.d.ts +5 -2
  24. package/dist/neutral/statementGraphPorts.d.ts.map +1 -1
  25. package/dist/neutral/statementGraphWakeGrantAuthorizer.d.ts +4 -4
  26. package/dist/neutral/statementGraphWakeGrantAuthorizer.d.ts.map +1 -1
  27. package/dist/neutral/wakeSubscriptionEncoding.d.ts +12 -0
  28. package/dist/neutral/wakeSubscriptionEncoding.d.ts.map +1 -0
  29. package/dist/neutral/wakeSubscriptionHpke.d.ts +52 -0
  30. package/dist/neutral/wakeSubscriptionHpke.d.ts.map +1 -0
  31. package/package.json +12 -11
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Finalized lifecycle evidence shared by service and subscription revisions.
3
+ * Claim sources are already canonical Statement Graph sources; they are
4
+ * compared exactly and are never inferred from fields inside object bodies.
5
+ */
6
+ export interface LifecycleRevisionEvidence {
7
+ readonly claimedAtBlock: number;
8
+ readonly objectHash: string;
9
+ readonly revision: number;
10
+ readonly revokedAtBlock?: number;
11
+ readonly source: string;
12
+ readonly supersedes?: string;
13
+ }
14
+ export interface PublisherServiceLifecycleRevision extends LifecycleRevisionEvidence {
15
+ readonly encryptionKeys: readonly string[];
16
+ readonly eventKinds: readonly string[];
17
+ readonly expiresAtBlock?: number;
18
+ readonly preferredEncryptionKey: string;
19
+ readonly serviceId: string;
20
+ readonly validFromBlock: number;
21
+ }
22
+ export interface PublisherEncryptionKeyLifecycle {
23
+ readonly claimedAtBlock: number;
24
+ readonly expiresAtBlock?: number;
25
+ readonly keyId: string;
26
+ readonly objectHash: string;
27
+ readonly revokedAtBlock?: number;
28
+ readonly source: string;
29
+ readonly validFromBlock: number;
30
+ }
31
+ export interface WakeSubscriptionLifecycleRevision extends LifecycleRevisionEvidence {
32
+ readonly expiresAtBlock: number;
33
+ readonly subscriptionId: string;
34
+ }
35
+ export interface PublisherAcceptanceLifecycle {
36
+ readonly acceptanceBlock: number;
37
+ readonly objectHash: string;
38
+ readonly revokedAtBlock?: number;
39
+ readonly source: string;
40
+ readonly subscription: string;
41
+ }
42
+ export interface PublisherServiceSelectionInput {
43
+ readonly eventKind: string;
44
+ readonly finalizedHead: number;
45
+ readonly publisherSource: string;
46
+ readonly serviceId?: string;
47
+ readonly services: readonly PublisherServiceLifecycleRevision[];
48
+ }
49
+ export interface PublisherServiceSelectionSuccess {
50
+ readonly ok: true;
51
+ readonly service: PublisherServiceLifecycleRevision;
52
+ }
53
+ export type PublisherServiceSelectionFailureReason = 'ambiguous-service' | 'invalid-revision-chain' | 'service-not-found';
54
+ export interface PublisherServiceSelectionFailure {
55
+ readonly ok: false;
56
+ readonly reason: PublisherServiceSelectionFailureReason;
57
+ }
58
+ export type PublisherServiceSelection = PublisherServiceSelectionFailure | PublisherServiceSelectionSuccess;
59
+ export interface PreferredEncryptionKeyInput {
60
+ readonly finalizedHead: number;
61
+ readonly keys: readonly PublisherEncryptionKeyLifecycle[];
62
+ readonly service: PublisherServiceLifecycleRevision;
63
+ }
64
+ export interface PreferredEncryptionKeySuccess {
65
+ readonly key: PublisherEncryptionKeyLifecycle;
66
+ readonly ok: true;
67
+ }
68
+ export type PreferredEncryptionKeyFailureReason = 'ambiguous-key' | 'preferred-key-inactive' | 'preferred-key-not-found' | 'preferred-key-not-referenced';
69
+ export interface PreferredEncryptionKeyFailure {
70
+ readonly ok: false;
71
+ readonly reason: PreferredEncryptionKeyFailureReason;
72
+ }
73
+ export type PreferredEncryptionKeyResolution = PreferredEncryptionKeyFailure | PreferredEncryptionKeySuccess;
74
+ export interface SubscriptionActivationInput {
75
+ readonly acceptances: readonly PublisherAcceptanceLifecycle[];
76
+ readonly finalizedHead: number;
77
+ readonly publisherSource: string;
78
+ readonly subscriberSource: string;
79
+ readonly subscriptionId: string;
80
+ readonly subscriptions: readonly WakeSubscriptionLifecycleRevision[];
81
+ }
82
+ export interface SubscriptionActivationSuccess {
83
+ readonly acceptance: PublisherAcceptanceLifecycle;
84
+ readonly activeFromBlock: number;
85
+ readonly ok: true;
86
+ readonly pendingReplacement: boolean;
87
+ readonly subscription: WakeSubscriptionLifecycleRevision;
88
+ }
89
+ export type SubscriptionActivationFailureReason = 'ambiguous-acceptance' | 'invalid-revision-chain' | 'subscription-inactive' | 'subscription-not-found' | 'subscription-pending';
90
+ export interface SubscriptionActivationFailure {
91
+ readonly ok: false;
92
+ readonly reason: SubscriptionActivationFailureReason;
93
+ }
94
+ export type SubscriptionActivation = SubscriptionActivationFailure | SubscriptionActivationSuccess;
95
+ /** Selects exactly one active service; response order never breaks ambiguity. */
96
+ export declare function selectPublisherService(input: PublisherServiceSelectionInput): PublisherServiceSelection;
97
+ /** Resolves the exact preferred descriptor; another active key is never a fallback. */
98
+ export declare function resolvePreferredEncryptionKey(input: PreferredEncryptionKeyInput): PreferredEncryptionKeyResolution;
99
+ /**
100
+ * Selects the highest revision whose acceptance cutover has arrived. A newer
101
+ * pending revision leaves the prior activation in place; after cutover, an
102
+ * inactive replacement never falls back to an older accepted revision.
103
+ */
104
+ export declare function selectSubscriptionActivation(input: SubscriptionActivationInput): SubscriptionActivation;
105
+ //# sourceMappingURL=lifecycleSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycleSelection.d.ts","sourceRoot":"","sources":["../../src/lifecycleSelection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,iCAAkC,SAAQ,yBAAyB;IAClF,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAChC;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAA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MAAM,mCAAmC,GACzC,sBAAsB,GACtB,wBAAwB,GACxB,uBAAuB,GACvB,wBAAwB,GACxB,sBAAsB,CAAA;AAE5B,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAA;IAClB,QAAQ,CAAC,MAAM,EAAE,mCAAmC,CAAA;CACrD;AAED,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,6BAA6B,CAAA;AAwIlG,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,8BAA8B,GAAG,yBAAyB,CAmBvG;AAED,uFAAuF;AACvF,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,2BAA2B,GACjC,gCAAgC,CAuBlC;AA8CD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,GAAG,sBAAsB,CA+BvG"}
@@ -12,6 +12,8 @@ export interface MemoryStatementGrantGraph extends StatementGraphGrantReadModel
12
12
  grant: WakeGrantObject;
13
13
  objectHash: string;
14
14
  source: string;
15
+ /** Defaults to `grant.publisher`. */
16
+ subject?: string;
15
17
  }) => void;
16
18
  /**
17
19
  * Claim a revocation object negating `grant`. There is no revoke verb in v2 —
@@ -23,6 +25,8 @@ export interface MemoryStatementGrantGraph extends StatementGraphGrantReadModel
23
25
  grantObjectHash: string;
24
26
  objectHash: string;
25
27
  source: string;
28
+ /** Defaults to the subject of the referenced grant Claim. */
29
+ subject?: string;
26
30
  }) => void;
27
31
  setHead: (block: number) => void;
28
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"memoryStatementGrantGraph.d.ts","sourceRoot":"","sources":["../../src/memoryStatementGrantGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,gCAAgC,CAAA;AAO1F,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,0BAA0B,CAAA;AAEjC,MAAM,WAAW,yBAA0B,SAAQ,4BAA4B;IAC7E;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE;QACb,KAAK,EAAE,MAAM,CAAA;QACb,kDAAkD;QAClD,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,eAAe,CAAA;QACtB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;KACf,KAAK,IAAI,CAAA;IACV;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,eAAe,EAAE,MAAM,CAAA;QACvB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;KACf,KAAK,IAAI,CAAA;IACV,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,SAAI,GAAG,yBAAyB,CAmG1F"}
1
+ {"version":3,"file":"memoryStatementGrantGraph.d.ts","sourceRoot":"","sources":["../../src/memoryStatementGrantGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,gCAAgC,CAAA;AAO1F,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,0BAA0B,CAAA;AAEjC,MAAM,WAAW,yBAA0B,SAAQ,4BAA4B;IAC7E;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE;QACb,KAAK,EAAE,MAAM,CAAA;QACb,kDAAkD;QAClD,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,eAAe,CAAA;QACtB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;QACd,qCAAqC;QACrC,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,KAAK,IAAI,CAAA;IACV;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,eAAe,EAAE,MAAM,CAAA;QACvB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;QACd,6DAA6D;QAC7D,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,KAAK,IAAI,CAAA;IACV,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,SAAI,GAAG,yBAAyB,CAqH1F"}
@@ -24,8 +24,9 @@ export interface MemoryWakeInbox extends AtomicWakeInbox {
24
24
  *
25
25
  * Writes are ordered so a failing sink cannot consume `jti` or `wakeId` without
26
26
  * a recoverable receipt. It is **not** durable: process death between enqueue
27
- * and record commit redelivers the wake, and no state survives restart. Gate 5
28
- * requires a durable adapter; this is local evidence only.
27
+ * and record commit redelivers the wake, and no state survives restart. The
28
+ * historical core implementation-plan Gate 5 requires a durable adapter; this
29
+ * is local evidence only.
29
30
  */
30
31
  export declare function createMemoryWakeInbox(options?: MemoryWakeInboxOptions): MemoryWakeInbox;
31
32
  //# sourceMappingURL=memoryWakeInbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memoryWakeInbox.d.ts","sourceRoot":"","sources":["../../src/memoryWakeInbox.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC/D,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;CACnC;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC;AAeD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAiG3F"}
1
+ {"version":3,"file":"memoryWakeInbox.d.ts","sourceRoot":"","sources":["../../src/memoryWakeInbox.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC/D,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;CACnC;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC;AAeD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAiG3F"}
@@ -0,0 +1,97 @@
1
+ import type { EndpointChallenge, HandshakeId, Hash, NormalizedAddress } from '@xyo-network/event-kit-schemas';
2
+ import type { WakeSubscriptionPrivateKey } from './wakeSubscriptionHpke.ts';
3
+ export interface PublisherEncryptionKeyLookup {
4
+ /** Canonical descriptor object hash named by the subscription. */
5
+ readonly encryptionKey: Hash;
6
+ /** Stable key identifier named by both descriptor and subscription. */
7
+ readonly keyId: HandshakeId;
8
+ /** Exact publisher whose dedicated key is requested. */
9
+ readonly publisher: NormalizedAddress;
10
+ }
11
+ /**
12
+ * Publisher key-custody boundary. Implementations resolve one exact descriptor
13
+ * identity and MUST NOT try another key after a miss or decrypt failure.
14
+ */
15
+ export interface PublisherEncryptionKeyStore {
16
+ getPrivateKey: (lookup: PublisherEncryptionKeyLookup) => Promise<WakeSubscriptionPrivateKey | undefined>;
17
+ }
18
+ export type PublisherEndpointChallengeState = 'attempted' | 'issued' | 'verified';
19
+ export interface PublisherEndpointChallengeRecord {
20
+ readonly challenge: EndpointChallenge;
21
+ readonly challengeHash: Hash;
22
+ readonly responseHash?: Hash;
23
+ readonly state: PublisherEndpointChallengeState;
24
+ }
25
+ export interface IssuePublisherEndpointChallengeInput {
26
+ readonly challenge: EndpointChallenge;
27
+ readonly challengeHash: Hash;
28
+ }
29
+ export type IssuePublisherEndpointChallengeResult = {
30
+ readonly kind: 'collision';
31
+ } | {
32
+ readonly kind: 'duplicate';
33
+ readonly record: PublisherEndpointChallengeRecord;
34
+ } | {
35
+ readonly kind: 'issued';
36
+ readonly record: PublisherEndpointChallengeRecord;
37
+ };
38
+ export interface BeginPublisherEndpointChallengeAttemptInput {
39
+ readonly challengeHash: Hash;
40
+ readonly nowSeconds: number;
41
+ }
42
+ export type BeginPublisherEndpointChallengeAttemptResult = {
43
+ readonly kind: 'already-attempted';
44
+ readonly record: PublisherEndpointChallengeRecord;
45
+ } | {
46
+ readonly kind: 'expired';
47
+ readonly record: PublisherEndpointChallengeRecord;
48
+ } | {
49
+ readonly kind: 'missing';
50
+ } | {
51
+ readonly kind: 'started';
52
+ readonly record: PublisherEndpointChallengeRecord;
53
+ } | {
54
+ readonly kind: 'verified';
55
+ readonly record: PublisherEndpointChallengeRecord;
56
+ };
57
+ export interface CompletePublisherEndpointChallengeInput {
58
+ readonly challengeHash: Hash;
59
+ readonly nowSeconds: number;
60
+ readonly responseHash: Hash;
61
+ }
62
+ export type CompletePublisherEndpointChallengeResult = {
63
+ readonly kind: 'collision';
64
+ readonly record: PublisherEndpointChallengeRecord;
65
+ } | {
66
+ readonly kind: 'duplicate';
67
+ readonly record: PublisherEndpointChallengeRecord;
68
+ } | {
69
+ readonly kind: 'expired';
70
+ readonly record: PublisherEndpointChallengeRecord;
71
+ } | {
72
+ readonly kind: 'missing';
73
+ } | {
74
+ readonly kind: 'not-attempted';
75
+ readonly record: PublisherEndpointChallengeRecord;
76
+ } | {
77
+ readonly kind: 'verified';
78
+ readonly record: PublisherEndpointChallengeRecord;
79
+ };
80
+ /**
81
+ * Durable, linearizable endpoint-challenge boundary.
82
+ *
83
+ * `issue` binds the exact strict challenge body to its canonical hash.
84
+ * `beginAttempt` atomically grants at most one outbound attempt while the
85
+ * challenge is live; callers never resend an already-attempted challenge.
86
+ * `completeVerified` atomically records one exact response hash and rechecks
87
+ * the exclusive expiry window for a new decision. Once verified, an exact
88
+ * retry returns `duplicate` even after expiry so crash recovery can resume the
89
+ * already-authorized acceptance; a different response is a `collision`.
90
+ */
91
+ export interface PublisherEndpointChallengeStore {
92
+ beginAttempt: (input: BeginPublisherEndpointChallengeAttemptInput) => Promise<BeginPublisherEndpointChallengeAttemptResult>;
93
+ completeVerified: (input: CompletePublisherEndpointChallengeInput) => Promise<CompletePublisherEndpointChallengeResult>;
94
+ get: (challengeHash: Hash) => Promise<PublisherEndpointChallengeRecord | undefined>;
95
+ issue: (input: IssuePublisherEndpointChallengeInput) => Promise<IssuePublisherEndpointChallengeResult>;
96
+ }
97
+ //# sourceMappingURL=publisherHandshakeStores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherHandshakeStores.d.ts","sourceRoot":"","sources":["../../src/publisherHandshakeStores.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAA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;;;;;;;;;;GAUG;AACH,MAAM,WAAW,+BAA+B;IAC9C,YAAY,EAAE,CACZ,KAAK,EAAE,2CAA2C,KAC/C,OAAO,CAAC,4CAA4C,CAAC,CAAA;IAC1D,gBAAgB,EAAE,CAChB,KAAK,EAAE,uCAAuC,KAC3C,OAAO,CAAC,wCAAwC,CAAC,CAAA;IACtD,GAAG,EAAE,CAAC,aAAa,EAAE,IAAI,KAAK,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAAA;IACnF,KAAK,EAAE,CAAC,KAAK,EAAE,oCAAoC,KAAK,OAAO,CAAC,qCAAqC,CAAC,CAAA;CACvG"}
@@ -0,0 +1,127 @@
1
+ import type { ChainId, EncryptedWakeSubscription, EndpointChallenge, EndpointChallengeResponse, Hash, NormalizedAddress, PublisherEncryptionKey, PublisherService, WakeGrantObject, WakeSubscriptionAcceptance, WakeSubscriptionPlaintext } from '@xyo-network/event-kit-schemas';
2
+ import type { HashedHandshakeObject } from './handshakeConstruction.ts';
3
+ import type { BeginPublisherEndpointChallengeAttemptResult, PublisherEncryptionKeyStore, PublisherEndpointChallengeStore } from './publisherHandshakeStores.ts';
4
+ /**
5
+ * Finalized, publisher-scoped read-model output for one exact subscriber
6
+ * fan-out Claim. The caller remains responsible for finalized Claim authority,
7
+ * service/key selection, lifecycle revocations, and revalidation before
8
+ * publishing acceptance; this boundary independently recomputes immutable
9
+ * body hashes and enforces publisher-private constraints.
10
+ */
11
+ export interface PublisherSubscriptionCandidate {
12
+ readonly chainId: ChainId;
13
+ readonly finalizedHead: number;
14
+ readonly grant: HashedHandshakeObject<WakeGrantObject>;
15
+ readonly key: HashedHandshakeObject<PublisherEncryptionKey>;
16
+ readonly keys: PublisherEncryptionKeyStore;
17
+ readonly publisher: NormalizedAddress;
18
+ readonly service: HashedHandshakeObject<PublisherService>;
19
+ /** Finalized fan-out Claim source; this is the subscriber identity used in HPKE AAD. */
20
+ readonly subscriber: NormalizedAddress;
21
+ readonly subscription: HashedHandshakeObject<EncryptedWakeSubscription>;
22
+ /** Finalized block containing the exact service/grant/subscription fan-out Claim. */
23
+ readonly tupleBlock: number;
24
+ /** All object hashes in that one fan-out Claim. */
25
+ readonly tupleObjectHashes: readonly Hash[];
26
+ /** Publisher subject under which the finalized fan-out Claim was discovered. */
27
+ readonly tupleSubject: NormalizedAddress;
28
+ }
29
+ export type PublisherSubscriptionValidationFailureReason = 'body-hash-mismatch' | 'decryption-failed' | 'grant-binding-invalid' | 'grant-scope-invalid' | 'key-binding-invalid' | 'key-inactive' | 'key-store-unavailable' | 'malformed-candidate' | 'private-key-not-found' | 'service-inactive' | 'service-limit-invalid' | 'subscription-binding-invalid' | 'subscription-expiry-invalid' | 'tuple-binding-invalid';
30
+ export interface PublisherSubscriptionValidationFailure {
31
+ readonly ok: false;
32
+ readonly reason: PublisherSubscriptionValidationFailureReason;
33
+ }
34
+ export interface PublisherEndpointChallengeContext {
35
+ readonly chainId: ChainId;
36
+ readonly encryptionKey: Hash;
37
+ readonly eventKind: EncryptedWakeSubscription['eventKind'];
38
+ readonly grant: Hash;
39
+ readonly keyId: EncryptedWakeSubscription['keyId'];
40
+ readonly publisher: NormalizedAddress;
41
+ readonly service: Hash;
42
+ readonly subscriber: NormalizedAddress;
43
+ readonly subscription: Hash;
44
+ }
45
+ export interface ValidatedPublisherSubscription {
46
+ readonly context: PublisherEndpointChallengeContext;
47
+ readonly finalizedHead: number;
48
+ readonly grant: HashedHandshakeObject<WakeGrantObject>;
49
+ readonly key: HashedHandshakeObject<PublisherEncryptionKey>;
50
+ readonly ok: true;
51
+ readonly plaintext: WakeSubscriptionPlaintext;
52
+ readonly service: HashedHandshakeObject<PublisherService>;
53
+ readonly subscription: HashedHandshakeObject<EncryptedWakeSubscription>;
54
+ readonly tupleBlock: number;
55
+ }
56
+ export type PublisherSubscriptionValidation = PublisherSubscriptionValidationFailure | ValidatedPublisherSubscription;
57
+ export interface IssuePublisherEndpointChallengeApiInput {
58
+ readonly issuedAt: number;
59
+ readonly lifetimeSeconds?: number;
60
+ readonly store: PublisherEndpointChallengeStore;
61
+ readonly subscription: ValidatedPublisherSubscription;
62
+ }
63
+ export type IssuePublisherEndpointChallengeApiResult = {
64
+ readonly ok: false;
65
+ readonly reason: 'challenge-collision' | 'challenge-store-invalid' | 'challenge-store-unavailable';
66
+ } | {
67
+ readonly challenge: EndpointChallenge;
68
+ readonly challengeHash: Hash;
69
+ readonly disposition: 'duplicate' | 'issued';
70
+ readonly ok: true;
71
+ };
72
+ export interface BeginPublisherEndpointChallengeAttemptApiInput {
73
+ readonly challengeHash: Hash;
74
+ readonly nowSeconds: number;
75
+ readonly store: PublisherEndpointChallengeStore;
76
+ }
77
+ export type BeginPublisherEndpointChallengeAttemptApiResult = BeginPublisherEndpointChallengeAttemptResult | {
78
+ readonly kind: 'store-invalid' | 'store-unavailable';
79
+ };
80
+ export interface CompletePublisherEndpointChallengeApiInput {
81
+ readonly challenge: EndpointChallenge;
82
+ /**
83
+ * Publisher-local Unix second for the one-time proof-verification and
84
+ * acceptance decision. Finalized replay cannot and does not re-evaluate this
85
+ * value from XL1 block time.
86
+ */
87
+ readonly nowSeconds: number;
88
+ readonly response: EndpointChallengeResponse;
89
+ readonly store: PublisherEndpointChallengeStore;
90
+ readonly subscription: ValidatedPublisherSubscription;
91
+ }
92
+ export type CompletePublisherEndpointChallengeFailureReason = 'challenge-context-invalid' | 'challenge-expired' | 'challenge-not-attempted' | 'challenge-not-found' | 'challenge-response-collision' | 'challenge-store-invalid' | 'challenge-store-unavailable' | 'invalid-proof';
93
+ export interface CompletePublisherEndpointChallengeFailure {
94
+ readonly ok: false;
95
+ readonly reason: CompletePublisherEndpointChallengeFailureReason;
96
+ }
97
+ export interface CompletePublisherEndpointChallengeSuccess {
98
+ readonly acceptance: WakeSubscriptionAcceptance;
99
+ readonly acceptanceHash: Hash;
100
+ readonly challengeHash: Hash;
101
+ readonly disposition: 'duplicate' | 'verified';
102
+ readonly ok: true;
103
+ readonly responseHash: Hash;
104
+ }
105
+ export type CompletePublisherEndpointChallengeApiResult = CompletePublisherEndpointChallengeFailure | CompletePublisherEndpointChallengeSuccess;
106
+ /**
107
+ * Validate one read-model-qualified finalized public tuple, resolve exactly
108
+ * one dedicated private key, decrypt once, and enforce the private grant and
109
+ * filter scope. No algorithm, key, service, or AAD fallback is attempted after
110
+ * failure. Callers must resolve the finalized lifecycle again after challenge
111
+ * and before publishing acceptance.
112
+ */
113
+ export declare function validateAndDecryptPublisherSubscription(candidate: PublisherSubscriptionCandidate): Promise<PublisherSubscriptionValidation>;
114
+ /** Exact challenge tuple comparison; every context field is mandatory. */
115
+ export declare function endpointChallengeMatchesPublisherContext(challenge: EndpointChallenge, context: PublisherEndpointChallengeContext): boolean;
116
+ /** Create and durably issue a fresh challenge for one validated tuple. */
117
+ export declare function issuePublisherEndpointChallenge(input: IssuePublisherEndpointChallengeApiInput): Promise<IssuePublisherEndpointChallengeApiResult>;
118
+ /** Claim the one permitted outbound challenge attempt before any HTTP call. */
119
+ export declare function beginPublisherEndpointChallengeAttempt(input: BeginPublisherEndpointChallengeAttemptApiInput): Promise<BeginPublisherEndpointChallengeAttemptApiResult>;
120
+ /**
121
+ * Verify exact tuple context and proof in its Unix-time window, atomically
122
+ * consume the durable challenge, then construct the exact publisher acceptance
123
+ * object. Publishing that object attests to this in-window decision; later
124
+ * finalization does not re-run a wall-clock check.
125
+ */
126
+ export declare function completePublisherEndpointChallenge(input: CompletePublisherEndpointChallengeApiInput): Promise<CompletePublisherEndpointChallengeApiResult>;
127
+ //# sourceMappingURL=publisherSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherSubscription.d.ts","sourceRoot":"","sources":["../../src/publisherSubscription.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,IAAI,EACJ,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,yB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,KAAK,CAAA;IAClB,QAAQ,CAAC,MAAM,EAAE,+CAA+C,CAAA;CACjE;AAED,MAAM,WAAW,yCAAyC;IACxD,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAA;IAC/C,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAA;IAC7B,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,CAAA;IAC9C,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;IACjB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAA;CAC5B;AAED,MAAM,MAAM,2CAA2C,GACjD,yCAAyC,GACzC,yCAAyC,CAAA;AA6M/C;;;;;;GAMG;AACH,wBAAsB,uCAAuC,CAC3D,SAAS,EAAE,8BAA8B,GACxC,OAAO,CAAC,+BAA+B,CAAC,CAgB1C;AAED,0EAA0E;AAC1E,wBAAgB,wCAAwC,CACtD,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAYT;AAcD,0EAA0E;AAC1E,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,wCAAwC,CAAC,CAuBnD;AAED,+EAA+E;AAC/E,wBAAsB,sCAAsC,CAC1D,KAAK,EAAE,8CAA8C,GACpD,OAAO,CAAC,+CAA+C,CAAC,CAuB1D;AAsCD;;;;;GAKG;AACH,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,0CAA0C,GAChD,OAAO,CAAC,2CAA2C,CAAC,CAwDtD"}
@@ -7,7 +7,7 @@
7
7
  * preserves the fields below. Do not claim direct structural assignment.
8
8
  */
9
9
  /**
10
- * One materialized `(source, objectHash)` claim.
10
+ * One materialized `(source, subject, objectHash)` claim.
11
11
  *
12
12
  * `firstBlock`/`firstEventHash` are frozen at materialization; a redundant
13
13
  * claim advances only `lastBlock`. Authorization reads `firstBlock`, so
@@ -21,6 +21,7 @@ export interface StatementGrantClaim {
21
21
  readonly lastBlock: number;
22
22
  readonly objectHash: string;
23
23
  readonly source: string;
24
+ readonly subject: string;
24
25
  }
25
26
  export interface StatementGrantObject {
26
27
  readonly assurance: string;
@@ -32,9 +33,11 @@ export interface StatementGrantObject {
32
33
  export interface StatementGrantClaimQuery {
33
34
  readonly declaredObjectSchemaPrefix?: string;
34
35
  readonly objectHash?: string;
36
+ /** Event Kit publisher address the Claim is about. */
37
+ readonly subject?: string;
35
38
  }
36
39
  export interface StatementGraphGrantReadModel {
37
- /** Claims made **by** `source`. v2 has no `target`, so there is no incoming direction. */
40
+ /** Claims made **by** `source`, optionally narrowed by their aboutness subject. */
38
41
  claims: (source: string, query?: StatementGrantClaimQuery) => Promise<readonly StatementGrantClaim[]>;
39
42
  head: () => Promise<number>;
40
43
  object: (objectHash: string) => Promise<StatementGrantObject | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"statementGraphPorts.d.ts","sourceRoot":"","sources":["../../src/statementGraphPorts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC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AG,IAAI,CAAA;CAC1D;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAA;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,4BAA4B;IAC3C,mFAAmF;IACnF,MAAM,EAAE,CACN,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,wBAAwB,KAC7B,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAA;IAC5C,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3B,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;CAC1E"}
@@ -7,11 +7,11 @@ export interface StatementGraphWakeGrantAuthorizerOptions {
7
7
  * Adapts a canonical Statement Graph v2 read model to the evidence-bearing
8
8
  * D-002 grant authorization port. Each decision is bound to one stable head.
9
9
  *
10
- * v2 is append-only with no `target` and no lifecycle `state`, so this layer
11
- * owns two things the protocol used to:
10
+ * v2 is append-only with no lifecycle `state`, so this layer owns two things
11
+ * the protocol used to:
12
12
  *
13
- * - **Aboutness.** The publisher a grant enables is read from the grant
14
- * object's `publisher` param, not from a claim edge.
13
+ * - **Aboutness.** The requested publisher must match both the Claim's
14
+ * `subject` and the grant object's `publisher` field.
15
15
  * - **Negation.** A grant is disabled by a further claim, by the *same pinned
16
16
  * controller*, of a revocation object referencing that grant's hash.
17
17
  * Revocations from any other source are ignored.
@@ -1 +1 @@
1
- {"version":3,"file":"statementGraphWakeGrantAuthorizer.d.ts","sourceRoot":"","sources":["../../src/statementGraphWakeGrantAuthorizer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAGV,mBAAmB,EAEpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,0BAA0B,CAAA;AAEjC,MAAM,WAAW,wCAAwC;IACvD,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAA;CAC9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,wCAAwC,GAChD,mBAAmB,CA4CrB"}
1
+ {"version":3,"file":"statementGraphWakeGrantAuthorizer.d.ts","sourceRoot":"","sources":["../../src/statementGraphWakeGrantAuthorizer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAGV,mBAAmB,EAEpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,0BAA0B,CAAA;AAEjC,MAAM,WAAW,wCAAwC;IACvD,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAA;CAC9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,wCAAwC,GAChD,mBAAmB,CA+CrB"}
@@ -0,0 +1,12 @@
1
+ import type { EncryptedWakeSubscription, NormalizedAddress, WakeSubscriptionCleartext, WakeSubscriptionPlaintext } from '@xyo-network/event-kit-schemas';
2
+ /**
3
+ * Canonical HPKE additional authenticated data. `subscriber` is the finalized
4
+ * Statement Graph claim source and therefore cannot be inferred from the
5
+ * subscription body itself.
6
+ */
7
+ export declare function wakeSubscriptionAadBytes(subscription: WakeSubscriptionCleartext | EncryptedWakeSubscription, subscriber: NormalizedAddress): Uint8Array;
8
+ /** Validate and encode the encrypted subscription plaintext as canonical JCS UTF-8. */
9
+ export declare function wakeSubscriptionPlaintextBytes(plaintext: WakeSubscriptionPlaintext): Uint8Array;
10
+ /** Decode only strict UTF-8 whose bytes are already the canonical plaintext encoding. */
11
+ export declare function wakeSubscriptionPlaintextFromBytes(encoded: Uint8Array): WakeSubscriptionPlaintext;
12
+ //# sourceMappingURL=wakeSubscriptionEncoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wakeSubscriptionEncoding.d.ts","sourceRoot":"","sources":["../../src/wakeSubscriptionEncoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AA0BvC;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,yBAAyB,GAAG,yBAAyB,EACnE,UAAU,EAAE,iBAAiB,GAC5B,UAAU,CAsBZ;AAED,uFAAuF;AACvF,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,yBAAyB,GAAG,UAAU,CAO/F;AAED,yFAAyF;AACzF,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,UAAU,GAAG,yBAAyB,CAUjG"}
@@ -0,0 +1,52 @@
1
+ import type { Base64Url32Bytes, EncryptedWakeSubscription, HandshakeId, Hash, NormalizedAddress, WakeSubscriptionCleartext, WakeSubscriptionPlaintext } from '@xyo-network/event-kit-schemas';
2
+ export interface WakeSubscriptionEncryptionKeyPair {
3
+ /** Raw 32-byte X25519 private key encoded as canonical unpadded base64url. */
4
+ privateKey: Base64Url32Bytes;
5
+ /** Raw 32-byte X25519 public key encoded as canonical unpadded base64url. */
6
+ publicKey: Base64Url32Bytes;
7
+ }
8
+ export interface WakeSubscriptionPublicKey {
9
+ /** Canonical hash of the publisher-authored key descriptor. */
10
+ encryptionKey: Hash;
11
+ /** Stable key identifier copied from that descriptor. */
12
+ keyId: HandshakeId;
13
+ /** Raw X25519 public key from that descriptor. */
14
+ publicKey: Base64Url32Bytes;
15
+ }
16
+ export interface WakeSubscriptionPrivateKey {
17
+ /** Canonical hash of the publisher-authored key descriptor. */
18
+ encryptionKey: Hash;
19
+ /** Stable key identifier copied from that descriptor. */
20
+ keyId: HandshakeId;
21
+ /** Raw X25519 private key held off-chain by the publisher. */
22
+ privateKey: Base64Url32Bytes;
23
+ }
24
+ export interface EncryptWakeSubscriptionInput {
25
+ plaintext: WakeSubscriptionPlaintext;
26
+ publisherKey: WakeSubscriptionPublicKey;
27
+ subscriber: NormalizedAddress;
28
+ subscription: WakeSubscriptionCleartext;
29
+ }
30
+ export interface DecryptWakeSubscriptionInput {
31
+ publisherKey: WakeSubscriptionPrivateKey;
32
+ subscriber: NormalizedAddress;
33
+ subscription: EncryptedWakeSubscription;
34
+ }
35
+ /** Deliberately carries no low-level cause that could become a decryption oracle. */
36
+ export declare class WakeSubscriptionDecryptionError extends Error {
37
+ readonly name = "WakeSubscriptionDecryptionError";
38
+ constructor();
39
+ }
40
+ /** Generate a dedicated X25519 encryption key; never reuse the publisher signing key. */
41
+ export declare function generateWakeSubscriptionEncryptionKeyPair(): Promise<WakeSubscriptionEncryptionKeyPair>;
42
+ /**
43
+ * One-shot RFC 9180 Base-mode encryption with X25519/HKDF-SHA256/AES-128-GCM.
44
+ * Ephemeral key material is always generated inside the HPKE implementation.
45
+ */
46
+ export declare function encryptWakeSubscription(input: EncryptWakeSubscriptionInput): Promise<EncryptedWakeSubscription>;
47
+ /**
48
+ * One-shot decryption. All malformed inputs, key mismatches, authentication
49
+ * failures, and noncanonical plaintexts collapse to the same public error.
50
+ */
51
+ export declare function decryptWakeSubscription(input: DecryptWakeSubscriptionInput): Promise<WakeSubscriptionPlaintext>;
52
+ //# sourceMappingURL=wakeSubscriptionHpke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wakeSubscriptionHpke.d.ts","sourceRoot":"","sources":["../../src/wakeSubscriptionHpke.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EACzB,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AA0CvC,MAAM,WAAW,iCAAiC;IAChD,8EAA8E;IAC9E,UAAU,EAAE,gBAAgB,CAAA;IAC5B,6EAA6E;IAC7E,SAAS,EAAE,gBAAgB,CAAA;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,+DAA+D;IAC/D,aAAa,EAAE,IAAI,CAAA;IACnB,yDAAyD;IACzD,KAAK,EAAE,WAAW,CAAA;IAClB,kDAAkD;IAClD,SAAS,EAAE,gBAAgB,CAAA;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,aAAa,EAAE,IAAI,CAAA;IACnB,yDAAyD;IACzD,KAAK,EAAE,WAAW,CAAA;IAClB,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,CAAA;CAC7B;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,yBAAyB,CAAA;IACpC,YAAY,EAAE,yBAAyB,CAAA;IACvC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,YAAY,EAAE,yBAAyB,CAAA;CACxC;AAED,MAAM,WAAW,4BAA4B;IAC3C,YAAY,EAAE,0BAA0B,CAAA;IACxC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,YAAY,EAAE,yBAAyB,CAAA;CACxC;AAED,qFAAqF;AACrF,qBAAa,+BAAgC,SAAQ,KAAK;IACxD,SAAkB,IAAI,qCAAoC;;CAK3D;AAwBD,yFAAyF;AACzF,wBAAsB,yCAAyC,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAW5G;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CA0BpC;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAwBpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/event-kit-protocol",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "Wallet-JWT Payload verification and admission contracts for XL1 Event Kit",
5
5
  "keywords": [
6
6
  "xyo",
@@ -17,7 +17,7 @@
17
17
  "url": "git+https://github.com/XYOracleNetwork/event-kit.git",
18
18
  "directory": "packages/protocol"
19
19
  },
20
- "license": "UNLICENSED",
20
+ "license": "LGPL-3.0-only",
21
21
  "sideEffects": false,
22
22
  "type": "module",
23
23
  "exports": {
@@ -33,27 +33,28 @@
33
33
  "README.md"
34
34
  ],
35
35
  "dependencies": {
36
- "@xyo-network/event-kit-schemas": "~0.0.1"
36
+ "@hpke/core": "~1.9.0",
37
+ "@xyo-network/event-kit-schemas": "~0.1.1"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@ariestools/sdk": "~8.1.9",
40
- "@ariestools/toolchain": "~9.1.0",
41
- "@ariestools/tsconfig": "~9.1.0",
41
+ "@ariestools/toolchain": "~9.1.2",
42
+ "@ariestools/tsconfig": "~9.1.2",
42
43
  "@opentelemetry/api": "~1.9.1",
43
- "@xyo-network/sdk": "~7.2.3",
44
- "@xyo-network/sdk-protocol": "~7.2.4",
45
- "eslint": "~10.8.1",
44
+ "@xyo-network/sdk": "~7.3.1",
45
+ "@xyo-network/sdk-protocol": "~7.3.3",
46
+ "eslint": "~10.9.1",
46
47
  "eslint-import-resolver-typescript": "~4.4.5",
47
48
  "typescript": "~6.0.3",
48
- "vite": "~8.2.1",
49
+ "vite": "~8.2.2",
49
50
  "vitest": "~4.1.11",
50
51
  "zod": "~4.4.3"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "@ariestools/sdk": "^8.1",
54
55
  "@opentelemetry/api": "^1.9",
55
- "@xyo-network/sdk": "^7.2",
56
- "@xyo-network/sdk-protocol": "^7.2",
56
+ "@xyo-network/sdk": "^7.3",
57
+ "@xyo-network/sdk-protocol": "^7.3",
57
58
  "zod": "^4.4"
58
59
  },
59
60
  "engines": {