@privos_ai/app-server 0.1.0 → 0.3.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 (51) hide show
  1. package/README.md +189 -0
  2. package/dist/app-descriptor.d.ts +17 -0
  3. package/dist/app-descriptor.d.ts.map +1 -1
  4. package/dist/app-descriptor.js +38 -0
  5. package/dist/app-descriptor.js.map +1 -1
  6. package/dist/context/tool-call-context.d.ts +3 -0
  7. package/dist/context/tool-call-context.d.ts.map +1 -1
  8. package/dist/direct/express-router.d.ts +5 -0
  9. package/dist/direct/express-router.d.ts.map +1 -1
  10. package/dist/direct/express-router.js +104 -12
  11. package/dist/direct/express-router.js.map +1 -1
  12. package/dist/direct/http-ingress.d.ts.map +1 -1
  13. package/dist/direct/http-ingress.js +10 -0
  14. package/dist/direct/http-ingress.js.map +1 -1
  15. package/dist/index.d.ts +10 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +5 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/manifest-lint-cli.d.ts +3 -0
  20. package/dist/manifest-lint-cli.d.ts.map +1 -0
  21. package/dist/manifest-lint-cli.js +18 -0
  22. package/dist/manifest-lint-cli.js.map +1 -0
  23. package/dist/manifest-tools.d.ts +15 -0
  24. package/dist/manifest-tools.d.ts.map +1 -0
  25. package/dist/manifest-tools.js +0 -0
  26. package/dist/manifest-tools.js.map +1 -0
  27. package/dist/relay/relay-client.d.ts +5 -1
  28. package/dist/relay/relay-client.d.ts.map +1 -1
  29. package/dist/relay/relay-client.js +81 -10
  30. package/dist/relay/relay-client.js.map +1 -1
  31. package/dist/runtime.d.ts +3 -1
  32. package/dist/runtime.d.ts.map +1 -1
  33. package/dist/runtime.js +28 -1
  34. package/dist/runtime.js.map +1 -1
  35. package/dist/workload/dispatch-assertion.d.ts +167 -0
  36. package/dist/workload/dispatch-assertion.d.ts.map +1 -0
  37. package/dist/workload/dispatch-assertion.js +653 -0
  38. package/dist/workload/dispatch-assertion.js.map +1 -0
  39. package/dist/workload/index.d.ts +7 -0
  40. package/dist/workload/index.d.ts.map +1 -0
  41. package/dist/workload/index.js +4 -0
  42. package/dist/workload/index.js.map +1 -0
  43. package/dist/workload/publisher-runtime-trust.d.ts +118 -0
  44. package/dist/workload/publisher-runtime-trust.d.ts.map +1 -0
  45. package/dist/workload/publisher-runtime-trust.js +918 -0
  46. package/dist/workload/publisher-runtime-trust.js.map +1 -0
  47. package/dist/workload/workload-identity.d.ts +118 -0
  48. package/dist/workload/workload-identity.d.ts.map +1 -0
  49. package/dist/workload/workload-identity.js +451 -0
  50. package/dist/workload/workload-identity.js.map +1 -0
  51. package/package.json +13 -1
