@githolon/runtime 0.110.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.md +45 -0
- package/dist/RUNTIME-SOURCES.sha256 +289 -0
- package/dist/application-reception.js +206 -0
- package/dist/nomos-native-runtime.js +22519 -0
- package/dist/nomos-runner.html +13 -0
- package/dist/nomos-runner.js +34769 -0
- package/dist/remote-reception.cjs +582 -0
- package/dist/remote-reception.js +555 -0
- package/dist/typescript-application-desk.js +796 -0
- package/package.json +71 -0
- package/runner/README.md +75 -0
- package/runner/build.ts +225 -0
- package/runner/node-entry.mjs +31858 -0
- package/runner/nomos-runner.html +13 -0
- package/runner/shims.js +17 -0
- package/src/admission_decision.ts +60 -0
- package/src/application_reception.ts +134 -0
- package/src/nominal_value.ts +122 -0
- package/src/protocol/nomos/custody/v1/snapshot_pb.d.ts +67 -0
- package/src/protocol/nomos/custody/v1/snapshot_pb.js +18 -0
- package/src/protocol/nomos/discovery/v1/workspace_placement_pb.d.ts +56 -0
- package/src/protocol/nomos/discovery/v1/workspace_placement_pb.js +18 -0
- package/src/protocol/nomos/kernel/v1/kernel_pb.d.ts +11183 -0
- package/src/protocol/nomos/kernel/v1/kernel_pb.js +2217 -0
- package/src/protocol/nomos/kernel/v1/progress_pb.d.ts +250 -0
- package/src/protocol/nomos/kernel/v1/progress_pb.js +66 -0
- package/src/protocol/nomos/runtime/v2/application_desk_pb.d.ts +162 -0
- package/src/protocol/nomos/runtime/v2/application_desk_pb.js +60 -0
- package/src/protocol/nomos/runtime/v2/application_readiness_desk_pb.d.ts +202 -0
- package/src/protocol/nomos/runtime/v2/application_readiness_desk_pb.js +67 -0
- package/src/protocol/nomos/runtime/v2/authentication_desk_pb.d.ts +158 -0
- package/src/protocol/nomos/runtime/v2/authentication_desk_pb.js +50 -0
- package/src/protocol/nomos/runtime/v2/compatibility_desk_pb.d.ts +204 -0
- package/src/protocol/nomos/runtime/v2/compatibility_desk_pb.js +68 -0
- package/src/protocol/nomos/runtime/v2/correspondence_desk_pb.d.ts +3661 -0
- package/src/protocol/nomos/runtime/v2/correspondence_desk_pb.js +735 -0
- package/src/protocol/nomos/runtime/v2/credentials_desk_pb.d.ts +122 -0
- package/src/protocol/nomos/runtime/v2/credentials_desk_pb.js +41 -0
- package/src/protocol/nomos/runtime/v2/custody_desk_pb.d.ts +611 -0
- package/src/protocol/nomos/runtime/v2/custody_desk_pb.js +123 -0
- package/src/protocol/nomos/runtime/v2/framework_pb.d.ts +211 -0
- package/src/protocol/nomos/runtime/v2/framework_pb.js +29 -0
- package/src/protocol/nomos/runtime/v2/identity_desk_pb.d.ts +305 -0
- package/src/protocol/nomos/runtime/v2/identity_desk_pb.js +61 -0
- package/src/protocol/nomos/runtime/v2/interaction_desk_pb.d.ts +73 -0
- package/src/protocol/nomos/runtime/v2/interaction_desk_pb.js +25 -0
- package/src/protocol/nomos/runtime/v2/law_desk_pb.d.ts +133 -0
- package/src/protocol/nomos/runtime/v2/law_desk_pb.js +39 -0
- package/src/protocol/nomos/runtime/v2/maintenance_desk_pb.d.ts +267 -0
- package/src/protocol/nomos/runtime/v2/maintenance_desk_pb.js +84 -0
- package/src/protocol/nomos/runtime/v2/model_adoption_desk_pb.d.ts +233 -0
- package/src/protocol/nomos/runtime/v2/model_adoption_desk_pb.js +57 -0
- package/src/protocol/nomos/runtime/v2/observability_desk_pb.d.ts +1015 -0
- package/src/protocol/nomos/runtime/v2/observability_desk_pb.js +230 -0
- package/src/protocol/nomos/runtime/v2/placement_desk_pb.d.ts +431 -0
- package/src/protocol/nomos/runtime/v2/placement_desk_pb.js +125 -0
- package/src/protocol/nomos/runtime/v2/receiving_group_desk_pb.d.ts +336 -0
- package/src/protocol/nomos/runtime/v2/receiving_group_desk_pb.js +78 -0
- package/src/protocol/nomos/runtime/v2/records_desk_pb.d.ts +716 -0
- package/src/protocol/nomos/runtime/v2/records_desk_pb.js +200 -0
- package/src/protocol/nomos/runtime/v2/recovery_desk_pb.d.ts +535 -0
- package/src/protocol/nomos/runtime/v2/recovery_desk_pb.js +160 -0
- package/src/protocol/nomos/runtime/v2/residency_desk_pb.d.ts +1162 -0
- package/src/protocol/nomos/runtime/v2/residency_desk_pb.js +212 -0
- package/src/protocol/nomos/runtime/v2/runtime_pb.d.ts +796 -0
- package/src/protocol/nomos/runtime/v2/runtime_pb.js +72 -0
- package/src/protocol/nomos/runtime/v2/sealing_desk_pb.d.ts +581 -0
- package/src/protocol/nomos/runtime/v2/sealing_desk_pb.js +149 -0
- package/src/remote_reception.public.d.ts +97 -0
- package/src/remote_reception.ts +446 -0
- package/src/typescript_application_desk.public.d.ts +62 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.13.0 with parameter "target=js+dts,import_extension=js"
|
|
2
|
+
// @generated from file nomos/runtime/v2/sealing_desk.proto (package nomos.runtime.v2, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import { enumDesc, fileDesc, messageDesc, tsEnum } from "@bufbuild/protobuf/codegenv2";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Describes the file nomos/runtime/v2/sealing_desk.proto.
|
|
9
|
+
*/
|
|
10
|
+
export const file_nomos_runtime_v2_sealing_desk = /*@__PURE__*/
|
|
11
|
+
fileDesc("CiNub21vcy9ydW50aW1lL3YyL3NlYWxpbmdfZGVzay5wcm90bxIQbm9tb3MucnVudGltZS52MiKAAQoQU2VhbEZpZWxkUmVxdWVzdBIRCglzY29wZV9rZXkYASABKAwSDQoFc2NvcGUYAiABKAkSDQoFZXBvY2gYAyABKAQSFQoNYWdncmVnYXRlX3NpZBgEIAEoCRIRCglmaWVsZF9zaWQYBSABKAkSEQoJcGxhaW50ZXh0GAYgASgJIiMKD1NlYWxGaWVsZFJlc3VsdBIQCghlbnZlbG9wZRgBIAEoCSIqCg5Pd25lZFJlY29yZFJlZhIMCgR0eXBlGAEgASgJEgoKAmlkGAIgASgJImcKFE93bmVkU2NvcGVLZXlSZXF1ZXN0Eg0KBXNjb3BlGAEgASgJEjUKBnJlY29yZBgCIAEoCzIgLm5vbW9zLnJ1bnRpbWUudjIuT3duZWRSZWNvcmRSZWZIAIgBAUIJCgdfcmVjb3JkIlgKFU93bmVkU2NvcGVLZXlzUmVxdWVzdBINCgVzY29wZRgBIAEoCRIwCgZyZWNvcmQYAiABKAsyIC5ub21vcy5ydW50aW1lLnYyLk93bmVkUmVjb3JkUmVmIsQCCg1Pd25lZFNjb3BlS2V5Eg0KBXNjb3BlGAEgASgJEg0KBWVwb2NoGAIgASgEEgsKA2tleRgDIAEoDBIeChFvd25lZF9rZXlfc3ViamVjdBgEIAEoCUgAiAEBEh8KEm93bmVkX2N1c3RvZHlfdXNkYRgFIAEoDEgBiAEBEhYKCXdvcmtzcGFjZRgGIAEoCUgCiAEBEhsKDmtleV9jb21taXRtZW50GAcgASgJSAOIAQESJgoZcHJpbmNpcGFsX3dyYXBwaW5nX3B1YmxpYxgIIAEoCUgEiAEBQhQKEl9vd25lZF9rZXlfc3ViamVjdEIVChNfb3duZWRfY3VzdG9keV91c2RhQgwKCl93b3Jrc3BhY2VCEQoPX2tleV9jb21taXRtZW50QhwKGl9wcmluY2lwYWxfd3JhcHBpbmdfcHVibGljIkIKEU93bmVkU2NvcGVLZXlMaXN0Ei0KBGtleXMYASADKAsyHy5ub21vcy5ydW50aW1lLnYyLk93bmVkU2NvcGVLZXkiaQoaRW5zdXJlT3duZWRJZGVudGl0eVJlcXVlc3QSDQoFc2NvcGUYASABKAkSDgoGZG9tYWluGAIgASgJEhoKDWRvbWFpbl9zaGEyNTYYAyABKAlIAIgBAUIQCg5fZG9tYWluX3NoYTI1NiIWChRPd25lZElkZW50aXR5RW5zdXJlZCJvChtQcm90ZWN0T3duZWRJZGVudGl0eVJlcXVlc3QSDQoFc2NvcGUYASABKAkSDgoGZG9tYWluGAIgASgJEhUKDWRvbWFpbl9zaGEyNTYYAyABKAkSGgoScmVjb3ZlcnlfcHJpbmNpcGFsGAQgASgJIlgKF093bmVkSWRlbnRpdHlQcm90ZWN0aW9uEg4KBnN0YXR1cxgBIAEoCRIaChJyZWNvdmVyeV9wcmluY2lwYWwYAiABKAkSEQoJdW5jaGFuZ2VkGAMgASgIIqUBCh9QcmVwYXJlT3duZWRSZWNvcmRBY3Rpb25SZXF1ZXN0EjMKBmFjdGlvbhgBIAEoDjIjLm5vbW9zLnJ1bnRpbWUudjIuT3duZWRSZWNvcmRBY3Rpb24SDQoFc2NvcGUYAiABKAkSMAoGcmVjb3JkGAMgASgLMiAubm9tb3MucnVudGltZS52Mi5Pd25lZFJlY29yZFJlZhIMCgRwZWVyGAQgASgJIpkBCgxPd25lZEtleVdyYXASGwoTcmVjaXBpZW50X3ByaW5jaXBhbBgBIAEoCRIcChRyZWNpcGllbnRfcHVibGljX2tleRgCIAEoCRIcChRlcGhlbWVyYWxfcHVibGljX2tleRgDIAEoDBISCgpjaXBoZXJ0ZXh0GAQgASgMEhIKBWVwb2NoGAUgASgESACIAQFCCAoGX2Vwb2NoIq0CChZPd25lZFJlY29yZFByZXBhcmF0aW9uEhkKEW93bmVkX2tleV9zdWJqZWN0GAEgASgJEh8KEm93bmVkX2N1c3RvZHlfdXNkYRgCIAEoDEgBiAEBEjgKBXNoYXJlGAogASgLMicubm9tb3MucnVudGltZS52Mi5Pd25lZFNoYXJlUHJlcGFyYXRpb25IABI8Cgd1bnNoYXJlGAsgASgLMikubm9tb3MucnVudGltZS52Mi5Pd25lZFVuc2hhcmVQcmVwYXJhdGlvbkgAEj4KCHRyYW5zZmVyGAwgASgLMioubm9tb3MucnVudGltZS52Mi5Pd25lZFRyYW5zZmVyUHJlcGFyYXRpb25IAEIICgZhY3Rpb25CFQoTX293bmVkX2N1c3RvZHlfdXNkYSKJAQoVT3duZWRTaGFyZVByZXBhcmF0aW9uEhEKCXJlY29yZF9pZBgBIAEoCRIMCgRwZWVyGAIgASgJEg0KBWVwb2NoGAMgASgEEhEKCXNoYXJlZF9hdBgEIAEoCRItCgV3cmFwcxgFIAMoCzIeLm5vbW9zLnJ1bnRpbWUudjIuT3duZWRLZXlXcmFwIowBChdPd25lZFVuc2hhcmVQcmVwYXJhdGlvbhIRCglyZWNvcmRfaWQYASABKAkSDAoEcGVlchgCIAEoCRINCgVlcG9jaBgDIAEoBBISCgpjaGFuZ2VkX2F0GAQgASgJEi0KBXdyYXBzGAUgAygLMh4ubm9tb3MucnVudGltZS52Mi5Pd25lZEtleVdyYXAitQEKGE93bmVkVHJhbnNmZXJQcmVwYXJhdGlvbhIRCglyZWNvcmRfaWQYASABKAkSEQoJbmV3X293bmVyGAIgASgJEhgKEHByZXZpb3VzX3JlYWRlcnMYAyADKAkSDQoFZXBvY2gYBCABKAQSEgoKY2hhbmdlZF9hdBgFIAEoCRI2Cg5oaXN0b3JpY193cmFwcxgGIAMoCzIeLm5vbW9zLnJ1bnRpbWUudjIuT3duZWRLZXlXcmFwInwKGU93bmVkQmlydGhTY29wZUtleVJlcXVlc3QSDQoFc2NvcGUYASABKAkSEQoJbmFtZXNwYWNlGAIgASgJEgsKA2tleRgDIAEoCRIwCgZyZWNvcmQYBCABKAsyIC5ub21vcy5ydW50aW1lLnYyLk93bmVkUmVjb3JkUmVmKpoBChFPd25lZFJlY29yZEFjdGlvbhIjCh9PV05FRF9SRUNPUkRfQUNUSU9OX1VOU1BFQ0lGSUVEEAASHQoZT1dORURfUkVDT1JEX0FDVElPTl9TSEFSRRABEh8KG09XTkVEX1JFQ09SRF9BQ1RJT05fVU5TSEFSRRACEiAKHE9XTkVEX1JFQ09SRF9BQ1RJT05fVFJBTlNGRVIQA2IGcHJvdG8z");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Describes the message nomos.runtime.v2.SealFieldRequest.
|
|
15
|
+
* Use `create(SealFieldRequestSchema)` to create a new message.
|
|
16
|
+
*/
|
|
17
|
+
export const SealFieldRequestSchema = /*@__PURE__*/
|
|
18
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 0);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Describes the message nomos.runtime.v2.SealFieldResult.
|
|
22
|
+
* Use `create(SealFieldResultSchema)` to create a new message.
|
|
23
|
+
*/
|
|
24
|
+
export const SealFieldResultSchema = /*@__PURE__*/
|
|
25
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 1);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Describes the message nomos.runtime.v2.OwnedRecordRef.
|
|
29
|
+
* Use `create(OwnedRecordRefSchema)` to create a new message.
|
|
30
|
+
*/
|
|
31
|
+
export const OwnedRecordRefSchema = /*@__PURE__*/
|
|
32
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 2);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Describes the message nomos.runtime.v2.OwnedScopeKeyRequest.
|
|
36
|
+
* Use `create(OwnedScopeKeyRequestSchema)` to create a new message.
|
|
37
|
+
*/
|
|
38
|
+
export const OwnedScopeKeyRequestSchema = /*@__PURE__*/
|
|
39
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 3);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Describes the message nomos.runtime.v2.OwnedScopeKeysRequest.
|
|
43
|
+
* Use `create(OwnedScopeKeysRequestSchema)` to create a new message.
|
|
44
|
+
*/
|
|
45
|
+
export const OwnedScopeKeysRequestSchema = /*@__PURE__*/
|
|
46
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 4);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Describes the message nomos.runtime.v2.OwnedScopeKey.
|
|
50
|
+
* Use `create(OwnedScopeKeySchema)` to create a new message.
|
|
51
|
+
*/
|
|
52
|
+
export const OwnedScopeKeySchema = /*@__PURE__*/
|
|
53
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 5);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Describes the message nomos.runtime.v2.OwnedScopeKeyList.
|
|
57
|
+
* Use `create(OwnedScopeKeyListSchema)` to create a new message.
|
|
58
|
+
*/
|
|
59
|
+
export const OwnedScopeKeyListSchema = /*@__PURE__*/
|
|
60
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 6);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Describes the message nomos.runtime.v2.EnsureOwnedIdentityRequest.
|
|
64
|
+
* Use `create(EnsureOwnedIdentityRequestSchema)` to create a new message.
|
|
65
|
+
*/
|
|
66
|
+
export const EnsureOwnedIdentityRequestSchema = /*@__PURE__*/
|
|
67
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 7);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Describes the message nomos.runtime.v2.OwnedIdentityEnsured.
|
|
71
|
+
* Use `create(OwnedIdentityEnsuredSchema)` to create a new message.
|
|
72
|
+
*/
|
|
73
|
+
export const OwnedIdentityEnsuredSchema = /*@__PURE__*/
|
|
74
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 8);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Describes the message nomos.runtime.v2.ProtectOwnedIdentityRequest.
|
|
78
|
+
* Use `create(ProtectOwnedIdentityRequestSchema)` to create a new message.
|
|
79
|
+
*/
|
|
80
|
+
export const ProtectOwnedIdentityRequestSchema = /*@__PURE__*/
|
|
81
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 9);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Describes the message nomos.runtime.v2.OwnedIdentityProtection.
|
|
85
|
+
* Use `create(OwnedIdentityProtectionSchema)` to create a new message.
|
|
86
|
+
*/
|
|
87
|
+
export const OwnedIdentityProtectionSchema = /*@__PURE__*/
|
|
88
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 10);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Describes the message nomos.runtime.v2.PrepareOwnedRecordActionRequest.
|
|
92
|
+
* Use `create(PrepareOwnedRecordActionRequestSchema)` to create a new message.
|
|
93
|
+
*/
|
|
94
|
+
export const PrepareOwnedRecordActionRequestSchema = /*@__PURE__*/
|
|
95
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 11);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Describes the message nomos.runtime.v2.OwnedKeyWrap.
|
|
99
|
+
* Use `create(OwnedKeyWrapSchema)` to create a new message.
|
|
100
|
+
*/
|
|
101
|
+
export const OwnedKeyWrapSchema = /*@__PURE__*/
|
|
102
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 12);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Describes the message nomos.runtime.v2.OwnedRecordPreparation.
|
|
106
|
+
* Use `create(OwnedRecordPreparationSchema)` to create a new message.
|
|
107
|
+
*/
|
|
108
|
+
export const OwnedRecordPreparationSchema = /*@__PURE__*/
|
|
109
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 13);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Describes the message nomos.runtime.v2.OwnedSharePreparation.
|
|
113
|
+
* Use `create(OwnedSharePreparationSchema)` to create a new message.
|
|
114
|
+
*/
|
|
115
|
+
export const OwnedSharePreparationSchema = /*@__PURE__*/
|
|
116
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 14);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Describes the message nomos.runtime.v2.OwnedUnsharePreparation.
|
|
120
|
+
* Use `create(OwnedUnsharePreparationSchema)` to create a new message.
|
|
121
|
+
*/
|
|
122
|
+
export const OwnedUnsharePreparationSchema = /*@__PURE__*/
|
|
123
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 15);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Describes the message nomos.runtime.v2.OwnedTransferPreparation.
|
|
127
|
+
* Use `create(OwnedTransferPreparationSchema)` to create a new message.
|
|
128
|
+
*/
|
|
129
|
+
export const OwnedTransferPreparationSchema = /*@__PURE__*/
|
|
130
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 16);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Describes the message nomos.runtime.v2.OwnedBirthScopeKeyRequest.
|
|
134
|
+
* Use `create(OwnedBirthScopeKeyRequestSchema)` to create a new message.
|
|
135
|
+
*/
|
|
136
|
+
export const OwnedBirthScopeKeyRequestSchema = /*@__PURE__*/
|
|
137
|
+
messageDesc(file_nomos_runtime_v2_sealing_desk, 17);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Describes the enum nomos.runtime.v2.OwnedRecordAction.
|
|
141
|
+
*/
|
|
142
|
+
export const OwnedRecordActionSchema = /*@__PURE__*/
|
|
143
|
+
enumDesc(file_nomos_runtime_v2_sealing_desk, 0);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @generated from enum nomos.runtime.v2.OwnedRecordAction
|
|
147
|
+
*/
|
|
148
|
+
export const OwnedRecordAction = /*@__PURE__*/
|
|
149
|
+
tsEnum(OwnedRecordActionSchema);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export interface RemoteGeneratedCall {
|
|
2
|
+
readonly domain: string;
|
|
3
|
+
readonly directive: string;
|
|
4
|
+
readonly protobufType: string;
|
|
5
|
+
readonly protobufPayload: Uint8Array;
|
|
6
|
+
readonly routingCandidates: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RemoteReceptionCredentials {
|
|
10
|
+
readonly principal: string;
|
|
11
|
+
readonly authorSecret: Uint8Array;
|
|
12
|
+
readonly authToken?: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RemoteReceptionOptions {
|
|
16
|
+
readonly address: string;
|
|
17
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface RemoteGeneratedRead {
|
|
21
|
+
readonly query: string;
|
|
22
|
+
readonly protobufType: string;
|
|
23
|
+
readonly protobufPayload: Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RemoteQueryResult {
|
|
27
|
+
readonly protobufType: string;
|
|
28
|
+
readonly protobufPayload: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RemoteOfferOptions {
|
|
32
|
+
readonly domainHash?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RemoteOfferAdmitted {
|
|
36
|
+
readonly head: string;
|
|
37
|
+
readonly intentId: string;
|
|
38
|
+
readonly intentOut?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RemoteBirthCertificate {
|
|
42
|
+
readonly child: string;
|
|
43
|
+
readonly founder: string;
|
|
44
|
+
readonly verified: boolean;
|
|
45
|
+
readonly parentKey: Uint8Array;
|
|
46
|
+
readonly parentId: string;
|
|
47
|
+
readonly epoch: number | bigint;
|
|
48
|
+
readonly signature: Uint8Array;
|
|
49
|
+
readonly verifiedVia?: string;
|
|
50
|
+
readonly idpToken?: string;
|
|
51
|
+
readonly capturedClock?: number | bigint;
|
|
52
|
+
readonly authProviderIssuer?: string;
|
|
53
|
+
readonly authProviderJwks?: string;
|
|
54
|
+
readonly authProviderAudience?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface RemoteSignedBirthCertificate extends Omit<RemoteBirthCertificate, "epoch" | "capturedClock"> {
|
|
58
|
+
readonly epoch: bigint;
|
|
59
|
+
readonly capturedClock?: bigint;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Stateless typed HTTP correspondence with a remote Nomos Peer Office. */
|
|
63
|
+
export declare class RemoteReception {
|
|
64
|
+
constructor(options: RemoteReceptionOptions);
|
|
65
|
+
read(
|
|
66
|
+
workspace: string,
|
|
67
|
+
generated: RemoteGeneratedRead,
|
|
68
|
+
credentials: RemoteReceptionCredentials,
|
|
69
|
+
): Promise<RemoteQueryResult>;
|
|
70
|
+
offer(
|
|
71
|
+
workspace: string,
|
|
72
|
+
generated: RemoteGeneratedCall,
|
|
73
|
+
credentials: RemoteReceptionCredentials,
|
|
74
|
+
options?: RemoteOfferOptions,
|
|
75
|
+
): Promise<RemoteOfferAdmitted>;
|
|
76
|
+
readById(workspace: string, aggregateType: string, aggregateId: string,
|
|
77
|
+
credentials: RemoteReceptionCredentials): Promise<Uint8Array>;
|
|
78
|
+
readByType(workspace: string, aggregateType: string,
|
|
79
|
+
credentials: RemoteReceptionCredentials): Promise<Uint8Array>;
|
|
80
|
+
rows(
|
|
81
|
+
workspace: string,
|
|
82
|
+
query: string,
|
|
83
|
+
arguments_: Readonly<Record<string, unknown>>,
|
|
84
|
+
credentials: RemoteReceptionCredentials,
|
|
85
|
+
): Promise<unknown>;
|
|
86
|
+
byId(
|
|
87
|
+
workspace: string,
|
|
88
|
+
aggregateId: string,
|
|
89
|
+
aggregateType: string,
|
|
90
|
+
credentials: RemoteReceptionCredentials,
|
|
91
|
+
): Promise<unknown>;
|
|
92
|
+
signBirthCertificate(
|
|
93
|
+
workspace: string,
|
|
94
|
+
certificate: RemoteBirthCertificate,
|
|
95
|
+
signerSecret: Uint8Array,
|
|
96
|
+
): Promise<RemoteSignedBirthCertificate>;
|
|
97
|
+
}
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { NomosTypedOfferFailure } from "./admission_decision.ts";
|
|
2
|
+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
3
|
+
import { AnySchema } from "@bufbuild/protobuf/wkt";
|
|
4
|
+
import {
|
|
5
|
+
AuthoringOptionsSchema,
|
|
6
|
+
ByIdQuerySchema,
|
|
7
|
+
ByTypeQuerySchema,
|
|
8
|
+
BirthCertificateSchema,
|
|
9
|
+
CallRequestSchema,
|
|
10
|
+
DirectiveCallSchema,
|
|
11
|
+
OfferRequestSchema,
|
|
12
|
+
QueryAuthoritySchema,
|
|
13
|
+
QueryRequestSchema,
|
|
14
|
+
QueryResultFormat,
|
|
15
|
+
RowsQuerySchema,
|
|
16
|
+
SignBirthCertificateRequestSchema,
|
|
17
|
+
WorkspaceTargetSchema,
|
|
18
|
+
type BirthCertificate,
|
|
19
|
+
type CallRequest,
|
|
20
|
+
type CallResponse,
|
|
21
|
+
type OfferAdmitted,
|
|
22
|
+
type QueryRequest,
|
|
23
|
+
} from "../../../adapter/proto/nomos/kernel/v1/kernel_pb.js";
|
|
24
|
+
import { KernelCallRequestSchema } from "../../../adapter/proto/nomos/runtime/v2/application_desk_pb.js";
|
|
25
|
+
import { CredentialUse } from "../../../adapter/proto/nomos/runtime/v2/credentials_desk_pb.js";
|
|
26
|
+
import {
|
|
27
|
+
RuntimeRequestSchema,
|
|
28
|
+
RuntimeResponseSchema,
|
|
29
|
+
} from "../../../adapter/proto/nomos/runtime/v2/runtime_pb.js";
|
|
30
|
+
import { structToProto, valueFromProto } from "../../src/runtime/protobuf_values.ts";
|
|
31
|
+
import type { ReceptionGeneratedCall } from "./application_reception.ts";
|
|
32
|
+
|
|
33
|
+
const RUNTIME_REQUEST = "application/vnd.nomos.runtime-request+protobuf";
|
|
34
|
+
const RUNTIME_RESPONSE = "application/vnd.nomos.runtime-response+protobuf";
|
|
35
|
+
const RUNTIME_PROTOCOL = 2;
|
|
36
|
+
const KERNEL_PROTOCOL = 1;
|
|
37
|
+
|
|
38
|
+
export interface RemoteReceptionCredentials {
|
|
39
|
+
readonly principal: string;
|
|
40
|
+
readonly authorSecret: Uint8Array;
|
|
41
|
+
readonly authToken?: Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RemoteReceptionOptions {
|
|
45
|
+
readonly address: string;
|
|
46
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RemoteGeneratedRead {
|
|
50
|
+
readonly query: string;
|
|
51
|
+
readonly protobufType: string;
|
|
52
|
+
readonly protobufPayload: Uint8Array;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RemoteQueryResult {
|
|
56
|
+
readonly protobufType: string;
|
|
57
|
+
readonly protobufPayload: Uint8Array;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RemoteOfferOptions {
|
|
61
|
+
readonly domainHash?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RemoteBirthCertificate {
|
|
65
|
+
readonly child: string;
|
|
66
|
+
readonly founder: string;
|
|
67
|
+
readonly verified: boolean;
|
|
68
|
+
readonly parentKey: Uint8Array;
|
|
69
|
+
readonly parentId: string;
|
|
70
|
+
readonly epoch: number | bigint;
|
|
71
|
+
readonly signature: Uint8Array;
|
|
72
|
+
readonly verifiedVia?: string;
|
|
73
|
+
readonly idpToken?: string;
|
|
74
|
+
readonly capturedClock?: number | bigint;
|
|
75
|
+
readonly authProviderIssuer?: string;
|
|
76
|
+
readonly authProviderJwks?: string;
|
|
77
|
+
readonly authProviderAudience?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The small HTTP correspondence edge of Reception.
|
|
82
|
+
*
|
|
83
|
+
* This class owns no workspace, kernel, custody, sync or retry lifecycle. It
|
|
84
|
+
* carries one exact Runtime-v2 paper to a remote Peer Office and returns that
|
|
85
|
+
* office's typed receipt. Credentials remain call-scoped because this process
|
|
86
|
+
* is merely a correspondent, not another Nomos peer.
|
|
87
|
+
*/
|
|
88
|
+
export class RemoteReception {
|
|
89
|
+
readonly #address: string;
|
|
90
|
+
readonly #fetch: typeof globalThis.fetch;
|
|
91
|
+
#requestId = 0n;
|
|
92
|
+
|
|
93
|
+
constructor(options: RemoteReceptionOptions) {
|
|
94
|
+
this.#address = options.address.replace(/\/+$/, "");
|
|
95
|
+
if (!/^https?:\/\//.test(this.#address)) {
|
|
96
|
+
throw new TypeError("Remote Reception requires an http(s) peer address");
|
|
97
|
+
}
|
|
98
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
99
|
+
if (typeof this.#fetch !== "function") {
|
|
100
|
+
throw new TypeError("Remote Reception requires a fetch implementation");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Send one compiler-generated call through the target workspace's ordinary offer gate. */
|
|
105
|
+
async offer(
|
|
106
|
+
workspace: string,
|
|
107
|
+
generated: ReceptionGeneratedCall,
|
|
108
|
+
credentials: RemoteReceptionCredentials,
|
|
109
|
+
options: RemoteOfferOptions = {},
|
|
110
|
+
): Promise<OfferAdmitted> {
|
|
111
|
+
this.#validateCredentials(credentials);
|
|
112
|
+
const call = create(CallRequestSchema, {
|
|
113
|
+
protocolVersion: KERNEL_PROTOCOL,
|
|
114
|
+
requestId: this.#kernelRequestId("offer"),
|
|
115
|
+
operation: {
|
|
116
|
+
case: "offer",
|
|
117
|
+
value: create(OfferRequestSchema, {
|
|
118
|
+
target: this.#target(workspace),
|
|
119
|
+
...(options.domainHash === undefined ? {} : { controllerLawHash: options.domainHash }),
|
|
120
|
+
intent: {
|
|
121
|
+
case: "call",
|
|
122
|
+
value: create(DirectiveCallSchema, {
|
|
123
|
+
domain: generated.domain,
|
|
124
|
+
directive: generated.directive,
|
|
125
|
+
operation: create(AnySchema, {
|
|
126
|
+
typeUrl: generated.protobufType,
|
|
127
|
+
value: generated.protobufPayload,
|
|
128
|
+
}),
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
authoring: create(AuthoringOptionsSchema, {
|
|
132
|
+
actor: credentials.principal,
|
|
133
|
+
authToken: credentials.authToken ?? new Uint8Array(),
|
|
134
|
+
authorSecret: credentials.authorSecret,
|
|
135
|
+
spans: true,
|
|
136
|
+
}),
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
const response = await this.#call(workspace, call, CredentialUse.CALL_PROVIDED);
|
|
141
|
+
if (response.outcome.case === "failure") {
|
|
142
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
143
|
+
}
|
|
144
|
+
if (response.outcome.case !== "offer") {
|
|
145
|
+
throw new Error(`kernel returned '${response.outcome.case || "empty"}' for a generated offer`);
|
|
146
|
+
}
|
|
147
|
+
const outcome = response.outcome.value.outcome;
|
|
148
|
+
if (outcome.case !== "admitted") {
|
|
149
|
+
const detail = outcome.case === "refused"
|
|
150
|
+
? outcome.value.refusal?.message ?? "target law refused the offer"
|
|
151
|
+
: outcome.case === "deadLettered"
|
|
152
|
+
? `dead-lettered: ${outcome.value.reason}`
|
|
153
|
+
: outcome.case === "quarantined"
|
|
154
|
+
? `quarantined: ${outcome.value.reason}`
|
|
155
|
+
: outcome.case === "blockedOnDependency"
|
|
156
|
+
? `blocked: ${outcome.value.detail}`
|
|
157
|
+
: `unexpected offer outcome '${outcome.case || "empty"}'`;
|
|
158
|
+
throw new NomosTypedOfferFailure(response.outcome.value, detail);
|
|
159
|
+
}
|
|
160
|
+
return outcome.value;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Execute one compiler-generated read at the remote peer. Query meaning,
|
|
165
|
+
* readiness and authorization stay there; this correspondent owns no local
|
|
166
|
+
* interaction, custody, law preparation or replica-follow lifecycle.
|
|
167
|
+
*/
|
|
168
|
+
async read(
|
|
169
|
+
workspace: string,
|
|
170
|
+
generated: RemoteGeneratedRead,
|
|
171
|
+
credentials: RemoteReceptionCredentials,
|
|
172
|
+
): Promise<RemoteQueryResult> {
|
|
173
|
+
this.#validateCredentials(credentials);
|
|
174
|
+
const response = await this.#call(workspace, create(CallRequestSchema, {
|
|
175
|
+
protocolVersion: KERNEL_PROTOCOL,
|
|
176
|
+
requestId: this.#kernelRequestId("generated-read"),
|
|
177
|
+
operation: { case: "query", value: create(QueryRequestSchema, {
|
|
178
|
+
target: this.#target(workspace),
|
|
179
|
+
authority: create(QueryAuthoritySchema, {
|
|
180
|
+
authToken: credentials.authToken ?? new Uint8Array(),
|
|
181
|
+
authorSecret: credentials.authorSecret,
|
|
182
|
+
principalClaim: credentials.principal,
|
|
183
|
+
}),
|
|
184
|
+
resultFormat: QueryResultFormat.APPLICATION_PROTOBUF,
|
|
185
|
+
query: { case: "rows", value: create(RowsQuerySchema, {
|
|
186
|
+
id: generated.query,
|
|
187
|
+
principal: credentials.principal,
|
|
188
|
+
applicationArguments: create(AnySchema, {
|
|
189
|
+
typeUrl: generated.protobufType, value: generated.protobufPayload,
|
|
190
|
+
}),
|
|
191
|
+
}) },
|
|
192
|
+
}) },
|
|
193
|
+
}), CredentialUse.CALL_PROVIDED);
|
|
194
|
+
if (response.outcome.case === "failure") {
|
|
195
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
196
|
+
}
|
|
197
|
+
if (response.outcome.case !== "query" || response.outcome.value.result.case !== "applicationResult") {
|
|
198
|
+
throw new Error("Remote Reception did not return generated query result bytes");
|
|
199
|
+
}
|
|
200
|
+
const result = response.outcome.value.result.value;
|
|
201
|
+
return { protobufType: result.typeUrl, protobufPayload: result.value };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Temporary fixed-framework read used while the remaining framework queries
|
|
206
|
+
* gain generated result messages. Application/domain reads do not use this.
|
|
207
|
+
*/
|
|
208
|
+
async rows(
|
|
209
|
+
workspace: string,
|
|
210
|
+
query: string,
|
|
211
|
+
arguments_: Readonly<Record<string, unknown>>,
|
|
212
|
+
credentials: RemoteReceptionCredentials,
|
|
213
|
+
): Promise<unknown> {
|
|
214
|
+
this.#validateCredentials(credentials);
|
|
215
|
+
const call = create(CallRequestSchema, {
|
|
216
|
+
protocolVersion: KERNEL_PROTOCOL,
|
|
217
|
+
requestId: this.#kernelRequestId("query"),
|
|
218
|
+
operation: {
|
|
219
|
+
case: "query",
|
|
220
|
+
value: create(QueryRequestSchema, {
|
|
221
|
+
target: this.#target(workspace),
|
|
222
|
+
authority: create(QueryAuthoritySchema, {
|
|
223
|
+
authToken: credentials.authToken ?? new Uint8Array(),
|
|
224
|
+
authorSecret: credentials.authorSecret,
|
|
225
|
+
}),
|
|
226
|
+
resultFormat: QueryResultFormat.LEGACY_VALUE,
|
|
227
|
+
query: {
|
|
228
|
+
case: "rows",
|
|
229
|
+
value: create(RowsQuerySchema, {
|
|
230
|
+
id: query,
|
|
231
|
+
arguments: structToProto(arguments_),
|
|
232
|
+
principal: credentials.principal,
|
|
233
|
+
}),
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
const response = await this.#call(workspace, call, CredentialUse.CALL_PROVIDED);
|
|
239
|
+
if (response.outcome.case === "failure") {
|
|
240
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
241
|
+
}
|
|
242
|
+
if (response.outcome.case !== "query") {
|
|
243
|
+
throw new Error(`kernel returned '${response.outcome.case || "empty"}' for a framework query`);
|
|
244
|
+
}
|
|
245
|
+
if (response.outcome.value.result.case !== "value") {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`kernel returned '${response.outcome.value.result.case || "empty"}' for a legacy framework query`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return valueFromProto(response.outcome.value.result.value);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Canonical aggregate bytes for the generated collection's own decoder. */
|
|
254
|
+
readById(workspace: string, aggregateType: string, aggregateId: string,
|
|
255
|
+
credentials: RemoteReceptionCredentials): Promise<Uint8Array> {
|
|
256
|
+
return this.#readUsda(workspace, { case: "byId", value: create(ByIdQuerySchema, {
|
|
257
|
+
aggregateType, aggregateId, principal: credentials.principal,
|
|
258
|
+
}) }, credentials);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Canonical aggregate bytes for a generated collection, not a host-parsed business schema. */
|
|
262
|
+
readByType(workspace: string, aggregateType: string,
|
|
263
|
+
credentials: RemoteReceptionCredentials): Promise<Uint8Array> {
|
|
264
|
+
return this.#readUsda(workspace, { case: "byType", value: create(ByTypeQuerySchema, {
|
|
265
|
+
aggregateType, principal: credentials.principal,
|
|
266
|
+
}) }, credentials);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async #readUsda(workspace: string, query: QueryRequest["query"],
|
|
270
|
+
credentials: RemoteReceptionCredentials): Promise<Uint8Array> {
|
|
271
|
+
this.#validateCredentials(credentials);
|
|
272
|
+
const response = await this.#call(workspace, create(CallRequestSchema, {
|
|
273
|
+
protocolVersion: KERNEL_PROTOCOL, requestId: this.#kernelRequestId("generated-collection"),
|
|
274
|
+
operation: { case: "query", value: create(QueryRequestSchema, {
|
|
275
|
+
target: this.#target(workspace), resultFormat: QueryResultFormat.NOMINAL_USDA, query,
|
|
276
|
+
authority: create(QueryAuthoritySchema, {
|
|
277
|
+
authToken: credentials.authToken ?? new Uint8Array(), authorSecret: credentials.authorSecret,
|
|
278
|
+
principalClaim: credentials.principal,
|
|
279
|
+
}),
|
|
280
|
+
}) },
|
|
281
|
+
}), CredentialUse.CALL_PROVIDED);
|
|
282
|
+
if (response.outcome.case === "failure") {
|
|
283
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
284
|
+
}
|
|
285
|
+
if (response.outcome.case !== "query" || response.outcome.value.result.case !== "resultUsda") {
|
|
286
|
+
throw new Error("Remote Reception did not return canonical aggregate bytes");
|
|
287
|
+
}
|
|
288
|
+
return response.outcome.value.result.value;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Fixed-framework aggregate lookup; generated application reads use their generated result messages. */
|
|
292
|
+
async byId(
|
|
293
|
+
workspace: string,
|
|
294
|
+
aggregateId: string,
|
|
295
|
+
aggregateType: string,
|
|
296
|
+
credentials: RemoteReceptionCredentials,
|
|
297
|
+
): Promise<unknown> {
|
|
298
|
+
this.#validateCredentials(credentials);
|
|
299
|
+
const call = create(CallRequestSchema, {
|
|
300
|
+
protocolVersion: KERNEL_PROTOCOL,
|
|
301
|
+
requestId: this.#kernelRequestId("query-by-id"),
|
|
302
|
+
operation: {
|
|
303
|
+
case: "query",
|
|
304
|
+
value: create(QueryRequestSchema, {
|
|
305
|
+
target: this.#target(workspace),
|
|
306
|
+
authority: create(QueryAuthoritySchema, {
|
|
307
|
+
authToken: credentials.authToken ?? new Uint8Array(),
|
|
308
|
+
authorSecret: credentials.authorSecret,
|
|
309
|
+
}),
|
|
310
|
+
resultFormat: QueryResultFormat.LEGACY_VALUE,
|
|
311
|
+
query: {
|
|
312
|
+
case: "byId",
|
|
313
|
+
value: create(ByIdQuerySchema, {
|
|
314
|
+
aggregateId,
|
|
315
|
+
aggregateType,
|
|
316
|
+
}),
|
|
317
|
+
},
|
|
318
|
+
}),
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
const response = await this.#call(workspace, call, CredentialUse.CALL_PROVIDED);
|
|
322
|
+
if (response.outcome.case === "failure") {
|
|
323
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
324
|
+
}
|
|
325
|
+
if (response.outcome.case !== "query") {
|
|
326
|
+
throw new Error(`kernel returned '${response.outcome.case || "empty"}' for a framework lookup`);
|
|
327
|
+
}
|
|
328
|
+
if (response.outcome.value.result.case !== "value") {
|
|
329
|
+
throw new Error(
|
|
330
|
+
`kernel returned '${response.outcome.value.result.case || "empty"}' for a legacy framework lookup`,
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return valueFromProto(response.outcome.value.result.value);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Ask the target kernel to sign its canonical birth-certificate message. */
|
|
337
|
+
async signBirthCertificate(
|
|
338
|
+
workspace: string,
|
|
339
|
+
certificate: RemoteBirthCertificate,
|
|
340
|
+
signerSecret: Uint8Array,
|
|
341
|
+
): Promise<BirthCertificate> {
|
|
342
|
+
if (signerSecret.byteLength !== 32) {
|
|
343
|
+
throw new TypeError("birth-certificate signing requires one 32-byte device key");
|
|
344
|
+
}
|
|
345
|
+
const { epoch, capturedClock, ...certificateFields } = certificate;
|
|
346
|
+
const call = create(CallRequestSchema, {
|
|
347
|
+
protocolVersion: KERNEL_PROTOCOL,
|
|
348
|
+
requestId: this.#kernelRequestId("sign-birth-certificate"),
|
|
349
|
+
operation: {
|
|
350
|
+
case: "signBirthCertificate",
|
|
351
|
+
value: create(SignBirthCertificateRequestSchema, {
|
|
352
|
+
certificate: create(BirthCertificateSchema, {
|
|
353
|
+
...certificateFields,
|
|
354
|
+
epoch: BigInt(epoch),
|
|
355
|
+
...(capturedClock === undefined
|
|
356
|
+
? {}
|
|
357
|
+
: { capturedClock: BigInt(capturedClock) }),
|
|
358
|
+
}),
|
|
359
|
+
signerSecret,
|
|
360
|
+
}),
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
const response = await this.#call(workspace, call, CredentialUse.NONE);
|
|
364
|
+
if (response.outcome.case === "failure") {
|
|
365
|
+
throw new Error(`${response.outcome.value.code}: ${response.outcome.value.message}`);
|
|
366
|
+
}
|
|
367
|
+
if (response.outcome.case !== "signBirthCertificate") {
|
|
368
|
+
throw new Error(
|
|
369
|
+
`kernel returned '${response.outcome.case || "empty"}' for birth-certificate signing`,
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
if (!response.outcome.value.certificate) {
|
|
373
|
+
throw new Error("kernel returned no signed birth certificate");
|
|
374
|
+
}
|
|
375
|
+
return response.outcome.value.certificate;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
async #call(
|
|
379
|
+
workspace: string,
|
|
380
|
+
call: CallRequest,
|
|
381
|
+
credentialUse: CredentialUse,
|
|
382
|
+
): Promise<CallResponse> {
|
|
383
|
+
if (!workspace || /[\s/]/.test(workspace)) {
|
|
384
|
+
throw new TypeError(`invalid workspace '${workspace}'`);
|
|
385
|
+
}
|
|
386
|
+
const requestId = ++this.#requestId;
|
|
387
|
+
const session = `remote-reception:${workspace}`;
|
|
388
|
+
const paper = toBinary(RuntimeRequestSchema, create(RuntimeRequestSchema, {
|
|
389
|
+
protocolVersion: RUNTIME_PROTOCOL,
|
|
390
|
+
requestId,
|
|
391
|
+
target: { workspace, session },
|
|
392
|
+
command: {
|
|
393
|
+
case: "kernelCall",
|
|
394
|
+
value: create(KernelCallRequestSchema, { session, request: call, credentialUse }),
|
|
395
|
+
},
|
|
396
|
+
}));
|
|
397
|
+
const response = await this.#fetch(
|
|
398
|
+
`${this.#address}/v2/workspaces/${encodeURIComponent(workspace)}/runtime`,
|
|
399
|
+
{
|
|
400
|
+
method: "POST",
|
|
401
|
+
headers: { accept: RUNTIME_RESPONSE, "content-type": RUNTIME_REQUEST },
|
|
402
|
+
body: paper,
|
|
403
|
+
},
|
|
404
|
+
);
|
|
405
|
+
if (!response.ok) {
|
|
406
|
+
throw new Error(`Remote Reception returned HTTP ${response.status}: ${(await response.text()).slice(0, 500)}`);
|
|
407
|
+
}
|
|
408
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
409
|
+
if (!contentType.includes(RUNTIME_RESPONSE)) {
|
|
410
|
+
throw new Error(`Remote Reception returned '${contentType || "no content type"}'`);
|
|
411
|
+
}
|
|
412
|
+
const runtime = fromBinary(RuntimeResponseSchema, new Uint8Array(await response.arrayBuffer()));
|
|
413
|
+
if (runtime.protocolVersion !== RUNTIME_PROTOCOL || runtime.requestId !== requestId) {
|
|
414
|
+
throw new Error("Remote Reception returned an unrelated Runtime-v2 receipt");
|
|
415
|
+
}
|
|
416
|
+
if (runtime.outcome.case === "failure") {
|
|
417
|
+
throw new Error(`${runtime.outcome.value.code}: ${runtime.outcome.value.message}`);
|
|
418
|
+
}
|
|
419
|
+
if (runtime.outcome.case === "blocked") {
|
|
420
|
+
throw new Error(`Remote Reception blocked on '${runtime.outcome.value.reason.case || "unknown"}'`);
|
|
421
|
+
}
|
|
422
|
+
if (runtime.outcome.case !== "kernelCall") {
|
|
423
|
+
throw new Error(`Remote Reception returned '${runtime.outcome.case || "empty"}' for a kernel paper`);
|
|
424
|
+
}
|
|
425
|
+
return runtime.outcome.value;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
#target(workspace: string) {
|
|
429
|
+
return create(WorkspaceTargetSchema, {
|
|
430
|
+
repo: `/work/ws/${workspace}`,
|
|
431
|
+
workspace,
|
|
432
|
+
branch: "main",
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#kernelRequestId(operation: string): string {
|
|
437
|
+
return `remote-reception:${operation}:${this.#requestId + 1n}`;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
#validateCredentials(credentials: RemoteReceptionCredentials): void {
|
|
441
|
+
if (!credentials.principal.trim()) throw new TypeError("Remote Reception requires a principal");
|
|
442
|
+
if (credentials.authorSecret.byteLength !== 32) {
|
|
443
|
+
throw new TypeError("Remote Reception requires one 32-byte device key");
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|