@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
@@ -1,108 +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
-
7
- import { Buffer } from 'buffer';
8
- import { access, readFile } from 'node:fs/promises';
9
- import path from 'node:path';
10
- import { TextEncoder, TextDecoder } from 'node:util';
11
-
12
- globalThis.Buffer = Buffer;
13
- if (!globalThis.TextEncoder) {
14
- globalThis.TextEncoder = TextEncoder as typeof globalThis.TextEncoder;
15
- }
16
- if (!globalThis.TextDecoder) {
17
- globalThis.TextDecoder = TextDecoder as typeof globalThis.TextDecoder;
18
- }
19
-
20
- declare global {
21
- interface Window {
22
- Module: unknown;
23
- VirtruFipsWasmLib?: unknown;
24
- }
25
- }
26
-
27
- type FipsReadyLike = {
28
- isInitialized: boolean;
29
- generateKey: (...args: unknown[]) => Promise<unknown>;
30
- };
31
-
32
- if (typeof window !== 'undefined' && !window.Module) {
33
- window.Module = {};
34
- }
35
-
36
- // Prefer the copied local WASM artifact used by package scripts.
37
- const copiedWasmFilePath = path.resolve(process.cwd(), 'public/virtru.wasm');
38
- // Fallback for direct local runs when copy-wasm has not been executed.
39
- const sourceWasmFilePath = path.resolve(
40
- process.cwd(),
41
- '../fips-crypto-js/src/utils/virtru.wasm'
42
- );
43
-
44
- let resolvedWasmFilePath = copiedWasmFilePath;
45
- try {
46
- await access(copiedWasmFilePath);
47
- } catch {
48
- resolvedWasmFilePath = sourceWasmFilePath;
49
- }
50
-
51
- const originalFetch = globalThis.fetch;
52
-
53
- globalThis.fetch = async function (input, init) {
54
- const url =
55
- typeof input === 'string'
56
- ? input
57
- : input instanceof URL
58
- ? input.href
59
- : input.url;
60
-
61
- if (url && url.includes('virtru.wasm')) {
62
- const wasmBytes = await readFile(resolvedWasmFilePath);
63
- return new Response(wasmBytes, {
64
- status: 200,
65
- headers: {
66
- 'content-type': 'application/wasm',
67
- },
68
- });
69
- }
70
-
71
- return originalFetch(input as RequestInfo, init);
72
- };
73
-
74
- await import('@virtru-private/fips-crypto-js');
75
-
76
- const isFipsReady = (candidate: unknown): candidate is FipsReadyLike => {
77
- return (
78
- !!candidate &&
79
- typeof candidate === 'object' &&
80
- 'isInitialized' in candidate &&
81
- (candidate as { isInitialized: boolean }).isInitialized === true &&
82
- 'generateKey' in candidate &&
83
- typeof (candidate as { generateKey: unknown }).generateKey === 'function'
84
- );
85
- };
86
-
87
- if (!isFipsReady(window.VirtruFipsWasmLib)) {
88
- await new Promise<void>((resolve, reject) => {
89
- const timeout = setTimeout(
90
- () =>
91
- reject(
92
- new Error(
93
- 'Timeout waiting for VirtruCrypto WASM initialization in unit setup.'
94
- )
95
- ),
96
- 10000
97
- );
98
- const onReady = () => {
99
- clearTimeout(timeout);
100
- resolve();
101
- };
102
- window.addEventListener('wasmReady', onReady, { once: true });
103
- });
104
- }
105
-
106
- if (!isFipsReady(window.VirtruFipsWasmLib)) {
107
- throw new Error('VirtruCrypto was loaded but not initialized in unit setup.');
108
- }
package/tsconfig.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2020", "ES2021.WeakRef", "DOM", "DOM.Iterable"],
7
- "skipLibCheck": true,
8
- "baseUrl": ".",
9
- "paths": {
10
- "@src/*": ["src/*"]
11
- },
12
-
13
- /* Bundler mode */
14
- "moduleResolution": "bundler",
15
- "allowImportingTsExtensions": false,
16
- "verbatimModuleSyntax": true,
17
- "moduleDetection": "force",
18
- "noEmit": false,
19
- "declaration": true,
20
- "outDir": "dist",
21
- "emitDeclarationOnly": false,
22
-
23
- /* Linting */
24
- "strict": true,
25
- "noUnusedLocals": true,
26
- "noUnusedParameters": true,
27
- // "erasableSyntaxOnly": false,
28
- "noFallthroughCasesInSwitch": true
29
- // "noUncheckedSideEffectImports": true
30
- },
31
- "include": ["tests"]
32
- }
package/update-protos.sh DELETED
@@ -1,63 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- REPO_URL="git@github.com:virtru-corp/data-security-platform.git"
6
- CLONE_DIR=".dsp"
7
- DEST_DIR="src/gen/"
8
- FILES_TO_COPY="sdk_web/src/gen/"
9
-
10
- echo "Cloning repository..."
11
- if test -d "$CLONE_DIR"; then
12
- echo "Repo exists? Try: rm -rf '$CLONE_DIR'"
13
- exit 1
14
- fi
15
- git clone --depth=1 "$REPO_URL" "$CLONE_DIR"
16
-
17
- echo "Updating repo buf.gen.yaml to generate for dsp-sdk..."
18
- echo >>"$CLONE_DIR/buf.gen.yaml"
19
- # Copy buf.gen.yaml over to our cloned reposiroty, modifying it to output to our src/gen/ directory
20
- sed '1,/plugins:/d' buf.gen.yaml | sed 's# src/gen# ../src/gen#' >>"$CLONE_DIR/buf.gen.yaml"
21
-
22
- pushd "$CLONE_DIR"
23
-
24
- echo "Generating protos..."
25
- make proto-generate
26
-
27
- popd
28
-
29
- echo "Removing repo..."
30
- rm -rf "$CLONE_DIR"
31
-
32
-
33
- echo "Prepending copyright headers to TypeScript files..."
34
- VIRTRU_LICENSE=$(cat <<EOF
35
- /*
36
- * Copyright (c) Virtru Corporation. All rights reserved.
37
- *
38
- * Your use of this file is governed by the Virtu Terms of Service <https://www.virtru.com/terms-of-service/>.
39
- */
40
- EOF
41
- )
42
-
43
- # Find all .ts files and loop through them
44
- git status --porcelain | grep -E '(M|A)' | cut -b 4- | sed "s#^#$(git rev-parse --show-toplevel)/#" | sed "s#^$(pwd)/##" | sort | uniq | grep "$DEST_DIR" | while read -r ts_file; do
45
- echo "Processing $ts_file..."
46
- TMPFILE="${ts_file}.tmp"
47
-
48
- # Prepend header: Concatenate header + original file -> temp file, then move back
49
- rm -f "$TMPFILE"
50
- touch "$TMPFILE"
51
- echo "$VIRTRU_LICENSE" >$TMPFILE
52
- echo >>$TMPFILE
53
- cat "$ts_file" >>"$TMPFILE"
54
- mv "$TMPFILE" "$ts_file"
55
- done
56
-
57
- echo "Re-adding to stage, for prettier..."
58
- git add src/gen
59
-
60
- echo "Running prettier..."
61
- rush prettier
62
-
63
- echo "Protos updated successfully!"
package/vitest.config.ts DELETED
@@ -1,48 +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
-
7
- import { defineConfig } from 'vitest/config';
8
- import path from 'path';
9
-
10
- export default defineConfig({
11
- plugins: [],
12
- test: {
13
- environment: 'jsdom',
14
- globals: true,
15
- setupFiles: ['./tests/setup-unit.ts'],
16
- include: [
17
- 'tests/dsp.test.ts',
18
- 'tests/dsp-client.test.ts',
19
- 'tests/fips-crypto.unit.test.ts',
20
- 'src/lib/utils.test.ts',
21
- ],
22
- testTimeout: 30000,
23
- hookTimeout: 30000,
24
- fileParallelism: false,
25
- silent: false,
26
- logHeapUsage: false,
27
- },
28
- // Pre-bundle CommonJS workspace deps used by fips-crypto tests
29
- optimizeDeps: {
30
- include: ['buffer', '@virtru-private/fips-crypto-js'],
31
- },
32
- build: {
33
- outDir: 'dist',
34
- },
35
- resolve: {
36
- alias: {
37
- '@src': path.resolve(__dirname, 'src'),
38
- '@virtru-private/fips-crypto-js': path.resolve(
39
- __dirname,
40
- '../fips-crypto-js/src/index.js'
41
- ),
42
- },
43
- },
44
- define: {
45
- global: 'globalThis',
46
- 'process.env': {},
47
- },
48
- });