@rentnerproxy/app-contracts 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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/contracts.schema.json +4007 -0
  4. package/dist/Types/contract.types.d.ts +15 -0
  5. package/dist/Types/contract.types.js +1 -0
  6. package/dist/catalog.d.ts +352 -0
  7. package/dist/catalog.js +54 -0
  8. package/dist/client.d.ts +31 -0
  9. package/dist/client.js +66 -0
  10. package/dist/http-operations.d.ts +333 -0
  11. package/dist/http-operations.generated.d.ts +299 -0
  12. package/dist/http-operations.generated.js +300 -0
  13. package/dist/http-operations.js +17 -0
  14. package/dist/http.d.ts +127 -0
  15. package/dist/http.js +142 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +4 -0
  18. package/dist/manifest.d.ts +90 -0
  19. package/dist/manifest.js +106 -0
  20. package/dist/platform-api.d.ts +282 -0
  21. package/dist/platform-api.js +287 -0
  22. package/dist/primitives.d.ts +33 -0
  23. package/dist/primitives.js +87 -0
  24. package/dist/provider-api.d.ts +221 -0
  25. package/dist/provider-api.js +227 -0
  26. package/dist/publication.d.ts +410 -0
  27. package/dist/publication.js +50 -0
  28. package/dist/runtime.d.ts +75 -0
  29. package/dist/runtime.js +88 -0
  30. package/dist/schemas.d.ts +926 -0
  31. package/dist/schemas.js +114 -0
  32. package/dist/ui-bridge.d.ts +81 -0
  33. package/dist/ui-bridge.js +92 -0
  34. package/dist/validation.d.ts +784 -0
  35. package/dist/validation.js +245 -0
  36. package/dist/wire.d.ts +31 -0
  37. package/dist/wire.js +54 -0
  38. package/fixtures.json +1094 -0
  39. package/http-fixtures.json +829 -0
  40. package/openapi.json +2557 -0
  41. package/package.json +56 -5
  42. package/protocol-fixtures.json +1804 -0
  43. package/upstream-probe-fixtures.json +852 -0
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import { catalog, catalogRelease, packageArtifact, revocation, } from './catalog.js';
3
+ import { httpComponents, httpPaths } from './http.js';
4
+ import { rpcLimits } from './http-operations.js';
5
+ import { appManifest } from './manifest.js';
6
+ import { jsonValue, platformApiSchemas } from './platform-api.js';
7
+ import { contractVersion, sourceIdentity } from './primitives.js';
8
+ import { providerSchemas } from './provider-api.js';
9
+ import { approval, candidate, publication } from './publication.js';
10
+ import { runtimeSchemas } from './runtime.js';
11
+ import { uiBridgeSchemas } from './ui-bridge.js';
12
+ import { operation, problem } from './wire.js';
13
+ export const protocolSchemas = {
14
+ ...runtimeSchemas,
15
+ ...providerSchemas,
16
+ ...platformApiSchemas,
17
+ ...uiBridgeSchemas,
18
+ Problem: problem,
19
+ Operation: operation,
20
+ };
21
+ const schemas = {
22
+ JsonValue: jsonValue,
23
+ SourceIdentity: sourceIdentity,
24
+ AppManifest: appManifest,
25
+ PackageArtifact: packageArtifact,
26
+ CatalogRelease: catalogRelease,
27
+ Revocation: revocation,
28
+ Catalog: catalog,
29
+ Candidate: candidate,
30
+ Approval: approval,
31
+ Publication: publication,
32
+ ...protocolSchemas,
33
+ };
34
+ const compatibility = {
35
+ requests: 'Versioned requests and closed package, approval, credential and bridge records reject unknown fields. Omitted optional fields are absent. Null is valid only where explicitly declared.',
36
+ responses: 'Readers tolerate additional fields only in open response schemas. Unknown discriminants, required capabilities and security-relevant values are rejected.',
37
+ encoding: 'Protocol member names use camelCase. IDs, revisions and cursors are strings. Timestamps use UTC with milliseconds. Numbers stay within the safe JSON integer magnitude, including in app payloads and open fields. Decoders must reject duplicate members and invalid Unicode. The JSON depth limit counts nested arrays and objects.',
38
+ evolution: 'Within v1 preserve required fields, units, defaults and semantics. Add new optional response fields only to open shapes. Breaking wire changes require a new major version and negotiation before use.',
39
+ admission: 'Check payload bounds and authenticated identity before dispatch. Recheck current installation generation, user delegation, capability and resource scope at the platform boundary. Bound concurrent requests per installation.',
40
+ optionalMarketplace: 'Use separate bounded background requests and keep enrichment outside trusted catalog and installation decisions. Cache or omit enrichment if unavailable. Respect the advertised request size, page and deadline limits.',
41
+ };
42
+ const runtimeEvidence = {
43
+ profile: 'rentnerproxy-linux-v1',
44
+ platformCommit: '195bd9b66dec662c9bb81ca2b1a3a4f889f15f3f',
45
+ workflowRun: 'https://github.com/RentnerProxy/platform/actions/runs/44192659551',
46
+ bunVersion: '1.4.4',
47
+ highestReferencedGlibc: '2.17',
48
+ testedTargets: [
49
+ {
50
+ target: 'linux-amd64',
51
+ machine: 'x86_64',
52
+ kernel: '7.0.0-1014-aws',
53
+ libc: 'glibc 2.41',
54
+ elfAbi: 'Linux 3.2.0',
55
+ },
56
+ {
57
+ target: 'linux-arm64',
58
+ machine: 'aarch64',
59
+ kernel: '7.0.0-1017-azure',
60
+ libc: 'glibc 2.41',
61
+ elfAbi: 'Linux 3.7.0',
62
+ },
63
+ ],
64
+ description: 'Observed appliances verified both private sockets, generation revocation, frame-bound UI and signed local installation followed by offline startup. These measurements describe the exercised environments. Package admission checks the target and runtime profile on the actual appliance.',
65
+ };
66
+ export function buildContractDocuments() {
67
+ const registry = z.registry();
68
+ for (const [id, schema] of Object.entries(schemas))
69
+ registry.add(schema, { id });
70
+ const converted = z.toJSONSchema(registry, {
71
+ target: 'draft-2020-12',
72
+ uri: (id) => '#/$defs/' + id,
73
+ override: ({ jsonSchema }) => {
74
+ // Both SDKs validate the IPv6 format, including embedded IPv4 notation.
75
+ if (jsonSchema.format === 'ipv6')
76
+ delete jsonSchema.pattern;
77
+ },
78
+ });
79
+ const definitions = Object.fromEntries(Object.entries(converted.schemas).map(([name, schema]) => {
80
+ const { $schema: _dialect, $id: _localId, ...definition } = schema;
81
+ return [name, definition];
82
+ }));
83
+ return {
84
+ 'contracts.schema.json': {
85
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
86
+ $id: 'urn:rentnerproxy:app-contracts:' + contractVersion,
87
+ title: 'RentnerProxy App Contracts',
88
+ description: 'Enable JSON Schema format assertions when validating these documents. The SDK validates formats including IP addresses and timestamps.',
89
+ $ref: '#/$defs/Catalog',
90
+ $defs: definitions,
91
+ 'x-rentnerproxy-protocol-documents': Object.keys(protocolSchemas),
92
+ 'x-rentnerproxy-compatibility': compatibility,
93
+ },
94
+ 'openapi.json': {
95
+ openapi: '3.1.2',
96
+ info: {
97
+ title: 'RentnerProxy App Protocol',
98
+ version: contractVersion,
99
+ description: 'Stable version 1 contract for native apps. HTTP uses the declared private Unix socket for each operation. The matching SDK verifies cross-record invariants. Platform authorization is required at the runtime boundary.',
100
+ },
101
+ paths: httpPaths,
102
+ 'x-rentnerproxy-rpc-limits': rpcLimits,
103
+ 'x-rentnerproxy-compatibility': compatibility,
104
+ 'x-rentnerproxy-runtime-evidence': runtimeEvidence,
105
+ components: {
106
+ ...httpComponents,
107
+ schemas: Object.fromEntries(Object.keys(schemas).map((name) => [
108
+ name,
109
+ { $ref: './contracts.schema.json#/$defs/' + name },
110
+ ])),
111
+ },
112
+ },
113
+ };
114
+ }
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ export declare const uiBridgeSchemas: {
3
+ UiBridgeMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ type: z.ZodLiteral<"runtime:ready">;
5
+ nonce: z.ZodString;
6
+ }, z.core.$strict>, z.ZodObject<{
7
+ installId: z.ZodString;
8
+ installationGeneration: z.ZodNumber;
9
+ generation: z.ZodNumber;
10
+ type: z.ZodLiteral<"runtime:bootstrap">;
11
+ bridgeVersion: z.ZodLiteral<"1.0.0">;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ installId: z.ZodString;
14
+ installationGeneration: z.ZodNumber;
15
+ generation: z.ZodNumber;
16
+ type: z.ZodLiteral<"connected">;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ installId: z.ZodString;
19
+ installationGeneration: z.ZodNumber;
20
+ generation: z.ZodNumber;
21
+ type: z.ZodLiteral<"context">;
22
+ theme: z.ZodEnum<{
23
+ dark: "dark";
24
+ light: "light";
25
+ }>;
26
+ locale: z.ZodString;
27
+ route: z.ZodString;
28
+ ready: z.ZodBoolean;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ installId: z.ZodString;
31
+ installationGeneration: z.ZodNumber;
32
+ generation: z.ZodNumber;
33
+ type: z.ZodLiteral<"navigate">;
34
+ route: z.ZodString;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ installId: z.ZodString;
37
+ installationGeneration: z.ZodNumber;
38
+ generation: z.ZodNumber;
39
+ type: z.ZodLiteral<"dialog">;
40
+ requestId: z.ZodString;
41
+ dialogId: z.ZodString;
42
+ }, z.core.$strict>, z.ZodObject<{
43
+ installId: z.ZodString;
44
+ installationGeneration: z.ZodNumber;
45
+ generation: z.ZodNumber;
46
+ type: z.ZodLiteral<"dialogResult">;
47
+ requestId: z.ZodString;
48
+ outcome: z.ZodEnum<{
49
+ cancelled: "cancelled";
50
+ confirmed: "confirmed";
51
+ }>;
52
+ }, z.core.$strict>, z.ZodObject<{
53
+ installId: z.ZodString;
54
+ installationGeneration: z.ZodNumber;
55
+ generation: z.ZodNumber;
56
+ type: z.ZodLiteral<"apiRequest">;
57
+ requestId: z.ZodString;
58
+ operationId: z.ZodString;
59
+ idempotencyKey: z.ZodString;
60
+ payload: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ installId: z.ZodString;
63
+ installationGeneration: z.ZodNumber;
64
+ generation: z.ZodNumber;
65
+ type: z.ZodLiteral<"apiResult">;
66
+ requestId: z.ZodString;
67
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
68
+ ok: z.ZodLiteral<true>;
69
+ payload: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
70
+ }, z.core.$strict>, z.ZodObject<{
71
+ ok: z.ZodLiteral<false>;
72
+ problem: z.ZodObject<{
73
+ type: z.ZodString;
74
+ title: z.ZodString;
75
+ status: z.ZodNumber;
76
+ code: z.ZodString;
77
+ requestId: z.ZodString;
78
+ }, z.core.$strict>;
79
+ }, z.core.$strict>], "ok">;
80
+ }, z.core.$strict>], "type">;
81
+ };
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ import { appApiPayload } from './platform-api.js';
3
+ import { positiveInteger, recordId } from './primitives.js';
4
+ import { problem } from './wire.js';
5
+ const binding = {
6
+ installId: recordId,
7
+ installationGeneration: positiveInteger.describe('Installation generation assigned by the native manager.'),
8
+ generation: positiveInteger.describe('Session channel generation. Each bootstrap increases it within the frame.'),
9
+ };
10
+ const route = recordId.describe('Route ID from the host route allowlist.');
11
+ const ready = z
12
+ .strictObject({
13
+ type: z.literal('runtime:ready'),
14
+ nonce: z
15
+ .string()
16
+ .min(1)
17
+ .max(128)
18
+ .regex(/^[A-Za-z0-9_-]+$/),
19
+ })
20
+ .describe('The iframe targets the exact host origin and transfers one private document control port. The host checks the expected iframe WindowProxy, the opaque origin (the string "null"), and the nonce issued for this frame before accepting the port.');
21
+ const bootstrap = z
22
+ .strictObject({
23
+ type: z.literal('runtime:bootstrap'),
24
+ bridgeVersion: z.literal('1.0.0'),
25
+ ...binding,
26
+ })
27
+ .describe('The host selects the bridge version and transfers one fresh session port over the private document control port. Validate the port transfer separately from the payload.');
28
+ const connected = z
29
+ .strictObject({ type: z.literal('connected'), ...binding })
30
+ .describe('The iframe acknowledges the bootstrap on the active session port.');
31
+ const context = z
32
+ .strictObject({
33
+ type: z.literal('context'),
34
+ ...binding,
35
+ theme: z.enum(['light', 'dark']),
36
+ locale: z
37
+ .string()
38
+ .max(64)
39
+ .regex(/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/),
40
+ route,
41
+ ready: z.boolean(),
42
+ })
43
+ .describe('The host sends current UI context on the active session port.');
44
+ const navigate = z
45
+ .strictObject({ type: z.literal('navigate'), ...binding, route })
46
+ .describe('The iframe requests a host route on the active session port.');
47
+ const dialog = z.strictObject({
48
+ type: z.literal('dialog'),
49
+ ...binding,
50
+ requestId: recordId,
51
+ dialogId: recordId.describe('A dialog declared by the installed app. The host controls rendering and focus.'),
52
+ });
53
+ const dialogResult = z.strictObject({
54
+ type: z.literal('dialogResult'),
55
+ ...binding,
56
+ requestId: recordId,
57
+ outcome: z.enum(['confirmed', 'cancelled']),
58
+ });
59
+ const apiRequest = z
60
+ .strictObject({
61
+ type: z.literal('apiRequest'),
62
+ ...binding,
63
+ requestId: recordId,
64
+ operationId: recordId,
65
+ idempotencyKey: recordId,
66
+ payload: appApiPayload,
67
+ })
68
+ .describe('Only call a declared operation through the authenticated app gateway with current permissions.');
69
+ const apiResult = z.strictObject({
70
+ type: z.literal('apiResult'),
71
+ ...binding,
72
+ requestId: recordId,
73
+ result: z.discriminatedUnion('ok', [
74
+ z.strictObject({ ok: z.literal(true), payload: appApiPayload }),
75
+ z.strictObject({ ok: z.literal(false), problem }),
76
+ ]),
77
+ });
78
+ export const uiBridgeSchemas = {
79
+ UiBridgeMessage: z
80
+ .discriminatedUnion('type', [
81
+ ready,
82
+ bootstrap,
83
+ connected,
84
+ context,
85
+ navigate,
86
+ dialog,
87
+ dialogResult,
88
+ apiRequest,
89
+ apiResult,
90
+ ])
91
+ .describe('Check the transfer count and ports outside payload validation. Require the active session port and matching install ID, installation generation, and channel generation for session messages. Close replaced session ports and revoke both ports when the document or installation binding expires. Protected resource actions require the current installation generation and authorization through the authenticated gateway.'),
92
+ };