@virtru/dsp-sdk 0.4.1 → 0.6.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 (123) 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/dist/src/lib/fips-crypto/asymmetric.d.ts +35 -0
  8. package/dist/src/lib/fips-crypto/asymmetric.js +116 -0
  9. package/dist/src/lib/fips-crypto/key-format.d.ts +51 -0
  10. package/dist/src/lib/fips-crypto/key-format.js +233 -0
  11. package/dist/src/lib/fips-crypto/keys.d.ts +26 -0
  12. package/dist/src/lib/fips-crypto/keys.js +123 -0
  13. package/dist/src/lib/fips-crypto/primitives.d.ts +41 -0
  14. package/dist/src/lib/fips-crypto/primitives.js +105 -0
  15. package/dist/src/lib/fips-crypto/symmetric.d.ts +61 -0
  16. package/dist/src/lib/fips-crypto/symmetric.js +152 -0
  17. package/dist/src/lib/fips-crypto-service.d.ts +5 -0
  18. package/dist/src/lib/fips-crypto-service.js +44 -0
  19. package/dist/src/lib/utils.d.ts +8 -2
  20. package/dist/src/lib/utils.js +8 -9
  21. package/package.json +31 -5
  22. package/.prettierrc +0 -3
  23. package/.rush/temp/chunked-rush-logs/dsp-sdk._phase_build.chunks.jsonl +0 -12
  24. package/.rush/temp/chunked-rush-logs/dsp-sdk._phase_test.chunks.jsonl +0 -43
  25. package/.rush/temp/package-deps__phase_build.json +0 -68
  26. package/.rush/temp/shrinkwrap-deps.json +0 -1257
  27. package/CHANGELOG.json +0 -278
  28. package/buf.gen.yaml +0 -17
  29. package/buf.yaml +0 -4
  30. package/config/jest.config.json +0 -6
  31. package/config/rig.json +0 -8
  32. package/dist/tests/dsp-client.test.d.ts +0 -1
  33. package/dist/tests/dsp-client.test.js +0 -73
  34. package/dist/tests/dsp.test.d.ts +0 -1
  35. package/dist/tests/dsp.test.js +0 -92
  36. package/dist/tests/mocks/create-export-artifacts.d.ts +0 -2
  37. package/dist/tests/mocks/create-export-artifacts.js +0 -13
  38. package/dist/tests/mocks/tagging-pdp-tag.d.ts +0 -2
  39. package/dist/tests/mocks/tagging-pdp-tag.js +0 -11
  40. package/dist/tests/mocks/well-known-configuration.d.ts +0 -2
  41. package/dist/tests/mocks/well-known-configuration.js +0 -12
  42. package/dist/tests/setup-msw.d.ts +0 -9
  43. package/dist/tests/setup-msw.js +0 -30
  44. package/eslint.config.mjs +0 -28
  45. package/lib-commonjs/src/gen/buf/validate/validate_pb.js +0 -487
  46. package/lib-commonjs/src/gen/config/v1/config_pb.js +0 -142
  47. package/lib-commonjs/src/gen/config/v1/kas_config_pb.js +0 -72
  48. package/lib-commonjs/src/gen/config/v1/meta_pb.js +0 -36
  49. package/lib-commonjs/src/gen/config/v1/outlook_config_pb.js +0 -67
  50. package/lib-commonjs/src/gen/config/v1/secureviewer_config_pb.js +0 -67
  51. package/lib-commonjs/src/gen/config/v1/tagging_pb.js +0 -246
  52. package/lib-commonjs/src/gen/google/api/annotations_pb.js +0 -33
  53. package/lib-commonjs/src/gen/google/api/http_pb.js +0 -44
  54. package/lib-commonjs/src/gen/policyimportexport/v1/policy_import_export_pb.js +0 -93
  55. package/lib-commonjs/src/gen/shared/v1/shared_pb.js +0 -95
  56. package/lib-commonjs/src/gen/tagging/pdp/v2/tagging_pb.js +0 -277
  57. package/lib-commonjs/src/gen/version/v1/version_pb.js +0 -40
  58. package/lib-commonjs/src/gen/virtru/common/common_pb.js +0 -76
  59. package/lib-commonjs/src/gen/virtru/policy/certificates/v1/certificates_pb.js +0 -77
  60. package/lib-commonjs/src/gen/virtru/policy/objects_pb.js +0 -143
  61. package/lib-commonjs/src/index.js +0 -48
  62. package/lib-commonjs/src/lib/client.js +0 -66
  63. package/lib-commonjs/src/lib/consts.js +0 -10
  64. package/lib-commonjs/src/lib/dsp.js +0 -49
  65. package/lib-commonjs/src/lib/utils.js +0 -402
  66. package/lib-commonjs/tests/dsp-client.test.js +0 -75
  67. package/lib-commonjs/tests/dsp.test.js +0 -94
  68. package/lib-commonjs/tests/mocks/create-export-artifacts.js +0 -17
  69. package/lib-commonjs/tests/mocks/tagging-pdp-tag.js +0 -15
  70. package/lib-commonjs/tests/mocks/well-known-configuration.js +0 -16
  71. package/lib-commonjs/tests/setup-msw.js +0 -33
  72. package/src/gen/buf/validate/validate_pb.ts +0 -4879
  73. package/src/gen/config/formatters/testdata/v1/test_pb.ts +0 -287
  74. package/src/gen/config/v1/config_connect.ts +0 -111
  75. package/src/gen/config/v1/config_pb.ts +0 -439
  76. package/src/gen/config/v1/kas_config_pb.ts +0 -183
  77. package/src/gen/config/v1/meta_pb.ts +0 -72
  78. package/src/gen/config/v1/outlook_config_pb.ts +0 -242
  79. package/src/gen/config/v1/secureviewer_config_pb.ts +0 -161
  80. package/src/gen/config/v1/tagging_pb.ts +0 -456
  81. package/src/gen/google/api/annotations_pb.ts +0 -43
  82. package/src/gen/google/api/http_pb.ts +0 -486
  83. package/src/gen/helloworld/v1/helloworld_connect.ts +0 -49
  84. package/src/gen/helloworld/v1/helloworld_pb.ts +0 -104
  85. package/src/gen/kas/nanotdf/v1/nanotdf_rewrap_connect.ts +0 -39
  86. package/src/gen/kas/nanotdf/v1/nanotdf_rewrap_pb.ts +0 -207
  87. package/src/gen/policyimportexport/v1/policy_import_export_connect.ts +0 -56
  88. package/src/gen/policyimportexport/v1/policy_import_export_pb.ts +0 -332
  89. package/src/gen/shared/v1/shared_connect.ts +0 -61
  90. package/src/gen/shared/v1/shared_pb.ts +0 -240
  91. package/src/gen/shared/v2/shared_connect.ts +0 -39
  92. package/src/gen/shared/v2/shared_pb.ts +0 -122
  93. package/src/gen/tagging/pdp/v2/externalprocessors/processor_connect.ts +0 -156
  94. package/src/gen/tagging/pdp/v2/externalprocessors/processor_pb.ts +0 -709
  95. package/src/gen/tagging/pdp/v2/stanag/stanag_pb.ts +0 -953
  96. package/src/gen/tagging/pdp/v2/tagging_connect.ts +0 -73
  97. package/src/gen/tagging/pdp/v2/tagging_pb.ts +0 -1064
  98. package/src/gen/version/v1/version_connect.ts +0 -31
  99. package/src/gen/version/v1/version_pb.ts +0 -143
  100. package/src/gen/virtru/common/common_pb.ts +0 -201
  101. package/src/gen/virtru/policy/certificates/v1/certificates_connect.ts +0 -44
  102. package/src/gen/virtru/policy/certificates/v1/certificates_pb.ts +0 -305
  103. package/src/gen/virtru/policy/objects_pb.ts +0 -253
  104. package/src/gen/web-admin/v1/config_connect.ts +0 -52
  105. package/src/gen/web-admin/v1/config_pb.ts +0 -173
  106. package/src/index.ts +0 -62
  107. package/src/lib/client.ts +0 -90
  108. package/src/lib/consts.ts +0 -8
  109. package/src/lib/dsp.ts +0 -65
  110. package/src/lib/utils.test.ts +0 -412
  111. package/src/lib/utils.ts +0 -524
  112. package/src/vite-env.d.ts +0 -7
  113. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -30
  114. package/temp/test/jest/haste-map-b055a9550e6d9f9b43d8ad29b1607278-49d19aee56a0732eca9c014a51272338-8710993d07b75a801b0956e67ffc46fa +0 -0
  115. package/tests/dsp-client.test.ts +0 -95
  116. package/tests/dsp.test.ts +0 -119
  117. package/tests/mocks/create-export-artifacts.ts +0 -16
  118. package/tests/mocks/tagging-pdp-tag.ts +0 -13
  119. package/tests/mocks/well-known-configuration.ts +0 -15
  120. package/tests/setup-msw.ts +0 -35
  121. package/tsconfig.json +0 -32
  122. package/update-protos.sh +0 -63
  123. package/vitest.config.ts +0 -32
