@opentdf/sdk 0.3.0 → 0.3.2-beta.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 (227) hide show
  1. package/dist/cjs/src/access/access-fetch.js +155 -0
  2. package/dist/cjs/src/access/access-rpc.js +131 -0
  3. package/dist/cjs/src/access.js +81 -107
  4. package/dist/cjs/src/auth/oidc.js +2 -2
  5. package/dist/cjs/src/nanotdf/Client.js +17 -13
  6. package/dist/cjs/src/nanotdf/models/Header.js +2 -2
  7. package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +2 -2
  8. package/dist/cjs/src/opentdf.js +43 -9
  9. package/dist/cjs/src/platform/authorization/authorization_pb.js +138 -0
  10. package/dist/cjs/src/platform/buf/validate/validate_pb.js +410 -0
  11. package/dist/cjs/src/platform/common/common_pb.js +79 -0
  12. package/dist/cjs/src/platform/entityresolution/entity_resolution_pb.js +49 -0
  13. package/dist/cjs/src/platform/google/api/annotations_pb.js +30 -0
  14. package/dist/cjs/src/platform/google/api/http_pb.js +37 -0
  15. package/dist/cjs/src/platform/kas/kas_pb.js +96 -0
  16. package/dist/cjs/src/platform/policy/actions/actions_pb.js +70 -0
  17. package/dist/cjs/src/platform/policy/attributes/attributes_pb.js +240 -0
  18. package/dist/cjs/src/platform/policy/kasregistry/key_access_server_registry_pb.js +236 -0
  19. package/dist/cjs/src/platform/policy/keymanagement/key_management_pb.js +70 -0
  20. package/dist/cjs/src/platform/policy/namespaces/namespaces_pb.js +121 -0
  21. package/dist/cjs/src/platform/policy/objects_pb.js +395 -0
  22. package/dist/cjs/src/platform/policy/registeredresources/registered_resources_pb.js +132 -0
  23. package/dist/cjs/src/platform/policy/resourcemapping/resource_mapping_pb.js +139 -0
  24. package/dist/cjs/src/platform/policy/selectors_pb.js +67 -0
  25. package/dist/cjs/src/platform/policy/subjectmapping/subject_mapping_pb.js +146 -0
  26. package/dist/cjs/src/platform/policy/unsafe/unsafe_pb.js +124 -0
  27. package/dist/cjs/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +68 -0
  28. package/dist/cjs/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +307 -0
  29. package/dist/cjs/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +33 -0
  30. package/dist/cjs/src/platform.js +124 -0
  31. package/dist/cjs/src/policy/api.js +21 -38
  32. package/dist/cjs/src/policy/attributes.js +4 -1
  33. package/dist/cjs/src/policy/granter.js +9 -9
  34. package/dist/cjs/src/utils.js +31 -1
  35. package/dist/cjs/src/version.js +2 -2
  36. package/dist/cjs/tdf3/src/assertions.js +5 -5
  37. package/dist/cjs/tdf3/src/client/index.js +24 -18
  38. package/dist/cjs/tdf3/src/tdf.js +16 -10
  39. package/dist/types/src/access/access-fetch.d.ts +21 -0
  40. package/dist/types/src/access/access-fetch.d.ts.map +1 -0
  41. package/dist/types/src/access/access-rpc.d.ts +22 -0
  42. package/dist/types/src/access/access-rpc.d.ts.map +1 -0
  43. package/dist/types/src/access.d.ts +19 -11
  44. package/dist/types/src/access.d.ts.map +1 -1
  45. package/dist/types/src/nanotdf/Client.d.ts +3 -1
  46. package/dist/types/src/nanotdf/Client.d.ts.map +1 -1
  47. package/dist/types/src/opentdf.d.ts +5 -1
  48. package/dist/types/src/opentdf.d.ts.map +1 -1
  49. package/dist/types/src/platform/authorization/authorization_pb.d.ts +609 -0
  50. package/dist/types/src/platform/authorization/authorization_pb.d.ts.map +1 -0
  51. package/dist/types/src/platform/buf/validate/validate_pb.d.ts +4466 -0
  52. package/dist/types/src/platform/buf/validate/validate_pb.d.ts.map +1 -0
  53. package/dist/types/src/platform/common/common_pb.d.ts +112 -0
  54. package/dist/types/src/platform/common/common_pb.d.ts.map +1 -0
  55. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts +199 -0
  56. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts.map +1 -0
  57. package/dist/types/src/platform/google/api/annotations_pb.d.ts +14 -0
  58. package/dist/types/src/platform/google/api/annotations_pb.d.ts.map +1 -0
  59. package/dist/types/src/platform/google/api/http_pb.d.ts +441 -0
  60. package/dist/types/src/platform/google/api/http_pb.d.ts.map +1 -0
  61. package/dist/types/src/platform/kas/kas_pb.d.ts +404 -0
  62. package/dist/types/src/platform/kas/kas_pb.d.ts.map +1 -0
  63. package/dist/types/src/platform/policy/actions/actions_pb.d.ts +265 -0
  64. package/dist/types/src/platform/policy/actions/actions_pb.d.ts.map +1 -0
  65. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts +1022 -0
  66. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts.map +1 -0
  67. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +1306 -0
  68. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts.map +1 -0
  69. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts +269 -0
  70. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts.map +1 -0
  71. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts +448 -0
  72. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts.map +1 -0
  73. package/dist/types/src/platform/policy/objects_pb.d.ts +1112 -0
  74. package/dist/types/src/platform/policy/objects_pb.d.ts.map +1 -0
  75. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts +539 -0
  76. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts.map +1 -0
  77. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +558 -0
  78. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts.map +1 -0
  79. package/dist/types/src/platform/policy/selectors_pb.d.ts +221 -0
  80. package/dist/types/src/platform/policy/selectors_pb.d.ts.map +1 -0
  81. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +582 -0
  82. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts.map +1 -0
  83. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts +513 -0
  84. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts.map +1 -0
  85. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts +62 -0
  86. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts.map +1 -0
  87. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts +1441 -0
  88. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts.map +1 -0
  89. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +59 -0
  90. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts.map +1 -0
  91. package/dist/types/src/platform.d.ts +49 -0
  92. package/dist/types/src/platform.d.ts.map +1 -0
  93. package/dist/types/src/policy/api.d.ts +1 -1
  94. package/dist/types/src/policy/api.d.ts.map +1 -1
  95. package/dist/types/src/policy/attributes.d.ts +10 -87
  96. package/dist/types/src/policy/attributes.d.ts.map +1 -1
  97. package/dist/types/src/policy/granter.d.ts.map +1 -1
  98. package/dist/types/src/utils.d.ts +10 -0
  99. package/dist/types/src/utils.d.ts.map +1 -1
  100. package/dist/types/src/version.d.ts +1 -1
  101. package/dist/types/tdf3/src/assertions.d.ts +1 -1
  102. package/dist/types/tdf3/src/assertions.d.ts.map +1 -1
  103. package/dist/types/tdf3/src/client/index.d.ts +8 -3
  104. package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
  105. package/dist/types/tdf3/src/models/manifest.d.ts +1 -1
  106. package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -1
  107. package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
  108. package/dist/web/src/access/access-fetch.js +150 -0
  109. package/dist/web/src/access/access-rpc.js +125 -0
  110. package/dist/web/src/access.js +82 -110
  111. package/dist/web/src/auth/oidc.js +2 -2
  112. package/dist/web/src/nanotdf/Client.js +18 -14
  113. package/dist/web/src/nanotdf/models/Header.js +2 -2
  114. package/dist/web/src/nanotdf-crypto/keyAgreement.js +2 -2
  115. package/dist/web/src/opentdf.js +44 -10
  116. package/dist/web/src/platform/authorization/authorization_pb.js +135 -0
  117. package/dist/web/src/platform/buf/validate/validate_pb.js +407 -0
  118. package/dist/web/src/platform/common/common_pb.js +76 -0
  119. package/dist/web/src/platform/entityresolution/entity_resolution_pb.js +46 -0
  120. package/dist/web/src/platform/google/api/annotations_pb.js +27 -0
  121. package/dist/web/src/platform/google/api/http_pb.js +34 -0
  122. package/dist/web/src/platform/kas/kas_pb.js +93 -0
  123. package/dist/web/src/platform/policy/actions/actions_pb.js +67 -0
  124. package/dist/web/src/platform/policy/attributes/attributes_pb.js +237 -0
  125. package/dist/web/src/platform/policy/kasregistry/key_access_server_registry_pb.js +233 -0
  126. package/dist/web/src/platform/policy/keymanagement/key_management_pb.js +67 -0
  127. package/dist/web/src/platform/policy/namespaces/namespaces_pb.js +118 -0
  128. package/dist/web/src/platform/policy/objects_pb.js +392 -0
  129. package/dist/web/src/platform/policy/registeredresources/registered_resources_pb.js +129 -0
  130. package/dist/web/src/platform/policy/resourcemapping/resource_mapping_pb.js +136 -0
  131. package/dist/web/src/platform/policy/selectors_pb.js +64 -0
  132. package/dist/web/src/platform/policy/subjectmapping/subject_mapping_pb.js +143 -0
  133. package/dist/web/src/platform/policy/unsafe/unsafe_pb.js +121 -0
  134. package/dist/web/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +65 -0
  135. package/dist/web/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +304 -0
  136. package/dist/web/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +30 -0
  137. package/dist/web/src/platform.js +87 -0
  138. package/dist/web/src/policy/api.js +23 -40
  139. package/dist/web/src/policy/attributes.js +3 -2
  140. package/dist/web/src/policy/granter.js +9 -9
  141. package/dist/web/src/utils.js +29 -1
  142. package/dist/web/src/version.js +2 -2
  143. package/dist/web/tdf3/src/assertions.js +5 -5
  144. package/dist/web/tdf3/src/client/index.js +26 -20
  145. package/dist/web/tdf3/src/tdf.js +16 -10
  146. package/package.json +17 -1
  147. package/src/access/access-fetch.ts +202 -0
  148. package/src/access/access-rpc.ts +175 -0
  149. package/src/access.ts +113 -138
  150. package/src/auth/oidc.ts +1 -1
  151. package/src/nanotdf/Client.ts +28 -18
  152. package/src/nanotdf/models/Header.ts +1 -1
  153. package/src/nanotdf-crypto/keyAgreement.ts +1 -1
  154. package/src/opentdf.ts +67 -11
  155. package/src/platform/authorization/authorization_pb.ts +689 -0
  156. package/src/platform/buf/validate/validate_pb.ts +4626 -0
  157. package/src/platform/common/common_pb.ts +135 -0
  158. package/src/platform/entityresolution/entity_resolution_pb.ts +233 -0
  159. package/src/platform/google/api/annotations_pb.ts +39 -0
  160. package/src/platform/google/api/http_pb.ts +474 -0
  161. package/src/platform/kas/kas_pb.ts +484 -0
  162. package/src/platform/policy/actions/actions_pb.ts +312 -0
  163. package/src/platform/policy/attributes/attributes_pb.ts +1181 -0
  164. package/src/platform/policy/kasregistry/key_access_server_registry_pb.ts +1482 -0
  165. package/src/platform/policy/keymanagement/key_management_pb.ts +316 -0
  166. package/src/platform/policy/namespaces/namespaces_pb.ts +528 -0
  167. package/src/platform/policy/objects_pb.ts +1319 -0
  168. package/src/platform/policy/registeredresources/registered_resources_pb.ts +623 -0
  169. package/src/platform/policy/resourcemapping/resource_mapping_pb.ts +658 -0
  170. package/src/platform/policy/selectors_pb.ts +277 -0
  171. package/src/platform/policy/subjectmapping/subject_mapping_pb.ts +687 -0
  172. package/src/platform/policy/unsafe/unsafe_pb.ts +593 -0
  173. package/src/platform/protoc-gen-openapiv2/options/annotations_pb.ts +83 -0
  174. package/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.ts +1615 -0
  175. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.ts +78 -0
  176. package/src/platform.ts +122 -0
  177. package/src/policy/api.ts +29 -42
  178. package/src/policy/attributes.ts +12 -108
  179. package/src/policy/granter.ts +7 -8
  180. package/src/utils.ts +30 -0
  181. package/src/version.ts +1 -1
  182. package/tdf3/src/assertions.ts +4 -4
  183. package/tdf3/src/client/index.ts +42 -19
  184. package/tdf3/src/models/manifest.ts +2 -1
  185. package/tdf3/src/tdf.ts +25 -16
  186. package/src/platform/authorization/authorization_connect.d.ts +0 -44
  187. package/src/platform/authorization/authorization_connect.js +0 -44
  188. package/src/platform/authorization/authorization_pb.d.ts +0 -707
  189. package/src/platform/authorization/authorization_pb.js +0 -372
  190. package/src/platform/common/common_pb.d.ts +0 -129
  191. package/src/platform/common/common_pb.js +0 -58
  192. package/src/platform/entityresolution/entity_resolution_connect.d.ts +0 -35
  193. package/src/platform/entityresolution/entity_resolution_connect.js +0 -35
  194. package/src/platform/entityresolution/entity_resolution_pb.d.ts +0 -242
  195. package/src/platform/entityresolution/entity_resolution_pb.js +0 -139
  196. package/src/platform/kas/kas_connect.d.ts +0 -59
  197. package/src/platform/kas/kas_connect.js +0 -59
  198. package/src/platform/kas/kas_pb.d.ts +0 -200
  199. package/src/platform/kas/kas_pb.js +0 -84
  200. package/src/platform/policy/attributes/attributes_connect.d.ts +0 -168
  201. package/src/platform/policy/attributes/attributes_connect.js +0 -168
  202. package/src/platform/policy/attributes/attributes_pb.d.ts +0 -929
  203. package/src/platform/policy/attributes/attributes_pb.js +0 -363
  204. package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +0 -62
  205. package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +0 -62
  206. package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +0 -283
  207. package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +0 -113
  208. package/src/platform/policy/namespaces/namespaces_connect.d.ts +0 -62
  209. package/src/platform/policy/namespaces/namespaces_connect.js +0 -62
  210. package/src/platform/policy/namespaces/namespaces_pb.d.ts +0 -270
  211. package/src/platform/policy/namespaces/namespaces_pb.js +0 -110
  212. package/src/platform/policy/objects_pb.d.ts +0 -725
  213. package/src/platform/policy/objects_pb.js +0 -288
  214. package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +0 -259
  215. package/src/platform/policy/resourcemapping/resource_mapping_connect.js +0 -259
  216. package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +0 -314
  217. package/src/platform/policy/resourcemapping/resource_mapping_pb.js +0 -142
  218. package/src/platform/policy/selectors_pb.d.ts +0 -269
  219. package/src/platform/policy/selectors_pb.js +0 -110
  220. package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +0 -118
  221. package/src/platform/policy/subjectmapping/subject_mapping_connect.js +0 -118
  222. package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +0 -672
  223. package/src/platform/policy/subjectmapping/subject_mapping_pb.js +0 -260
  224. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +0 -26
  225. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +0 -26
  226. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +0 -75
  227. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +0 -35
