@virtru/dsp-sdk 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/README.md +81 -3
  3. package/dist/src/fips.d.ts +7 -0
  4. package/dist/src/fips.js +12 -0
  5. package/dist/src/lib/dsp.d.ts +17 -1
  6. package/dist/src/lib/dsp.js +28 -5
  7. package/package.json +25 -4
  8. package/.prettierrc +0 -3
  9. package/.rush/temp/chunked-rush-logs/dsp-sdk._phase_build.chunks.jsonl +0 -12
  10. package/.rush/temp/chunked-rush-logs/dsp-sdk._phase_test.chunks.jsonl +0 -383
  11. package/.rush/temp/package-deps__phase_build.json +0 -76
  12. package/.rush/temp/shrinkwrap-deps.json +0 -1262
  13. package/CHANGELOG.json +0 -299
  14. package/buf.gen.yaml +0 -17
  15. package/buf.yaml +0 -4
  16. package/config/jest.config.json +0 -6
  17. package/config/rig.json +0 -8
  18. package/dist/tests/dsp-client.test.d.ts +0 -1
  19. package/dist/tests/dsp-client.test.js +0 -73
  20. package/dist/tests/dsp.test.d.ts +0 -1
  21. package/dist/tests/dsp.test.js +0 -92
  22. package/dist/tests/fips-crypto.unit.test.d.ts +0 -1
  23. package/dist/tests/fips-crypto.unit.test.js +0 -258
  24. package/dist/tests/mocks/create-export-artifacts.d.ts +0 -2
  25. package/dist/tests/mocks/create-export-artifacts.js +0 -13
  26. package/dist/tests/mocks/tagging-pdp-tag.d.ts +0 -2
  27. package/dist/tests/mocks/tagging-pdp-tag.js +0 -11
  28. package/dist/tests/mocks/well-known-configuration.d.ts +0 -2
  29. package/dist/tests/mocks/well-known-configuration.js +0 -12
  30. package/dist/tests/setup-msw.d.ts +0 -9
  31. package/dist/tests/setup-msw.js +0 -30
  32. package/dist/tests/setup-unit.d.ts +0 -7
  33. package/dist/tests/setup-unit.js +0 -70
  34. package/eslint.config.mjs +0 -28
  35. package/lib-commonjs/src/gen/buf/validate/validate_pb.js +0 -487
  36. package/lib-commonjs/src/gen/config/v1/config_pb.js +0 -142
  37. package/lib-commonjs/src/gen/config/v1/kas_config_pb.js +0 -72
  38. package/lib-commonjs/src/gen/config/v1/meta_pb.js +0 -36
  39. package/lib-commonjs/src/gen/config/v1/outlook_config_pb.js +0 -67
  40. package/lib-commonjs/src/gen/config/v1/secureviewer_config_pb.js +0 -67
  41. package/lib-commonjs/src/gen/config/v1/tagging_pb.js +0 -246
  42. package/lib-commonjs/src/gen/google/api/annotations_pb.js +0 -33
  43. package/lib-commonjs/src/gen/google/api/http_pb.js +0 -44
  44. package/lib-commonjs/src/gen/policyimportexport/v1/policy_import_export_pb.js +0 -93
  45. package/lib-commonjs/src/gen/shared/v1/shared_pb.js +0 -95
  46. package/lib-commonjs/src/gen/tagging/pdp/v2/tagging_pb.js +0 -277
  47. package/lib-commonjs/src/gen/version/v1/version_pb.js +0 -40
  48. package/lib-commonjs/src/gen/virtru/common/common_pb.js +0 -76
  49. package/lib-commonjs/src/gen/virtru/policy/certificates/v1/certificates_pb.js +0 -77
  50. package/lib-commonjs/src/gen/virtru/policy/objects_pb.js +0 -143
  51. package/lib-commonjs/src/index.js +0 -48
  52. package/lib-commonjs/src/lib/client.js +0 -66
  53. package/lib-commonjs/src/lib/consts.js +0 -10
  54. package/lib-commonjs/src/lib/dsp.js +0 -49
  55. package/lib-commonjs/src/lib/fips-crypto/asymmetric.js +0 -126
  56. package/lib-commonjs/src/lib/fips-crypto/key-format.js +0 -243
  57. package/lib-commonjs/src/lib/fips-crypto/keys.js +0 -134
  58. package/lib-commonjs/src/lib/fips-crypto/primitives.js +0 -112
  59. package/lib-commonjs/src/lib/fips-crypto/symmetric.js +0 -162
  60. package/lib-commonjs/src/lib/fips-crypto-service.js +0 -57
  61. package/lib-commonjs/src/lib/utils.js +0 -401
  62. package/lib-commonjs/tests/dsp-client.test.js +0 -75
  63. package/lib-commonjs/tests/dsp.test.js +0 -94
  64. package/lib-commonjs/tests/fips-crypto.unit.test.js +0 -260
  65. package/lib-commonjs/tests/mocks/create-export-artifacts.js +0 -17
  66. package/lib-commonjs/tests/mocks/tagging-pdp-tag.js +0 -15
  67. package/lib-commonjs/tests/mocks/well-known-configuration.js +0 -16
  68. package/lib-commonjs/tests/setup-msw.js +0 -33
  69. package/lib-commonjs/tests/setup-unit.js +0 -72
  70. package/public/virtru.wasm +0 -0
  71. package/src/gen/buf/validate/validate_pb.ts +0 -4879
  72. package/src/gen/config/formatters/testdata/v1/test_pb.ts +0 -287
  73. package/src/gen/config/v1/config_connect.ts +0 -111
  74. package/src/gen/config/v1/config_pb.ts +0 -439
  75. package/src/gen/config/v1/kas_config_pb.ts +0 -183
  76. package/src/gen/config/v1/meta_pb.ts +0 -72
  77. package/src/gen/config/v1/outlook_config_pb.ts +0 -242
  78. package/src/gen/config/v1/secureviewer_config_pb.ts +0 -161
  79. package/src/gen/config/v1/tagging_pb.ts +0 -456
  80. package/src/gen/google/api/annotations_pb.ts +0 -43
  81. package/src/gen/google/api/http_pb.ts +0 -486
  82. package/src/gen/helloworld/v1/helloworld_connect.ts +0 -49
  83. package/src/gen/helloworld/v1/helloworld_pb.ts +0 -104
  84. package/src/gen/kas/nanotdf/v1/nanotdf_rewrap_connect.ts +0 -39
  85. package/src/gen/kas/nanotdf/v1/nanotdf_rewrap_pb.ts +0 -207
  86. package/src/gen/policyimportexport/v1/policy_import_export_connect.ts +0 -56
  87. package/src/gen/policyimportexport/v1/policy_import_export_pb.ts +0 -332
  88. package/src/gen/shared/v1/shared_connect.ts +0 -61
  89. package/src/gen/shared/v1/shared_pb.ts +0 -240
  90. package/src/gen/shared/v2/shared_connect.ts +0 -39
  91. package/src/gen/shared/v2/shared_pb.ts +0 -122
  92. package/src/gen/tagging/pdp/v2/externalprocessors/processor_connect.ts +0 -156
  93. package/src/gen/tagging/pdp/v2/externalprocessors/processor_pb.ts +0 -709
  94. package/src/gen/tagging/pdp/v2/stanag/stanag_pb.ts +0 -953
  95. package/src/gen/tagging/pdp/v2/tagging_connect.ts +0 -73
  96. package/src/gen/tagging/pdp/v2/tagging_pb.ts +0 -1064
  97. package/src/gen/version/v1/version_connect.ts +0 -31
  98. package/src/gen/version/v1/version_pb.ts +0 -143
  99. package/src/gen/virtru/common/common_pb.ts +0 -201
  100. package/src/gen/virtru/policy/certificates/v1/certificates_connect.ts +0 -44
  101. package/src/gen/virtru/policy/certificates/v1/certificates_pb.ts +0 -305
  102. package/src/gen/virtru/policy/objects_pb.ts +0 -253
  103. package/src/gen/web-admin/v1/config_connect.ts +0 -52
  104. package/src/gen/web-admin/v1/config_pb.ts +0 -173
  105. package/src/index.ts +0 -62
  106. package/src/lib/client.ts +0 -90
  107. package/src/lib/consts.ts +0 -8
  108. package/src/lib/dsp.ts +0 -65
  109. package/src/lib/fips-crypto/asymmetric.ts +0 -162
  110. package/src/lib/fips-crypto/key-format.ts +0 -287
  111. package/src/lib/fips-crypto/keys.ts +0 -190
  112. package/src/lib/fips-crypto/primitives.ts +0 -197
  113. package/src/lib/fips-crypto/symmetric.ts +0 -213
  114. package/src/lib/fips-crypto-service.ts +0 -58
  115. package/src/lib/utils.test.ts +0 -415
  116. package/src/lib/utils.ts +0 -525
  117. package/src/vite-env.d.ts +0 -7
  118. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -38
  119. package/temp/test/jest/haste-map-b055a9550e6d9f9b43d8ad29b1607278-49d19aee56a0732eca9c014a51272338-8710993d07b75a801b0956e67ffc46fa +0 -0
  120. package/tests/dsp-client.test.ts +0 -95
  121. package/tests/dsp.test.ts +0 -119
  122. package/tests/fips-crypto.unit.test.ts +0 -412
  123. package/tests/mocks/create-export-artifacts.ts +0 -16
  124. package/tests/mocks/tagging-pdp-tag.ts +0 -13
  125. package/tests/mocks/well-known-configuration.ts +0 -15
  126. package/tests/setup-msw.ts +0 -35
  127. package/tests/setup-unit.ts +0 -108
  128. package/tsconfig.json +0 -32
  129. package/update-protos.sh +0 -63
  130. package/vitest.config.ts +0 -48
