node-redfish 1.0.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.
- package/LICENSE +201 -0
- package/README.md +138 -0
- package/dist/client.d.ts +125 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.integration.test.d.ts +2 -0
- package/dist/client.integration.test.d.ts.map +1 -0
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +346 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +342 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.ts +200 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 ProjectSource V.o.F.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# node-redfish
|
|
2
|
+
|
|
3
|
+
[](https://github.com/SourceRegistry/node-redfish/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/node-redfish)
|
|
5
|
+
[](https://www.npmjs.com/package/node-redfish)
|
|
6
|
+
[](https://sourceregistry.github.io/node-redfish/)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
9
|
+
|
|
10
|
+
A TypeScript client for querying and managing [Redfish](https://www.dmtf.org/standards/redfish)-compliant BMCs (Dell iDRAC, HPE iLO, Lenovo XCC, Supermicro, and other DMTF Redfish implementations).
|
|
11
|
+
|
|
12
|
+
Ships as dual ESM/CJS with bundled type declarations, built with [Vite](https://vitejs.dev) in library mode.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install node-redfish
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { RedfishClient } from 'node-redfish';
|
|
24
|
+
|
|
25
|
+
const client = new RedfishClient({
|
|
26
|
+
baseUrl: 'https://10.0.0.5',
|
|
27
|
+
auth: { type: 'session', username: 'admin', password: 'secret' },
|
|
28
|
+
// Most BMCs ship a self-signed TLS certificate.
|
|
29
|
+
insecure: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await client.connect();
|
|
33
|
+
|
|
34
|
+
const root = await client.getServiceRoot();
|
|
35
|
+
console.log(root.RedfishVersion);
|
|
36
|
+
|
|
37
|
+
const systems = await client.getSystems();
|
|
38
|
+
for (const system of systems) {
|
|
39
|
+
console.log(system.Id, system.PowerState, system.Status?.Health);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
await client.resetSystem(systems[0].Id!, 'GracefulRestart');
|
|
43
|
+
|
|
44
|
+
await client.disconnect();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Authentication
|
|
48
|
+
|
|
49
|
+
Three strategies are supported via the `auth` option:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// HTTP Basic auth on every request
|
|
53
|
+
{ type: 'basic', username: 'admin', password: 'secret' }
|
|
54
|
+
|
|
55
|
+
// Redfish session auth: connect() creates a session and captures
|
|
56
|
+
// X-Auth-Token; disconnect() deletes it.
|
|
57
|
+
{ type: 'session', username: 'admin', password: 'secret' }
|
|
58
|
+
|
|
59
|
+
// A pre-existing X-Auth-Token / bearer-style token
|
|
60
|
+
{ type: 'token', token: 'abc123' }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Omit `auth` (or pass `{ type: 'none' }`) for unauthenticated requests.
|
|
64
|
+
|
|
65
|
+
### Self-signed certificates
|
|
66
|
+
|
|
67
|
+
BMCs commonly present a self-signed or vendor-CA certificate. Pass `insecure: true` to skip TLS verification (backed by an [undici](https://github.com/nodejs/undici) `Agent`).
|
|
68
|
+
|
|
69
|
+
### API surface
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
client.getServiceRoot();
|
|
73
|
+
|
|
74
|
+
client.getSystems(); // expanded ComputerSystem[]
|
|
75
|
+
client.getSystemIds(); // string[] of resource IDs
|
|
76
|
+
client.getSystem(id);
|
|
77
|
+
client.resetSystem(id, resetType); // 'On' | 'ForceOff' | 'GracefulRestart' | ...
|
|
78
|
+
|
|
79
|
+
client.getChassisCollection();
|
|
80
|
+
client.getChassis(id);
|
|
81
|
+
client.getPower(chassisId);
|
|
82
|
+
client.getThermal(chassisId);
|
|
83
|
+
|
|
84
|
+
client.getManagers();
|
|
85
|
+
client.getManager(id);
|
|
86
|
+
client.resetManager(id, resetType);
|
|
87
|
+
|
|
88
|
+
client.getSessions();
|
|
89
|
+
|
|
90
|
+
// Generic escape hatches for anything not wrapped above
|
|
91
|
+
client.get(path);
|
|
92
|
+
client.post(path, body);
|
|
93
|
+
client.patch(path, body, etag); // sends If-Match when etag is given
|
|
94
|
+
client.put(path, body, etag);
|
|
95
|
+
client.delete(path);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`resetSystem`/`resetManager` read the action `target` URL from the resource's own `Actions` block (per the Redfish spec) rather than assuming a fixed path, and throw `RedfishActionNotSupportedError` if the resource doesn't advertise that action.
|
|
99
|
+
|
|
100
|
+
### Errors
|
|
101
|
+
|
|
102
|
+
- `RedfishError` — non-2xx response; carries `status`, `statusText`, parsed `body`, and `extendedInfo` (from `@Message.ExtendedInfo`).
|
|
103
|
+
- `RedfishTimeoutError` — request exceeded `timeoutMs` (default 15s).
|
|
104
|
+
- `RedfishActionNotSupportedError` — requested action isn't present on the resource.
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
npm ci
|
|
110
|
+
npm run lint
|
|
111
|
+
npm run typecheck
|
|
112
|
+
npm test
|
|
113
|
+
npm run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Integration tests
|
|
117
|
+
|
|
118
|
+
`npm test` only runs against a mocked `fetch`. `src/client.integration.test.ts` additionally exercises the client against a real Redfish HTTP server — [DMTF's own reference emulator](https://github.com/DMTF/Redfish-Interface-Emulator) — and is skipped automatically when nothing answers at `REDFISH_TEST_BASE_URL` (default `http://localhost:5000`):
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
docker run --rm -p 5000:5000 dmtf/redfish-interface-emulator:latest
|
|
122
|
+
npm run test:integration
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
It covers the read surface (`getServiceRoot`, `getSystems`, `getSystem`, `getChassisCollection`) and action discovery/invocation (`resetSystem`). The emulator's bundled `SessionService` fixture predates the current spec and doesn't support session creation, so `{ type: 'session' }` auth isn't covered by it.
|
|
126
|
+
|
|
127
|
+
Other DMTF tooling worth knowing about if you're extending this package:
|
|
128
|
+
- [Redfish-Mockup-Server](https://github.com/DMTF/Redfish-Mockup-Server) — serves static JSON mockups (GET-only), useful for read-path fixtures against specific vendor mockup data (DSP2043).
|
|
129
|
+
- [Redfish-Service-Validator](https://github.com/DMTF/Redfish-Service-Validator) / [Redfish-Protocol-Validator](https://github.com/DMTF/Redfish-Protocol-Validator) — conformance checkers for a *service*, not a client, but useful for validating any target BMC before filing a bug against this client.
|
|
130
|
+
- [python-redfish-library](https://github.com/DMTF/python-redfish-library) — DMTF's official Python client; this package's `auth`/`connect`/`disconnect` shape and the `insecure` TLS option mirror its `redfish_client`/`login`/`cafile` design.
|
|
131
|
+
|
|
132
|
+
## Publishing
|
|
133
|
+
|
|
134
|
+
CI (`.github/workflows/ci.yml`) publishes to npm on `v*` tags using the `NPM_TOKEN` repository secret. Once this package is enrolled in [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers), the publish job should switch to OIDC (`id-token: write` + `npm publish --provenance`, no token secret) — see the `TODO` in the workflow file.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
Apache-2.0
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Chassis, ComputerSystem, Manager, Power, RedfishCollection, ResetType, ServiceRoot, Session, Thermal } from './types.js';
|
|
2
|
+
export interface RedfishAuthBasic {
|
|
3
|
+
type: 'basic';
|
|
4
|
+
username: string;
|
|
5
|
+
password: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RedfishAuthSession {
|
|
8
|
+
type: 'session';
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RedfishAuthToken {
|
|
13
|
+
type: 'token';
|
|
14
|
+
token: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RedfishAuthNone {
|
|
17
|
+
type: 'none';
|
|
18
|
+
}
|
|
19
|
+
export type RedfishAuth = RedfishAuthBasic | RedfishAuthSession | RedfishAuthToken | RedfishAuthNone;
|
|
20
|
+
export interface RedfishClientOptions {
|
|
21
|
+
/** Base URL of the BMC, e.g. `https://10.0.0.5` */
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
/** Authentication strategy. Defaults to `{ type: 'none' }`. */
|
|
24
|
+
auth?: RedfishAuth;
|
|
25
|
+
/**
|
|
26
|
+
* Skip TLS certificate verification. Most BMCs ship a self-signed
|
|
27
|
+
* certificate, so this is commonly needed. Defaults to `false`.
|
|
28
|
+
*/
|
|
29
|
+
insecure?: boolean;
|
|
30
|
+
/** Root service path. Defaults to `/redfish/v1`. */
|
|
31
|
+
servicePath?: string;
|
|
32
|
+
/** Per-request timeout in milliseconds. Defaults to 15000. */
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
/** Override the fetch implementation (mainly for testing). */
|
|
35
|
+
fetch?: typeof fetch;
|
|
36
|
+
}
|
|
37
|
+
export interface RedfishResponse<T> {
|
|
38
|
+
data: T;
|
|
39
|
+
status: number;
|
|
40
|
+
etag?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface RequestOptions {
|
|
43
|
+
method?: string;
|
|
44
|
+
body?: unknown;
|
|
45
|
+
etag?: string;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Client for querying and managing Redfish-compliant BMCs.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const client = new RedfishClient({
|
|
55
|
+
* baseUrl: 'https://10.0.0.5',
|
|
56
|
+
* auth: { type: 'session', username: 'admin', password: 'secret' },
|
|
57
|
+
* insecure: true,
|
|
58
|
+
* });
|
|
59
|
+
* await client.connect();
|
|
60
|
+
* const systems = await client.getSystems();
|
|
61
|
+
* await client.resetSystem(systems[0].Id!, 'GracefulRestart');
|
|
62
|
+
* await client.disconnect();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare class RedfishClient {
|
|
66
|
+
private readonly baseUrl;
|
|
67
|
+
private readonly servicePath;
|
|
68
|
+
private readonly auth;
|
|
69
|
+
private readonly timeoutMs;
|
|
70
|
+
private readonly fetchImpl;
|
|
71
|
+
private readonly dispatcher;
|
|
72
|
+
private token;
|
|
73
|
+
private sessionLocation;
|
|
74
|
+
constructor(options: RedfishClientOptions);
|
|
75
|
+
/** Whether the client currently holds a session token (from `connect()` or `type: 'token'` auth). */
|
|
76
|
+
get isAuthenticated(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Establishes a session for `{ type: 'session' }` auth by creating a
|
|
79
|
+
* Redfish session and capturing the `X-Auth-Token`. No-op for other auth
|
|
80
|
+
* types.
|
|
81
|
+
*/
|
|
82
|
+
connect(): Promise<void>;
|
|
83
|
+
/** Deletes the active session, if one was established via `connect()`. */
|
|
84
|
+
disconnect(): Promise<void>;
|
|
85
|
+
/** Fetches the service root document (`/redfish/v1/`). */
|
|
86
|
+
getServiceRoot(): Promise<ServiceRoot>;
|
|
87
|
+
getSystems(): Promise<ComputerSystem[]>;
|
|
88
|
+
getSystemIds(): Promise<string[]>;
|
|
89
|
+
getSystem(id: string): Promise<ComputerSystem>;
|
|
90
|
+
/**
|
|
91
|
+
* Invokes `#ComputerSystem.Reset` on the given system. The action target
|
|
92
|
+
* is read from the system's `Actions` block so vendor-specific paths are
|
|
93
|
+
* respected; falls back to the standard path if absent.
|
|
94
|
+
*/
|
|
95
|
+
resetSystem(id: string, resetType: ResetType): Promise<void>;
|
|
96
|
+
getChassisCollection(): Promise<Chassis[]>;
|
|
97
|
+
getChassisIds(): Promise<string[]>;
|
|
98
|
+
getChassis(id: string): Promise<Chassis>;
|
|
99
|
+
getPower(chassisId: string): Promise<Power>;
|
|
100
|
+
getThermal(chassisId: string): Promise<Thermal>;
|
|
101
|
+
getManagers(): Promise<Manager[]>;
|
|
102
|
+
getManagerIds(): Promise<string[]>;
|
|
103
|
+
getManager(id: string): Promise<Manager>;
|
|
104
|
+
resetManager(id: string, resetType: ResetType): Promise<void>;
|
|
105
|
+
getSessions(): Promise<Session[]>;
|
|
106
|
+
get<T>(path: string): Promise<T>;
|
|
107
|
+
/** PATCH a resource. Pass `etag` to send `If-Match` (recommended by the Redfish spec for PATCH). */
|
|
108
|
+
patch<T>(path: string, body: unknown, etag?: string): Promise<T>;
|
|
109
|
+
/** PUT a full resource replacement. Rarely used by Redfish services compared to PATCH. */
|
|
110
|
+
put<T>(path: string, body: unknown, etag?: string): Promise<T>;
|
|
111
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
112
|
+
delete<T = void>(path: string): Promise<T>;
|
|
113
|
+
/** Fetches a Redfish collection resource (the `Members` array of `@odata.id` links), unexpanded. */
|
|
114
|
+
getCollection(path: string): Promise<RedfishCollection>;
|
|
115
|
+
/** Fetches a collection and resolves every member to its full resource body. */
|
|
116
|
+
getExpandedCollection<T>(path: string): Promise<T[]>;
|
|
117
|
+
private getCollectionIds;
|
|
118
|
+
private invokeAction;
|
|
119
|
+
private withinService;
|
|
120
|
+
private resolve;
|
|
121
|
+
private authHeaders;
|
|
122
|
+
private request;
|
|
123
|
+
private rawFetch;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,OAAO,EACP,KAAK,EAEL,iBAAiB,EAEjB,SAAS,EACT,WAAW,EACX,OAAO,EACP,OAAO,EACR,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAErG,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D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C,CAAC;IAKjD,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAKhD,oGAAoG;IACpG,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIvD,gFAAgF;IAC1E,qBAAqB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;YAK5C,gBAAgB;YAKhB,YAAY;IAY1B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,WAAW;YAWL,OAAO;YAkCP,QAAQ;CAuBvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.integration.test.d.ts","sourceRoot":"","sources":["../src/client.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RedfishErrorPayload } from './types.js';
|
|
2
|
+
/** Thrown for any non-2xx response from a Redfish service. */
|
|
3
|
+
export declare class RedfishError extends Error {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly statusText: string;
|
|
7
|
+
readonly body?: RedfishErrorPayload | string;
|
|
8
|
+
constructor(message: string, options: {
|
|
9
|
+
url: string;
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
body?: RedfishErrorPayload | string;
|
|
13
|
+
});
|
|
14
|
+
/** Extracted `@Message.ExtendedInfo` entries, if the service returned an extended-info error body. */
|
|
15
|
+
get extendedInfo(): Array<{
|
|
16
|
+
MessageId?: string;
|
|
17
|
+
Message?: string;
|
|
18
|
+
Severity?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
/** Thrown when a request exceeds the configured timeout. */
|
|
22
|
+
export declare class RedfishTimeoutError extends Error {
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly timeoutMs: number;
|
|
25
|
+
constructor(url: string, timeoutMs: number);
|
|
26
|
+
}
|
|
27
|
+
/** Thrown when a resource does not expose an action the client was asked to invoke. */
|
|
28
|
+
export declare class RedfishActionNotSupportedError extends Error {
|
|
29
|
+
readonly action: string;
|
|
30
|
+
readonly resourceId: string;
|
|
31
|
+
constructor(action: string, resourceId: string);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,8DAA8D;AAC9D,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;gBAEjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAA;KAAE;IAS9H,sGAAsG;IACtG,IAAI,YAAY,IAAI,KAAK,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAKrF;CACF;AAED,4DAA4D;AAC5D,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,GAAG,EAAE,MAAM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