node-redfish 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -1,17 +1,56 @@
1
+ <div align="center">
2
+
3
+ <a href="https://www.dmtf.org/standards/redfish">
4
+ <img src="https://redfish.dmtf.org/sites/default/files/DMTF_Redfish_logo_R.jpg" alt="DMTF Redfish logo" width="320" />
5
+ </a>
6
+
1
7
  # node-redfish
2
8
 
3
- [![CI](https://github.com/SourceRegistry/node-redfish/actions/workflows/ci.yml/badge.svg)](https://github.com/SourceRegistry/node-redfish/actions/workflows/ci.yml)
4
- [![npm version](https://img.shields.io/npm/v/node-redfish.svg)](https://www.npmjs.com/package/node-redfish)
5
- [![npm downloads](https://img.shields.io/npm/dm/node-redfish.svg)](https://www.npmjs.com/package/node-redfish)
6
- [![docs](https://img.shields.io/badge/docs-typedoc-blue)](https://sourceregistry.github.io/node-redfish/)
7
- [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
8
- [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
9
+ TypeScript client for the DMTF [Redfish](https://www.dmtf.org/standards/redfish) API
10
+
11
+ [![CI](https://img.shields.io/github/actions/workflow/status/SourceRegistry/node-redfish/ci.yml?branch=main&label=CI)](https://github.com/SourceRegistry/node-redfish/actions/workflows/ci.yml)
12
+ [![npm version](https://img.shields.io/npm/v/node-redfish)](https://www.npmjs.com/package/node-redfish)
13
+ [![npm downloads](https://img.shields.io/npm/dm/node-redfish)](https://www.npmjs.com/package/node-redfish)
14
+ [![Node.js](https://img.shields.io/node/v/node-redfish)](https://nodejs.org)
15
+ [![License](https://img.shields.io/npm/l/node-redfish)](./LICENSE)
16
+
17
+ [Documentation](https://sourceregistry.github.io/node-redfish/) |
18
+ [npm](https://www.npmjs.com/package/node-redfish) |
19
+ [Changelog](./CHANGELOG.md) |
20
+ [Issues](https://github.com/SourceRegistry/node-redfish/issues) |
21
+ [Security](./SECURITY.md)
22
+
23
+ </div>
24
+
25
+ ## Overview
26
+
27
+ `node-redfish` is a client library for querying and managing baseboard management controllers (BMCs) that implement the DMTF Redfish standard, including Dell iDRAC, HPE iLO, Lenovo XClarity Controller, and Supermicro BMCs.
9
28
 
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).
29
+ **Key capabilities**
11
30
 
12
- Ships as dual ESM/CJS with bundled type declarations. Full API reference: **https://sourceregistry.github.io/node-redfish/**
31
+ - HTTP Basic, Redfish session (`X-Auth-Token`), and pre-issued token authentication
32
+ - Optional acceptance of self-signed or vendor-issued TLS certificates
33
+ - Action targets resolved from each resource's `Actions` block, as defined by the specification
34
+ - Typed helpers for Systems, Chassis, Managers, and Sessions, plus generic request methods for any other resource
35
+ - Dual ESM/CommonJS distribution with bundled type declarations
13
36
 
14
- ## Install
37
+ ## Contents
38
+
39
+ - [Requirements](#requirements)
40
+ - [Installation](#installation)
41
+ - [Usage](#usage)
42
+ - [Authentication](#authentication)
43
+ - [Self-signed certificates](#self-signed-certificates)
44
+ - [API surface](#api-surface)
45
+ - [Errors](#errors)
46
+ - [Contributing](#contributing)
47
+ - [License](#license)
48
+
49
+ ## Requirements
50
+
51
+ - Node.js 18.17 or later
52
+
53
+ ## Installation
15
54
 
16
55
  ```sh
17
56
  npm install node-redfish
@@ -99,14 +138,20 @@ client.delete(path);
99
138
 
100
139
  ### Errors
101
140
 
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.
141
+ | Error | When it's thrown |
142
+ | --- | --- |
143
+ | `RedfishError` | Non-2xx response; carries `status`, `statusText`, parsed `body`, and `extendedInfo` (from `@Message.ExtendedInfo`). |
144
+ | `RedfishTimeoutError` | Request exceeded `timeoutMs` (default 15s). |
145
+ | `RedfishActionNotSupportedError` | Requested action isn't present on the resource. |
105
146
 
106
147
  ## Contributing
107
148
 
108
149
  See [DEVELOPMENT.md](./DEVELOPMENT.md) for local setup, testing (including integration tests against a real Redfish server), and the release process.
109
150
 
151
+ Bug reports and feature requests are welcome through the [issue tracker](https://github.com/SourceRegistry/node-redfish/issues/new/choose). To report a security vulnerability, follow the [security policy](./SECURITY.md) instead of opening a public issue.
152
+
110
153
  ## License
111
154
 
112
- Apache-2.0
155
+ [Apache-2.0](./LICENSE)
156
+
157
+ <sub>Redfish and the Redfish logo are trademarks of DMTF. This project is not affiliated with or endorsed by DMTF.</sub>
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let undici = require("undici");
3
- //#region src/errors.ts
3
+ // src/errors.ts
4
4
  /** Thrown for any non-2xx response from a Redfish service. */
5
5
  var RedfishError = class extends Error {
6
6
  url;
@@ -43,8 +43,7 @@ var RedfishActionNotSupportedError = class extends Error {
43
43
  this.resourceId = resourceId;
44
44
  }
45
45
  };
46
- //#endregion
47
- //#region src/client.ts
46
+ // src/client.ts
48
47
  var DEFAULT_SERVICE_PATH = "/redfish/v1";
49
48
  var DEFAULT_TIMEOUT_MS = 15e3;
50
49
  /**
@@ -337,7 +336,6 @@ async function throwRedfishError(response) {
337
336
  body
338
337
  });
339
338
  }
340
- //#endregion
341
339
  exports.RedfishActionNotSupportedError = RedfishActionNotSupportedError;
342
340
  exports.RedfishClient = RedfishClient;
343
341
  exports.RedfishError = RedfishError;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RedfishErrorPayload } from './types.js';\n\n/** Thrown for any non-2xx response from a Redfish service. */\nexport class RedfishError extends Error {\n readonly url: string;\n readonly status: number;\n readonly statusText: string;\n readonly body?: RedfishErrorPayload | string;\n\n constructor(message: string, options: { url: string; status: number; statusText: string; body?: RedfishErrorPayload | string }) {\n super(message);\n this.name = 'RedfishError';\n this.url = options.url;\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n\n /** Extracted `@Message.ExtendedInfo` entries, if the service returned an extended-info error body. */\n get extendedInfo(): Array<{ MessageId?: string; Message?: string; Severity?: string }> {\n if (this.body && typeof this.body === 'object') {\n return this.body.error?.['@Message.ExtendedInfo'] ?? [];\n }\n return [];\n }\n}\n\n/** Thrown when a request exceeds the configured timeout. */\nexport class RedfishTimeoutError extends Error {\n readonly url: string;\n readonly timeoutMs: number;\n\n constructor(url: string, timeoutMs: number) {\n super(`Request to ${url} timed out after ${timeoutMs}ms`);\n this.name = 'RedfishTimeoutError';\n this.url = url;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/** Thrown when a resource does not expose an action the client was asked to invoke. */\nexport class RedfishActionNotSupportedError extends Error {\n readonly action: string;\n readonly resourceId: string;\n\n constructor(action: string, resourceId: string) {\n super(`Resource \"${resourceId}\" does not support action \"${action}\"`);\n this.name = 'RedfishActionNotSupportedError';\n this.action = action;\n this.resourceId = resourceId;\n }\n}\n","import { Agent } from 'undici';\nimport { RedfishActionNotSupportedError, RedfishError, RedfishTimeoutError } from './errors.js';\nimport type {\n Chassis,\n ComputerSystem,\n Manager,\n Power,\n RedfishAction,\n RedfishCollection,\n RedfishErrorPayload,\n ResetType,\n ServiceRoot,\n Session,\n Thermal,\n} from './types.js';\n\nexport interface RedfishAuthBasic {\n type: 'basic';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthSession {\n type: 'session';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthToken {\n type: 'token';\n token: string;\n}\n\nexport interface RedfishAuthNone {\n type: 'none';\n}\n\nexport type RedfishAuth = RedfishAuthBasic | RedfishAuthSession | RedfishAuthToken | RedfishAuthNone;\n\nexport interface RedfishClientOptions {\n /** Base URL of the BMC, e.g. `https://10.0.0.5` */\n baseUrl: string;\n /** Authentication strategy. Defaults to `{ type: 'none' }`. */\n auth?: RedfishAuth;\n /**\n * Skip TLS certificate verification. Most BMCs ship a self-signed\n * certificate, so this is commonly needed. Defaults to `false`.\n */\n insecure?: boolean;\n /** Root service path. Defaults to `/redfish/v1`. */\n servicePath?: string;\n /** Per-request timeout in milliseconds. Defaults to 15000. */\n timeoutMs?: number;\n /** Override the fetch implementation (mainly for testing). */\n fetch?: typeof fetch;\n}\n\nexport interface RedfishResponse<T> {\n data: T;\n status: number;\n etag?: string;\n}\n\nexport interface RequestOptions {\n method?: string;\n body?: unknown;\n etag?: string;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nconst DEFAULT_SERVICE_PATH = '/redfish/v1';\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\n/**\n * Client for querying and managing Redfish-compliant BMCs.\n *\n * @example\n * ```ts\n * const client = new RedfishClient({\n * baseUrl: 'https://10.0.0.5',\n * auth: { type: 'session', username: 'admin', password: 'secret' },\n * insecure: true,\n * });\n * await client.connect();\n * const systems = await client.getSystems();\n * await client.resetSystem(systems[0].Id!, 'GracefulRestart');\n * await client.disconnect();\n * ```\n */\nexport class RedfishClient {\n private readonly baseUrl: string;\n private readonly servicePath: string;\n private readonly auth: RedfishAuth;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof fetch;\n private readonly dispatcher: Agent | undefined;\n\n private token: string | undefined;\n private sessionLocation: string | undefined;\n\n constructor(options: RedfishClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError('RedfishClient requires a `baseUrl`');\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.servicePath = normalizeServicePath(options.servicePath ?? DEFAULT_SERVICE_PATH);\n this.auth = options.auth ?? { type: 'none' };\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.dispatcher = options.insecure ? new Agent({ connect: { rejectUnauthorized: false } }) : undefined;\n\n if (this.auth.type === 'token') {\n this.token = this.auth.token;\n }\n }\n\n /** Whether the client currently holds a session token (from `connect()` or `type: 'token'` auth). */\n get isAuthenticated(): boolean {\n return Boolean(this.token) || this.auth.type === 'basic';\n }\n\n /**\n * Establishes a session for `{ type: 'session' }` auth by creating a\n * Redfish session and capturing the `X-Auth-Token`. No-op for other auth\n * types.\n */\n async connect(): Promise<void> {\n if (this.auth.type !== 'session') {\n return;\n }\n const url = this.resolve(`${this.servicePath}/SessionService/Sessions`);\n const response = await this.rawFetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Accept: 'application/json' },\n body: JSON.stringify({ UserName: this.auth.username, Password: this.auth.password }),\n });\n if (!response.ok) {\n await throwRedfishError(response);\n }\n const token = response.headers.get('x-auth-token');\n if (!token) {\n throw new RedfishError('Session creation succeeded but no X-Auth-Token header was returned', {\n url,\n status: response.status,\n statusText: response.statusText,\n });\n }\n this.token = token;\n this.sessionLocation = response.headers.get('location') ?? undefined;\n // Drain the body so the connection can be reused.\n await response.text().catch(() => undefined);\n }\n\n /** Deletes the active session, if one was established via `connect()`. */\n async disconnect(): Promise<void> {\n if (!this.sessionLocation) {\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n return;\n }\n const url = this.resolve(this.sessionLocation);\n await this.rawFetch(url, { method: 'DELETE', headers: this.authHeaders() }).catch(() => undefined);\n this.sessionLocation = undefined;\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n }\n\n /** Fetches the service root document (`/redfish/v1/`). */\n getServiceRoot(): Promise<ServiceRoot> {\n return this.get<ServiceRoot>(this.servicePath);\n }\n\n // ---------------------------------------------------------------------\n // Systems\n // ---------------------------------------------------------------------\n\n getSystems(): Promise<ComputerSystem[]> {\n return this.getExpandedCollection<ComputerSystem>('Systems');\n }\n\n getSystemIds(): Promise<string[]> {\n return this.getCollectionIds('Systems');\n }\n\n getSystem(id: string): Promise<ComputerSystem> {\n return this.get<ComputerSystem>(`${this.servicePath}/Systems/${id}`);\n }\n\n /**\n * Invokes `#ComputerSystem.Reset` on the given system. The action target\n * is read from the system's `Actions` block so vendor-specific paths are\n * respected; falls back to the standard path if absent.\n */\n async resetSystem(id: string, resetType: ResetType): Promise<void> {\n const system = await this.getSystem(id);\n const action = system.Actions?.['#ComputerSystem.Reset'];\n await this.invokeAction(action, '#ComputerSystem.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Chassis\n // ---------------------------------------------------------------------\n\n getChassisCollection(): Promise<Chassis[]> {\n return this.getExpandedCollection<Chassis>('Chassis');\n }\n\n getChassisIds(): Promise<string[]> {\n return this.getCollectionIds('Chassis');\n }\n\n getChassis(id: string): Promise<Chassis> {\n return this.get<Chassis>(`${this.servicePath}/Chassis/${id}`);\n }\n\n async getPower(chassisId: string): Promise<Power> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Power?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Power`;\n return this.get<Power>(path);\n }\n\n async getThermal(chassisId: string): Promise<Thermal> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Thermal?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Thermal`;\n return this.get<Thermal>(path);\n }\n\n // ---------------------------------------------------------------------\n // Managers\n // ---------------------------------------------------------------------\n\n getManagers(): Promise<Manager[]> {\n return this.getExpandedCollection<Manager>('Managers');\n }\n\n getManagerIds(): Promise<string[]> {\n return this.getCollectionIds('Managers');\n }\n\n getManager(id: string): Promise<Manager> {\n return this.get<Manager>(`${this.servicePath}/Managers/${id}`);\n }\n\n async resetManager(id: string, resetType: ResetType): Promise<void> {\n const manager = await this.getManager(id);\n const action = manager.Actions?.['#Manager.Reset'];\n await this.invokeAction(action, '#Manager.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Sessions\n // ---------------------------------------------------------------------\n\n getSessions(): Promise<Session[]> {\n return this.getExpandedCollection<Session>('SessionService/Sessions');\n }\n\n // ---------------------------------------------------------------------\n // Generic request helpers\n // ---------------------------------------------------------------------\n\n async get<T>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'GET' });\n return data;\n }\n\n /** PATCH a resource. Pass `etag` to send `If-Match` (recommended by the Redfish spec for PATCH). */\n async patch<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PATCH', body, etag });\n return data;\n }\n\n /** PUT a full resource replacement. Rarely used by Redfish services compared to PATCH. */\n async put<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PUT', body, etag });\n return data;\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'POST', body });\n return data;\n }\n\n async delete<T = void>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'DELETE' });\n return data;\n }\n\n /** Fetches a Redfish collection resource (the `Members` array of `@odata.id` links), unexpanded. */\n getCollection(path: string): Promise<RedfishCollection> {\n return this.get<RedfishCollection>(this.withinService(path));\n }\n\n /** Fetches a collection and resolves every member to its full resource body. */\n async getExpandedCollection<T>(path: string): Promise<T[]> {\n const collection = await this.getCollection(this.withinService(path));\n return Promise.all(collection.Members.map((member) => this.get<T>(member['@odata.id'])));\n }\n\n private async getCollectionIds(path: string): Promise<string[]> {\n const collection = await this.getCollection(this.withinService(path));\n return collection.Members.map((member) => idFromODataId(member['@odata.id']));\n }\n\n private async invokeAction(\n action: RedfishAction | undefined,\n actionName: string,\n body: unknown,\n resourceId: string,\n ): Promise<void> {\n if (!action?.target) {\n throw new RedfishActionNotSupportedError(actionName, resourceId);\n }\n await this.request(action.target, { method: 'POST', body });\n }\n\n private withinService(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('/')) {\n return path;\n }\n return `${this.servicePath}/${path}`;\n }\n\n private resolve(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://')) {\n return path;\n }\n return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n }\n\n private authHeaders(): Record<string, string> {\n if (this.token) {\n return { 'X-Auth-Token': this.token };\n }\n if (this.auth.type === 'basic') {\n const encoded = base64Encode(`${this.auth.username}:${this.auth.password}`);\n return { Authorization: `Basic ${encoded}` };\n }\n return {};\n }\n\n private async request<T>(path: string, options: RequestOptions): Promise<RedfishResponse<T>> {\n const url = this.resolve(this.withinService(path));\n const headers: Record<string, string> = {\n Accept: 'application/json',\n ...this.authHeaders(),\n ...options.headers,\n };\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n if (options.etag) {\n headers['If-Match'] = options.etag;\n }\n\n const response = await this.rawFetch(url, {\n method: options.method ?? 'GET',\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: options.signal,\n });\n\n if (!response.ok) {\n await throwRedfishError(response);\n }\n\n const etag = response.headers.get('etag') ?? undefined;\n if (response.status === 204) {\n return { data: undefined as T, status: response.status, etag };\n }\n const text = await response.text();\n const data = text.length > 0 ? (JSON.parse(text) as T) : (undefined as T);\n return { data, status: response.status, etag };\n }\n\n private async rawFetch(url: string, init: { method: string; headers?: Record<string, string>; body?: string; signal?: AbortSignal }): Promise<Response> {\n const controller = new AbortController();\n const signals = init.signal ? [init.signal, controller.signal] : [controller.signal];\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n return await this.fetchImpl(url, {\n method: init.method,\n headers: init.headers,\n body: init.body,\n signal: combineSignals(signals),\n // `dispatcher` is an undici-specific extension used to control TLS\n // verification; not part of the standard fetch types.\n ...(this.dispatcher ? { dispatcher: this.dispatcher } : {}),\n } as RequestInit);\n } catch (error) {\n if (controller.signal.aborted) {\n throw new RedfishTimeoutError(url, this.timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nfunction normalizeServicePath(path: string): string {\n const trimmed = path.replace(/\\/+$/, '');\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\nfunction idFromODataId(odataId: string): string {\n const segments = odataId.replace(/\\/+$/, '').split('/');\n return segments[segments.length - 1] ?? odataId;\n}\n\nfunction base64Encode(value: string): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(value, 'utf-8').toString('base64');\n }\n // Browser / edge runtime fallback.\n return btoa(value);\n}\n\nfunction combineSignals(signals: AbortSignal[]): AbortSignal {\n if (signals.length === 1) {\n return signals[0] as AbortSignal;\n }\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort();\n break;\n }\n signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n return controller.signal;\n}\n\nasync function throwRedfishError(response: Response): Promise<never> {\n const text = await response.text().catch(() => '');\n let body: RedfishErrorPayload | string = text;\n try {\n body = text ? (JSON.parse(text) as RedfishErrorPayload) : text;\n } catch {\n // leave body as raw text\n }\n const message =\n (typeof body === 'object' && body.error?.message) || `Redfish request failed: ${response.status} ${response.statusText}`;\n throw new RedfishError(message, {\n url: response.url,\n status: response.status,\n statusText: response.statusText,\n body,\n });\n}\n"],"mappings":";;;;AAGA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CACA;CAEA,YAAY,SAAiB,SAAmG;EAC9H,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;;CAGA,IAAI,eAAmF;EACrF,IAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,UACpC,OAAO,KAAK,KAAK,QAAQ,4BAA4B,CAAC;EAExD,OAAO,CAAC;CACV;AACF;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAC7C;CACA;CAEA,YAAY,KAAa,WAAmB;EAC1C,MAAM,cAAc,IAAI,mBAAmB,UAAU,GAAG;EACxD,KAAK,OAAO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AAO,WAAY,2BAA2B,SAAS,OAAO,GAAG,SAAS,cAC9E;EAC9B,KAAK,SAAS;EACd,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["Agent"],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RedfishErrorPayload } from './types.js';\n\n/** Thrown for any non-2xx response from a Redfish service. */\nexport class RedfishError extends Error {\n readonly url: string;\n readonly status: number;\n readonly statusText: string;\n readonly body?: RedfishErrorPayload | string;\n\n constructor(message: string, options: { url: string; status: number; statusText: string; body?: RedfishErrorPayload | string }) {\n super(message);\n this.name = 'RedfishError';\n this.url = options.url;\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n\n /** Extracted `@Message.ExtendedInfo` entries, if the service returned an extended-info error body. */\n get extendedInfo(): Array<{ MessageId?: string; Message?: string; Severity?: string }> {\n if (this.body && typeof this.body === 'object') {\n return this.body.error?.['@Message.ExtendedInfo'] ?? [];\n }\n return [];\n }\n}\n\n/** Thrown when a request exceeds the configured timeout. */\nexport class RedfishTimeoutError extends Error {\n readonly url: string;\n readonly timeoutMs: number;\n\n constructor(url: string, timeoutMs: number) {\n super(`Request to ${url} timed out after ${timeoutMs}ms`);\n this.name = 'RedfishTimeoutError';\n this.url = url;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/** Thrown when a resource does not expose an action the client was asked to invoke. */\nexport class RedfishActionNotSupportedError extends Error {\n readonly action: string;\n readonly resourceId: string;\n\n constructor(action: string, resourceId: string) {\n super(`Resource \"${resourceId}\" does not support action \"${action}\"`);\n this.name = 'RedfishActionNotSupportedError';\n this.action = action;\n this.resourceId = resourceId;\n }\n}\n","import { Agent } from 'undici';\nimport { RedfishActionNotSupportedError, RedfishError, RedfishTimeoutError } from './errors.js';\nimport type {\n Chassis,\n ComputerSystem,\n Manager,\n Power,\n RedfishAction,\n RedfishCollection,\n RedfishErrorPayload,\n ResetType,\n ServiceRoot,\n Session,\n Thermal,\n} from './types.js';\n\nexport interface RedfishAuthBasic {\n type: 'basic';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthSession {\n type: 'session';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthToken {\n type: 'token';\n token: string;\n}\n\nexport interface RedfishAuthNone {\n type: 'none';\n}\n\nexport type RedfishAuth = RedfishAuthBasic | RedfishAuthSession | RedfishAuthToken | RedfishAuthNone;\n\nexport interface RedfishClientOptions {\n /** Base URL of the BMC, e.g. `https://10.0.0.5` */\n baseUrl: string;\n /** Authentication strategy. Defaults to `{ type: 'none' }`. */\n auth?: RedfishAuth;\n /**\n * Skip TLS certificate verification. Most BMCs ship a self-signed\n * certificate, so this is commonly needed. Defaults to `false`.\n */\n insecure?: boolean;\n /** Root service path. Defaults to `/redfish/v1`. */\n servicePath?: string;\n /** Per-request timeout in milliseconds. Defaults to 15000. */\n timeoutMs?: number;\n /** Override the fetch implementation (mainly for testing). */\n fetch?: typeof fetch;\n}\n\nexport interface RedfishResponse<T> {\n data: T;\n status: number;\n etag?: string;\n}\n\nexport interface RequestOptions {\n method?: string;\n body?: unknown;\n etag?: string;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nconst DEFAULT_SERVICE_PATH = '/redfish/v1';\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\n/**\n * Client for querying and managing Redfish-compliant BMCs.\n *\n * @example\n * ```ts\n * const client = new RedfishClient({\n * baseUrl: 'https://10.0.0.5',\n * auth: { type: 'session', username: 'admin', password: 'secret' },\n * insecure: true,\n * });\n * await client.connect();\n * const systems = await client.getSystems();\n * await client.resetSystem(systems[0].Id!, 'GracefulRestart');\n * await client.disconnect();\n * ```\n */\nexport class RedfishClient {\n private readonly baseUrl: string;\n private readonly servicePath: string;\n private readonly auth: RedfishAuth;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof fetch;\n private readonly dispatcher: Agent | undefined;\n\n private token: string | undefined;\n private sessionLocation: string | undefined;\n\n constructor(options: RedfishClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError('RedfishClient requires a `baseUrl`');\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.servicePath = normalizeServicePath(options.servicePath ?? DEFAULT_SERVICE_PATH);\n this.auth = options.auth ?? { type: 'none' };\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.dispatcher = options.insecure ? new Agent({ connect: { rejectUnauthorized: false } }) : undefined;\n\n if (this.auth.type === 'token') {\n this.token = this.auth.token;\n }\n }\n\n /** Whether the client currently holds a session token (from `connect()` or `type: 'token'` auth). */\n get isAuthenticated(): boolean {\n return Boolean(this.token) || this.auth.type === 'basic';\n }\n\n /**\n * Establishes a session for `{ type: 'session' }` auth by creating a\n * Redfish session and capturing the `X-Auth-Token`. No-op for other auth\n * types.\n */\n async connect(): Promise<void> {\n if (this.auth.type !== 'session') {\n return;\n }\n const url = this.resolve(`${this.servicePath}/SessionService/Sessions`);\n const response = await this.rawFetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Accept: 'application/json' },\n body: JSON.stringify({ UserName: this.auth.username, Password: this.auth.password }),\n });\n if (!response.ok) {\n await throwRedfishError(response);\n }\n const token = response.headers.get('x-auth-token');\n if (!token) {\n throw new RedfishError('Session creation succeeded but no X-Auth-Token header was returned', {\n url,\n status: response.status,\n statusText: response.statusText,\n });\n }\n this.token = token;\n this.sessionLocation = response.headers.get('location') ?? undefined;\n // Drain the body so the connection can be reused.\n await response.text().catch(() => undefined);\n }\n\n /** Deletes the active session, if one was established via `connect()`. */\n async disconnect(): Promise<void> {\n if (!this.sessionLocation) {\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n return;\n }\n const url = this.resolve(this.sessionLocation);\n await this.rawFetch(url, { method: 'DELETE', headers: this.authHeaders() }).catch(() => undefined);\n this.sessionLocation = undefined;\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n }\n\n /** Fetches the service root document (`/redfish/v1/`). */\n getServiceRoot(): Promise<ServiceRoot> {\n return this.get<ServiceRoot>(this.servicePath);\n }\n\n // ---------------------------------------------------------------------\n // Systems\n // ---------------------------------------------------------------------\n\n getSystems(): Promise<ComputerSystem[]> {\n return this.getExpandedCollection<ComputerSystem>('Systems');\n }\n\n getSystemIds(): Promise<string[]> {\n return this.getCollectionIds('Systems');\n }\n\n getSystem(id: string): Promise<ComputerSystem> {\n return this.get<ComputerSystem>(`${this.servicePath}/Systems/${id}`);\n }\n\n /**\n * Invokes `#ComputerSystem.Reset` on the given system. The action target\n * is read from the system's `Actions` block so vendor-specific paths are\n * respected; falls back to the standard path if absent.\n */\n async resetSystem(id: string, resetType: ResetType): Promise<void> {\n const system = await this.getSystem(id);\n const action = system.Actions?.['#ComputerSystem.Reset'];\n await this.invokeAction(action, '#ComputerSystem.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Chassis\n // ---------------------------------------------------------------------\n\n getChassisCollection(): Promise<Chassis[]> {\n return this.getExpandedCollection<Chassis>('Chassis');\n }\n\n getChassisIds(): Promise<string[]> {\n return this.getCollectionIds('Chassis');\n }\n\n getChassis(id: string): Promise<Chassis> {\n return this.get<Chassis>(`${this.servicePath}/Chassis/${id}`);\n }\n\n async getPower(chassisId: string): Promise<Power> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Power?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Power`;\n return this.get<Power>(path);\n }\n\n async getThermal(chassisId: string): Promise<Thermal> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Thermal?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Thermal`;\n return this.get<Thermal>(path);\n }\n\n // ---------------------------------------------------------------------\n // Managers\n // ---------------------------------------------------------------------\n\n getManagers(): Promise<Manager[]> {\n return this.getExpandedCollection<Manager>('Managers');\n }\n\n getManagerIds(): Promise<string[]> {\n return this.getCollectionIds('Managers');\n }\n\n getManager(id: string): Promise<Manager> {\n return this.get<Manager>(`${this.servicePath}/Managers/${id}`);\n }\n\n async resetManager(id: string, resetType: ResetType): Promise<void> {\n const manager = await this.getManager(id);\n const action = manager.Actions?.['#Manager.Reset'];\n await this.invokeAction(action, '#Manager.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Sessions\n // ---------------------------------------------------------------------\n\n getSessions(): Promise<Session[]> {\n return this.getExpandedCollection<Session>('SessionService/Sessions');\n }\n\n // ---------------------------------------------------------------------\n // Generic request helpers\n // ---------------------------------------------------------------------\n\n async get<T>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'GET' });\n return data;\n }\n\n /** PATCH a resource. Pass `etag` to send `If-Match` (recommended by the Redfish spec for PATCH). */\n async patch<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PATCH', body, etag });\n return data;\n }\n\n /** PUT a full resource replacement. Rarely used by Redfish services compared to PATCH. */\n async put<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PUT', body, etag });\n return data;\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'POST', body });\n return data;\n }\n\n async delete<T = void>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'DELETE' });\n return data;\n }\n\n /** Fetches a Redfish collection resource (the `Members` array of `@odata.id` links), unexpanded. */\n getCollection(path: string): Promise<RedfishCollection> {\n return this.get<RedfishCollection>(this.withinService(path));\n }\n\n /** Fetches a collection and resolves every member to its full resource body. */\n async getExpandedCollection<T>(path: string): Promise<T[]> {\n const collection = await this.getCollection(this.withinService(path));\n return Promise.all(collection.Members.map((member) => this.get<T>(member['@odata.id'])));\n }\n\n private async getCollectionIds(path: string): Promise<string[]> {\n const collection = await this.getCollection(this.withinService(path));\n return collection.Members.map((member) => idFromODataId(member['@odata.id']));\n }\n\n private async invokeAction(\n action: RedfishAction | undefined,\n actionName: string,\n body: unknown,\n resourceId: string,\n ): Promise<void> {\n if (!action?.target) {\n throw new RedfishActionNotSupportedError(actionName, resourceId);\n }\n await this.request(action.target, { method: 'POST', body });\n }\n\n private withinService(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('/')) {\n return path;\n }\n return `${this.servicePath}/${path}`;\n }\n\n private resolve(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://')) {\n return path;\n }\n return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n }\n\n private authHeaders(): Record<string, string> {\n if (this.token) {\n return { 'X-Auth-Token': this.token };\n }\n if (this.auth.type === 'basic') {\n const encoded = base64Encode(`${this.auth.username}:${this.auth.password}`);\n return { Authorization: `Basic ${encoded}` };\n }\n return {};\n }\n\n private async request<T>(path: string, options: RequestOptions): Promise<RedfishResponse<T>> {\n const url = this.resolve(this.withinService(path));\n const headers: Record<string, string> = {\n Accept: 'application/json',\n ...this.authHeaders(),\n ...options.headers,\n };\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n if (options.etag) {\n headers['If-Match'] = options.etag;\n }\n\n const response = await this.rawFetch(url, {\n method: options.method ?? 'GET',\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: options.signal,\n });\n\n if (!response.ok) {\n await throwRedfishError(response);\n }\n\n const etag = response.headers.get('etag') ?? undefined;\n if (response.status === 204) {\n return { data: undefined as T, status: response.status, etag };\n }\n const text = await response.text();\n const data = text.length > 0 ? (JSON.parse(text) as T) : (undefined as T);\n return { data, status: response.status, etag };\n }\n\n private async rawFetch(url: string, init: { method: string; headers?: Record<string, string>; body?: string; signal?: AbortSignal }): Promise<Response> {\n const controller = new AbortController();\n const signals = init.signal ? [init.signal, controller.signal] : [controller.signal];\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n return await this.fetchImpl(url, {\n method: init.method,\n headers: init.headers,\n body: init.body,\n signal: combineSignals(signals),\n // `dispatcher` is an undici-specific extension used to control TLS\n // verification; not part of the standard fetch types.\n ...(this.dispatcher ? { dispatcher: this.dispatcher } : {}),\n } as RequestInit);\n } catch (error) {\n if (controller.signal.aborted) {\n throw new RedfishTimeoutError(url, this.timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nfunction normalizeServicePath(path: string): string {\n const trimmed = path.replace(/\\/+$/, '');\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\nfunction idFromODataId(odataId: string): string {\n const segments = odataId.replace(/\\/+$/, '').split('/');\n return segments[segments.length - 1] ?? odataId;\n}\n\nfunction base64Encode(value: string): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(value, 'utf-8').toString('base64');\n }\n // Browser / edge runtime fallback.\n return btoa(value);\n}\n\nfunction combineSignals(signals: AbortSignal[]): AbortSignal {\n if (signals.length === 1) {\n return signals[0] as AbortSignal;\n }\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort();\n break;\n }\n signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n return controller.signal;\n}\n\nasync function throwRedfishError(response: Response): Promise<never> {\n const text = await response.text().catch(() => '');\n let body: RedfishErrorPayload | string = text;\n try {\n body = text ? (JSON.parse(text) as RedfishErrorPayload) : text;\n } catch {\n // leave body as raw text\n }\n const message =\n (typeof body === 'object' && body.error?.message) || `Redfish request failed: ${response.status} ${response.statusText}`;\n throw new RedfishError(message, {\n url: response.url,\n status: response.status,\n statusText: response.statusText,\n body,\n });\n}\n"],"mappings":";;;;AAGA,IAAa,eAAb,cAAkC,MAAM;CAC7B;CACA;CACA;CACA;CAET,YAAY,SAAiB,SAAmG;EAC9H,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;;CA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AAC;CAC3E;CACA,OAAO,WAAW;AACpB;AAEA,eAAe,kBAAkB,UAAoC;CACnE,MAAM,OAAO,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,EAAE;CACjD,IAAI,OAAqC;CACzC,IAAI;EACF,OAAO,OAAQ,KAAK,MAAM,IAAI,IAA4B;CAC5D,QAAQ,CAER;CAGA,MAAM,IAAI,aADP,OAAO,SAAS,YAAY,KAAK,OAAO,WAAY,2BAA2B,SAAS,OAAO,GAAG,SAAS,cAC9E;EAC9B,KAAK,SAAS;EACd,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB;CACF,CAAC;AACH"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Agent } from "undici";
2
- //#region src/errors.ts
2
+ // src/errors.ts
3
3
  /** Thrown for any non-2xx response from a Redfish service. */
4
4
  var RedfishError = class extends Error {
5
5
  url;
@@ -42,8 +42,7 @@ var RedfishActionNotSupportedError = class extends Error {
42
42
  this.resourceId = resourceId;
43
43
  }
44
44
  };
45
- //#endregion
46
- //#region src/client.ts
45
+ // src/client.ts
47
46
  var DEFAULT_SERVICE_PATH = "/redfish/v1";
48
47
  var DEFAULT_TIMEOUT_MS = 15e3;
49
48
  /**
@@ -336,7 +335,6 @@ async function throwRedfishError(response) {
336
335
  body
337
336
  });
338
337
  }
339
- //#endregion
340
338
  export { RedfishActionNotSupportedError, RedfishClient, RedfishError, RedfishTimeoutError };
341
339
 
342
340
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RedfishErrorPayload } from './types.js';\n\n/** Thrown for any non-2xx response from a Redfish service. */\nexport class RedfishError extends Error {\n readonly url: string;\n readonly status: number;\n readonly statusText: string;\n readonly body?: RedfishErrorPayload | string;\n\n constructor(message: string, options: { url: string; status: number; statusText: string; body?: RedfishErrorPayload | string }) {\n super(message);\n this.name = 'RedfishError';\n this.url = options.url;\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n\n /** Extracted `@Message.ExtendedInfo` entries, if the service returned an extended-info error body. */\n get extendedInfo(): Array<{ MessageId?: string; Message?: string; Severity?: string }> {\n if (this.body && typeof this.body === 'object') {\n return this.body.error?.['@Message.ExtendedInfo'] ?? [];\n }\n return [];\n }\n}\n\n/** Thrown when a request exceeds the configured timeout. */\nexport class RedfishTimeoutError extends Error {\n readonly url: string;\n readonly timeoutMs: number;\n\n constructor(url: string, timeoutMs: number) {\n super(`Request to ${url} timed out after ${timeoutMs}ms`);\n this.name = 'RedfishTimeoutError';\n this.url = url;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/** Thrown when a resource does not expose an action the client was asked to invoke. */\nexport class RedfishActionNotSupportedError extends Error {\n readonly action: string;\n readonly resourceId: string;\n\n constructor(action: string, resourceId: string) {\n super(`Resource \"${resourceId}\" does not support action \"${action}\"`);\n this.name = 'RedfishActionNotSupportedError';\n this.action = action;\n this.resourceId = resourceId;\n }\n}\n","import { Agent } from 'undici';\nimport { RedfishActionNotSupportedError, RedfishError, RedfishTimeoutError } from './errors.js';\nimport type {\n Chassis,\n ComputerSystem,\n Manager,\n Power,\n RedfishAction,\n RedfishCollection,\n RedfishErrorPayload,\n ResetType,\n ServiceRoot,\n Session,\n Thermal,\n} from './types.js';\n\nexport interface RedfishAuthBasic {\n type: 'basic';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthSession {\n type: 'session';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthToken {\n type: 'token';\n token: string;\n}\n\nexport interface RedfishAuthNone {\n type: 'none';\n}\n\nexport type RedfishAuth = RedfishAuthBasic | RedfishAuthSession | RedfishAuthToken | RedfishAuthNone;\n\nexport interface RedfishClientOptions {\n /** Base URL of the BMC, e.g. `https://10.0.0.5` */\n baseUrl: string;\n /** Authentication strategy. Defaults to `{ type: 'none' }`. */\n auth?: RedfishAuth;\n /**\n * Skip TLS certificate verification. Most BMCs ship a self-signed\n * certificate, so this is commonly needed. Defaults to `false`.\n */\n insecure?: boolean;\n /** Root service path. Defaults to `/redfish/v1`. */\n servicePath?: string;\n /** Per-request timeout in milliseconds. Defaults to 15000. */\n timeoutMs?: number;\n /** Override the fetch implementation (mainly for testing). */\n fetch?: typeof fetch;\n}\n\nexport interface RedfishResponse<T> {\n data: T;\n status: number;\n etag?: string;\n}\n\nexport interface RequestOptions {\n method?: string;\n body?: unknown;\n etag?: string;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nconst DEFAULT_SERVICE_PATH = '/redfish/v1';\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\n/**\n * Client for querying and managing Redfish-compliant BMCs.\n *\n * @example\n * ```ts\n * const client = new RedfishClient({\n * baseUrl: 'https://10.0.0.5',\n * auth: { type: 'session', username: 'admin', password: 'secret' },\n * insecure: true,\n * });\n * await client.connect();\n * const systems = await client.getSystems();\n * await client.resetSystem(systems[0].Id!, 'GracefulRestart');\n * await client.disconnect();\n * ```\n */\nexport class RedfishClient {\n private readonly baseUrl: string;\n private readonly servicePath: string;\n private readonly auth: RedfishAuth;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof fetch;\n private readonly dispatcher: Agent | undefined;\n\n private token: string | undefined;\n private sessionLocation: string | undefined;\n\n constructor(options: RedfishClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError('RedfishClient requires a `baseUrl`');\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.servicePath = normalizeServicePath(options.servicePath ?? DEFAULT_SERVICE_PATH);\n this.auth = options.auth ?? { type: 'none' };\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.dispatcher = options.insecure ? new Agent({ connect: { rejectUnauthorized: false } }) : undefined;\n\n if (this.auth.type === 'token') {\n this.token = this.auth.token;\n }\n }\n\n /** Whether the client currently holds a session token (from `connect()` or `type: 'token'` auth). */\n get isAuthenticated(): boolean {\n return Boolean(this.token) || this.auth.type === 'basic';\n }\n\n /**\n * Establishes a session for `{ type: 'session' }` auth by creating a\n * Redfish session and capturing the `X-Auth-Token`. No-op for other auth\n * types.\n */\n async connect(): Promise<void> {\n if (this.auth.type !== 'session') {\n return;\n }\n const url = this.resolve(`${this.servicePath}/SessionService/Sessions`);\n const response = await this.rawFetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Accept: 'application/json' },\n body: JSON.stringify({ UserName: this.auth.username, Password: this.auth.password }),\n });\n if (!response.ok) {\n await throwRedfishError(response);\n }\n const token = response.headers.get('x-auth-token');\n if (!token) {\n throw new RedfishError('Session creation succeeded but no X-Auth-Token header was returned', {\n url,\n status: response.status,\n statusText: response.statusText,\n });\n }\n this.token = token;\n this.sessionLocation = response.headers.get('location') ?? undefined;\n // Drain the body so the connection can be reused.\n await response.text().catch(() => undefined);\n }\n\n /** Deletes the active session, if one was established via `connect()`. */\n async disconnect(): Promise<void> {\n if (!this.sessionLocation) {\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n return;\n }\n const url = this.resolve(this.sessionLocation);\n await this.rawFetch(url, { method: 'DELETE', headers: this.authHeaders() }).catch(() => undefined);\n this.sessionLocation = undefined;\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n }\n\n /** Fetches the service root document (`/redfish/v1/`). */\n getServiceRoot(): Promise<ServiceRoot> {\n return this.get<ServiceRoot>(this.servicePath);\n }\n\n // ---------------------------------------------------------------------\n // Systems\n // ---------------------------------------------------------------------\n\n getSystems(): Promise<ComputerSystem[]> {\n return this.getExpandedCollection<ComputerSystem>('Systems');\n }\n\n getSystemIds(): Promise<string[]> {\n return this.getCollectionIds('Systems');\n }\n\n getSystem(id: string): Promise<ComputerSystem> {\n return this.get<ComputerSystem>(`${this.servicePath}/Systems/${id}`);\n }\n\n /**\n * Invokes `#ComputerSystem.Reset` on the given system. The action target\n * is read from the system's `Actions` block so vendor-specific paths are\n * respected; falls back to the standard path if absent.\n */\n async resetSystem(id: string, resetType: ResetType): Promise<void> {\n const system = await this.getSystem(id);\n const action = system.Actions?.['#ComputerSystem.Reset'];\n await this.invokeAction(action, '#ComputerSystem.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Chassis\n // ---------------------------------------------------------------------\n\n getChassisCollection(): Promise<Chassis[]> {\n return this.getExpandedCollection<Chassis>('Chassis');\n }\n\n getChassisIds(): Promise<string[]> {\n return this.getCollectionIds('Chassis');\n }\n\n getChassis(id: string): Promise<Chassis> {\n return this.get<Chassis>(`${this.servicePath}/Chassis/${id}`);\n }\n\n async getPower(chassisId: string): Promise<Power> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Power?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Power`;\n return this.get<Power>(path);\n }\n\n async getThermal(chassisId: string): Promise<Thermal> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Thermal?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Thermal`;\n return this.get<Thermal>(path);\n }\n\n // ---------------------------------------------------------------------\n // Managers\n // ---------------------------------------------------------------------\n\n getManagers(): Promise<Manager[]> {\n return this.getExpandedCollection<Manager>('Managers');\n }\n\n getManagerIds(): Promise<string[]> {\n return this.getCollectionIds('Managers');\n }\n\n getManager(id: string): Promise<Manager> {\n return this.get<Manager>(`${this.servicePath}/Managers/${id}`);\n }\n\n async resetManager(id: string, resetType: ResetType): Promise<void> {\n const manager = await this.getManager(id);\n const action = manager.Actions?.['#Manager.Reset'];\n await this.invokeAction(action, '#Manager.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Sessions\n // ---------------------------------------------------------------------\n\n getSessions(): Promise<Session[]> {\n return this.getExpandedCollection<Session>('SessionService/Sessions');\n }\n\n // ---------------------------------------------------------------------\n // Generic request helpers\n // ---------------------------------------------------------------------\n\n async get<T>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'GET' });\n return data;\n }\n\n /** PATCH a resource. Pass `etag` to send `If-Match` (recommended by the Redfish spec for PATCH). */\n async patch<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PATCH', body, etag });\n return data;\n }\n\n /** PUT a full resource replacement. Rarely used by Redfish services compared to PATCH. */\n async put<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PUT', body, etag });\n return data;\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'POST', body });\n return data;\n }\n\n async delete<T = void>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'DELETE' });\n return data;\n }\n\n /** Fetches a Redfish collection resource (the `Members` array of `@odata.id` links), unexpanded. */\n getCollection(path: string): Promise<RedfishCollection> {\n return this.get<RedfishCollection>(this.withinService(path));\n }\n\n /** Fetches a collection and resolves every member to its full resource body. */\n async getExpandedCollection<T>(path: string): Promise<T[]> {\n const collection = await this.getCollection(this.withinService(path));\n return Promise.all(collection.Members.map((member) => this.get<T>(member['@odata.id'])));\n }\n\n private async getCollectionIds(path: string): Promise<string[]> {\n const collection = await this.getCollection(this.withinService(path));\n return collection.Members.map((member) => idFromODataId(member['@odata.id']));\n }\n\n private async invokeAction(\n action: RedfishAction | undefined,\n actionName: string,\n body: unknown,\n resourceId: string,\n ): Promise<void> {\n if (!action?.target) {\n throw new RedfishActionNotSupportedError(actionName, resourceId);\n }\n await this.request(action.target, { method: 'POST', body });\n }\n\n private withinService(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('/')) {\n return path;\n }\n return `${this.servicePath}/${path}`;\n }\n\n private resolve(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://')) {\n return path;\n }\n return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n }\n\n private authHeaders(): Record<string, string> {\n if (this.token) {\n return { 'X-Auth-Token': this.token };\n }\n if (this.auth.type === 'basic') {\n const encoded = base64Encode(`${this.auth.username}:${this.auth.password}`);\n return { Authorization: `Basic ${encoded}` };\n }\n return {};\n }\n\n private async request<T>(path: string, options: RequestOptions): Promise<RedfishResponse<T>> {\n const url = this.resolve(this.withinService(path));\n const headers: Record<string, string> = {\n Accept: 'application/json',\n ...this.authHeaders(),\n ...options.headers,\n };\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n if (options.etag) {\n headers['If-Match'] = options.etag;\n }\n\n const response = await this.rawFetch(url, {\n method: options.method ?? 'GET',\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: options.signal,\n });\n\n if (!response.ok) {\n await throwRedfishError(response);\n }\n\n const etag = response.headers.get('etag') ?? undefined;\n if (response.status === 204) {\n return { data: undefined as T, status: response.status, etag };\n }\n const text = await response.text();\n const data = text.length > 0 ? (JSON.parse(text) as T) : (undefined as T);\n return { data, status: response.status, etag };\n }\n\n private async rawFetch(url: string, init: { method: string; headers?: Record<string, string>; body?: string; signal?: AbortSignal }): Promise<Response> {\n const controller = new AbortController();\n const signals = init.signal ? [init.signal, controller.signal] : [controller.signal];\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n return await this.fetchImpl(url, {\n method: init.method,\n headers: init.headers,\n body: init.body,\n signal: combineSignals(signals),\n // `dispatcher` is an undici-specific extension used to control TLS\n // verification; not part of the standard fetch types.\n ...(this.dispatcher ? { dispatcher: this.dispatcher } : {}),\n } as RequestInit);\n } catch (error) {\n if (controller.signal.aborted) {\n throw new RedfishTimeoutError(url, this.timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nfunction normalizeServicePath(path: string): string {\n const trimmed = path.replace(/\\/+$/, '');\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\nfunction idFromODataId(odataId: string): string {\n const segments = odataId.replace(/\\/+$/, '').split('/');\n return segments[segments.length - 1] ?? odataId;\n}\n\nfunction base64Encode(value: string): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(value, 'utf-8').toString('base64');\n }\n // Browser / edge runtime fallback.\n return btoa(value);\n}\n\nfunction combineSignals(signals: AbortSignal[]): AbortSignal {\n if (signals.length === 1) {\n return signals[0] as AbortSignal;\n }\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort();\n break;\n }\n signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n return controller.signal;\n}\n\nasync function throwRedfishError(response: Response): Promise<never> {\n const text = await response.text().catch(() => '');\n let body: RedfishErrorPayload | string = text;\n try {\n body = text ? (JSON.parse(text) as RedfishErrorPayload) : text;\n } catch {\n // leave body as raw text\n }\n const message =\n (typeof body === 'object' && body.error?.message) || `Redfish request failed: ${response.status} ${response.statusText}`;\n throw new RedfishError(message, {\n url: response.url,\n status: response.status,\n statusText: response.statusText,\n body,\n });\n}\n"],"mappings":";;;AAGA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CACA;CAEA,YAAY,SAAiB,SAAmG;EAC9H,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;;CAGA,IAAI,eAAmF;EACrF,IAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,UACpC,OAAO,KAAK,KAAK,QAAQ,4BAA4B,CAAC;EAExD,OAAO,CAAC;CACV;AACF;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAC7C;CACA;CAEA,YAAY,KAAa,WAAmB;EAC1C,MAAM,cAAc,IAAI,mBAAmB,UAAU,GAAG;EACxD,KAAK,OAAO;EACZ,KAAK,MAAM;EACX,KAAK,YAAY;CACnB;AACF;;AAGA,IAAa,iCAAb,cAAoD,MAAM;CACxD;CACA;CAEA,YAAY,QAAgB,YAAoB;EAC9C,MAAM,aAAa,WAAW,6BAA6B,OAAO,EA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src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RedfishErrorPayload } from './types.js';\n\n/** Thrown for any non-2xx response from a Redfish service. */\nexport class RedfishError extends Error {\n readonly url: string;\n readonly status: number;\n readonly statusText: string;\n readonly body?: RedfishErrorPayload | string;\n\n constructor(message: string, options: { url: string; status: number; statusText: string; body?: RedfishErrorPayload | string }) {\n super(message);\n this.name = 'RedfishError';\n this.url = options.url;\n this.status = options.status;\n this.statusText = options.statusText;\n this.body = options.body;\n }\n\n /** Extracted `@Message.ExtendedInfo` entries, if the service returned an extended-info error body. */\n get extendedInfo(): Array<{ MessageId?: string; Message?: string; Severity?: string }> {\n if (this.body && typeof this.body === 'object') {\n return this.body.error?.['@Message.ExtendedInfo'] ?? [];\n }\n return [];\n }\n}\n\n/** Thrown when a request exceeds the configured timeout. */\nexport class RedfishTimeoutError extends Error {\n readonly url: string;\n readonly timeoutMs: number;\n\n constructor(url: string, timeoutMs: number) {\n super(`Request to ${url} timed out after ${timeoutMs}ms`);\n this.name = 'RedfishTimeoutError';\n this.url = url;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/** Thrown when a resource does not expose an action the client was asked to invoke. */\nexport class RedfishActionNotSupportedError extends Error {\n readonly action: string;\n readonly resourceId: string;\n\n constructor(action: string, resourceId: string) {\n super(`Resource \"${resourceId}\" does not support action \"${action}\"`);\n this.name = 'RedfishActionNotSupportedError';\n this.action = action;\n this.resourceId = resourceId;\n }\n}\n","import { Agent } from 'undici';\nimport { RedfishActionNotSupportedError, RedfishError, RedfishTimeoutError } from './errors.js';\nimport type {\n Chassis,\n ComputerSystem,\n Manager,\n Power,\n RedfishAction,\n RedfishCollection,\n RedfishErrorPayload,\n ResetType,\n ServiceRoot,\n Session,\n Thermal,\n} from './types.js';\n\nexport interface RedfishAuthBasic {\n type: 'basic';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthSession {\n type: 'session';\n username: string;\n password: string;\n}\n\nexport interface RedfishAuthToken {\n type: 'token';\n token: string;\n}\n\nexport interface RedfishAuthNone {\n type: 'none';\n}\n\nexport type RedfishAuth = RedfishAuthBasic | RedfishAuthSession | RedfishAuthToken | RedfishAuthNone;\n\nexport interface RedfishClientOptions {\n /** Base URL of the BMC, e.g. `https://10.0.0.5` */\n baseUrl: string;\n /** Authentication strategy. Defaults to `{ type: 'none' }`. */\n auth?: RedfishAuth;\n /**\n * Skip TLS certificate verification. Most BMCs ship a self-signed\n * certificate, so this is commonly needed. Defaults to `false`.\n */\n insecure?: boolean;\n /** Root service path. Defaults to `/redfish/v1`. */\n servicePath?: string;\n /** Per-request timeout in milliseconds. Defaults to 15000. */\n timeoutMs?: number;\n /** Override the fetch implementation (mainly for testing). */\n fetch?: typeof fetch;\n}\n\nexport interface RedfishResponse<T> {\n data: T;\n status: number;\n etag?: string;\n}\n\nexport interface RequestOptions {\n method?: string;\n body?: unknown;\n etag?: string;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nconst DEFAULT_SERVICE_PATH = '/redfish/v1';\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\n/**\n * Client for querying and managing Redfish-compliant BMCs.\n *\n * @example\n * ```ts\n * const client = new RedfishClient({\n * baseUrl: 'https://10.0.0.5',\n * auth: { type: 'session', username: 'admin', password: 'secret' },\n * insecure: true,\n * });\n * await client.connect();\n * const systems = await client.getSystems();\n * await client.resetSystem(systems[0].Id!, 'GracefulRestart');\n * await client.disconnect();\n * ```\n */\nexport class RedfishClient {\n private readonly baseUrl: string;\n private readonly servicePath: string;\n private readonly auth: RedfishAuth;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof fetch;\n private readonly dispatcher: Agent | undefined;\n\n private token: string | undefined;\n private sessionLocation: string | undefined;\n\n constructor(options: RedfishClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError('RedfishClient requires a `baseUrl`');\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '');\n this.servicePath = normalizeServicePath(options.servicePath ?? DEFAULT_SERVICE_PATH);\n this.auth = options.auth ?? { type: 'none' };\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.dispatcher = options.insecure ? new Agent({ connect: { rejectUnauthorized: false } }) : undefined;\n\n if (this.auth.type === 'token') {\n this.token = this.auth.token;\n }\n }\n\n /** Whether the client currently holds a session token (from `connect()` or `type: 'token'` auth). */\n get isAuthenticated(): boolean {\n return Boolean(this.token) || this.auth.type === 'basic';\n }\n\n /**\n * Establishes a session for `{ type: 'session' }` auth by creating a\n * Redfish session and capturing the `X-Auth-Token`. No-op for other auth\n * types.\n */\n async connect(): Promise<void> {\n if (this.auth.type !== 'session') {\n return;\n }\n const url = this.resolve(`${this.servicePath}/SessionService/Sessions`);\n const response = await this.rawFetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Accept: 'application/json' },\n body: JSON.stringify({ UserName: this.auth.username, Password: this.auth.password }),\n });\n if (!response.ok) {\n await throwRedfishError(response);\n }\n const token = response.headers.get('x-auth-token');\n if (!token) {\n throw new RedfishError('Session creation succeeded but no X-Auth-Token header was returned', {\n url,\n status: response.status,\n statusText: response.statusText,\n });\n }\n this.token = token;\n this.sessionLocation = response.headers.get('location') ?? undefined;\n // Drain the body so the connection can be reused.\n await response.text().catch(() => undefined);\n }\n\n /** Deletes the active session, if one was established via `connect()`. */\n async disconnect(): Promise<void> {\n if (!this.sessionLocation) {\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n return;\n }\n const url = this.resolve(this.sessionLocation);\n await this.rawFetch(url, { method: 'DELETE', headers: this.authHeaders() }).catch(() => undefined);\n this.sessionLocation = undefined;\n this.token = this.auth.type === 'token' ? this.auth.token : undefined;\n }\n\n /** Fetches the service root document (`/redfish/v1/`). */\n getServiceRoot(): Promise<ServiceRoot> {\n return this.get<ServiceRoot>(this.servicePath);\n }\n\n // ---------------------------------------------------------------------\n // Systems\n // ---------------------------------------------------------------------\n\n getSystems(): Promise<ComputerSystem[]> {\n return this.getExpandedCollection<ComputerSystem>('Systems');\n }\n\n getSystemIds(): Promise<string[]> {\n return this.getCollectionIds('Systems');\n }\n\n getSystem(id: string): Promise<ComputerSystem> {\n return this.get<ComputerSystem>(`${this.servicePath}/Systems/${id}`);\n }\n\n /**\n * Invokes `#ComputerSystem.Reset` on the given system. The action target\n * is read from the system's `Actions` block so vendor-specific paths are\n * respected; falls back to the standard path if absent.\n */\n async resetSystem(id: string, resetType: ResetType): Promise<void> {\n const system = await this.getSystem(id);\n const action = system.Actions?.['#ComputerSystem.Reset'];\n await this.invokeAction(action, '#ComputerSystem.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Chassis\n // ---------------------------------------------------------------------\n\n getChassisCollection(): Promise<Chassis[]> {\n return this.getExpandedCollection<Chassis>('Chassis');\n }\n\n getChassisIds(): Promise<string[]> {\n return this.getCollectionIds('Chassis');\n }\n\n getChassis(id: string): Promise<Chassis> {\n return this.get<Chassis>(`${this.servicePath}/Chassis/${id}`);\n }\n\n async getPower(chassisId: string): Promise<Power> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Power?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Power`;\n return this.get<Power>(path);\n }\n\n async getThermal(chassisId: string): Promise<Thermal> {\n const chassis = await this.getChassis(chassisId);\n const path = chassis.Thermal?.['@odata.id'] ?? `${this.servicePath}/Chassis/${chassisId}/Thermal`;\n return this.get<Thermal>(path);\n }\n\n // ---------------------------------------------------------------------\n // Managers\n // ---------------------------------------------------------------------\n\n getManagers(): Promise<Manager[]> {\n return this.getExpandedCollection<Manager>('Managers');\n }\n\n getManagerIds(): Promise<string[]> {\n return this.getCollectionIds('Managers');\n }\n\n getManager(id: string): Promise<Manager> {\n return this.get<Manager>(`${this.servicePath}/Managers/${id}`);\n }\n\n async resetManager(id: string, resetType: ResetType): Promise<void> {\n const manager = await this.getManager(id);\n const action = manager.Actions?.['#Manager.Reset'];\n await this.invokeAction(action, '#Manager.Reset', { ResetType: resetType }, id);\n }\n\n // ---------------------------------------------------------------------\n // Sessions\n // ---------------------------------------------------------------------\n\n getSessions(): Promise<Session[]> {\n return this.getExpandedCollection<Session>('SessionService/Sessions');\n }\n\n // ---------------------------------------------------------------------\n // Generic request helpers\n // ---------------------------------------------------------------------\n\n async get<T>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'GET' });\n return data;\n }\n\n /** PATCH a resource. Pass `etag` to send `If-Match` (recommended by the Redfish spec for PATCH). */\n async patch<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PATCH', body, etag });\n return data;\n }\n\n /** PUT a full resource replacement. Rarely used by Redfish services compared to PATCH. */\n async put<T>(path: string, body: unknown, etag?: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'PUT', body, etag });\n return data;\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'POST', body });\n return data;\n }\n\n async delete<T = void>(path: string): Promise<T> {\n const { data } = await this.request<T>(path, { method: 'DELETE' });\n return data;\n }\n\n /** Fetches a Redfish collection resource (the `Members` array of `@odata.id` links), unexpanded. */\n getCollection(path: string): Promise<RedfishCollection> {\n return this.get<RedfishCollection>(this.withinService(path));\n }\n\n /** Fetches a collection and resolves every member to its full resource body. */\n async getExpandedCollection<T>(path: string): Promise<T[]> {\n const collection = await this.getCollection(this.withinService(path));\n return Promise.all(collection.Members.map((member) => this.get<T>(member['@odata.id'])));\n }\n\n private async getCollectionIds(path: string): Promise<string[]> {\n const collection = await this.getCollection(this.withinService(path));\n return collection.Members.map((member) => idFromODataId(member['@odata.id']));\n }\n\n private async invokeAction(\n action: RedfishAction | undefined,\n actionName: string,\n body: unknown,\n resourceId: string,\n ): Promise<void> {\n if (!action?.target) {\n throw new RedfishActionNotSupportedError(actionName, resourceId);\n }\n await this.request(action.target, { method: 'POST', body });\n }\n\n private withinService(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('/')) {\n return path;\n }\n return `${this.servicePath}/${path}`;\n }\n\n private resolve(path: string): string {\n if (path.startsWith('http://') || path.startsWith('https://')) {\n return path;\n }\n return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n }\n\n private authHeaders(): Record<string, string> {\n if (this.token) {\n return { 'X-Auth-Token': this.token };\n }\n if (this.auth.type === 'basic') {\n const encoded = base64Encode(`${this.auth.username}:${this.auth.password}`);\n return { Authorization: `Basic ${encoded}` };\n }\n return {};\n }\n\n private async request<T>(path: string, options: RequestOptions): Promise<RedfishResponse<T>> {\n const url = this.resolve(this.withinService(path));\n const headers: Record<string, string> = {\n Accept: 'application/json',\n ...this.authHeaders(),\n ...options.headers,\n };\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n if (options.etag) {\n headers['If-Match'] = options.etag;\n }\n\n const response = await this.rawFetch(url, {\n method: options.method ?? 'GET',\n headers,\n body: options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: options.signal,\n });\n\n if (!response.ok) {\n await throwRedfishError(response);\n }\n\n const etag = response.headers.get('etag') ?? undefined;\n if (response.status === 204) {\n return { data: undefined as T, status: response.status, etag };\n }\n const text = await response.text();\n const data = text.length > 0 ? (JSON.parse(text) as T) : (undefined as T);\n return { data, status: response.status, etag };\n }\n\n private async rawFetch(url: string, init: { method: string; headers?: Record<string, string>; body?: string; signal?: AbortSignal }): Promise<Response> {\n const controller = new AbortController();\n const signals = init.signal ? [init.signal, controller.signal] : [controller.signal];\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n return await this.fetchImpl(url, {\n method: init.method,\n headers: init.headers,\n body: init.body,\n signal: combineSignals(signals),\n // `dispatcher` is an undici-specific extension used to control TLS\n // verification; not part of the standard fetch types.\n ...(this.dispatcher ? { dispatcher: this.dispatcher } : {}),\n } as RequestInit);\n } catch (error) {\n if (controller.signal.aborted) {\n throw new RedfishTimeoutError(url, this.timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timeout);\n }\n }\n}\n\nfunction normalizeServicePath(path: string): string {\n const trimmed = path.replace(/\\/+$/, '');\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\nfunction idFromODataId(odataId: string): string {\n const segments = odataId.replace(/\\/+$/, '').split('/');\n return segments[segments.length - 1] ?? odataId;\n}\n\nfunction base64Encode(value: string): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(value, 'utf-8').toString('base64');\n }\n // Browser / edge runtime fallback.\n return btoa(value);\n}\n\nfunction combineSignals(signals: AbortSignal[]): AbortSignal {\n if (signals.length === 1) {\n return signals[0] as AbortSignal;\n }\n if (typeof AbortSignal.any === 'function') {\n return AbortSignal.any(signals);\n }\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort();\n break;\n }\n signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n return controller.signal;\n}\n\nasync function throwRedfishError(response: Response): Promise<never> {\n const text = await response.text().catch(() => '');\n let body: RedfishErrorPayload | string = text;\n try {\n body = text ? (JSON.parse(text) as RedfishErrorPayload) : text;\n } catch {\n // leave body as raw text\n }\n const message =\n (typeof body === 'object' && body.error?.message) || `Redfish request failed: ${response.status} ${response.statusText}`;\n throw new RedfishError(message, {\n url: response.url,\n status: response.status,\n statusText: response.statusText,\n body,\n });\n}\n"],"mappings":";;;AAGA,IAAa,eAAb,cAAkC,MAAM;CAC7B;CACA;CACA;CACA;CAET,YAAY,SAAiB,SAAmG;EAC9H,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;CACtB;;CAGA,IAAI,eAAmF;EACrF,IAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,UACpC,OAAO,KAAK,KAAK,QAAQ,4BAA4B,CAAC;EAExD,OAAO,CAAC;CACV;AACF;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CACpC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AM,IAAI,IAA4B;CAC5D,QAAQ,CAER;CAGA,MAAM,IAAI,aADP,OAAO,SAAS,YAAY,KAAK,OAAO,WAAY,2BAA2B,SAAS,OAAO,GAAG,SAAS,cAC9E;EAC9B,KAAK,SAAS;EACd,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-redfish",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Client for querying and managing Redfish-compliant BMCs (DMTF Redfish)",
5
5
  "keywords": [
6
6
  "redfish",
@@ -56,21 +56,21 @@
56
56
  "release:dry": "semantic-release --dry-run --no-ci"
57
57
  },
58
58
  "dependencies": {
59
- "undici": "^8.10.2"
59
+ "undici": "^8.14.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@semantic-release/changelog": "^6.0.3",
63
- "@semantic-release/git": "^10.0.1",
64
- "@types/node": "^26.4.1",
65
- "@typescript-eslint/eslint-plugin": "^8.18.0",
66
- "@typescript-eslint/parser": "^8.18.0",
67
- "@vitest/coverage-v8": "^5.0.0",
68
- "eslint": "^10.10.0",
62
+ "@semantic-release/changelog": "^7.0.0",
63
+ "@semantic-release/git": "^11.0.1",
64
+ "@types/node": "^26.6.11",
65
+ "@typescript-eslint/eslint-plugin": "^8.74.0",
66
+ "@typescript-eslint/parser": "^8.74.0",
67
+ "@vitest/coverage-v8": "^5.1.2",
68
+ "eslint": "^10.16.0",
69
69
  "semantic-release": "^25.0.9",
70
70
  "typedoc": "^0.28.20",
71
- "typescript": "^6.0.3",
72
- "vite": "^8.2.2",
73
- "vite-plugin-dts": "^5.1.0",
74
- "vitest": "^5.0.0"
71
+ "typescript": "~6.0.3",
72
+ "vite": "^8.4.0",
73
+ "vite-plugin-dts": "^5.1.2",
74
+ "vitest": "^5.1.2"
75
75
  }
76
76
  }