package/CHANGELOG.json DELETED
@@ -1,299 +0,0 @@
1
- {
2
- "name": "@virtru/dsp-sdk",
3
- "entries": [
4
- {
5
- "version": "0.5.0",
6
- "tag": "@virtru/dsp-sdk_v0.5.0",
7
- "date": "Thu, 12 Mar 2026 16:58:37 GMT",
8
- "comments": {
9
- "minor": [
10
- {
11
- "comment": "add FipsCryptoService implementation",
12
- "author": "Elizabeth Healy <35498075+elizabethhealy@users.noreply.github.com>",
13
- "commit": "4c648dadd354ee4840048227dd4de8282948ae9a"
14
- }
15
- ],
16
- "none": [
17
- {
18
- "comment": "Replace npm run with rushx in package.json scripts",
19
- "author": "Paul Flynn <pflynn@virtru.com>",
20
- "commit": "8cadfd6a018691df41a880f028385f506e29eb82"
21
- }
22
- ]
23
- }
24
- },
25
- {
26
- "version": "0.4.1",
27
- "tag": "@virtru/dsp-sdk_v0.4.1",
28
- "date": "Tue, 03 Mar 2026 16:24:41 GMT",
29
- "comments": {
30
- "none": [
31
- {
32
- "comment": "Updated README to include NanoTDF decryption example",
33
- "author": "Aaron Hopper <aaron.hopper@virtru.com>",
34
- "commit": "ad26795e82e8020eec3f81b4f639e5d6614e730e"
35
- }
36
- ],
37
- "patch": [
38
- {
39
- "comment": "fix: move build tools (heft, heft-web-rig) from dependencies to devDependencies to remove vulnerable minimatch transitive dep for consumers",
40
- "author": "Paul Flynn <pflynn@virtru.com>",
41
- "commit": "d4c8af9f1af9401ccbb42ba47df74e3b96eb4045"
42
- }
43
- ]
44
- }
45
- },
46
- {
47
- "version": "0.4.0",
48
- "tag": "@virtru/dsp-sdk_v0.4.0",
49
- "date": "Tue, 24 Feb 2026 15:09:15 GMT",
50
- "comments": {
51
- "minor": [
52
- {
53
- "comment": "feat: add heft and rig configuration files for project setup",
54
- "author": "virtru-dubich <85224435+virtru-dubich@users.noreply.github.com>",
55
- "commit": "ac9f6949cf9b6b6969340c8cae351e92f16cf5a6"
56
- }
57
- ]
58
- }
59
- },
60
- {
61
- "version": "0.3.2",
62
- "tag": "@virtru/dsp-sdk_v0.3.2",
63
- "date": "Tue, 17 Feb 2026 17:33:08 GMT",
64
- "comments": {
65
- "patch": [
66
- {
67
- "comment": "Add update-proto script",
68
- "author": "Nick <79929408+ntrevino-virtru@users.noreply.github.com>",
69
- "commit": "6f94c2989ae42d107cbc614cc74d4ad67b871e25"
70
- }
71
- ]
72
- }
73
- },
74
- {
75
- "version": "0.3.1",
76
- "tag": "@virtru/dsp-sdk_v0.3.1",
77
- "date": "Thu, 29 Jan 2026 20:55:50 GMT",
78
- "comments": {
79
- "patch": [
80
- {
81
- "comment": "bump web-sdk",
82
- "author": "Dillon Thompson <dj.thompson715@gmail.com>",
83
- "commit": "151576eefb4b2ba12507246a991aa06b2f85f485"
84
- }
85
- ]
86
- }
87
- },
88
- {
89
- "version": "0.3.0",
90
- "tag": "@virtru/dsp-sdk_v0.3.0",
91
- "date": "Thu, 22 Jan 2026 21:04:08 GMT",
92
- "comments": {
93
- "minor": [
94
- {
95
- "comment": "Move assertions to DSP SDK",
96
- "author": "Paul Flynn <pflynn@virtru.com>",
97
- "commit": "53b3d7f0a3b0fb810c7b193278b736fc10b4a80c"
98
- }
99
- ]
100
- }
101
- },
102
- {
103
- "version": "0.2.4",
104
- "tag": "@virtru/dsp-sdk_v0.2.4",
105
- "date": "Thu, 22 Jan 2026 14:53:21 GMT",
106
- "comments": {
107
- "patch": [
108
- {
109
- "comment": "Fix: add vitest config to resolve .js imports to .ts files for Vite 5 compatibility",
110
- "author": "Paul Flynn <pflynn@virtru.com>",
111
- "commit": "fc12e7d4c123d3d5e627e1aff561d638cc6bcd0c"
112
- }
113
- ]
114
- }
115
- },
116
- {
117
- "version": "0.2.3",
118
- "tag": "@virtru/dsp-sdk_v0.2.3",
119
- "date": "Wed, 14 Jan 2026 21:32:11 GMT",
120
- "comments": {
121
- "patch": [
122
- {
123
- "comment": "Update @opentdf/sdk dependency",
124
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
125
- "commit": "6e37a9084749630870675ea12bf58b9ba290bef0"
126
- }
127
- ]
128
- }
129
- },
130
- {
131
- "version": "0.2.2",
132
- "tag": "@virtru/dsp-sdk_v0.2.2",
133
- "date": "Thu, 20 Nov 2025 15:03:47 GMT",
134
- "comments": {
135
- "patch": [
136
- {
137
- "comment": "Upgrade to support node 22",
138
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
139
- "commit": "40b0ce0977a40315dbe806864a41555df7a02170"
140
- }
141
- ]
142
- }
143
- },
144
- {
145
- "version": "0.2.1",
146
- "tag": "@virtru/dsp-sdk_v0.2.1",
147
- "date": "Thu, 13 Nov 2025 17:06:33 GMT",
148
- "comments": {
149
- "patch": [
150
- {
151
- "comment": "Add LICENSE file",
152
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
153
- "commit": "cf505ad5568c1fb85c9c131cffdbd5be248edb2c"
154
- }
155
- ]
156
- }
157
- },
158
- {
159
- "version": "0.2.0",
160
- "tag": "@virtru/dsp-sdk_v0.2.0",
161
- "date": "Wed, 05 Nov 2025 18:47:57 GMT",
162
- "comments": {
163
- "minor": [
164
- {
165
- "comment": "bump web-sdk for better obligation errors",
166
- "author": "Krish Suchak <42231639+alkalescent@users.noreply.github.com>",
167
- "commit": "c8cf11dc3903cf957dcab68bf4f585242af0f195"
168
- }
169
- ]
170
- }
171
- },
172
- {
173
- "version": "0.1.11",
174
- "tag": "@virtru/dsp-sdk_v0.1.11",
175
- "date": "Wed, 05 Nov 2025 17:52:35 GMT",
176
- "comments": {
177
- "patch": [
178
- {
179
- "comment": "Update Connect RPC gen client stubs",
180
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
181
- "commit": "96a5915fff56f4e1f58161d4bf2ed236a3bd0159"
182
- }
183
- ]
184
- }
185
- },
186
- {
187
- "version": "0.1.10",
188
- "tag": "@virtru/dsp-sdk_v0.1.10",
189
- "date": "Fri, 31 Oct 2025 19:39:15 GMT",
190
- "comments": {
191
- "patch": [
192
- {
193
- "comment": "Moved from @virtru-private/dsp-sdk",
194
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
195
- "commit": "f8c2642e17366f7f9499df19d0c8bd15bdc31680"
196
- }
197
- ]
198
- }
199
- },
200
- {
201
- "version": "0.1.9",
202
- "tag": "@virtru-private/dsp-sdk_v0.1.9",
203
- "date": "Tue, 28 Oct 2025 14:38:10 GMT",
204
- "comments": {
205
- "patch": [
206
- {
207
- "comment": "add license header",
208
- "author": "Scott Hamrick <2623452+cshamrick@users.noreply.github.com>",
209
- "commit": "22e408fe9ffd48061d622e7a9184abf3257f52a0"
210
- }
211
- ]
212
- }
213
- },
214
- {
215
- "version": "0.1.8",
216
- "tag": "@virtru-private/dsp-sdk_v0.1.8",
217
- "date": "Mon, 20 Oct 2025 20:07:25 GMT",
218
- "comments": {
219
- "patch": [
220
- {
221
- "comment": "re-export platform client generated stubs",
222
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
223
- "commit": "2439a19a28ff09131a88dd0531985ca2d3f2ae8e"
224
- }
225
- ]
226
- }
227
- },
228
- {
229
- "version": "0.1.7",
230
- "tag": "@virtru-private/dsp-sdk_v0.1.7",
231
- "date": "Fri, 17 Oct 2025 20:51:30 GMT",
232
- "comments": {
233
- "patch": [
234
- {
235
- "comment": "bump @opentdf/sdk to v0.5.0",
236
- "author": "Jake Van Vorhis <83739412+jakedoublev@users.noreply.github.com>",
237
- "commit": "259d4ab6e578c15d4d8985fc21ae4d5fd925e37c"
238
- }
239
- ]
240
- }
241
- },
242
- {
243
- "version": "0.1.6",
244
- "tag": "@virtru-private/dsp-sdk_v0.1.6",
245
- "date": "Fri, 26 Sep 2025 15:27:03 GMT",
246
- "comments": {
247
- "patch": [
248
- {
249
- "comment": "Fixes dsp-sdk client exported type inference",
250
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
251
- "commit": "dee75420c5bb30d06339fe4decb3c8abd75ca5dd"
252
- }
253
- ]
254
- }
255
- },
256
- {
257
- "version": "0.1.5",
258
- "tag": "@virtru-private/dsp-sdk_v0.1.5",
259
- "date": "Tue, 23 Sep 2025 19:37:57 GMT",
260
- "comments": {
261
- "patch": [
262
- {
263
- "comment": "Update DSP WebSDK to pass options.authProvider downstream",
264
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
265
- "commit": "9b02838ad5bf25d866889baaf8e6b333d163b8fa"
266
- }
267
- ]
268
- }
269
- },
270
- {
271
- "version": "0.1.4",
272
- "tag": "@virtru-private/dsp-sdk_v0.1.4",
273
- "date": "Fri, 12 Sep 2025 15:24:17 GMT",
274
- "comments": {
275
- "patch": [
276
- {
277
- "comment": "Export types from opentdf",
278
- "author": "Sara Tarnvik <54858371+stvik@users.noreply.github.com>",
279
- "commit": "b0e20f740cd6d1ddc1c7e8b084a6594097614ec0"
280
- }
281
- ]
282
- }
283
- },
284
- {
285
- "version": "0.1.3",
286
- "tag": "@virtru-private/dsp-sdk_v0.1.3",
287
- "date": "Thu, 11 Sep 2025 19:23:03 GMT",
288
- "comments": {
289
- "patch": [
290
- {
291
- "comment": "add DSP Web SDK as new monorepo project",
292
- "author": "Ryan Yanulites <ryanulites@virtru.com>",
293
- "commit": "fc0ab3e5529baebca2068f560a18b7464a6d2e5a"
294
- }
295
- ]
296
- }
297
- }
298
- ]
299
- }
package/buf.gen.yaml DELETED
@@ -1,17 +0,0 @@
1
- version: v2
2
- managed:
3
- enabled: true
4
- disable:
5
- - file_option: go_package
6
- module: buf.build/bufbuild/protovalidate
7
- - file_option: go_package
8
- module: buf.build/googleapis/googleapis
9
- plugins:
10
- - remote: buf.build/bufbuild/es:v2.3.0
11
- out: src/gen
12
- opt:
13
- - target=ts
14
- - remote: buf.build/connectrpc/es:v1.6.1
15
- out: src/gen
16
- opt:
17
- - target=ts
package/buf.yaml DELETED
@@ -1,4 +0,0 @@
1
- version: v2
2
- deps:
3
- - buf.build/bufbuild/protovalidate:v0.11.1
4
- - buf.build/googleapis/googleapis
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "@rushstack/heft-web-rig/profiles/library/config/jest.config.json",
3
- "roots": [],
4
- "testMatch": [],
5
- "passWithNoTests": true
6
- }
package/config/rig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- // The "rig.json" file directs tools to look for their config files in an external package.
3
- // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4
- "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5
-
6
- "rigPackageName": "@rushstack/heft-web-rig",
7
- "rigProfile": "library"
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
1
- /*
2
- * Copyright (c) Virtru Corporation. All rights reserved.
3
- *
4
- * Your use of this file is governed by the Virtu Terms of Service <https://www.virtru.com/terms-of-service/>.
5
- */
6
- import { expect, test, vi, beforeEach } from 'vitest';
7
- import { DSPClient } from '../src/index';
8
- import { mockTaggingPDPResponse } from './mocks/tagging-pdp-tag';
9
- import { mockCreateExportArtifactsResponse } from './mocks/create-export-artifacts';
10
- const platformUrl = 'https://dsp.example.com';
11
- // Mock fetch globally
12
- const mockFetch = vi.fn();
13
- global.fetch = mockFetch;
14
- beforeEach(() => {
15
- mockFetch.mockReset();
16
- // Setup default mock responses
17
- mockFetch.mockImplementation(async (url) => {
18
- if (url.includes('/tagging.pdp.v2.TaggingPDPService/Tag')) {
19
- return {
20
- ok: true,
21
- status: 200,
22
- json: async () => mockTaggingPDPResponse(),
23
- headers: new Headers({
24
- 'Content-Type': 'application/json',
25
- }),
26
- };
27
- }
28
- if (url.includes('/policyimportexport.v1.PolicyArtifactService/CreateExportArtifacts')) {
29
- return {
30
- ok: true,
31
- status: 200,
32
- json: async () => mockCreateExportArtifactsResponse(),
33
- headers: new Headers({
34
- 'Content-Type': 'application/json',
35
- }),
36
- };
37
- }
38
- return {
39
- ok: false,
40
- status: 404,
41
- json: async () => ({}),
42
- headers: new Headers(),
43
- };
44
- });
45
- });
46
- test('should create a new DSPClient instance with platformUrl', async () => {
47
- const client = new DSPClient({ platformUrl });
48
- expect(client).toBeInstanceOf(DSPClient);
49
- });
50
- test('should throw an error if platformUrl is not provided', async () => {
51
- expect(() => new DSPClient({})).toThrowError('platformUrl is required for DSP client');
52
- });
53
- test('should perform RPC calls using the taggingPDPService', async () => {
54
- const client = new DSPClient({ platformUrl });
55
- expect(client).toBeInstanceOf(DSPClient);
56
- const result = await client.v2.taggingPDPService.tag({});
57
- expect(result.$typeName).toBe('tagging.pdp.v2.TaggingPDPResponse');
58
- });
59
- test('should perform RPC calls using the policyArtifactService', async () => {
60
- const client = new DSPClient({ platformUrl });
61
- expect(client).toBeInstanceOf(DSPClient);
62
- const result = await client.v1.policyArtifactService.createExportArtifacts({});
63
- expect(result.$typeName).toBe('policyimportexport.v1.CreateExportArtifactsResponse');
64
- });
65
- test('should use provided interceptors when making RPC calls', async () => {
66
- const mockInterceptor = vi.fn((next) => next);
67
- const client = new DSPClient({
68
- platformUrl,
69
- interceptors: [mockInterceptor],
70
- });
71
- await client.v2.taggingPDPService.tag({});
72
- expect(mockInterceptor).toHaveBeenCalled();
73
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,92 +0,0 @@
1
- /*
2
- * Copyright (c) Virtru Corporation. All rights reserved.
3
- *
4
- * Your use of this file is governed by the Virtu Terms of Service <https://www.virtru.com/terms-of-service/>.
5
- */
6
- import { expect, test, vi, beforeEach } from 'vitest';
7
- import { DSP } from '../src';
8
- import { mockTaggingPDPResponse } from './mocks/tagging-pdp-tag';
9
- import { HttpRequest, withHeaders } from '@opentdf/sdk';
10
- import { mockWellKnownConfiguration } from './mocks/well-known-configuration';
11
- const platformUrl = 'https://dsp.example.com';
12
- // Mock fetch globally
13
- const mockFetch = vi.fn();
14
- global.fetch = mockFetch;
15
- const authProvider = {
16
- updateClientPublicKey: async () => { },
17
- withCreds: async (req) => withHeaders(req, {
18
- Authorization: 'Bearer dummy auth token for testing purposes',
19
- }),
20
- };
21
- beforeEach(() => {
22
- mockFetch.mockReset();
23
- // Setup default mock responses
24
- mockFetch.mockImplementation(async (url) => {
25
- if (url.includes('/tagging.pdp.v2.TaggingPDPService/Tag')) {
26
- return {
27
- ok: true,
28
- status: 200,
29
- json: async () => mockTaggingPDPResponse(),
30
- headers: new Headers({
31
- 'Content-Type': 'application/json',
32
- }),
33
- };
34
- }
35
- if (url.includes('/wellknownconfiguration.WellKnownService/GetWellKnownConfiguration')) {
36
- return {
37
- ok: true,
38
- status: 200,
39
- json: async () => mockWellKnownConfiguration(),
40
- headers: new Headers({
41
- 'Content-Type': 'application/json',
42
- }),
43
- };
44
- }
45
- return {
46
- ok: false,
47
- status: 404,
48
- json: async () => ({}),
49
- headers: new Headers(),
50
- };
51
- });
52
- });
53
- test('should create a new DSP instance with platformUrl', () => {
54
- const dsp = new DSP({ platformUrl, authProvider });
55
- expect(dsp).toBeInstanceOf(DSP);
56
- });
57
- test('should throw an error if platformUrl is not provided', () => {
58
- expect(() => new DSP({ authProvider })).toThrowError('platformUrl is required for DSP client');
59
- });
60
- test('should create a new DSP instance with platformUrl and authProvider', () => {
61
- const dsp = new DSP({ platformUrl, authProvider });
62
- expect(dsp).toBeInstanceOf(DSP);
63
- });
64
- test('should perform RPC calls using the DSP client service', async () => {
65
- const dsp = new DSP({ platformUrl, authProvider });
66
- const result = await dsp.services.v2.taggingPDPService.tag({});
67
- expect(result.$typeName).toBe('tagging.pdp.v2.TaggingPDPResponse');
68
- });
69
- test('should perform RPC calls via internal PlatformClient service', async () => {
70
- const dsp = new DSP({ platformUrl, authProvider });
71
- const result = await dsp.services.v1.wellknown.getWellKnownConfiguration({});
72
- expect(result.$typeName).toBe('wellknownconfiguration.GetWellKnownConfigurationResponse');
73
- });
74
- test('should use provided interceptors when making RPC calls', async () => {
75
- const mockInterceptor = vi.fn((next) => next);
76
- const dsp = new DSP({
77
- platformUrl,
78
- authProvider,
79
- interceptors: [mockInterceptor],
80
- });
81
- await dsp.services.v2.taggingPDPService.tag({});
82
- expect(mockInterceptor).toHaveBeenCalled();
83
- });
84
- test('should expose expected service structure', () => {
85
- const dsp = new DSP({ platformUrl, authProvider });
86
- expect(dsp.services).toHaveProperty('v1');
87
- expect(dsp.services.v2).toHaveProperty('taggingPDPService');
88
- expect(dsp.services.v1).toHaveProperty('wellknown');
89
- });
90
- test('should throw if authProvider is missing', () => {
91
- expect(() => new DSP({ platformUrl })).toThrowError('Client ID or custom AuthProvider must be defined');
92
- });
@@ -1 +0,0 @@
1
- export {};