@@ -0,0 +1,167 @@
1
+ import { type JsonWebKey } from 'node:crypto';
2
+ import type { WorkloadBrokerContext } from './workload-identity.js';
3
+ export type VerifiedDispatchActor = Readonly<{
4
+ subject: string;
5
+ username?: string;
6
+ roomId?: string;
7
+ }>;
8
+ export type VerifiedDispatchAssertion = Readonly<{
9
+ jti: string;
10
+ issuedAt: number;
11
+ expiresAt: number;
12
+ actor?: VerifiedDispatchActor;
13
+ }>;
14
+ export type RuntimeDispatchExecutionModeV3 = 'SELF_HOSTED_LOCAL' | 'PUBLISHER_HOSTED';
15
+ export type RuntimeDispatchAffinityV3 = Readonly<{
16
+ workspaceId: string;
17
+ deploymentId: string;
18
+ mcpAppId: string;
19
+ executionMode: RuntimeDispatchExecutionModeV3;
20
+ generationId: string;
21
+ generationNumber: number;
22
+ runtimeInstallationId: string;
23
+ manifestDigest: string;
24
+ resourceManifestHash: string;
25
+ /** Optional post-readiness expectation. The signed assertion always contains this field. */
26
+ runtimeResourceInventoryHash?: string;
27
+ /** Optional post-readiness expectation. The signed assertion always contains this field. */
28
+ runtimeApprovalReceiptHash?: string;
29
+ /** Optional current-state expectation. The signed assertion always contains this field. */
30
+ runtimeAuthorizationEpoch?: number;
31
+ }>;
32
+ export type RuntimeDispatchTrustV3 = Readonly<{
33
+ hubKid: string;
34
+ hubPublicJwk: JsonWebKey;
35
+ affinity: RuntimeDispatchAffinityV3;
36
+ }>;
37
+ export type RuntimeDispatchTrustHintV3 = Readonly<{
38
+ kid: string;
39
+ workspaceId: string;
40
+ deploymentId: string;
41
+ mcpAppId: string;
42
+ executionMode: RuntimeDispatchExecutionModeV3;
43
+ generationId: string;
44
+ generationNumber: number;
45
+ runtimeInstallationId: string;
46
+ authorizationContext: 'workspace' | 'room';
47
+ roomId?: string;
48
+ authorizationBindingId?: string;
49
+ /** True only when the actual RPC body is one of the three frozen readiness messages. */
50
+ preactivationReadiness?: true;
51
+ }>;
52
+ export type RuntimeDispatchReplayInputV3 = Readonly<{
53
+ issuer: string;
54
+ jti: string;
55
+ nonce: string;
56
+ expiresAt: number;
57
+ now: number;
58
+ }>;
59
+ /** Implementations must atomically return true only when both the JTI and nonce are live-unseen. */
60
+ export interface RuntimeDispatchReplayConsumerV3 {
61
+ consume(input: RuntimeDispatchReplayInputV3): boolean | Promise<boolean>;
62
+ }
63
+ /** Process-local bounded replay protection. Publishers with multiple replicas must inject a shared atomic consumer. */
64
+ export declare class BoundedRuntimeDispatchReplayConsumerV3 implements RuntimeDispatchReplayConsumerV3 {
65
+ private readonly capacity;
66
+ private readonly jtis;
67
+ private readonly nonces;
68
+ constructor(capacity?: number);
69
+ consume(input: RuntimeDispatchReplayInputV3): boolean;
70
+ }
71
+ export type RuntimeDispatchTrustResolverV3 = (hint: RuntimeDispatchTrustHintV3) => RuntimeDispatchTrustV3 | Promise<RuntimeDispatchTrustV3>;
72
+ export type RuntimeDispatchSecurityV3 = Readonly<{
73
+ mode: 'required';
74
+ trust: RuntimeDispatchTrustV3 | RuntimeDispatchTrustResolverV3;
75
+ replayConsumer?: RuntimeDispatchReplayConsumerV3;
76
+ /** Unix seconds. Primarily useful for deterministic conformance tests. */
77
+ now?: () => number;
78
+ /** Default 5 seconds. Applies only to future `iat`, never to expiration. */
79
+ clockSkewSeconds?: number;
80
+ /** Explicit pre-activation exception. Never permits tools/call, resources/read, or custom methods. */
81
+ unsignedReadiness?: 'initialize-and-tools-list';
82
+ }>;
83
+ type CompleteRuntimeDispatchAffinityV3 = RuntimeDispatchAffinityV3 & Readonly<{
84
+ runtimeResourceInventoryHash: string;
85
+ runtimeApprovalReceiptHash: string;
86
+ runtimeAuthorizationEpoch: number;
87
+ }>;
88
+ type RuntimeDispatchCommonV3 = CompleteRuntimeDispatchAffinityV3 & Readonly<{
89
+ protocolVersion: 3;
90
+ type: 'hub-runtime-dispatch-assertion';
91
+ iss: string;
92
+ aud: string;
93
+ jti: string;
94
+ nonce: string;
95
+ iat: number;
96
+ exp: number;
97
+ authorizationContext: 'workspace' | 'room';
98
+ htm: 'POST';
99
+ htu: '/mcp';
100
+ bodyDigest: string;
101
+ }>;
102
+ export type VerifiedRuntimeDispatchAssertionV3 = (RuntimeDispatchCommonV3 & Readonly<{
103
+ authorizationContext: 'workspace';
104
+ }>) | (RuntimeDispatchCommonV3 & Readonly<{
105
+ authorizationContext: 'room';
106
+ roomId: string;
107
+ authorizationBindingId: string;
108
+ bindingReceiptHash: string;
109
+ bindingGrantHash: string;
110
+ bindingEpoch: number;
111
+ bindingTokenVersion: number;
112
+ }>);
113
+ export type RuntimeDispatchRelayAuthorizationV3 = Readonly<{
114
+ assertion: string;
115
+ runtimeInstallationId: string;
116
+ authorizationBindingId?: string;
117
+ }>;
118
+ export type RuntimeDispatchRelayEnvelopeV3 = Readonly<{
119
+ logicalRpc: Record<string, unknown>;
120
+ authorization: RuntimeDispatchRelayAuthorizationV3;
121
+ userMetadata?: unknown;
122
+ }>;
123
+ export declare function assertRuntimeDispatchTrustConfigurationV3(value: unknown): asserts value is RuntimeDispatchTrustV3;
124
+ export declare function parseRuntimeDispatchTrustV3Json(raw: string): RuntimeDispatchTrustV3;
125
+ export declare function sha256RuntimeDispatchBodyV3(body: unknown): string;
126
+ export declare function isUnsignedRuntimeReadinessRpcV3(body: unknown, security: RuntimeDispatchSecurityV3): boolean;
127
+ /** Exact readiness classification; it grants no authority without a verified signed assertion. */
128
+ export declare function isExactRuntimeReadinessRpcV3(body: unknown): boolean;
129
+ export declare function verifyRuntimeDispatchAssertionV3(input: {
130
+ compact: string;
131
+ body: unknown;
132
+ security: RuntimeDispatchSecurityV3;
133
+ /** When present, wrapper affinity is checked before the assertion is consumed for replay. */
134
+ relayAuthorization?: RuntimeDispatchRelayAuthorizationV3;
135
+ now?: number;
136
+ }): Promise<VerifiedRuntimeDispatchAssertionV3>;
137
+ export declare function extractRuntimeDispatchRelayEnvelopeV3(value: unknown): RuntimeDispatchRelayEnvelopeV3;
138
+ export declare function assertRuntimeDispatchRelayAffinityV3(authorization: RuntimeDispatchRelayAuthorizationV3, verified: VerifiedRuntimeDispatchAssertionV3): void;
139
+ export type VerifiedClusterDispatchAssertionV3 = Readonly<{
140
+ jti: string;
141
+ issuedAt: number;
142
+ expiresAt: number;
143
+ authorizationContext: 'workspace' | 'room';
144
+ roomId?: string;
145
+ authorizationBindingId?: string;
146
+ }>;
147
+ /**
148
+ * Verify the dispatch a Hub routes to an App Library runtime through its
149
+ * cluster. The assertion reuses the replica `typ` but carries generation
150
+ * affinity instead of replica affinity, so every field is checked against the
151
+ * generation the node attested — the runtime trusts no claim the broker did
152
+ * not already bind it to.
153
+ */
154
+ export declare function verifyClusterDispatchAssertionV3(input: {
155
+ compact: string;
156
+ body: unknown;
157
+ context: WorkloadBrokerContext;
158
+ now?: number;
159
+ }): VerifiedClusterDispatchAssertionV3;
160
+ export declare function verifyDispatchAssertion(input: {
161
+ compact: string;
162
+ body: unknown;
163
+ context: WorkloadBrokerContext;
164
+ now?: number;
165
+ }): VerifiedDispatchAssertion;
166
+ export {};
167
+ //# sourceMappingURL=dispatch-assertion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-assertion.d.ts","sourceRoot":"","sources":["../../src/workload/dispatch-assertion.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;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