@@ -0,0 +1,78 @@
1
+ // @generated by protoc-gen-es v2.2.5 with parameter "target=ts,import_extension=.js"
2
+ // @generated from file wellknownconfiguration/wellknown_configuration.proto (package wellknownconfiguration, syntax proto3)
3
+ /* eslint-disable */
4
+
5
+ import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv1";
6
+ import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv1";
7
+ import { file_google_api_annotations } from "../google/api/annotations_pb.js";
8
+ import { file_google_protobuf_struct } from "@bufbuild/protobuf/wkt";
9
+ import type { JsonObject, Message } from "@bufbuild/protobuf";
10
+
11
+ /**
12
+ * Describes the file wellknownconfiguration/wellknown_configuration.proto.
13
+ */
14
+ export const file_wellknownconfiguration_wellknown_configuration: GenFile = /*@__PURE__*/
15
+ fileDesc("CjR3ZWxsa25vd25jb25maWd1cmF0aW9uL3dlbGxrbm93bl9jb25maWd1cmF0aW9uLnByb3RvEhZ3ZWxsa25vd25jb25maWd1cmF0aW9uIrMBCg9XZWxsS25vd25Db25maWcSUQoNY29uZmlndXJhdGlvbhgBIAMoCzI6LndlbGxrbm93bmNvbmZpZ3VyYXRpb24uV2VsbEtub3duQ29uZmlnLkNvbmZpZ3VyYXRpb25FbnRyeRpNChJDb25maWd1cmF0aW9uRW50cnkSCwoDa2V5GAEgASgJEiYKBXZhbHVlGAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdDoCOAEiIgogR2V0V2VsbEtub3duQ29uZmlndXJhdGlvblJlcXVlc3QiUwohR2V0V2VsbEtub3duQ29uZmlndXJhdGlvblJlc3BvbnNlEi4KDWNvbmZpZ3VyYXRpb24YASABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0MtQBChBXZWxsS25vd25TZXJ2aWNlEr8BChlHZXRXZWxsS25vd25Db25maWd1cmF0aW9uEjgud2VsbGtub3duY29uZmlndXJhdGlvbi5HZXRXZWxsS25vd25Db25maWd1cmF0aW9uUmVxdWVzdBo5LndlbGxrbm93bmNvbmZpZ3VyYXRpb24uR2V0V2VsbEtub3duQ29uZmlndXJhdGlvblJlc3BvbnNlIi2QAgGC0+STAiQSIi8ud2VsbC1rbm93bi9vcGVudGRmLWNvbmZpZ3VyYXRpb25iBnByb3RvMw", [file_google_api_annotations, file_google_protobuf_struct]);
16
+
17
+ /**
18
+ * @generated from message wellknownconfiguration.WellKnownConfig
19
+ */
20
+ export type WellKnownConfig = Message<"wellknownconfiguration.WellKnownConfig"> & {
21
+ /**
22
+ * @generated from field: map<string, google.protobuf.Struct> configuration = 1;
23
+ */
24
+ configuration: { [key: string]: JsonObject };
25
+ };
26
+
27
+ /**
28
+ * Describes the message wellknownconfiguration.WellKnownConfig.
29
+ * Use `create(WellKnownConfigSchema)` to create a new message.
30
+ */
31
+ export const WellKnownConfigSchema: GenMessage<WellKnownConfig> = /*@__PURE__*/
32
+ messageDesc(file_wellknownconfiguration_wellknown_configuration, 0);
33
+
34
+ /**
35
+ * @generated from message wellknownconfiguration.GetWellKnownConfigurationRequest
36
+ */
37
+ export type GetWellKnownConfigurationRequest = Message<"wellknownconfiguration.GetWellKnownConfigurationRequest"> & {
38
+ };
39
+
40
+ /**
41
+ * Describes the message wellknownconfiguration.GetWellKnownConfigurationRequest.
42
+ * Use `create(GetWellKnownConfigurationRequestSchema)` to create a new message.
43
+ */
44
+ export const GetWellKnownConfigurationRequestSchema: GenMessage<GetWellKnownConfigurationRequest> = /*@__PURE__*/
45
+ messageDesc(file_wellknownconfiguration_wellknown_configuration, 1);
46
+
47
+ /**
48
+ * @generated from message wellknownconfiguration.GetWellKnownConfigurationResponse
49
+ */
50
+ export type GetWellKnownConfigurationResponse = Message<"wellknownconfiguration.GetWellKnownConfigurationResponse"> & {
51
+ /**
52
+ * @generated from field: google.protobuf.Struct configuration = 1;
53
+ */
54
+ configuration?: JsonObject;
55
+ };
56
+
57
+ /**
58
+ * Describes the message wellknownconfiguration.GetWellKnownConfigurationResponse.
59
+ * Use `create(GetWellKnownConfigurationResponseSchema)` to create a new message.
60
+ */
61
+ export const GetWellKnownConfigurationResponseSchema: GenMessage<GetWellKnownConfigurationResponse> = /*@__PURE__*/
62
+ messageDesc(file_wellknownconfiguration_wellknown_configuration, 2);
63
+
64
+ /**
65
+ * @generated from service wellknownconfiguration.WellKnownService
66
+ */
67
+ export const WellKnownService: GenService<{
68
+ /**
69
+ * @generated from rpc wellknownconfiguration.WellKnownService.GetWellKnownConfiguration
70
+ */
71
+ getWellKnownConfiguration: {
72
+ methodKind: "unary";
73
+ input: typeof GetWellKnownConfigurationRequestSchema;
74
+ output: typeof GetWellKnownConfigurationResponseSchema;
75
+ },
76
+ }> = /*@__PURE__*/
77
+ serviceDesc(file_wellknownconfiguration_wellknown_configuration, 0);
78
+
@@ -0,0 +1,122 @@
1
+ // export Connect RPC framework
2
+ export * as platformConnectWeb from '@connectrpc/connect-web';
3
+ export * as platformConnect from '@connectrpc/connect';
4
+
5
+ import { createConnectTransport } from '@connectrpc/connect-web';
6
+ import { AuthProvider } from '../tdf3/index.js';
7
+
8
+ import { Client, createClient, Interceptor } from '@connectrpc/connect';
9
+ import { WellKnownService } from './platform/wellknownconfiguration/wellknown_configuration_pb.js';
10
+ import { AuthorizationService } from './platform/authorization/authorization_pb.js';
11
+ import { EntityResolutionService } from './platform/entityresolution/entity_resolution_pb.js';
12
+ import { AccessService } from './platform/kas/kas_pb.js';
13
+ import { ActionService } from './platform/policy/actions/actions_pb.js';
14
+ import { AttributesService } from './platform/policy/attributes/attributes_pb.js';
15
+ import { KeyAccessServerRegistryService } from './platform/policy/kasregistry/key_access_server_registry_pb.js';
16
+ import { NamespaceService } from './platform/policy/namespaces/namespaces_pb.js';
17
+ import { ResourceMappingService } from './platform/policy/resourcemapping/resource_mapping_pb.js';
18
+ import { SubjectMappingService } from './platform/policy/subjectmapping/subject_mapping_pb.js';
19
+ import { UnsafeService } from './platform/policy/unsafe/unsafe_pb.js';
20
+
21
+ export interface PlatformServices {
22
+ authorization: Client<typeof AuthorizationService>;
23
+ entityResolution: Client<typeof EntityResolutionService>;
24
+ access: Client<typeof AccessService>;
25
+ action: Client<typeof ActionService>;
26
+ attributes: Client<typeof AttributesService>;
27
+ keyAccessServerRegistry: Client<typeof KeyAccessServerRegistryService>;
28
+ namespace: Client<typeof NamespaceService>;
29
+ resourceMapping: Client<typeof ResourceMappingService>;
30
+ subjectMapping: Client<typeof SubjectMappingService>;
31
+ unsafe: Client<typeof UnsafeService>;
32
+ wellknown: Client<typeof WellKnownService>;
33
+ }
34
+
35
+ export interface PlatformClientOptions {
36
+ // Optional authentication provider for generating auth interceptor.
37
+ authProvider?: AuthProvider;
38
+ // Array of custom interceptors to apply to rpc requests.
39
+ interceptors?: Interceptor[];
40
+ // Base URL of the platform API.
41
+ platformUrl: string;
42
+ }
43
+
44
+ /**
45
+ * A client for interacting with the Platform using the Connect RPC framework.
46
+ *
47
+ * This client provides access to various services offered by the Platform, such as
48
+ * authorization, entity resolution, key access, policy management, and more. It uses
49
+ * the Connect RPC framework to communicate with the platform's API endpoints.
50
+ *
51
+ * This client supports authentication via an `AuthProvider` or custom interceptors, which can
52
+ * be used to add authentication headers or other custom logic to outgoing requests.
53
+ *
54
+ */
55
+ export class PlatformClient {
56
+ readonly v1: PlatformServices;
57
+
58
+ constructor(options: PlatformClientOptions) {
59
+ const interceptors: Interceptor[] = [];
60
+
61
+ if (options.authProvider) {
62
+ const authInterceptor = createAuthInterceptor(options.authProvider);
63
+ interceptors.push(authInterceptor);
64
+ }
65
+
66
+ if (options.interceptors?.length) {
67
+ interceptors.push(...options.interceptors);
68
+ }
69
+
70
+ const transport = createConnectTransport({
71
+ baseUrl: options.platformUrl,
72
+ interceptors,
73
+ });
74
+
75
+ this.v1 = {
76
+ authorization: createClient(AuthorizationService, transport),
77
+ entityResolution: createClient(EntityResolutionService, transport),
78
+ access: createClient(AccessService, transport),
79
+ action: createClient(ActionService, transport),
80
+ attributes: createClient(AttributesService, transport),
81
+ keyAccessServerRegistry: createClient(KeyAccessServerRegistryService, transport),
82
+ namespace: createClient(NamespaceService, transport),
83
+ resourceMapping: createClient(ResourceMappingService, transport),
84
+ subjectMapping: createClient(SubjectMappingService, transport),
85
+ unsafe: createClient(UnsafeService, transport),
86
+ wellknown: createClient(WellKnownService, transport),
87
+ };
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Creates an interceptor that adds authentication headers to outgoing requests.
93
+ *
94
+ * This function uses the provided `AuthProvider` to generate authentication credentials
95
+ * for each request. The `AuthProvider` is expected to implement a `withCreds` method
96
+ * that returns an object containing authentication headers. These headers are then
97
+ * added to the request before it is sent to the server.
98
+ *
99
+ * @param authProvider - An instance of `AuthProvider` used to generate authentication credentials.
100
+ * @returns An `Interceptor` function that modifies requests to include authentication headers.
101
+ */
102
+ function createAuthInterceptor(authProvider: AuthProvider): Interceptor {
103
+ const authInterceptor: Interceptor = (next) => async (req) => {
104
+ const url = new URL(req.url);
105
+ const pathOnly = url.pathname;
106
+ // Signs only the path of the url in the request
107
+ const token = await authProvider.withCreds({
108
+ url: pathOnly,
109
+ method: 'POST',
110
+ headers: {
111
+ 'Content-Type': 'application/json',
112
+ },
113
+ });
114
+
115
+ Object.entries(token.headers).forEach(([key, value]) => {
116
+ req.header.set(key, value);
117
+ });
118
+
119
+ return await next(req);
120
+ };
121
+ return authInterceptor;
122
+ }
package/src/policy/api.ts CHANGED
@@ -1,61 +1,48 @@
1
- import { NetworkError, ServiceError } from '../errors.js';
1
+ import { NetworkError } from '../errors.js';
2
2
  import { AuthProvider } from '../auth/auth.js';
3
- import { rstrip } from '../utils.js';
4
- import { GetAttributeValuesByFqnsResponse, Value } from './attributes.js';
3
+ import { extractRpcErrorMessage, getPlatformUrlFromKasEndpoint } from '../utils.js';
4
+ import { PlatformClient } from '../platform.js';
5
+ import { Value } from './attributes.js';
6
+ import { GetAttributeValuesByFqnsResponse } from '../platform/policy/attributes/attributes_pb.js';
5
7
 
8
+ // TODO KAS: go over web-sdk and remove policyEndpoint that is only defined to be used here
6
9
  export async function attributeFQNsAsValues(
7
- kasUrl: string,
10
+ platformUrl: string,
8
11
  authProvider: AuthProvider,
9
12
  ...fqns: string[]
10
13
  ): Promise<Value[]> {
11
- const avs = new URLSearchParams();
12
- for (const fqn of fqns) {
13
- avs.append('fqns', fqn);
14
- }
15
- avs.append('withValue.withKeyAccessGrants', 'true');
16
- avs.append('withValue.withAttribute.withKeyAccessGrants', 'true');
17
- const uNoSlash = rstrip(kasUrl, '/');
18
- const uNoKas = uNoSlash.endsWith('/kas') ? uNoSlash.slice(0, -4) : uNoSlash;
19
- const url = `${uNoKas}/attributes/*/fqn?${avs}`;
20
- const req = await authProvider.withCreds({
21
- url,
22
- headers: {},
23
- method: 'GET',
24
- });
25
- let response: Response;
26
- try {
27
- response = await fetch(req.url, {
28
- mode: 'cors',
29
- credentials: 'same-origin',
30
- headers: req.headers,
31
- redirect: 'follow',
32
- referrerPolicy: 'no-referrer',
33
- });
34
- } catch (e) {
35
- throw new NetworkError(`network error [${req.method} ${req.url}]`, e);
36
- }
14
+ platformUrl = getPlatformUrlFromKasEndpoint(platformUrl);
15
+ const platform = new PlatformClient({ authProvider, platformUrl });
37
16
 
38
- if (!response.ok) {
39
- throw new ServiceError(`${req.method} ${req.url} => ${response.status} ${response.statusText}`);
40
- }
41
-
42
- let resp: GetAttributeValuesByFqnsResponse;
17
+ let response: GetAttributeValuesByFqnsResponse;
43
18
  try {
44
- resp = (await response.json()) as GetAttributeValuesByFqnsResponse;
19
+ response = await platform.v1.attributes.getAttributeValuesByFqns({
20
+ fqns,
21
+ withValue: {
22
+ withKeyAccessGrants: true,
23
+ withAttribute: {
24
+ withKeyAccessGrants: true,
25
+ },
26
+ },
27
+ });
45
28
  } catch (e) {
46
- throw new ServiceError(`response parse error [${req.method} ${req.url}]`, e);
29
+ throw new NetworkError(
30
+ `[${platformUrl}] [GetAttributeValuesByFqns] ${extractRpcErrorMessage(e)}`
31
+ );
47
32
  }
48
33
 
49
34
  const values: Value[] = [];
50
- for (const [fqn, av] of Object.entries(resp.fqnAttributeValues)) {
51
- if (!av.value) {
35
+ for (const [fqn, av] of Object.entries(response.fqnAttributeValues)) {
36
+ const value = av.value;
37
+ if (!value) {
52
38
  console.log(`Missing value definition for [${fqn}]; is this a valid attribute?`);
53
39
  continue;
54
40
  }
55
- if (av.attribute && !av.value.attribute) {
56
- av.value.attribute = av.attribute;
41
+ if (value && av.attribute && !value?.attribute) {
42
+ value.attribute = av.attribute;
57
43
  }
58
- values.push(av.value);
44
+
45
+ values.push(value);
59
46
  }
60
47
  return values;
61
48
  }
@@ -1,117 +1,21 @@
1
- export type Metadata = {
2
- /**
3
- * created_at set by server (entity who created will recorded in an audit event)
4
- * Format: date-time
5
- */
6
- createdAt?: string;
7
-
8
- /**
9
- * updated_at set by server (entity who updated will recorded in an audit event)
10
- * Format: date-time
11
- */
12
- updatedAt?: string;
13
-
14
- /** optional short description */
15
- labels?: Record<string, string>;
16
- };
17
-
18
- export type KasPublicKeyAlgorithm =
19
- | 'KAS_PUBLIC_KEY_ALG_ENUM_UNSPECIFIED'
20
- | 'KAS_PUBLIC_KEY_ALG_ENUM_RSA_2048'
21
- | 'KAS_PUBLIC_KEY_ALG_ENUM_EC_SECP256R1';
22
-
23
- export type KasPublicKey = {
24
- /** x509 ASN.1 content in PEM envelope, usually */
25
- pem: string;
26
- /** A unique string identifier for this key */
27
- kid: string;
28
- /**
29
- * @description A known algorithm type with any additional parameters encoded.
30
- * To start, these may be `rsa:2048` for encrypting ZTDF files and
31
- * `ec:secp256r1` for nanoTDF, but more formats may be added as needed.
32
- */
33
- alg: KasPublicKeyAlgorithm;
34
- };
1
+ import { GetAttributeValuesByFqnsResponse } from '../platform/policy/attributes/attributes_pb.js';
2
+ import { AttributeRuleTypeEnum } from '../platform/policy/objects_pb.js';
35
3
 
4
+ export type KasPublicKey = Value['kasKeys'][number];
5
+ export type Value = NonNullable<
6
+ GetAttributeValuesByFqnsResponse['fqnAttributeValues'][string]['value']
7
+ >;
36
8
  export type KasPublicKeySet = {
37
9
  keys: KasPublicKey[];
38
10
  };
39
11
 
40
- export type PublicKey = {
41
- /** kas public key url - optional since can also be retrieved via public key */
42
- remote?: string;
43
- /** public key; PEM of RSA public key; prefer `cached` */
44
- local?: string;
45
- /** public key with additional information. Current preferred version */
46
- cached?: KasPublicKeySet;
47
- };
48
-
49
- export type KeyAccessServer = {
50
- id?: string;
51
- /** Address of a KAS instance */
52
- uri: string;
53
- publicKey?: PublicKey;
54
- metadata?: Metadata;
55
- };
56
-
57
- export type Namespace = {
58
- /** uuid */
59
- id?: string;
60
- /** used to partition Attribute Definitions, support by namespace AuthN and enable federation */
61
- name?: string;
62
- fqn: string;
63
- /** active by default until explicitly deactivated */
64
- active?: boolean;
65
- metadata?: Metadata;
66
- grants?: KeyAccessServer[];
67
- };
68
-
69
- export type AttributeRuleType =
70
- | 'ATTRIBUTE_RULE_TYPE_ENUM_UNSPECIFIED'
71
- | 'ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF'
72
- | 'ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF'
73
- | 'ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY';
74
-
75
- export type Attribute = {
76
- /** UUID */
77
- id?: string;
78
- namespace?: Namespace;
79
- /** attribute name */
80
- name?: string;
81
- /** attribute rule enum */
82
- rule?: AttributeRuleType;
83
- values?: Value[];
84
- grants?: KeyAccessServer[];
85
- fqn: string;
86
- /** active by default until explicitly deactivated */
87
- active?: boolean;
88
- /** Common metadata */
89
- metadata?: Metadata;
90
- };
91
-
92
- // This is not currently needed by the client, but may be returned.
93
- // Setting it to unknown to allow it to be ignored for now.
94
- export type SubjectMapping = unknown;
95
-
96
- export type Value = {
97
- id?: string;
98
- attribute?: Attribute;
99
- value?: string;
100
- /** list of key access servers */
101
- grants?: KeyAccessServer[];
102
- fqn: string;
103
- /** active by default until explicitly deactivated */
104
- active?: boolean;
105
- subjectMappings?: SubjectMapping[];
106
- /** Common metadata */
107
- metadata?: Metadata;
108
- };
109
-
12
+ export type Metadata = Value['metadata'];
13
+ export type KeyAccessServer = Value['grants'][number];
14
+ export type Attribute = Value['attribute'];
15
+ export type SubjectMapping = Value['subjectMappings'][number];
16
+ export type Namespace = NonNullable<Value['attribute']>['namespace'];
110
17
  export type AttributeAndValue = {
111
18
  attribute: Attribute;
112
19
  value: Value;
113
20
  };
114
-
115
- export type GetAttributeValuesByFqnsResponse = {
116
- fqnAttributeValues: Record<string, AttributeAndValue>;
117
- };
21
+ export { AttributeRuleTypeEnum as AttributeRuleType };
@@ -36,17 +36,16 @@ type ComplexBooleanClause = {
36
36
  };
37
37
 
38
38
  export function booleanOperatorFor(rule?: AttributeRuleType): BooleanOperator {
39
- if (!rule) {
40
- return 'allOf';
41
- }
42
39
  switch (rule) {
43
- case 'ATTRIBUTE_RULE_TYPE_ENUM_UNSPECIFIED':
44
- case 'ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF':
40
+ case AttributeRuleType.UNSPECIFIED:
41
+ case AttributeRuleType.ALL_OF:
45
42
  return 'allOf';
46
- case 'ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF':
43
+ case AttributeRuleType.ANY_OF:
47
44
  return 'anyOf';
48
- case 'ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY':
45
+ case AttributeRuleType.HIERARCHY:
49
46
  return 'hierarchy';
47
+ default:
48
+ return 'allOf';
50
49
  }
51
50
  }
52
51
 
@@ -114,7 +113,7 @@ export function plan(dataAttrs: Value[]): KeySplitStep[] {
114
113
  });
115
114
  }
116
115
  }
117
- const op = booleanOperatorFor(attrClause.def.rule);
116
+ const op = booleanOperatorFor(attrClause.def?.rule);
118
117
  kcs.push({
119
118
  op,
120
119
  children: ccv,
package/src/utils.ts CHANGED
@@ -3,6 +3,7 @@ import { exportSPKI, importX509 } from 'jose';
3
3
  import { base64 } from './encodings/index.js';
4
4
  import { pemCertToCrypto, pemPublicToCrypto } from './nanotdf-crypto/pemPublicToCrypto.js';
5
5
  import { ConfigurationError } from './errors.js';
6
+ import { ConnectError } from '@connectrpc/connect';
6
7
 
7
8
  /**
8
9
  * Check to see if the given URL is 'secure'. This assumes:
@@ -139,3 +140,32 @@ export async function extractPemFromKeyString(keyString: string): Promise<string
139
140
 
140
141
  return pem;
141
142
  }
143
+
144
+ /**
145
+ * Extracts the error message from an RPC catch error.
146
+ */
147
+ export function extractRpcErrorMessage(error: unknown): string {
148
+ if (error instanceof ConnectError || error instanceof Error) {
149
+ return error.message;
150
+ }
151
+ return 'Unknown network error occurred';
152
+ }
153
+
154
+ /**
155
+ * Converts a KAS endpoint URL to a platform URL.
156
+ * If the KAS endpoint ends with '/kas', it returns the host url
157
+ * Otherwise, it returns the original KAS endpoint.
158
+ */
159
+ export function getPlatformUrlFromKasEndpoint(endpoint: string): string {
160
+ let result = endpoint || '';
161
+ if (result.endsWith('/')) {
162
+ result = rstrip(result, '/');
163
+ }
164
+ if (result.endsWith('/v2/rewrap')) {
165
+ result = result.slice(0, -10);
166
+ }
167
+ if (result.endsWith('/kas')) {
168
+ result = result.slice(0, -4);
169
+ }
170
+ return result;
171
+ }
package/src/version.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Exposes the released version number of the `@opentdf/sdk` package
3
3
  */
4
- export const version = '0.3.0';
4
+ export const version = '0.3.2'; // x-release-please-version
5
5
 
6
6
  /**
7
7
  * A string name used to label requests as coming from this library client.
@@ -161,7 +161,7 @@ export async function verify(
161
161
  export async function CreateAssertion(
162
162
  aggregateHash: Uint8Array | string,
163
163
  assertionConfig: AssertionConfig,
164
- tdfSpecVersion?: string
164
+ targetVersion?: string
165
165
  ): Promise<Assertion> {
166
166
  if (!assertionConfig.signingKey) {
167
167
  throw new ConfigurationError('Assertion signing key is required');
@@ -179,7 +179,7 @@ export async function CreateAssertion(
179
179
 
180
180
  const assertionHash = await hash(a);
181
181
  let encodedHash: string;
182
- switch (tdfSpecVersion || '4.3.0') {
182
+ switch (targetVersion || '4.3.0') {
183
183
  case '4.2.2':
184
184
  if (typeof aggregateHash !== 'string') {
185
185
  throw new ConfigurationError('Aggregate hash must be a string for TDF spec version 4.2.2');
@@ -189,7 +189,7 @@ export async function CreateAssertion(
189
189
  case '4.3.0':
190
190
  if (typeof aggregateHash === 'string') {
191
191
  throw new ConfigurationError(
192
- 'Aggregate hash must be a typed array for TDF spec version 4.2.2'
192
+ 'Aggregate hash must be a typed array for TDF spec version 4.3.0'
193
193
  );
194
194
  }
195
195
  const combinedHash = concatenateUint8Arrays(
@@ -199,7 +199,7 @@ export async function CreateAssertion(
199
199
  encodedHash = base64.encodeArrayBuffer(combinedHash);
200
200
  break;
201
201
  default:
202
- throw new ConfigurationError(`Unsupported TDF spec version: ${tdfSpecVersion}`);
202
+ throw new ConfigurationError(`Unsupported TDF spec version: [${targetVersion}]`);
203
203
  }
204
204
 
205
205
  return await sign(a, assertionHash, encodedHash, assertionConfig.signingKey);