package/CHANGELOG.json DELETED
@@ -1,278 +0,0 @@
1
- {
2
- "name": "@virtru/dsp-sdk",
3
- "entries": [
4
- {
5
- "version": "0.4.1",
6
- "tag": "@virtru/dsp-sdk_v0.4.1",
7
- "date": "Tue, 03 Mar 2026 16:24:41 GMT",
8
- "comments": {
9
- "none": [
10
- {
11
- "comment": "Updated README to include NanoTDF decryption example",
12
- "author": "Aaron Hopper <aaron.hopper@virtru.com>",
13
- "commit": "ad26795e82e8020eec3f81b4f639e5d6614e730e"
14
- }
15
- ],
16
- "patch": [
17
- {
18
- "comment": "fix: move build tools (heft, heft-web-rig) from dependencies to devDependencies to remove vulnerable minimatch transitive dep for consumers",
19
- "author": "Paul Flynn <pflynn@virtru.com>",
20
- "commit": "d4c8af9f1af9401ccbb42ba47df74e3b96eb4045"
21
- }
22
- ]
23
- }
24
- },
25
- {
26
- "version": "0.4.0",
27
- "tag": "@virtru/dsp-sdk_v0.4.0",
28
- "date": "Tue, 24 Feb 2026 15:09:15 GMT",
29
- "comments": {
30
- "minor": [
31
- {
32
- "comment": "feat: add heft and rig configuration files for project setup",
33
- "author": "virtru-dubich <85224435+virtru-dubich@users.noreply.github.com>",
34
- "commit": "ac9f6949cf9b6b6969340c8cae351e92f16cf5a6"
35
- }
36
- ]
37
- }
38
- },
39
- {
40
- "version": "0.3.2",
41
- "tag": "@virtru/dsp-sdk_v0.3.2",
42
- "date": "Tue, 17 Feb 2026 17:33:08 GMT",
43
- "comments": {
44
- "patch": [
45
- {
46
- "comment": "Add update-proto script",
47
- "author": "Nick <79929408+ntrevino-virtru@users.noreply.github.com>",
48
- "commit": "6f94c2989ae42d107cbc614cc74d4ad67b871e25"
49
- }
50
- ]
51
- }
52
- },
53
- {
54
- "version": "0.3.1",
55
- "tag": "@virtru/dsp-sdk_v0.3.1",
56
- "date": "Thu, 29 Jan 2026 20:55:50 GMT",
57
- "comments": {
58
- "patch": [
59
- {
60
- "comment": "bump web-sdk",
61
- "author": "Dillon Thompson <dj.thompson715@gmail.com>",
62
- "commit": "151576eefb4b2ba12507246a991aa06b2f85f485"
63
- }
64
- ]
65
- }
66
- },
67
- {
68
- "version": "0.3.0",
69
- "tag": "@virtru/dsp-sdk_v0.3.0",
70
- "date": "Thu, 22 Jan 2026 21:04:08 GMT",
71
- "comments": {
72
- "minor": [
73
- {
74
- "comment": "Move assertions to DSP SDK",
75
- "author": "Paul Flynn <pflynn@virtru.com>",
76
- "commit": "53b3d7f0a3b0fb810c7b193278b736fc10b4a80c"
77
- }
78
- ]
79
- }
80
- },
81
- {
82
- "version": "0.2.4",
83
- "tag": "@virtru/dsp-sdk_v0.2.4",
84
- "date": "Thu, 22 Jan 2026 14:53:21 GMT",
85
- "comments": {
86
- "patch": [
87
- {
88
- "comment": "Fix: add vitest config to resolve .js imports to .ts files for Vite 5 compatibility",
89
- "author": "Paul Flynn <pflynn@virtru.com>",
90
- "commit": "fc12e7d4c123d3d5e627e1aff561d638cc6bcd0c"
91
- }
92
- ]
93
- }
94
- },
95
- {
96
- "version": "0.2.3",
97
- "tag": "@virtru/dsp-sdk_v0.2.3",
98
- "date": "Wed, 14 Jan 2026 21:32:11 GMT",
99
- "comments": {
100
- "patch": [
101
- {
102
- "comment": "Update @opentdf/sdk dependency",
103
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
104
- "commit": "6e37a9084749630870675ea12bf58b9ba290bef0"
105
- }
106
- ]
107
- }
108
- },
109
- {
110
- "version": "0.2.2",
111
- "tag": "@virtru/dsp-sdk_v0.2.2",
112
- "date": "Thu, 20 Nov 2025 15:03:47 GMT",
113
- "comments": {
114
- "patch": [
115
- {
116
- "comment": "Upgrade to support node 22",
117
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
118
- "commit": "40b0ce0977a40315dbe806864a41555df7a02170"
119
- }
120
- ]
121
- }
122
- },
123
- {
124
- "version": "0.2.1",
125
- "tag": "@virtru/dsp-sdk_v0.2.1",
126
- "date": "Thu, 13 Nov 2025 17:06:33 GMT",
127
- "comments": {
128
- "patch": [
129
- {
130
- "comment": "Add LICENSE file",
131
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
132
- "commit": "cf505ad5568c1fb85c9c131cffdbd5be248edb2c"
133
- }
134
- ]
135
- }
136
- },
137
- {
138
- "version": "0.2.0",
139
- "tag": "@virtru/dsp-sdk_v0.2.0",
140
- "date": "Wed, 05 Nov 2025 18:47:57 GMT",
141
- "comments": {
142
- "minor": [
143
- {
144
- "comment": "bump web-sdk for better obligation errors",
145
- "author": "Krish Suchak <42231639+alkalescent@users.noreply.github.com>",
146
- "commit": "c8cf11dc3903cf957dcab68bf4f585242af0f195"
147
- }
148
- ]
149
- }
150
- },
151
- {
152
- "version": "0.1.11",
153
- "tag": "@virtru/dsp-sdk_v0.1.11",
154
- "date": "Wed, 05 Nov 2025 17:52:35 GMT",
155
- "comments": {
156
- "patch": [
157
- {
158
- "comment": "Update Connect RPC gen client stubs",
159
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
160
- "commit": "96a5915fff56f4e1f58161d4bf2ed236a3bd0159"
161
- }
162
- ]
163
- }
164
- },
165
- {
166
- "version": "0.1.10",
167
- "tag": "@virtru/dsp-sdk_v0.1.10",
168
- "date": "Fri, 31 Oct 2025 19:39:15 GMT",
169
- "comments": {
170
- "patch": [
171
- {
172
- "comment": "Moved from @virtru-private/dsp-sdk",
173
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
174
- "commit": "f8c2642e17366f7f9499df19d0c8bd15bdc31680"
175
- }
176
- ]
177
- }
178
- },
179
- {
180
- "version": "0.1.9",
181
- "tag": "@virtru-private/dsp-sdk_v0.1.9",
182
- "date": "Tue, 28 Oct 2025 14:38:10 GMT",
183
- "comments": {
184
- "patch": [
185
- {
186
- "comment": "add license header",
187
- "author": "Scott Hamrick <2623452+cshamrick@users.noreply.github.com>",
188
- "commit": "22e408fe9ffd48061d622e7a9184abf3257f52a0"
189
- }
190
- ]
191
- }
192
- },
193
- {
194
- "version": "0.1.8",
195
- "tag": "@virtru-private/dsp-sdk_v0.1.8",
196
- "date": "Mon, 20 Oct 2025 20:07:25 GMT",
197
- "comments": {
198
- "patch": [
199
- {
200
- "comment": "re-export platform client generated stubs",
201
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
202
- "commit": "2439a19a28ff09131a88dd0531985ca2d3f2ae8e"
203
- }
204
- ]
205
- }
206
- },
207
- {
208
- "version": "0.1.7",
209
- "tag": "@virtru-private/dsp-sdk_v0.1.7",
210
- "date": "Fri, 17 Oct 2025 20:51:30 GMT",
211
- "comments": {
212
- "patch": [
213
- {
214
- "comment": "bump @opentdf/sdk to v0.5.0",
215
- "author": "Jake Van Vorhis <83739412+jakedoublev@users.noreply.github.com>",
216
- "commit": "259d4ab6e578c15d4d8985fc21ae4d5fd925e37c"
217
- }
218
- ]
219
- }
220
- },
221
- {
222
- "version": "0.1.6",
223
- "tag": "@virtru-private/dsp-sdk_v0.1.6",
224
- "date": "Fri, 26 Sep 2025 15:27:03 GMT",
225
- "comments": {
226
- "patch": [
227
- {
228
- "comment": "Fixes dsp-sdk client exported type inference",
229
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
230
- "commit": "dee75420c5bb30d06339fe4decb3c8abd75ca5dd"
231
- }
232
- ]
233
- }
234
- },
235
- {
236
- "version": "0.1.5",
237
- "tag": "@virtru-private/dsp-sdk_v0.1.5",
238
- "date": "Tue, 23 Sep 2025 19:37:57 GMT",
239
- "comments": {
240
- "patch": [
241
- {
242
- "comment": "Update DSP WebSDK to pass options.authProvider downstream",
243
- "author": "Eugene Yakhnenko <eugene.yakhnenko@virtru.com>",
244
- "commit": "9b02838ad5bf25d866889baaf8e6b333d163b8fa"
245
- }
246
- ]
247
- }
248
- },
249
- {
250
- "version": "0.1.4",
251
- "tag": "@virtru-private/dsp-sdk_v0.1.4",
252
- "date": "Fri, 12 Sep 2025 15:24:17 GMT",
253
- "comments": {
254
- "patch": [
255
- {
256
- "comment": "Export types from opentdf",
257
- "author": "Sara Tarnvik <54858371+stvik@users.noreply.github.com>",
258
- "commit": "b0e20f740cd6d1ddc1c7e8b084a6594097614ec0"
259
- }
260
- ]
261
- }
262
- },
263
- {
264
- "version": "0.1.3",
265
- "tag": "@virtru-private/dsp-sdk_v0.1.3",
266
- "date": "Thu, 11 Sep 2025 19:23:03 GMT",
267
- "comments": {
268
- "patch": [
269
- {
270
- "comment": "add DSP Web SDK as new monorepo project",
271
- "author": "Ryan Yanulites <ryanulites@virtru.com>",
272
- "commit": "fc0ab3e5529baebca2068f560a18b7464a6d2e5a"
273
- }
274
- ]
275
- }
276
- }
277
- ]
278
- }
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,2 +0,0 @@
1
- import { type CreateExportArtifactsResponse } from '@src/gen/policyimportexport/v1/policy_import_export_pb';
2
- export declare const mockCreateExportArtifactsResponse: () => CreateExportArtifactsResponse;
@@ -1,13 +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 {} from '@src/gen/policyimportexport/v1/policy_import_export_pb';
7
- export const mockCreateExportArtifactsResponse = () => ({
8
- $typeName: 'policyimportexport.v1.CreateExportArtifactsResponse',
9
- artifact: {
10
- case: undefined,
11
- value: undefined,
12
- },
13
- });
@@ -1,2 +0,0 @@
1
- import { type TaggingPDPResponse } from '@src/gen/tagging/pdp/v2/tagging_pb';
2
- export declare const mockTaggingPDPResponse: () => TaggingPDPResponse;
@@ -1,11 +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 {} from '@src/gen/tagging/pdp/v2/tagging_pb';
7
- export const mockTaggingPDPResponse = () => ({
8
- $typeName: 'tagging.pdp.v2.TaggingPDPResponse',
9
- events: [],
10
- tags: [],
11
- });
@@ -1,2 +0,0 @@
1
- import { type GetWellKnownConfigurationResponse } from '@opentdf/sdk/platform/wellknownconfiguration/wellknown_configuration_pb.js';
2
- export declare const mockWellKnownConfiguration: () => GetWellKnownConfigurationResponse;
@@ -1,12 +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 {} from '@opentdf/sdk/platform/wellknownconfiguration/wellknown_configuration_pb.js';
7
- export const mockWellKnownConfiguration = () => ({
8
- $typeName: 'wellknownconfiguration.GetWellKnownConfigurationResponse',
9
- configuration: {
10
- wellKnown: {},
11
- },
12
- });
@@ -1,9 +0,0 @@
1
- import { type SetupWorker } from 'msw/browser';
2
- import { HttpHandler } from 'msw';
3
- /**
4
- * Sets up the MSW (Mock Service Worker) for testing.
5
- *
6
- * @param handlers - An array of HTTP handlers to be used with MSW.
7
- * @returns The MSW worker instance.
8
- */
9
- export declare function setupMSW(handlers: HttpHandler[]): SetupWorker | undefined;
@@ -1,30 +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 { setupWorker } from 'msw/browser';
7
- import { beforeAll, afterEach, afterAll } from 'vitest';
8
- import { HttpHandler } from 'msw';
9
- let worker;
10
- /**
11
- * Sets up the MSW (Mock Service Worker) for testing.
12
- *
13
- * @param handlers - An array of HTTP handlers to be used with MSW.
14
- * @returns The MSW worker instance.
15
- */
16
- export function setupMSW(handlers) {
17
- if (!worker) {
18
- worker = setupWorker(...handlers);
19
- beforeAll(async () => {
20
- await worker.start();
21
- });
22
- afterEach(() => worker.resetHandlers());
23
- afterAll(() => worker.stop());
24
- }
25
- else {
26
- // If worker already exists, just update handlers
27
- worker.resetHandlers(...handlers);
28
- }
29
- return worker;
30
- }
package/eslint.config.mjs DELETED
@@ -1,28 +0,0 @@
1
- import js from '@eslint/js';
2
- import globals from 'globals';
3
- import tseslint from 'typescript-eslint';
4
- import { defineConfig } from 'eslint/config';
5
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
6
-
7
- export default defineConfig(
8
- [
9
- tseslint.configs.recommended,
10
- eslintPluginPrettierRecommended,
11
- {
12
- files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
13
- plugins: { js, tseslint },
14
- },
15
- {
16
- files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
17
- languageOptions: { globals: globals.browser },
18
- },
19
- ],
20
- {
21
- ignores: ['dist/**'],
22
- },
23
- {
24
- linterOptions: {
25
- reportUnusedDisableDirectives: 'off',
26
- },
27
- }
28
- );