@orvello/sdk 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +39 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -394,8 +394,12 @@ interface OrvelloClientConfig {
|
|
|
394
394
|
*/
|
|
395
395
|
managementApiKey?: ValueProvider<string>;
|
|
396
396
|
/**
|
|
397
|
-
* Zusaetzliche Kopfzeilen fuer jede Anfrage
|
|
398
|
-
*
|
|
397
|
+
* Zusaetzliche Kopfzeilen fuer jede Anfrage an den Dienst: Geschaeftsaufrufe,
|
|
398
|
+
* Token-Tausch, Gesundheits- und Vertragsprobe, Preflight. Typischer Fall ist der
|
|
399
|
+
* Ausweis fuer eine Kante davor (Cloudflare Access), ohne den keiner dieser Wege
|
|
400
|
+
* durchkommt. Wird vor der Auth-Kopfzeile angewandt, kann sie also nicht
|
|
401
|
+
* versehentlich ueberschreiben. Andere Hosts (etwa ein vorsignierter
|
|
402
|
+
* Speicher-Link) bekommen sie nicht.
|
|
399
403
|
*/
|
|
400
404
|
headers?: HeadersProvider;
|
|
401
405
|
fetch?: typeof globalThis.fetch;
|
|
@@ -482,6 +486,12 @@ declare class OrvelloClient {
|
|
|
482
486
|
private envAuth;
|
|
483
487
|
private envManagementApiKey;
|
|
484
488
|
resolveBaseUrl(): Promise<string>;
|
|
489
|
+
/**
|
|
490
|
+
* Haengt die konfigurierten Kopfzeilen an, wenn die Anfrage an den Dienst selbst geht
|
|
491
|
+
* (Basis-Adresse oder eigener Token-Endpunkt). Schon gesetzte Kopfzeilen bleiben.
|
|
492
|
+
*/
|
|
493
|
+
private fetchWithServiceHeaders;
|
|
494
|
+
private isServiceOrigin;
|
|
485
495
|
private static resolveValue;
|
|
486
496
|
/**
|
|
487
497
|
* Der Verwaltungs-Schluessel, sofern hinterlegt.
|
package/dist/index.d.ts
CHANGED
|
@@ -394,8 +394,12 @@ interface OrvelloClientConfig {
|
|
|
394
394
|
*/
|
|
395
395
|
managementApiKey?: ValueProvider<string>;
|
|
396
396
|
/**
|
|
397
|
-
* Zusaetzliche Kopfzeilen fuer jede Anfrage
|
|
398
|
-
*
|
|
397
|
+
* Zusaetzliche Kopfzeilen fuer jede Anfrage an den Dienst: Geschaeftsaufrufe,
|
|
398
|
+
* Token-Tausch, Gesundheits- und Vertragsprobe, Preflight. Typischer Fall ist der
|
|
399
|
+
* Ausweis fuer eine Kante davor (Cloudflare Access), ohne den keiner dieser Wege
|
|
400
|
+
* durchkommt. Wird vor der Auth-Kopfzeile angewandt, kann sie also nicht
|
|
401
|
+
* versehentlich ueberschreiben. Andere Hosts (etwa ein vorsignierter
|
|
402
|
+
* Speicher-Link) bekommen sie nicht.
|
|
399
403
|
*/
|
|
400
404
|
headers?: HeadersProvider;
|
|
401
405
|
fetch?: typeof globalThis.fetch;
|
|
@@ -482,6 +486,12 @@ declare class OrvelloClient {
|
|
|
482
486
|
private envAuth;
|
|
483
487
|
private envManagementApiKey;
|
|
484
488
|
resolveBaseUrl(): Promise<string>;
|
|
489
|
+
/**
|
|
490
|
+
* Haengt die konfigurierten Kopfzeilen an, wenn die Anfrage an den Dienst selbst geht
|
|
491
|
+
* (Basis-Adresse oder eigener Token-Endpunkt). Schon gesetzte Kopfzeilen bleiben.
|
|
492
|
+
*/
|
|
493
|
+
private fetchWithServiceHeaders;
|
|
494
|
+
private isServiceOrigin;
|
|
485
495
|
private static resolveValue;
|
|
486
496
|
/**
|
|
487
497
|
* Der Verwaltungs-Schluessel, sofern hinterlegt.
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var CONTRACT_SHA256 = "bab3c1b429c28f8ac8aea5f9325c1205c6a29e2481efc868ad47a74d6587cc3d";
|
|
3
3
|
|
|
4
4
|
// src/diagnose.ts
|
|
5
|
-
var SDK_VERSION = "0.7.
|
|
5
|
+
var SDK_VERSION = "0.7.1" ;
|
|
6
6
|
function normalizeBaseUrl(raw) {
|
|
7
7
|
const trimmed = raw.trim();
|
|
8
8
|
if (!trimmed) throw new Error("Base URL cannot be empty");
|
|
@@ -735,7 +735,7 @@ function buildPath(operationId, params) {
|
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
// src/capabilities.ts
|
|
738
|
-
var SDK_VERSION2 = "0.7.
|
|
738
|
+
var SDK_VERSION2 = "0.7.1" ;
|
|
739
739
|
var CLIENT_MANAGEMENT_OPS = [
|
|
740
740
|
"oauth2_external_clients_list",
|
|
741
741
|
"oauth2_external_clients_get",
|
|
@@ -1035,7 +1035,8 @@ var OrvelloClient = class _OrvelloClient {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
this.managementApiKey = config.managementApiKey ?? this.envManagementApiKey();
|
|
1037
1037
|
this.extraHeaders = config.headers;
|
|
1038
|
-
|
|
1038
|
+
const rawFetch = config.fetch || globalThis.fetch;
|
|
1039
|
+
this.doFetch = typeof rawFetch === "function" ? ((input, init) => this.fetchWithServiceHeaders(rawFetch, input, init)) : rawFetch;
|
|
1039
1040
|
this.timeoutMs = config.timeoutMs ?? 15e3;
|
|
1040
1041
|
this.maxRetries = config.maxRetries ?? 3;
|
|
1041
1042
|
this.retryBaseDelayMs = config.retryBaseDelayMs ?? 500;
|
|
@@ -1073,6 +1074,41 @@ var OrvelloClient = class _OrvelloClient {
|
|
|
1073
1074
|
const val = typeof this.baseUrl === "function" ? await this.baseUrl() : this.baseUrl;
|
|
1074
1075
|
return val.replace(/\/+$/, "");
|
|
1075
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Haengt die konfigurierten Kopfzeilen an, wenn die Anfrage an den Dienst selbst geht
|
|
1079
|
+
* (Basis-Adresse oder eigener Token-Endpunkt). Schon gesetzte Kopfzeilen bleiben.
|
|
1080
|
+
*/
|
|
1081
|
+
async fetchWithServiceHeaders(rawFetch, input, init) {
|
|
1082
|
+
const configured = await _OrvelloClient.resolveValue(this.extraHeaders);
|
|
1083
|
+
if (!configured || Object.keys(configured).length === 0) return rawFetch(input, init);
|
|
1084
|
+
const target = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
1085
|
+
if (!await this.isServiceOrigin(target)) return rawFetch(input, init);
|
|
1086
|
+
const headers = new Headers(init?.headers ?? (typeof input === "object" && "headers" in input ? input.headers : void 0));
|
|
1087
|
+
for (const [name, value] of Object.entries(configured)) {
|
|
1088
|
+
if (!headers.has(name)) headers.set(name, value);
|
|
1089
|
+
}
|
|
1090
|
+
return rawFetch(input, { ...init, headers });
|
|
1091
|
+
}
|
|
1092
|
+
async isServiceOrigin(target) {
|
|
1093
|
+
let origin;
|
|
1094
|
+
try {
|
|
1095
|
+
origin = new URL(target).origin;
|
|
1096
|
+
} catch {
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
const own = [];
|
|
1100
|
+
try {
|
|
1101
|
+
own.push(new URL(await this.resolveBaseUrl()).origin);
|
|
1102
|
+
} catch {
|
|
1103
|
+
}
|
|
1104
|
+
if (typeof this.auth === "object" && "tokenUrl" in this.auth && this.auth.tokenUrl) {
|
|
1105
|
+
try {
|
|
1106
|
+
own.push(new URL(this.auth.tokenUrl).origin);
|
|
1107
|
+
} catch {
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
return own.includes(origin);
|
|
1111
|
+
}
|
|
1076
1112
|
static async resolveValue(provider) {
|
|
1077
1113
|
if (provider === void 0) return void 0;
|
|
1078
1114
|
return typeof provider === "function" ? await provider() : provider;
|