@opentdf/sdk 0.3.1 → 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 (219) 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 +42 -8
  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/client/index.js +23 -18
  37. package/dist/cjs/tdf3/src/tdf.js +5 -5
  38. package/dist/types/src/access/access-fetch.d.ts +21 -0
  39. package/dist/types/src/access/access-fetch.d.ts.map +1 -0
  40. package/dist/types/src/access/access-rpc.d.ts +22 -0
  41. package/dist/types/src/access/access-rpc.d.ts.map +1 -0
  42. package/dist/types/src/access.d.ts +19 -11
  43. package/dist/types/src/access.d.ts.map +1 -1
  44. package/dist/types/src/nanotdf/Client.d.ts +3 -1
  45. package/dist/types/src/nanotdf/Client.d.ts.map +1 -1
  46. package/dist/types/src/opentdf.d.ts +5 -1
  47. package/dist/types/src/opentdf.d.ts.map +1 -1
  48. package/dist/types/src/platform/authorization/authorization_pb.d.ts +609 -0
  49. package/dist/types/src/platform/authorization/authorization_pb.d.ts.map +1 -0
  50. package/dist/types/src/platform/buf/validate/validate_pb.d.ts +4466 -0
  51. package/dist/types/src/platform/buf/validate/validate_pb.d.ts.map +1 -0
  52. package/dist/types/src/platform/common/common_pb.d.ts +112 -0
  53. package/dist/types/src/platform/common/common_pb.d.ts.map +1 -0
  54. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts +199 -0
  55. package/dist/types/src/platform/entityresolution/entity_resolution_pb.d.ts.map +1 -0
  56. package/dist/types/src/platform/google/api/annotations_pb.d.ts +14 -0
  57. package/dist/types/src/platform/google/api/annotations_pb.d.ts.map +1 -0
  58. package/dist/types/src/platform/google/api/http_pb.d.ts +441 -0
  59. package/dist/types/src/platform/google/api/http_pb.d.ts.map +1 -0
  60. package/dist/types/src/platform/kas/kas_pb.d.ts +404 -0
  61. package/dist/types/src/platform/kas/kas_pb.d.ts.map +1 -0
  62. package/dist/types/src/platform/policy/actions/actions_pb.d.ts +265 -0
  63. package/dist/types/src/platform/policy/actions/actions_pb.d.ts.map +1 -0
  64. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts +1022 -0
  65. package/dist/types/src/platform/policy/attributes/attributes_pb.d.ts.map +1 -0
  66. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +1306 -0
  67. package/dist/types/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts.map +1 -0
  68. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts +269 -0
  69. package/dist/types/src/platform/policy/keymanagement/key_management_pb.d.ts.map +1 -0
  70. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts +448 -0
  71. package/dist/types/src/platform/policy/namespaces/namespaces_pb.d.ts.map +1 -0
  72. package/dist/types/src/platform/policy/objects_pb.d.ts +1112 -0
  73. package/dist/types/src/platform/policy/objects_pb.d.ts.map +1 -0
  74. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts +539 -0
  75. package/dist/types/src/platform/policy/registeredresources/registered_resources_pb.d.ts.map +1 -0
  76. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +558 -0
  77. package/dist/types/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts.map +1 -0
  78. package/dist/types/src/platform/policy/selectors_pb.d.ts +221 -0
  79. package/dist/types/src/platform/policy/selectors_pb.d.ts.map +1 -0
  80. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +582 -0
  81. package/dist/types/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts.map +1 -0
  82. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts +513 -0
  83. package/dist/types/src/platform/policy/unsafe/unsafe_pb.d.ts.map +1 -0
  84. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts +62 -0
  85. package/dist/types/src/platform/protoc-gen-openapiv2/options/annotations_pb.d.ts.map +1 -0
  86. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts +1441 -0
  87. package/dist/types/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.d.ts.map +1 -0
  88. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +59 -0
  89. package/dist/types/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts.map +1 -0
  90. package/dist/types/src/platform.d.ts +49 -0
  91. package/dist/types/src/platform.d.ts.map +1 -0
  92. package/dist/types/src/policy/api.d.ts +1 -1
  93. package/dist/types/src/policy/api.d.ts.map +1 -1
  94. package/dist/types/src/policy/attributes.d.ts +10 -87
  95. package/dist/types/src/policy/attributes.d.ts.map +1 -1
  96. package/dist/types/src/policy/granter.d.ts.map +1 -1
  97. package/dist/types/src/utils.d.ts +10 -0
  98. package/dist/types/src/utils.d.ts.map +1 -1
  99. package/dist/types/src/version.d.ts +1 -1
  100. package/dist/types/tdf3/src/client/index.d.ts +8 -3
  101. package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
  102. package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
  103. package/dist/web/src/access/access-fetch.js +150 -0
  104. package/dist/web/src/access/access-rpc.js +125 -0
  105. package/dist/web/src/access.js +82 -110
  106. package/dist/web/src/auth/oidc.js +2 -2
  107. package/dist/web/src/nanotdf/Client.js +18 -14
  108. package/dist/web/src/nanotdf/models/Header.js +2 -2
  109. package/dist/web/src/nanotdf-crypto/keyAgreement.js +2 -2
  110. package/dist/web/src/opentdf.js +43 -9
  111. package/dist/web/src/platform/authorization/authorization_pb.js +135 -0
  112. package/dist/web/src/platform/buf/validate/validate_pb.js +407 -0
  113. package/dist/web/src/platform/common/common_pb.js +76 -0
  114. package/dist/web/src/platform/entityresolution/entity_resolution_pb.js +46 -0
  115. package/dist/web/src/platform/google/api/annotations_pb.js +27 -0
  116. package/dist/web/src/platform/google/api/http_pb.js +34 -0
  117. package/dist/web/src/platform/kas/kas_pb.js +93 -0
  118. package/dist/web/src/platform/policy/actions/actions_pb.js +67 -0
  119. package/dist/web/src/platform/policy/attributes/attributes_pb.js +237 -0
  120. package/dist/web/src/platform/policy/kasregistry/key_access_server_registry_pb.js +233 -0
  121. package/dist/web/src/platform/policy/keymanagement/key_management_pb.js +67 -0
  122. package/dist/web/src/platform/policy/namespaces/namespaces_pb.js +118 -0
  123. package/dist/web/src/platform/policy/objects_pb.js +392 -0
  124. package/dist/web/src/platform/policy/registeredresources/registered_resources_pb.js +129 -0
  125. package/dist/web/src/platform/policy/resourcemapping/resource_mapping_pb.js +136 -0
  126. package/dist/web/src/platform/policy/selectors_pb.js +64 -0
  127. package/dist/web/src/platform/policy/subjectmapping/subject_mapping_pb.js +143 -0
  128. package/dist/web/src/platform/policy/unsafe/unsafe_pb.js +121 -0
  129. package/dist/web/src/platform/protoc-gen-openapiv2/options/annotations_pb.js +65 -0
  130. package/dist/web/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.js +304 -0
  131. package/dist/web/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +30 -0
  132. package/dist/web/src/platform.js +87 -0
  133. package/dist/web/src/policy/api.js +23 -40
  134. package/dist/web/src/policy/attributes.js +3 -2
  135. package/dist/web/src/policy/granter.js +9 -9
  136. package/dist/web/src/utils.js +29 -1
  137. package/dist/web/src/version.js +2 -2
  138. package/dist/web/tdf3/src/client/index.js +25 -20
  139. package/dist/web/tdf3/src/tdf.js +5 -5
  140. package/package.json +17 -1
  141. package/src/access/access-fetch.ts +202 -0
  142. package/src/access/access-rpc.ts +175 -0
  143. package/src/access.ts +113 -138
  144. package/src/auth/oidc.ts +1 -1
  145. package/src/nanotdf/Client.ts +28 -18
  146. package/src/nanotdf/models/Header.ts +1 -1
  147. package/src/nanotdf-crypto/keyAgreement.ts +1 -1
  148. package/src/opentdf.ts +66 -10
  149. package/src/platform/authorization/authorization_pb.ts +689 -0
  150. package/src/platform/buf/validate/validate_pb.ts +4626 -0
  151. package/src/platform/common/common_pb.ts +135 -0
  152. package/src/platform/entityresolution/entity_resolution_pb.ts +233 -0
  153. package/src/platform/google/api/annotations_pb.ts +39 -0
  154. package/src/platform/google/api/http_pb.ts +474 -0
  155. package/src/platform/kas/kas_pb.ts +484 -0
  156. package/src/platform/policy/actions/actions_pb.ts +312 -0
  157. package/src/platform/policy/attributes/attributes_pb.ts +1181 -0
  158. package/src/platform/policy/kasregistry/key_access_server_registry_pb.ts +1482 -0
  159. package/src/platform/policy/keymanagement/key_management_pb.ts +316 -0
  160. package/src/platform/policy/namespaces/namespaces_pb.ts +528 -0
  161. package/src/platform/policy/objects_pb.ts +1319 -0
  162. package/src/platform/policy/registeredresources/registered_resources_pb.ts +623 -0
  163. package/src/platform/policy/resourcemapping/resource_mapping_pb.ts +658 -0
  164. package/src/platform/policy/selectors_pb.ts +277 -0
  165. package/src/platform/policy/subjectmapping/subject_mapping_pb.ts +687 -0
  166. package/src/platform/policy/unsafe/unsafe_pb.ts +593 -0
  167. package/src/platform/protoc-gen-openapiv2/options/annotations_pb.ts +83 -0
  168. package/src/platform/protoc-gen-openapiv2/options/openapiv2_pb.ts +1615 -0
  169. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.ts +78 -0
  170. package/src/platform.ts +122 -0
  171. package/src/policy/api.ts +29 -42
  172. package/src/policy/attributes.ts +12 -108
  173. package/src/policy/granter.ts +7 -8
  174. package/src/utils.ts +30 -0
  175. package/src/version.ts +1 -1
  176. package/tdf3/src/client/index.ts +40 -19
  177. package/tdf3/src/tdf.ts +5 -6
  178. package/src/platform/authorization/authorization_connect.d.ts +0 -44
  179. package/src/platform/authorization/authorization_connect.js +0 -44
  180. package/src/platform/authorization/authorization_pb.d.ts +0 -707
  181. package/src/platform/authorization/authorization_pb.js +0 -372
  182. package/src/platform/common/common_pb.d.ts +0 -129
  183. package/src/platform/common/common_pb.js +0 -58
  184. package/src/platform/entityresolution/entity_resolution_connect.d.ts +0 -35
  185. package/src/platform/entityresolution/entity_resolution_connect.js +0 -35
  186. package/src/platform/entityresolution/entity_resolution_pb.d.ts +0 -242
  187. package/src/platform/entityresolution/entity_resolution_pb.js +0 -139
  188. package/src/platform/kas/kas_connect.d.ts +0 -59
  189. package/src/platform/kas/kas_connect.js +0 -59
  190. package/src/platform/kas/kas_pb.d.ts +0 -200
  191. package/src/platform/kas/kas_pb.js +0 -84
  192. package/src/platform/policy/attributes/attributes_connect.d.ts +0 -168
  193. package/src/platform/policy/attributes/attributes_connect.js +0 -168
  194. package/src/platform/policy/attributes/attributes_pb.d.ts +0 -929
  195. package/src/platform/policy/attributes/attributes_pb.js +0 -363
  196. package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +0 -62
  197. package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +0 -62
  198. package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +0 -283
  199. package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +0 -113
  200. package/src/platform/policy/namespaces/namespaces_connect.d.ts +0 -62
  201. package/src/platform/policy/namespaces/namespaces_connect.js +0 -62
  202. package/src/platform/policy/namespaces/namespaces_pb.d.ts +0 -270
  203. package/src/platform/policy/namespaces/namespaces_pb.js +0 -110
  204. package/src/platform/policy/objects_pb.d.ts +0 -725
  205. package/src/platform/policy/objects_pb.js +0 -288
  206. package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +0 -259
  207. package/src/platform/policy/resourcemapping/resource_mapping_connect.js +0 -259
  208. package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +0 -314
  209. package/src/platform/policy/resourcemapping/resource_mapping_pb.js +0 -142
  210. package/src/platform/policy/selectors_pb.d.ts +0 -269
  211. package/src/platform/policy/selectors_pb.js +0 -110
  212. package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +0 -118
  213. package/src/platform/policy/subjectmapping/subject_mapping_connect.js +0 -118
  214. package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +0 -672
  215. package/src/platform/policy/subjectmapping/subject_mapping_pb.js +0 -260
  216. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +0 -26
  217. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +0 -26
  218. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +0 -75
  219. 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.1';
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.
@@ -19,7 +19,12 @@ import { OIDCRefreshTokenProvider } from '../../../src/auth/oidc-refreshtoken-pr
19
19
  import { OIDCExternalJwtProvider } from '../../../src/auth/oidc-externaljwt-provider.js';
