@super-protocol/addons-tee 1.0.0 → 2.0.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 (95) hide show
  1. package/bindings/amd-sev-snp-napi-rs/amd-sev-snp-napi-rs.linux-x64-gnu.node +0 -0
  2. package/bindings/nvidia-native/README.md +174 -0
  3. package/bindings/nvidia-native/build/Release/libnvat.so.1.1.0 +0 -0
  4. package/bindings/nvidia-native/build/Release/nvidia_native.node +0 -0
  5. package/bindings/nvidia-native/package.json +26 -0
  6. package/bindings/nvidia-native/postinstall.js +40 -0
  7. package/bindings/sgx-native/build/Release/sgx_native.node +0 -0
  8. package/bindings/usr/lib/node_modules/node-addon-api/node_api.Makefile +6 -0
  9. package/bindings/usr/lib/node_modules/node-addon-api/nothing.target.mk +159 -0
  10. package/bindings/utils/virtee/libsev.so +0 -0
  11. package/bindings/utils/virtee/snpguest +0 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -2
  14. package/dist/nvidia-native-module/nvidia-attestation.d.ts +146 -0
  15. package/dist/nvidia-native-module/nvidia-attestation.js +374 -0
  16. package/dist/nvidia-native-module/nvidia-debug-state-policy.rego +45 -0
  17. package/dist/nvidia-native-module/nvidia-detailed-policy.rego +205 -0
  18. package/package.json +4 -2
  19. package/.editorconfig +0 -15
  20. package/.eslintrc.json +0 -61
  21. package/.prettierignore +0 -3
  22. package/.prettierrc +0 -15
  23. package/bindings/amd-sev-snp-napi-rs/package-lock.json +0 -40
  24. package/bindings/sgx-native/package-lock.json +0 -23
  25. package/bindings/sp-sev/.github/auto_assign-issues.yml +0 -5
  26. package/bindings/sp-sev/.github/auto_assign.yml +0 -21
  27. package/bindings/sp-sev/.github/dependabot.yml +0 -6
  28. package/bindings/sp-sev/.github/workflows/dco.yml +0 -10
  29. package/bindings/sp-sev/.github/workflows/lint.yml +0 -56
  30. package/bindings/sp-sev/.github/workflows/test.yml +0 -215
  31. package/bindings/sp-sev/.rustfmt.toml +0 -2
  32. package/bindings/sp-sev/CODEOWNERS +0 -1
  33. package/bindings/sp-sev/Cargo.lock +0 -2461
  34. package/bindings/sp-sev/Cargo.toml +0 -80
  35. package/bindings/sp-sev/LICENSE +0 -201
  36. package/bindings/sp-sev/README.md +0 -82
  37. package/bindings/sp-sev/build.rs +0 -17
  38. package/bindings/sp-sev/docs/attestation/README.md +0 -239
  39. package/bindings/sp-sev/docs/attestation/certchain.dot +0 -14
  40. package/bindings/sp-sev/docs/attestation/certchain.dot.png +0 -0
  41. package/bindings/sp-sev/docs/attestation/prerequisites.md +0 -6
  42. package/bindings/sp-sev/docs/attestation/process.msc +0 -60
  43. package/bindings/sp-sev/docs/attestation/process.msc.png +0 -0
  44. package/bindings/sp-sev/docs/attestation/protections.md +0 -53
  45. package/bindings/sp-sev/package-version.py +0 -11
  46. package/bindings/sp-sev/tests/api.rs +0 -194
  47. package/bindings/sp-sev/tests/certs.rs +0 -142
  48. package/bindings/sp-sev/tests/certs_data/cert_chain_milan +0 -74
  49. package/bindings/sp-sev/tests/certs_data/cert_chain_turin +0 -74
  50. package/bindings/sp-sev/tests/certs_data/report_milan.hex +0 -1
  51. package/bindings/sp-sev/tests/certs_data/vcek_milan.der +0 -0
  52. package/bindings/sp-sev/tests/certs_data/vcek_turin.der +0 -0
  53. package/bindings/sp-sev/tests/guest.rs +0 -57
  54. package/bindings/sp-sev/tests/id-block.rs +0 -172
  55. package/bindings/sp-sev/tests/measurement/ovmf_AmdSev_suffix.bin +0 -0
  56. package/bindings/sp-sev/tests/measurement/ovmf_OvmfX64_suffix.bin +0 -0
  57. package/bindings/sp-sev/tests/measurement/test_auth_block.bin +0 -0
  58. package/bindings/sp-sev/tests/measurement/test_auth_key.pem +0 -6
  59. package/bindings/sp-sev/tests/measurement/test_auth_sig.bin +0 -0
  60. package/bindings/sp-sev/tests/measurement/test_id_key.pem +0 -6
  61. package/bindings/sp-sev/tests/measurement/test_id_sig.bin +0 -0
  62. package/bindings/sp-sev/tests/measurement.rs +0 -510
  63. package/bindings/sp-sev/tests/naples/ark.cert.bad +0 -0
  64. package/bindings/sp-sev/tests/naples/ark.cert.sig +0 -0
  65. package/bindings/sp-sev/tests/naples/ark.rs +0 -38
  66. package/bindings/sp-sev/tests/naples/ask.rs +0 -29
  67. package/bindings/sp-sev/tests/naples/cek.cert +0 -0
  68. package/bindings/sp-sev/tests/naples/cek.rs +0 -30
  69. package/bindings/sp-sev/tests/naples/mod.rs +0 -20
  70. package/bindings/sp-sev/tests/naples/oca.cert +0 -0
  71. package/bindings/sp-sev/tests/naples/oca.rs +0 -45
  72. package/bindings/sp-sev/tests/naples/pdh.cert +0 -0
  73. package/bindings/sp-sev/tests/naples/pdh.rs +0 -28
  74. package/bindings/sp-sev/tests/naples/pek.cert +0 -0
  75. package/bindings/sp-sev/tests/naples/pek.rs +0 -32
  76. package/bindings/sp-sev/tests/rome/ark.rs +0 -33
  77. package/bindings/sp-sev/tests/rome/ask.rs +0 -29
  78. package/bindings/sp-sev/tests/rome/cek.cert +0 -0
  79. package/bindings/sp-sev/tests/rome/cek.rs +0 -29
  80. package/bindings/sp-sev/tests/rome/mod.rs +0 -16
  81. package/bindings/sp-sev/tests/rome/oca.cert +0 -0
  82. package/bindings/sp-sev/tests/rome/oca.rs +0 -45
  83. package/bindings/sp-sev/tests/rome/pdh.cert +0 -0
  84. package/bindings/sp-sev/tests/rome/pdh.rs +0 -28
  85. package/bindings/sp-sev/tests/rome/pek.cert +0 -0
  86. package/bindings/sp-sev/tests/rome/pek.rs +0 -32
  87. package/bindings/sp-sev/tests/session.rs +0 -39
  88. package/bindings/sp-sev/tests/sev_launch.rs +0 -120
  89. package/bindings/sp-sev/tests/snp_launch.rs +0 -108
  90. package/dto/src/AmdSevSnp.proto +0 -31
  91. package/dto/src/Compression.proto +0 -11
  92. package/dto/src/Hash.proto +0 -6
  93. package/dto/src/OrderReport.proto +0 -21
  94. package/dto/src/TRI.proto +0 -22
  95. package/dto/src/TeeDeviceInfo.proto +0 -46