20
20
  import { CryptoService } from '../crypto/declarations.js';
21
21
  import { type AuthProvider, HttpRequest, withHeaders } from '../../../src/auth/auth.js';
22
- import { pemToCryptoPublicKey, rstrip, validateSecureUrl } from '../../../src/utils.js';
22
+ import {
23
+ getPlatformUrlFromKasEndpoint,
24
+ pemToCryptoPublicKey,
25
+ rstrip,
26
+ validateSecureUrl,
27
+ } from '../../../src/utils.js';
23
28
 
24
29
  import {
25
30
  type EncryptParams,
@@ -39,6 +44,7 @@ import {
39
44
  EncryptParamsBuilder,
40
45
  } from './builders.js';
41
46
  import {
47
+ fetchKeyAccessServers,
42
48
  type KasPublicKeyInfo,
43
49
  keyAlgorithmToPublicKeyAlgorithm,
44
50
  OriginAllowList,
@@ -73,7 +79,7 @@ export const resolveKasInfo = async (
73
79
  kid?: string
74
80
  ): Promise<KasPublicKeyInfo> => {
75
81
  const k: CryptoKey = await pemToCryptoPublicKey(pem);
76
- const algorithm = keyAlgorithmToPublicKeyAlgorithm(k.algorithm);
82
+ const algorithm = keyAlgorithmToPublicKeyAlgorithm(k);
77
83
  return {
78
84
  key: Promise.resolve(k),
79
85
  publicKey: pem,
@@ -125,7 +131,7 @@ export interface ClientConfig {
125
131
  clientId?: string;
126
132
  dpopEnabled?: boolean;
127
133
  dpopKeys?: Promise<CryptoKeyPair>;
128
- kasEndpoint?: string;
134
+ kasEndpoint: string;
129
135
  /**
130
136
  * Service to use to look up ABAC. Used during autoconfigure. Defaults to
131
137
  * kasEndpoint without the trailing `/kas` path segment, if present.
@@ -133,9 +139,11 @@ export interface ClientConfig {
133
139
  policyEndpoint?: string;
134
140
  /**
135
141
  * List of allowed KASes to connect to for rewrap requests.
136
- * Defaults to `[kasEndpoint]`.
142
+ * Defaults to `[]`.
137
143
  */
138
144
  allowedKases?: string[];
145
+ // Platform URL to use to lookup allowed KASes when allowedKases is empty
146
+ platformUrl?: string;
139
147
  ignoreAllowList?: boolean;
140
148
  easEndpoint?: string;
141
149
  // DEPRECATED Ignored
@@ -237,7 +245,12 @@ export class Client {
237
245
  * List of allowed KASes to connect to for rewrap requests.
238
246
  * Defaults to `[this.kasEndpoint]`.
239
247
  */
240
- readonly allowedKases: OriginAllowList;
248
+ readonly allowedKases?: OriginAllowList;
249
+
250
+ /**
251
+ * URL of the platform, required to fetch list of allowed KASes when allowedKases is empty
252
+ */
253
+ readonly platformUrl?: string;
241
254
 
242
255
  readonly kasKeys: Record<string, Promise<KasPublicKeyInfo>[]> = {};
243
256
 
@@ -287,10 +300,17 @@ export class Client {
287
300
  this.kasEndpoint = clientConfig.keyRewrapEndpoint.replace(/\/rewrap$/, '');
288
301
  }
289
302
  this.kasEndpoint = rstrip(this.kasEndpoint, '/');
303
+
304
+ if (!validateSecureUrl(this.kasEndpoint)) {
305
+ throw new ConfigurationError(`Invalid KAS endpoint [${this.kasEndpoint}]`);
306
+ }
307
+
308
+ if (config.platformUrl) {
309
+ this.platformUrl = config.platformUrl;
310
+ }
311
+
290
312
  if (clientConfig.policyEndpoint) {
291
- this.policyEndpoint = rstrip(clientConfig.policyEndpoint, '/');
292
- } else if (this.kasEndpoint.endsWith('/kas')) {
293
- this.policyEndpoint = this.kasEndpoint.slice(0, -4);
313
+ this.policyEndpoint = getPlatformUrlFromKasEndpoint(clientConfig.policyEndpoint);
294
314
  }
295
315
 
296
316
  const kasOrigin = new URL(this.kasEndpoint).origin;
@@ -299,16 +319,12 @@ export class Client {
299
319
  clientConfig.allowedKases,
300
320
  !!clientConfig.ignoreAllowList
301
321
  );
302
- if (!validateSecureUrl(this.kasEndpoint) && !this.allowedKases.allows(kasOrigin)) {
303
- throw new ConfigurationError(`Invalid KAS endpoint [${this.kasEndpoint}]`);
304
- }
305
- } else {
306
- if (!validateSecureUrl(this.kasEndpoint)) {
322
+ if (!this.allowedKases.allows(kasOrigin)) {
323
+ // TODO PR: ask if in this cases it makes more sense to add defaultKASEndpoint to the allow list if the allowList is not empty but doesn't have the defaultKas
307
324
  throw new ConfigurationError(
308
- `Invalid KAS endpoint [${this.kasEndpoint}]; to force, please list it among allowedKases`
325
+ `Invalid KAS endpoint [${this.kasEndpoint}]. When allowedKases is set, defaultKASEndpoint needs to be in the allow list`
309
326
  );
310
327
  }
311
- this.allowedKases = new OriginAllowList([kasOrigin], !!clientConfig.ignoreAllowList);
312
328
  }
313
329
 
314
330
  this.authProvider = config.authProvider;
@@ -382,7 +398,7 @@ export class Client {
382
398
  keyMiddleware = defaultKeyMiddleware,
383
399
  streamMiddleware = async (stream: DecoratedReadableStream) => stream,
384
400
  tdfSpecVersion,
385
- wrappingKeyAlgorithm = 'rsa:2048',
401
+ wrappingKeyAlgorithm,
386
402
  } = opts;
387
403
  const scope = opts.scope ?? { attributes: [], dissem: [] };
388
404
 
@@ -427,8 +443,9 @@ export class Client {
427
443
  const detailedPlan = plan(avs);
428
444
  splitPlan = detailedPlan.map((kat) => {
429
445
  const { kas, sid } = kat;
430
- if (kas?.publicKey?.cached?.keys && !(kas.uri in this.kasKeys)) {
431
- const keys = kas.publicKey.cached.keys;
446
+ const pubKey = kas.publicKey?.publicKey;
447
+ if (pubKey?.case === 'cached' && pubKey.value.keys && !(kas.uri in this.kasKeys)) {
448
+ const keys = pubKey.value.keys;
432
449
  if (keys?.length) {
433
450
  this.kasKeys[kas.uri] = keys.map((key) => resolveKasInfo(key.pem, kas.uri, key.kid));
434
451
  }
@@ -531,8 +548,12 @@ export class Client {
531
548
  throw new ConfigurationError('AuthProvider missing');
532
549
  }
533
550
  const chunker = await makeChunkable(source);
534
- if (!allowList) {
551
+ if (!allowList && this.allowedKases) {
535
552
  allowList = this.allowedKases;
553
+ } else if (this.platformUrl) {
554
+ allowList = await fetchKeyAccessServers(this.platformUrl, this.authProvider);
555
+ } else {
556
+ throw new ConfigurationError('platformUrl is required when allowedKases is empty');
536
557
  }
537
558
 
538
559
  // Await in order to catch any errors from this call.