@@ -0,0 +1,174 @@
1
+ # NVIDIA Native Attestation Module
2
+
3
+ Node.js native addon for GPU attestation using NVIDIA Attestation SDK.
4
+
5
+ ## Features
6
+
7
+ - **Remote Attestation via NRAS**: Generate JWT tokens via NVIDIA Remote Attestation Service
8
+ - **Policy Verification**: Verify JWT with Rego policies
9
+ - **Device Topology**: Retrieve GPU and NVSwitch counts with dynamic library loading
10
+ - **Device Information**: Get NVIDIA GPU device information
11
+ - **TypeScript Support**: Full type support
12
+
13
+ ## Dependencies
14
+
15
+ ### Runtime (System Libraries)
16
+
17
+ ```bash
18
+ # Ubuntu/Debian
19
+ sudo apt-get install -y \
20
+ libcurl4-openssl-dev \
21
+ libxml2-dev \
22
+ libssl-dev \
23
+ libxmlsec1-dev \
24
+ libxmlsec1-openssl
25
+ ```
26
+
27
+ ### Build Dependencies
28
+
29
+ ```bash
30
+ sudo apt-get install -y build-essential cmake git python3
31
+ ```
32
+
33
+ ### NVIDIA Attestation SDK
34
+
35
+ The SDK is included as a git submodule and is built automatically on first build.
36
+
37
+ ## Build
38
+
39
+ ```bash
40
+ # 1. Initialize submodules
41
+ git submodule update --init --recursive
42
+
43
+ # 2. Build
44
+ ./build.sh
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ### TypeScript (Recommended)
50
+
51
+ ```typescript
52
+ import {
53
+ NvidiaAttestationService,
54
+ PERMISSIVE_POLICY
55
+ } from 'tee-addon';
56
+
57
+ const service = new NvidiaAttestationService();
58
+
59
+ // Attestation via NRAS
60
+ const result = await service.attestGpuWithNRAS({
61
+ serviceKey: 'your-api-key'
62
+ });
63
+
64
+ console.log('Success:', result.success);
65
+ console.log('JWT:', result.jwt);
66
+ console.log('Claims:', result.claims);
67
+ ```
68
+
69
+ ### Native C++
70
+
71
+ ```javascript
72
+ const { TNvidiaAttestation } = require('./build/Release/nvidia_native.node');
73
+
74
+ const attestation = new TNvidiaAttestation();
75
+ const nonce = Buffer.alloc(32);
76
+ const result = attestation.attestGpuWithNRAS(nonce);
77
+ console.log(result.success, result.jwt, result.claims);
78
+ ```
79
+
80
+ ## API Reference
81
+
82
+ ### generateNonce(nonceLength?)
83
+
84
+ Generates a cryptographic nonce via NVIDIA Attestation SDK.
85
+
86
+ **Parameters**:
87
+ - `nonceLength?: number` — length in bytes (default `32`)
88
+
89
+ **Returns**: `Buffer`
90
+
91
+ ### attestGpuWithNRAS(nonce?, serviceKey?, nrasUrl?)
92
+
93
+ Performs GPU attestation via NRAS.
94
+
95
+ **Returns**: `{success: boolean, jwt: string, claims: string}`
96
+
97
+ ### attestNvSwitchWithNRAS(nonce?, serviceKey?, nrasUrl?)
98
+
99
+ Performs NVSwitch attestation via NRAS.
100
+
101
+ **Returns**: `{success: boolean, jwt: string, claims: string}`
102
+
103
+ ### verifyJwt(jwt, serviceKey?, nrasUrl?)
104
+
105
+ Verifies detached EAT JWT cryptographically via NRAS and returns decoded claims.
106
+
107
+ **Returns**: `{result: boolean, claims: string, msg: string, logs: string}`
108
+
109
+ **Behavior**:
110
+ - Returns `{result: true, claims, msg: "Success"}` when cryptographic verification succeeds
111
+ - Returns `{result: false, claims, msg: "Attestation overall result is false"}` when verification reaches decision stage but overall result is false
112
+ - Throws `TypeError` for invalid input argument types/shape
113
+ - Throws `Error` for hard failures (malformed/invalid JWT payload, validate/decode failure, claims extraction/serialization failure, HTTP/JWKS processing failure)
114
+
115
+ ### evaluatePolicy(claims, regoPolicy)
116
+
117
+ Evaluates attestation claims against a Rego policy and returns policy diagnostics.
118
+
119
+ **Returns**: `{result: boolean, msg: string, details: string[], logs: string}`
120
+
121
+ **Behavior**:
122
+ - Returns `{result: true, msg: "Success", details: []}` when claims match the policy
123
+ - Returns `{result: false, msg, details}` when claims do not match the policy, with failed rule names in `details`
124
+ - Throws `TypeError` for invalid input argument types/shape
125
+ - Throws `Error` for policy evaluation failures
126
+
127
+ ### getDeviceTopology()
128
+
129
+ Retrieves NVIDIA device topology information (GPU and NVSwitch).
130
+
131
+ Dynamically loads NVML and NSCQ libraries, gets device counts, and unloads libraries automatically.
132
+
133
+ **Parameters**: None
134
+
135
+ **Returns**: `{gpuCount: number, nvswitchCount: number}`
136
+
137
+ **Throws**: Error if libraries are loaded but data retrieval fails
138
+
139
+ **Example**:
140
+ ```javascript
141
+ const topology = attestation.getDeviceTopology();
142
+ console.log(`GPUs: ${topology.gpuCount}`);
143
+ console.log(`NVSwitches: ${topology.nvswitchCount}`);
144
+ ```
145
+
146
+ **Error Handling**:
147
+ ```javascript
148
+ try {
149
+ const topology = attestation.getDeviceTopology();
150
+ console.log(`Found ${topology.gpuCount} GPUs and ${topology.nvswitchCount} NVSwitches`);
151
+ } catch (error) {
152
+ console.error('Failed to get topology:', error.message);
153
+ }
154
+ ```
155
+
156
+ **Notes**:
157
+ - Requires NVIDIA Driver with NVML support
158
+ - NVSwitch requires NSCQ library (optional)
159
+ - Returns 0 if libraries are not installed (graceful degradation)
160
+ - Throws if libraries are loaded but data retrieval fails
161
+
162
+ ### getDeviceInfo()
163
+
164
+ Retrieves device information.
165
+
166
+ **Returns**: `{deviceId: string, vendor: string, attestationSupported: boolean}`
167
+
168
+ ## See also
169
+
170
+ See the main project README for full documentation.
171
+
172
+ ## License
173
+
174
+ ISC
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "nvidia-native",
3
+ "version": "1.0.0",
4
+ "description": "Native Node.js addon for NVIDIA attestation",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "install": "node-gyp rebuild",
8
+ "build": "node-gyp rebuild",
9
+ "clean": "node-gyp clean"
10
+ },
11
+ "gypfile": true,
12
+ "dependencies": {
13
+ "node-addon-api": "^5.0.0"
14
+ },
15
+ "devDependencies": {
16
+ "node-gyp": "^9.0.0"
17
+ },
18
+ "keywords": [
19
+ "nvidia",
20
+ "attestation",
21
+ "tee",
22
+ "native"
23
+ ],
24
+ "author": "",
25
+ "license": "ISC"
26
+ }
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const releaseDir = path.join(__dirname, 'build', 'Release');
7
+ const libFile = 'libnvat.so.1.1.0';
8
+ const libPath = path.join(releaseDir, libFile);
9
+
10
+ if (!fs.existsSync(libPath)) {
11
+ console.error(`FATAL: Required library not found: ${libPath}`);
12
+ process.exit(1);
13
+ }
14
+
15
+ const symlink1 = path.join(releaseDir, 'libnvat.so.1');
16
+ const symlink2 = path.join(releaseDir, 'libnvat.so');
17
+
18
+ // Create symlink libnvat.so.1 -> libnvat.so.1.1.0
19
+ try {
20
+ if (fs.existsSync(symlink1)) {
21
+ fs.unlinkSync(symlink1);
22
+ }
23
+ fs.symlinkSync(libFile, symlink1);
24
+ console.log('Created symlink: libnvat.so.1 -> libnvat.so.1.1.0');
25
+ } catch (err) {
26
+ console.error(`FATAL: Failed to create symlink ${symlink1}: ${err.message}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ // Create symlink libnvat.so -> libnvat.so.1
31
+ try {
32
+ if (fs.existsSync(symlink2)) {
33
+ fs.unlinkSync(symlink2);
34
+ }
35
+ fs.symlinkSync('libnvat.so.1', symlink2);
36
+ console.log('Created symlink: libnvat.so -> libnvat.so.1');
37
+ } catch (err) {
38
+ console.error(`FATAL: Failed to create symlink ${symlink2}: ${err.message}`);
39
+ process.exit(1);
40
+ }
@@ -0,0 +1,6 @@
1
+ # This file is generated by gyp; do not edit.
2
+
3
+ export builddir_name ?= ./build/../../usr/lib/node_modules/node-addon-api/.
4
+ .PHONY: all
5
+ all:
6
+ $(MAKE) -C ../../../../nvidia-native/build nothing
@@ -0,0 +1,159 @@
1
+ # This file is generated by gyp; do not edit.
2
+
3
+ TOOLSET := target
4
+ TARGET := nothing
5
+ DEFS_Debug := \
6
+ '-DNODE_GYP_MODULE_NAME=nothing' \
7
+ '-DUSING_UV_SHARED=1' \
8
+ '-DUSING_V8_SHARED=1' \
9
+ '-DV8_DEPRECATION_WARNINGS=1' \
10
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
11
+ '-D_FILE_OFFSET_BITS=64' \
12
+ '-D_LARGEFILE_SOURCE' \
13
+ '-D__STDC_FORMAT_MACROS' \
14
+ '-DOPENSSL_NO_PINSHARED' \
15
+ '-DOPENSSL_THREADS' \
16
+ '-DDEBUG' \
17
+ '-D_DEBUG'
18
+
19
+ # Flags passed to all source files.
20
+ CFLAGS_Debug := \
21
+ -fPIC \
22
+ -pthread \
23
+ -Wall \
24
+ -Wextra \
25
+ -Wno-unused-parameter \
26
+ -m64 \
27
+ -g \
28
+ -O0
29
+
30
+ # Flags passed to only C files.
31
+ CFLAGS_C_Debug :=
32
+
33
+ # Flags passed to only C++ files.
34
+ CFLAGS_CC_Debug := \
35
+ -fno-rtti \
36
+ -fno-exceptions \
37
+ -std=gnu++17
38
+
39
+ INCS_Debug := \
40
+ -I/root/.cache/node-gyp/20.20.0/include/node \
41
+ -I/root/.cache/node-gyp/20.20.0/src \
42
+ -I/root/.cache/node-gyp/20.20.0/deps/openssl/config \
43
+ -I/root/.cache/node-gyp/20.20.0/deps/openssl/openssl/include \
44
+ -I/root/.cache/node-gyp/20.20.0/deps/uv/include \
45
+ -I/root/.cache/node-gyp/20.20.0/deps/zlib \
46
+ -I/root/.cache/node-gyp/20.20.0/deps/v8/include
47
+
48
+ DEFS_Release := \
49
+ '-DNODE_GYP_MODULE_NAME=nothing' \
50
+ '-DUSING_UV_SHARED=1' \
51
+ '-DUSING_V8_SHARED=1' \
52
+ '-DV8_DEPRECATION_WARNINGS=1' \
53
+ '-D_GLIBCXX_USE_CXX11_ABI=1' \
54
+ '-D_FILE_OFFSET_BITS=64' \
55
+ '-D_LARGEFILE_SOURCE' \
56
+ '-D__STDC_FORMAT_MACROS' \
57
+ '-DOPENSSL_NO_PINSHARED' \
58
+ '-DOPENSSL_THREADS'
59
+
60
+ # Flags passed to all source files.
61
+ CFLAGS_Release := \
62
+ -fPIC \
63
+ -pthread \
64
+ -Wall \
65
+ -Wextra \
66
+ -Wno-unused-parameter \
67
+ -m64 \
68
+ -O3 \
69
+ -fno-omit-frame-pointer
70
+
71
+ # Flags passed to only C files.
72
+ CFLAGS_C_Release :=
73
+
74
+ # Flags passed to only C++ files.
75
+ CFLAGS_CC_Release := \
76
+ -fno-rtti \
77
+ -fno-exceptions \
78
+ -std=gnu++17
79
+
80
+ INCS_Release := \
81
+ -I/root/.cache/node-gyp/20.20.0/include/node \
82
+ -I/root/.cache/node-gyp/20.20.0/src \
83
+ -I/root/.cache/node-gyp/20.20.0/deps/openssl/config \
84
+ -I/root/.cache/node-gyp/20.20.0/deps/openssl/openssl/include \
85
+ -I/root/.cache/node-gyp/20.20.0/deps/uv/include \
86
+ -I/root/.cache/node-gyp/20.20.0/deps/zlib \
87
+ -I/root/.cache/node-gyp/20.20.0/deps/v8/include
88
+
89
+ OBJS := \
90
+ $(obj).target/$(TARGET)/../../usr/lib/node_modules/node-addon-api/nothing.o
91
+
92
+ # Add to the list of files we specially track dependencies for.
93
+ all_deps += $(OBJS)
94
+
95
+ # CFLAGS et al overrides must be target-local.
96
+ # See "Target-specific Variable Values" in the GNU Make manual.
97
+ $(OBJS): TOOLSET := $(TOOLSET)
98
+ $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
99
+ $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
100
+
101
+ # Suffix rules, putting all outputs into $(obj).
102
+
103
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
104
+ @$(call do_cmd,cc,1)
105
+
106
+ # Try building from generated source, too.
107
+
108
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
109
+ @$(call do_cmd,cc,1)
110
+
111
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
112
+ @$(call do_cmd,cc,1)
113
+
114
+ # End of this set of suffix rules
115
+ ### Rules for final target.
116
+ LDFLAGS_Debug := \
117
+ -pthread \
118
+ -rdynamic \
119
+ -m64
120
+
121
+ LDFLAGS_Release := \
122
+ -pthread \
123
+ -rdynamic \
124
+ -m64
125
+
126
+ LIBS :=
127
+
128
+ $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
129
+ $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a: LIBS := $(LIBS)
130
+ $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a: TOOLSET := $(TOOLSET)
131
+ $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a: $(OBJS)
132
+ $(call create_archive,$@,$^)
133
+
134
+ # Add target alias
135
+ .PHONY: nothing
136
+ nothing: $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a
137
+
138
+ # Add target alias to "all" target.
139
+ .PHONY: all
140
+ all: nothing
141
+
142
+ # Add target alias
143
+ .PHONY: nothing
144
+ nothing: $(builddir)/nothing.a
145
+
146
+ # Copy this to the static library output path.
147
+ $(builddir)/nothing.a: TOOLSET := $(TOOLSET)
148
+ $(builddir)/nothing.a: $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a FORCE_DO_CMD
149
+ $(call do_cmd,copy)
150
+
151
+ all_deps += $(builddir)/nothing.a
152
+ # Short alias for building this static library.
153
+ .PHONY: nothing.a
154
+ nothing.a: $(obj).target/../../usr/lib/node_modules/node-addon-api/nothing.a $(builddir)/nothing.a
155
+
156
+ # Add static library to "all" target.
157
+ .PHONY: all
158
+ all: $(builddir)/nothing.a
159
+
Binary file
Binary file
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * as SgxNative from "./sgx-native-module";
2
+ export * as NvidiaNative from "./nvidia-native-module/nvidia-attestation";
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.SgxNative = void 0;
26
+ exports.NvidiaNative = exports.SgxNative = void 0;
27
27
  exports.SgxNative = __importStar(require("./sgx-native-module"));
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxpRUFBaUQifQ==
28
+ exports.NvidiaNative = __importStar(require("./nvidia-native-module/nvidia-attestation"));
29
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxpRUFBaUQ7QUFDakQsMEZBQTBFIn0=
@@ -0,0 +1,146 @@
1
+ /// <reference types="node" />
2
+ import { Static } from "@sinclair/typebox";
3
+ export declare const MIN_NONCE_LENGTH = 32;
4
+ export declare const DEFAULT_NRAS_URL = "https://nras.attestation.nvidia.com";
5
+ export declare const NVIDIA_DETAILED_POLICY_RELATIVE_PATH = "nvidia-detailed-policy.rego";
6
+ export declare const NVIDIA_DEBUG_STATE_POLICY_RELATIVE_PATH = "nvidia-debug-state-policy.rego";
7
+ export declare enum NvidiaDeviceType {
8
+ GPU = 0,
9
+ NVSWITCH = 1
10
+ }
11
+ declare const NvidiaAttestationResultSchema: import("@sinclair/typebox").TObject<{
12
+ success: import("@sinclair/typebox").TBoolean;
13
+ jwt: import("@sinclair/typebox").TString;
14
+ claims: import("@sinclair/typebox").TString;
15
+ logs: import("@sinclair/typebox").TString;
16
+ }>;
17
+ export type NvidiaAttestationResult = Static<typeof NvidiaAttestationResultSchema>;
18
+ declare const NvidiaDeviceTopologySchema: import("@sinclair/typebox").TObject<{
19
+ gpuCount: import("@sinclair/typebox").TInteger;
20
+ nvswitchCount: import("@sinclair/typebox").TInteger;
21
+ logs: import("@sinclair/typebox").TString;
22
+ }>;
23
+ export type NvidiaDeviceTopology = Static<typeof NvidiaDeviceTopologySchema>;
24
+ export type NvidiaAttestationOptions = {
25
+ nonce?: Buffer;
26
+ serviceKey?: string;
27
+ nrasUrl?: string;
28
+ };
29
+ export type NvidiaJwtVerificationParams = {
30
+ jwt: string;
31
+ serviceKey?: string;
32
+ nrasUrl?: string;
33
+ };
34
+ export type NvidiaPolicyEvaluationParams = {
35
+ claims: string;
36
+ regoPolicy: string;
37
+ };
38
+ declare const NvidiaJwtVerificationResultSchema: import("@sinclair/typebox").TObject<{
39
+ result: import("@sinclair/typebox").TBoolean;
40
+ claims: import("@sinclair/typebox").TString;
41
+ msg: import("@sinclair/typebox").TString;
42
+ logs: import("@sinclair/typebox").TString;
43
+ }>;
44
+ export type NvidiaJwtVerificationResult = Static<typeof NvidiaJwtVerificationResultSchema>;
45
+ declare const NvidiaPolicyEvaluationResultSchema: import("@sinclair/typebox").TObject<{
46
+ result: import("@sinclair/typebox").TBoolean;
47
+ msg: import("@sinclair/typebox").TString;
48
+ details: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
49
+ logs: import("@sinclair/typebox").TString;
50
+ }>;
51
+ export type NvidiaPolicyEvaluationResult = Static<typeof NvidiaPolicyEvaluationResultSchema>;
52
+ declare const NvtrustGPUInfoSchema: import("@sinclair/typebox").TObject<{
53
+ model: import("@sinclair/typebox").TString;
54
+ driverVersion: import("@sinclair/typebox").TString;
55
+ vbios: import("@sinclair/typebox").TString;
56
+ dbgStat: import("@sinclair/typebox").TBoolean;
57
+ }>;
58
+ export type NvtrustGPUInfo = Static<typeof NvtrustGPUInfoSchema>;
59
+ export declare class NvidiaAttestationError extends Error {
60
+ constructor(message?: string);
61
+ }
62
+ export declare class NvidiaAttestationErrorWithLogs extends NvidiaAttestationError {
63
+ readonly logs?: string | undefined;
64
+ constructor(message: string, logs?: string | undefined);
65
+ }
66
+ /**
67
+ * Parses a raw claims JSON string (array of JWT payloads) into typed GPU info objects.
68
+ *
69
+ * @param claims - JSON string containing an array of NVIDIA JWT payload objects.
70
+ * @returns Array of parsed and validated GPU info objects.
71
+ * @throws NvidiaAttestationError when the input is not valid JSON, not an array,
72
+ * or any element fails schema validation.
73
+ */
74
+ export declare function ParseGpuClaim(claims: string): NvtrustGPUInfo[];
75
+ export declare class NvidiaAttestationService {
76
+ private static readonly policyCache;
77
+ private readonly native;
78
+ private getNvidiaDetailedPolicyPath;
79
+ private getNvidiaDebugStatePolicyPath;
80
+ /**
81
+ * Loads bundled detailed NVIDIA Rego policy from package files.
82
+ *
83
+ * The policy content is cached after first successful read.
84
+ *
85
+ * @returns Rego policy text.
86
+ */
87
+ getNvidiaDetailedPolicy(): Promise<string>;
88
+ /**
89
+ * Loads bundled debug-state NVIDIA Rego policy from package files.
90
+ *
91
+ * Checks device type, secure boot and debug status.
92
+ * The policy content is cached after first successful read.
93
+ *
94
+ * @returns Rego policy text.
95
+ */
96
+ getNvidiaDebugStatePolicy(): Promise<string>;
97
+ /**
98
+ * Loads a policy file using single-flight caching keyed by absolute path.
99
+ *
100
+ * Concurrent callers for the same path share one in-flight read.
101
+ * On failure the cache entry is removed so the next call retries.
102
+ */
103
+ private loadCachedPolicy;
104
+ /**
105
+ * Creates NVIDIA attestation service instance and initializes native SDK bindings.
106
+ *
107
+ * @throws NvidiaAttestationError when native NVIDIA attestation layer cannot be initialized.
108
+ */
109
+ constructor();
110
+ /**
111
+ * Generates cryptographically secure nonce via native NVIDIA SDK.
112
+ *
113
+ * @param length - Nonce size in bytes (default: 32).
114
+ * @returns Nonce bytes.
115
+ */
116
+ generateNonce(length?: number): Promise<Buffer>;
117
+ /**
118
+ * Performs GPU attestation via NVIDIA Remote Attestation Service (NRAS).
119
+ *
120
+ * @param options - Attestation options.
121
+ * @returns Attestation result (`success`, `jwt`, `claims`).
122
+ */
123
+ attestGpuWithNRAS(options?: NvidiaAttestationOptions): Promise<NvidiaAttestationResult>;
124
+ /**
125
+ * Performs NVSwitch attestation via NVIDIA Remote Attestation Service (NRAS).
126
+ *
127
+ * @param options - Attestation options.
128
+ * @returns Attestation result (`success`, `jwt`, `claims`).
129
+ */
130
+ attestNvSwitchWithNRAS(options?: NvidiaAttestationOptions): Promise<NvidiaAttestationResult>;
131
+ /**
132
+ * Retrieves NVIDIA device topology (GPU and NVSwitch counts) from native layer.
133
+ *
134
+ * @returns Device topology data.
135
+ */
136
+ getDeviceTopology(): Promise<NvidiaDeviceTopology>;
137
+ /**
138
+ * Verifies detached EAT JWT cryptographically via NRAS and returns decoded claims.
139
+ */
140
+ verifyJwt(params: NvidiaJwtVerificationParams): Promise<NvidiaJwtVerificationResult>;
141
+ /**
142
+ * Evaluates attestation claims against a Rego policy and returns policy diagnostics.
143
+ */
144
+ evaluatePolicy(params: NvidiaPolicyEvaluationParams): Promise<NvidiaPolicyEvaluationResult>;
145
+ }
146
+ export {};