@zitadel/sdk 4.1.0-beta.13 → 4.1.0-beta.15
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 +70 -0
- package/dist/auth/client-credentials-authenticator-builder.d.ts +3 -1
- package/dist/auth/client-credentials-authenticator-builder.js +4 -3
- package/dist/auth/client-credentials-authenticator-builder.js.map +1 -1
- package/dist/auth/client-credentials-authenticator.d.ts +5 -2
- package/dist/auth/client-credentials-authenticator.js +11 -7
- package/dist/auth/client-credentials-authenticator.js.map +1 -1
- package/dist/auth/oauth-authenticator-builder.d.ts +4 -1
- package/dist/auth/oauth-authenticator-builder.js +5 -2
- package/dist/auth/oauth-authenticator-builder.js.map +1 -1
- package/dist/auth/oauth-authenticator.d.ts +19 -1
- package/dist/auth/oauth-authenticator.js +47 -1
- package/dist/auth/oauth-authenticator.js.map +1 -1
- package/dist/auth/openid.d.ts +3 -1
- package/dist/auth/openid.js +15 -5
- package/dist/auth/openid.js.map +1 -1
- package/dist/auth/webtoken-authenticator-builder.d.ts +3 -1
- package/dist/auth/webtoken-authenticator-builder.js +4 -3
- package/dist/auth/webtoken-authenticator-builder.js.map +1 -1
- package/dist/auth/webtoken-authenticator.d.ts +19 -3
- package/dist/auth/webtoken-authenticator.js +28 -11
- package/dist/auth/webtoken-authenticator.js.map +1 -1
- package/dist/configuration.d.ts +12 -1
- package/dist/configuration.js +35 -3
- package/dist/configuration.js.map +1 -1
- package/dist/index.d.ts +20 -4
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +4 -1
- package/dist/runtime.js.map +1 -1
- package/dist/transport-options.d.ts +20 -0
- package/dist/transport-options.js +37 -0
- package/dist/transport-options.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -203,6 +203,76 @@ Choose the authentication method that best suits your needs based on your
|
|
|
203
203
|
environment and security requirements. For more details, please refer to the
|
|
204
204
|
[Zitadel documentation on authenticating service users](https://zitadel.com/docs/guides/integrate/service-users/authenticate-service-users).
|
|
205
205
|
|
|
206
|
+
## Advanced Configuration
|
|
207
|
+
|
|
208
|
+
The SDK provides a `TransportOptions` object that allows you to customise
|
|
209
|
+
the underlying HTTP transport used for both OpenID discovery and API calls.
|
|
210
|
+
|
|
211
|
+
### Disabling TLS Verification
|
|
212
|
+
|
|
213
|
+
In development or testing environments with self-signed certificates, you can
|
|
214
|
+
disable TLS verification entirely:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import Zitadel from '@zitadel/sdk';
|
|
218
|
+
|
|
219
|
+
const zitadel = await Zitadel.withClientCredentials(
|
|
220
|
+
'https://your-instance.zitadel.cloud',
|
|
221
|
+
'client-id',
|
|
222
|
+
'client-secret',
|
|
223
|
+
{ insecure: true },
|
|
224
|
+
);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Using a Custom CA Certificate
|
|
228
|
+
|
|
229
|
+
If your Zitadel instance uses a certificate signed by a private CA, you can
|
|
230
|
+
provide the path to the CA certificate in PEM format:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import Zitadel from '@zitadel/sdk';
|
|
234
|
+
|
|
235
|
+
const zitadel = await Zitadel.withClientCredentials(
|
|
236
|
+
'https://your-instance.zitadel.cloud',
|
|
237
|
+
'client-id',
|
|
238
|
+
'client-secret',
|
|
239
|
+
{ caCertPath: '/path/to/ca.pem' },
|
|
240
|
+
);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Custom Default Headers
|
|
244
|
+
|
|
245
|
+
You can attach default headers to every outgoing request. This is useful for
|
|
246
|
+
custom routing or tracing headers:
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
import Zitadel from '@zitadel/sdk';
|
|
250
|
+
|
|
251
|
+
const zitadel = await Zitadel.withClientCredentials(
|
|
252
|
+
'https://your-instance.zitadel.cloud',
|
|
253
|
+
'client-id',
|
|
254
|
+
'client-secret',
|
|
255
|
+
{ defaultHeaders: { 'X-Custom-Header': 'my-value' } },
|
|
256
|
+
);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Proxy Configuration
|
|
260
|
+
|
|
261
|
+
If your environment requires routing traffic through an HTTP proxy, you can
|
|
262
|
+
specify the proxy URL. To authenticate with the proxy, embed the credentials
|
|
263
|
+
directly in the URL:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import Zitadel from '@zitadel/sdk';
|
|
267
|
+
|
|
268
|
+
const zitadel = await Zitadel.withClientCredentials(
|
|
269
|
+
'https://your-instance.zitadel.cloud',
|
|
270
|
+
'client-id',
|
|
271
|
+
'client-secret',
|
|
272
|
+
{ proxyUrl: 'http://user:pass@proxy:8080' },
|
|
273
|
+
);
|
|
274
|
+
```
|
|
275
|
+
|
|
206
276
|
## Design and Dependencies
|
|
207
277
|
|
|
208
278
|
This SDK is designed to be lean and efficient, focusing on providing a
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OAuthAuthenticatorBuilder } from './oauth-authenticator-builder.js';
|
|
2
2
|
import { ClientCredentialsAuthenticator } from './client-credentials-authenticator.js';
|
|
3
|
+
import type { TransportOptions } from '../transport-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* Builder for ClientCredentialsAuthenticator.
|
|
5
6
|
*
|
|
@@ -15,8 +16,9 @@ export declare class ClientCredentialsAuthenticatorBuilder extends OAuthAuthenti
|
|
|
15
16
|
* @param host The base URL for API endpoints.
|
|
16
17
|
* @param clientId The OAuth2 client identifier.
|
|
17
18
|
* @param clientSecret The OAuth2 client secret.
|
|
19
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
18
20
|
*/
|
|
19
|
-
constructor(host: string, clientId: string, clientSecret: string);
|
|
21
|
+
constructor(host: string, clientId: string, clientSecret: string, transportOptions?: TransportOptions);
|
|
20
22
|
/**
|
|
21
23
|
* Builds and returns a new ClientCredentialsAuthenticator instance.
|
|
22
24
|
*
|
|
@@ -15,9 +15,10 @@ export class ClientCredentialsAuthenticatorBuilder extends OAuthAuthenticatorBui
|
|
|
15
15
|
* @param host The base URL for API endpoints.
|
|
16
16
|
* @param clientId The OAuth2 client identifier.
|
|
17
17
|
* @param clientSecret The OAuth2 client secret.
|
|
18
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
18
19
|
*/
|
|
19
|
-
constructor(host, clientId, clientSecret) {
|
|
20
|
-
super(host);
|
|
20
|
+
constructor(host, clientId, clientSecret, transportOptions) {
|
|
21
|
+
super(host, transportOptions);
|
|
21
22
|
this.clientId = clientId;
|
|
22
23
|
this.clientSecret = clientSecret;
|
|
23
24
|
}
|
|
@@ -28,7 +29,7 @@ export class ClientCredentialsAuthenticatorBuilder extends OAuthAuthenticatorBui
|
|
|
28
29
|
*/
|
|
29
30
|
async build() {
|
|
30
31
|
await this.discoverOpenId();
|
|
31
|
-
return new ClientCredentialsAuthenticator(this.openId, this.clientId, this.clientSecret, this.authScopes);
|
|
32
|
+
return new ClientCredentialsAuthenticator(this.openId, this.clientId, this.clientSecret, this.authScopes, this.transportOptions);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
//# sourceMappingURL=client-credentials-authenticator-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-credentials-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/client-credentials-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"client-credentials-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/client-credentials-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAGvF;;;;;GAKG;AACH,MAAM,OAAO,qCAAsC,SAAQ,yBAAyB;IAW/D;IACA;IAXnB;;;;;;;OAOG;IACH,YACE,IAAY,EACK,QAAgB,EAChB,YAAoB,EACrC,gBAAmC;QAEnC,KAAK,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAJb,aAAQ,GAAR,QAAQ,CAAQ;QAChB,iBAAY,GAAZ,YAAY,CAAQ;IAIvC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,IAAI,8BAA8B,CACvC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,gBAAgB,CACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,6 +2,7 @@ import { OAuthAuthenticator } from './oauth-authenticator.js';
|
|
|
2
2
|
import { OpenId } from './openid.js';
|
|
3
3
|
import { ClientCredentialsAuthenticatorBuilder } from './client-credentials-authenticator-builder.js';
|
|
4
4
|
import * as oauth from 'oauth4webapi';
|
|
5
|
+
import type { TransportOptions } from '../transport-options.js';
|
|
5
6
|
/**
|
|
6
7
|
* OAuth2 Client Credentials Authenticator.
|
|
7
8
|
*
|
|
@@ -17,16 +18,18 @@ export declare class ClientCredentialsAuthenticator extends OAuthAuthenticator {
|
|
|
17
18
|
* @param clientId The OAuth2 client identifier.
|
|
18
19
|
* @param clientSecret The OAuth2 client secret.
|
|
19
20
|
* @param scope The scope for the token request.
|
|
21
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
20
22
|
*/
|
|
21
|
-
constructor(openId: OpenId, clientId: string, clientSecret: string, scope?: string);
|
|
23
|
+
constructor(openId: OpenId, clientId: string, clientSecret: string, scope?: string, transportOptions?: TransportOptions);
|
|
22
24
|
/**
|
|
23
25
|
* Returns a new builder instance for ClientCredentialsAuthenticator.
|
|
24
26
|
*
|
|
25
27
|
* @param host The base URL for API endpoints.
|
|
26
28
|
* @param clientId The OAuth2 client identifier.
|
|
27
29
|
* @param clientSecret The OAuth2 client secret.
|
|
30
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
28
31
|
* @returns A new builder instance.
|
|
29
32
|
*/
|
|
30
|
-
static builder(host: string, clientId: string, clientSecret: string): ClientCredentialsAuthenticatorBuilder;
|
|
33
|
+
static builder(host: string, clientId: string, clientSecret: string, transportOptions?: TransportOptions): ClientCredentialsAuthenticatorBuilder;
|
|
31
34
|
protected performTokenRequest(authServer: oauth.AuthorizationServer, client: oauth.Client): Promise<oauth.TokenEndpointResponse>;
|
|
32
35
|
}
|
|
@@ -16,11 +16,12 @@ export class ClientCredentialsAuthenticator extends OAuthAuthenticator {
|
|
|
16
16
|
* @param clientId The OAuth2 client identifier.
|
|
17
17
|
* @param clientSecret The OAuth2 client secret.
|
|
18
18
|
* @param scope The scope for the token request.
|
|
19
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
19
20
|
*/
|
|
20
|
-
constructor(openId, clientId, clientSecret, scope = 'openid urn:zitadel:iam:org:project:id:zitadel:aud') {
|
|
21
|
+
constructor(openId, clientId, clientSecret, scope = 'openid urn:zitadel:iam:org:project:id:zitadel:aud', transportOptions) {
|
|
21
22
|
const authServer = openId.getAuthorizationServer();
|
|
22
23
|
const client = { client_id: clientId };
|
|
23
|
-
super(authServer, client, scope);
|
|
24
|
+
super(authServer, client, scope, transportOptions);
|
|
24
25
|
this.clientAuth = oauth.ClientSecretBasic(clientSecret);
|
|
25
26
|
this.parameters = new URLSearchParams({
|
|
26
27
|
grant_type: 'client_credentials',
|
|
@@ -33,16 +34,19 @@ export class ClientCredentialsAuthenticator extends OAuthAuthenticator {
|
|
|
33
34
|
* @param host The base URL for API endpoints.
|
|
34
35
|
* @param clientId The OAuth2 client identifier.
|
|
35
36
|
* @param clientSecret The OAuth2 client secret.
|
|
37
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
36
38
|
* @returns A new builder instance.
|
|
37
39
|
*/
|
|
38
|
-
static builder(host, clientId, clientSecret) {
|
|
39
|
-
return new ClientCredentialsAuthenticatorBuilder(host, clientId, clientSecret);
|
|
40
|
+
static builder(host, clientId, clientSecret, transportOptions) {
|
|
41
|
+
return new ClientCredentialsAuthenticatorBuilder(host, clientId, clientSecret, transportOptions);
|
|
40
42
|
}
|
|
41
43
|
async performTokenRequest(authServer, client) {
|
|
44
|
+
const tokenOptions = await this.buildTokenRequestOptions();
|
|
45
|
+
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
46
|
+
tokenOptions[oauth.allowInsecureRequests] = true;
|
|
47
|
+
}
|
|
42
48
|
// noinspection JSDeprecatedSymbols
|
|
43
|
-
const response = await oauth.clientCredentialsGrantRequest(authServer, client, this.clientAuth, this.parameters,
|
|
44
|
-
[oauth.allowInsecureRequests]: process.env.JEST_WORKER_ID !== undefined,
|
|
45
|
-
});
|
|
49
|
+
const response = await oauth.clientCredentialsGrantRequest(authServer, client, this.clientAuth, this.parameters, tokenOptions);
|
|
46
50
|
return oauth.processClientCredentialsResponse(authServer, client, response);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-credentials-authenticator.js","sourceRoot":"","sources":["../../src/auth/client-credentials-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AACtG,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"client-credentials-authenticator.js","sourceRoot":"","sources":["../../src/auth/client-credentials-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAA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C,UAAU,EACf,YAAY,CACb,CAAC;QAEF,OAAO,KAAK,CAAC,gCAAgC,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenId } from './openid.js';
|
|
2
2
|
import { OAuthAuthenticator } from './oauth-authenticator.js';
|
|
3
|
+
import type { TransportOptions } from '../transport-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* Base builder for OAuth authenticators.
|
|
5
6
|
*
|
|
@@ -9,14 +10,16 @@ import { OAuthAuthenticator } from './oauth-authenticator.js';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare abstract class OAuthAuthenticatorBuilder {
|
|
11
12
|
protected readonly host: string;
|
|
13
|
+
protected readonly transportOptions?: TransportOptions | undefined;
|
|
12
14
|
protected authScopes: string;
|
|
13
15
|
protected openId: OpenId;
|
|
14
16
|
/**
|
|
15
17
|
* Constructs the builder with the required host.
|
|
16
18
|
*
|
|
17
19
|
* @param host The hostname of the OpenID provider.
|
|
20
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
18
21
|
*/
|
|
19
|
-
protected constructor(host: string);
|
|
22
|
+
protected constructor(host: string, transportOptions?: TransportOptions | undefined);
|
|
20
23
|
/**
|
|
21
24
|
* Overrides the default scopes.
|
|
22
25
|
*
|
|
@@ -8,15 +8,18 @@ import { OpenId } from './openid.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export class OAuthAuthenticatorBuilder {
|
|
10
10
|
host;
|
|
11
|
+
transportOptions;
|
|
11
12
|
authScopes = 'openid urn:zitadel:iam:org:project:id:zitadel:aud';
|
|
12
13
|
openId;
|
|
13
14
|
/**
|
|
14
15
|
* Constructs the builder with the required host.
|
|
15
16
|
*
|
|
16
17
|
* @param host The hostname of the OpenID provider.
|
|
18
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
17
19
|
*/
|
|
18
|
-
constructor(host) {
|
|
20
|
+
constructor(host, transportOptions) {
|
|
19
21
|
this.host = host;
|
|
22
|
+
this.transportOptions = transportOptions;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Overrides the default scopes.
|
|
@@ -30,7 +33,7 @@ export class OAuthAuthenticatorBuilder {
|
|
|
30
33
|
}
|
|
31
34
|
async discoverOpenId() {
|
|
32
35
|
if (!this.openId) {
|
|
33
|
-
this.openId = await OpenId.discover(this.host);
|
|
36
|
+
this.openId = await OpenId.discover(this.host, this.transportOptions);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/oauth-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"oauth-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/oauth-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;;;GAMG;AACH,MAAM,OAAgB,yBAAyB;IAYxB;IACA;IAZX,UAAU,GAClB,mDAAmD,CAAC;IAC5C,MAAM,CAAU;IAE1B;;;;;OAKG;IACH,YACqB,IAAY,EACZ,gBAAmC;QADnC,SAAI,GAAJ,IAAI,CAAQ;QACZ,qBAAgB,GAAhB,gBAAgB,CAAmB;IACrD,CAAC;IAEJ;;;;;OAKG;IACI,MAAM,CAAC,MAAyB;QACrC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,cAAc;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CAGF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Authenticator } from './authenticator.js';
|
|
2
2
|
import * as oauth from 'oauth4webapi';
|
|
3
|
+
import { type TransportOptions } from '../transport-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* Abstract base class for OAuth-based authenticators.
|
|
5
6
|
*
|
|
@@ -10,6 +11,7 @@ export declare abstract class OAuthAuthenticator extends Authenticator {
|
|
|
10
11
|
protected readonly authServer: oauth.AuthorizationServer;
|
|
11
12
|
protected readonly client: oauth.Client;
|
|
12
13
|
protected readonly scope: string;
|
|
14
|
+
protected readonly transportOptions?: TransportOptions | undefined;
|
|
13
15
|
/**
|
|
14
16
|
* The OAuth2 token.
|
|
15
17
|
*/
|
|
@@ -18,14 +20,30 @@ export declare abstract class OAuthAuthenticator extends Authenticator {
|
|
|
18
20
|
* The token's expiration timestamp.
|
|
19
21
|
*/
|
|
20
22
|
protected tokenExpiry: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* Cached dispatcher for reuse across token requests.
|
|
25
|
+
*/
|
|
26
|
+
private cachedDispatcher;
|
|
21
27
|
/**
|
|
22
28
|
* OAuthAuthenticator constructor.
|
|
23
29
|
*
|
|
24
30
|
* @param authServer The discovered authorization server metadata.
|
|
25
31
|
* @param client The OAuth2 client metadata.
|
|
26
32
|
* @param scope The scope for the token request.
|
|
33
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
34
|
+
*/
|
|
35
|
+
protected constructor(authServer: oauth.AuthorizationServer, client: oauth.Client, scope: string, transportOptions?: TransportOptions | undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Builds oauth4webapi request options from transport options.
|
|
38
|
+
*
|
|
39
|
+
* Constructs a customFetch wrapper that applies the configured dispatcher
|
|
40
|
+
* (for TLS/proxy settings) and default headers to all HTTP requests made
|
|
41
|
+
* by oauth4webapi functions.
|
|
42
|
+
*
|
|
43
|
+
* @returns An options object suitable for passing to oauth4webapi token
|
|
44
|
+
* request functions.
|
|
27
45
|
*/
|
|
28
|
-
protected
|
|
46
|
+
protected buildTokenRequestOptions(): Promise<Record<string | symbol, unknown>>;
|
|
29
47
|
/**
|
|
30
48
|
* Retrieve the authentication token using the OAuth2 flow.
|
|
31
49
|
*
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Authenticator } from './authenticator.js';
|
|
2
|
+
import * as oauth from 'oauth4webapi';
|
|
2
3
|
import { ZitadelException } from '../zitadel-exception.js';
|
|
4
|
+
import { buildDispatcher, } from '../transport-options.js';
|
|
3
5
|
/**
|
|
4
6
|
* Abstract base class for OAuth-based authenticators.
|
|
5
7
|
*
|
|
@@ -10,6 +12,7 @@ export class OAuthAuthenticator extends Authenticator {
|
|
|
10
12
|
authServer;
|
|
11
13
|
client;
|
|
12
14
|
scope;
|
|
15
|
+
transportOptions;
|
|
13
16
|
/**
|
|
14
17
|
* The OAuth2 token.
|
|
15
18
|
*/
|
|
@@ -18,18 +21,61 @@ export class OAuthAuthenticator extends Authenticator {
|
|
|
18
21
|
* The token's expiration timestamp.
|
|
19
22
|
*/
|
|
20
23
|
tokenExpiry = null;
|
|
24
|
+
/**
|
|
25
|
+
* Cached dispatcher for reuse across token requests.
|
|
26
|
+
*/
|
|
27
|
+
cachedDispatcher = null;
|
|
21
28
|
/**
|
|
22
29
|
* OAuthAuthenticator constructor.
|
|
23
30
|
*
|
|
24
31
|
* @param authServer The discovered authorization server metadata.
|
|
25
32
|
* @param client The OAuth2 client metadata.
|
|
26
33
|
* @param scope The scope for the token request.
|
|
34
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
27
35
|
*/
|
|
28
|
-
constructor(authServer, client, scope) {
|
|
36
|
+
constructor(authServer, client, scope, transportOptions) {
|
|
29
37
|
super(authServer.issuer);
|
|
30
38
|
this.authServer = authServer;
|
|
31
39
|
this.client = client;
|
|
32
40
|
this.scope = scope;
|
|
41
|
+
this.transportOptions = transportOptions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds oauth4webapi request options from transport options.
|
|
45
|
+
*
|
|
46
|
+
* Constructs a customFetch wrapper that applies the configured dispatcher
|
|
47
|
+
* (for TLS/proxy settings) and default headers to all HTTP requests made
|
|
48
|
+
* by oauth4webapi functions.
|
|
49
|
+
*
|
|
50
|
+
* @returns An options object suitable for passing to oauth4webapi token
|
|
51
|
+
* request functions.
|
|
52
|
+
*/
|
|
53
|
+
async buildTokenRequestOptions() {
|
|
54
|
+
const options = {};
|
|
55
|
+
if (this.authServer.issuer.startsWith('http://')) {
|
|
56
|
+
options[oauth.allowInsecureRequests] = true;
|
|
57
|
+
}
|
|
58
|
+
if (this.transportOptions?.defaultHeaders) {
|
|
59
|
+
options.headers = this.transportOptions.defaultHeaders;
|
|
60
|
+
}
|
|
61
|
+
if (this.cachedDispatcher === null) {
|
|
62
|
+
this.cachedDispatcher = buildDispatcher(this.transportOptions);
|
|
63
|
+
}
|
|
64
|
+
const dispatcher = await this.cachedDispatcher;
|
|
65
|
+
if (dispatcher || this.transportOptions?.defaultHeaders) {
|
|
66
|
+
const defaultHeaders = this.transportOptions?.defaultHeaders;
|
|
67
|
+
options[oauth.customFetch] = (url, fetchOptions) => {
|
|
68
|
+
if (defaultHeaders) {
|
|
69
|
+
const existingHeaders = (fetchOptions.headers ?? {});
|
|
70
|
+
fetchOptions.headers = { ...defaultHeaders, ...existingHeaders };
|
|
71
|
+
}
|
|
72
|
+
return fetch(url, {
|
|
73
|
+
...fetchOptions,
|
|
74
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return options;
|
|
33
79
|
}
|
|
34
80
|
/**
|
|
35
81
|
* Retrieve the authentication token using the OAuth2 flow.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authenticator.js","sourceRoot":"","sources":["../../src/auth/oauth-authenticator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth-authenticator.js","sourceRoot":"","sources":["../../src/auth/oauth-authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,aAAa;IAuBvC;IACA;IACA;IACA;IAzBrB;;OAEG;IACO,KAAK,GAAuC,IAAI,CAAC;IAC3D;;OAEG;IACO,WAAW,GAAkB,IAAI,CAAC;IAC5C;;OAEG;IACK,gBAAgB,GAA2C,IAAI,CAAC;IAExE;;;;;;;OAOG;IACH,YACqB,UAAqC,EACrC,MAAoB,EACpB,KAAa,EACb,gBAAmC;QAEtD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QALN,eAAU,GAAV,UAAU,CAA2B;QACrC,WAAM,GAAN,MAAM,CAAc;QACpB,UAAK,GAAL,KAAK,CAAQ;QACb,qBAAgB,GAAhB,gBAAgB,CAAmB;IAGxD,CAAC;IAED;;;;;;;;;OASG;IACO,KAAK,CAAC,wBAAwB;QAGtC,MAAM,OAAO,GAAqC,EAAE,CAAC;QAErD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACjD,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;QAC9C,CAAC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE,cAAc,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC;QACzD,C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,CAAC,YAAY,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY;QACvB,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC;YAChD,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC;YAE1D,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,gBAAgB,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CAMF"}
|
package/dist/auth/openid.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as oauth from 'oauth4webapi';
|
|
2
|
+
import { type TransportOptions } from '../transport-options.js';
|
|
2
3
|
/**
|
|
3
4
|
* OpenId class is responsible for fetching and storing important OpenID
|
|
4
5
|
* configuration endpoints. It interacts with the OpenID provider's
|
|
@@ -31,11 +32,12 @@ export declare class OpenId {
|
|
|
31
32
|
* and returns a new OpenId instance.
|
|
32
33
|
*
|
|
33
34
|
* @param hostname The hostname of the OpenID provider.
|
|
35
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
34
36
|
* @returns A promise that resolves to an OpenId instance.
|
|
35
37
|
* @throws {Error} If the provided hostname is empty, or if there's an
|
|
36
38
|
* error during the HTTP request or JSON parsing.
|
|
37
39
|
*/
|
|
38
|
-
static discover(hostname: string): Promise<OpenId>;
|
|
40
|
+
static discover(hostname: string, transportOptions?: TransportOptions): Promise<OpenId>;
|
|
39
41
|
/**
|
|
40
42
|
* Returns the discovered Authorization Server metadata.
|
|
41
43
|
*/
|
package/dist/auth/openid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildDispatcher, } from '../transport-options.js';
|
|
1
2
|
/**
|
|
2
3
|
* OpenId class is responsible for fetching and storing important OpenID
|
|
3
4
|
* configuration endpoints. It interacts with the OpenID provider's
|
|
@@ -11,7 +12,6 @@ export class OpenId {
|
|
|
11
12
|
*/
|
|
12
13
|
constructor(authServer) {
|
|
13
14
|
this.authServer = authServer;
|
|
14
|
-
//
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Builds and returns a URL object from the provided hostname.
|
|
@@ -34,9 +34,18 @@ export class OpenId {
|
|
|
34
34
|
/**
|
|
35
35
|
* Fetches the OpenID configuration from the well-known endpoint.
|
|
36
36
|
*/
|
|
37
|
-
static async fetchOpenIdConfiguration(hostname) {
|
|
37
|
+
static async fetchOpenIdConfiguration(hostname, transportOptions) {
|
|
38
38
|
const wellKnownUrl = this.buildWellKnownUrl(hostname);
|
|
39
|
-
const
|
|
39
|
+
const fetchInit = {};
|
|
40
|
+
if (transportOptions?.defaultHeaders) {
|
|
41
|
+
fetchInit.headers = transportOptions.defaultHeaders;
|
|
42
|
+
}
|
|
43
|
+
const dispatcher = await buildDispatcher(transportOptions);
|
|
44
|
+
if (dispatcher) {
|
|
45
|
+
fetchInit.dispatcher = dispatcher;
|
|
46
|
+
}
|
|
47
|
+
// eslint-disable-next-line no-undef
|
|
48
|
+
const response = await fetch(wellKnownUrl, fetchInit);
|
|
40
49
|
if (!response.ok) {
|
|
41
50
|
throw new Error(`Failed to fetch OpenID configuration: ${response.status} ${response.statusText}`);
|
|
42
51
|
}
|
|
@@ -55,15 +64,16 @@ export class OpenId {
|
|
|
55
64
|
* and returns a new OpenId instance.
|
|
56
65
|
*
|
|
57
66
|
* @param hostname The hostname of the OpenID provider.
|
|
67
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
58
68
|
* @returns A promise that resolves to an OpenId instance.
|
|
59
69
|
* @throws {Error} If the provided hostname is empty, or if there's an
|
|
60
70
|
* error during the HTTP request or JSON parsing.
|
|
61
71
|
*/
|
|
62
|
-
static async discover(hostname) {
|
|
72
|
+
static async discover(hostname, transportOptions) {
|
|
63
73
|
if (!hostname) {
|
|
64
74
|
throw new Error('Hostname cannot be empty.');
|
|
65
75
|
}
|
|
66
|
-
const authServer = await this.fetchOpenIdConfiguration(hostname);
|
|
76
|
+
const authServer = await this.fetchOpenIdConfiguration(hostname, transportOptions);
|
|
67
77
|
return new OpenId(authServer);
|
|
68
78
|
}
|
|
69
79
|
/**
|
package/dist/auth/openid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openid.js","sourceRoot":"","sources":["../../src/auth/openid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openid.js","sourceRoot":"","sources":["../../src/auth/openid.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,MAAM;IAIoB;IAHrC;;OAEG;IACH,YAAqC,UAAqC;QAArC,eAAU,GAAV,UAAU,CAA2B;IAAG,CAAC;IAE9E;;;OAGG;IACK,MAAM,CAAC,aAAa,CAAC,QAAgB;QAC3C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,GAAG,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,iBAAiB,CAAC,QAAgB;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACzC,GAAG,CAAC,QAAQ,GAAG,mCAAmC,CAAC;QACnD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,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;IAED;;OAEG;IACH,sBAAsB;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,qCAAqC;IACrC;;;;;;OAMG;IACI,gBAAgB;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;IACxC,CAAC;IAED,qCAAqC;IACrC;;;;;;OAMG;IACI,wBAAwB;QAC7B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC;IAChD,CAAC;IAED,qCAAqC;IACrC;;;;;;;OAOG;IACI,mBAAmB;QACxB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OAuthAuthenticatorBuilder } from './oauth-authenticator-builder.js';
|
|
2
2
|
import { WebTokenAuthenticator } from './webtoken-authenticator.js';
|
|
3
|
+
import type { TransportOptions } from '../transport-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* Builder for WebTokenAuthenticator.
|
|
5
6
|
*
|
|
@@ -36,8 +37,9 @@ export declare class WebTokenAuthenticatorBuilder extends OAuthAuthenticatorBuil
|
|
|
36
37
|
* @param jwtSubject The subject claim for the JWT.
|
|
37
38
|
* @param jwtAudience The audience claim for the JWT.
|
|
38
39
|
* @param privateKey The PEM-formatted private key used to sign the JWT.
|
|
40
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
39
41
|
*/
|
|
40
|
-
constructor(host: string, jwtIssuer: string, jwtSubject: string, jwtAudience: string, privateKey: string);
|
|
42
|
+
constructor(host: string, jwtIssuer: string, jwtSubject: string, jwtAudience: string, privateKey: string, transportOptions?: TransportOptions);
|
|
41
43
|
/**
|
|
42
44
|
* Sets the token lifetime in seconds.
|
|
43
45
|
*
|
|
@@ -36,9 +36,10 @@ export class WebTokenAuthenticatorBuilder extends OAuthAuthenticatorBuilder {
|
|
|
36
36
|
* @param jwtSubject The subject claim for the JWT.
|
|
37
37
|
* @param jwtAudience The audience claim for the JWT.
|
|
38
38
|
* @param privateKey The PEM-formatted private key used to sign the JWT.
|
|
39
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
39
40
|
*/
|
|
40
|
-
constructor(host, jwtIssuer, jwtSubject, jwtAudience, privateKey) {
|
|
41
|
-
super(host);
|
|
41
|
+
constructor(host, jwtIssuer, jwtSubject, jwtAudience, privateKey, transportOptions) {
|
|
42
|
+
super(host, transportOptions);
|
|
42
43
|
this.jwtIssuer = jwtIssuer;
|
|
43
44
|
this.jwtSubject = jwtSubject;
|
|
44
45
|
this.jwtAudience = jwtAudience;
|
|
@@ -85,7 +86,7 @@ export class WebTokenAuthenticatorBuilder extends OAuthAuthenticatorBuilder {
|
|
|
85
86
|
*/
|
|
86
87
|
async build() {
|
|
87
88
|
await this.discoverOpenId();
|
|
88
|
-
return WebTokenAuthenticator.create(this.openId, 'zitadel', this.authScopes, this.jwtIssuer, this.jwtSubject, this.jwtAudience, this.privateKey, this.lifetimeSeconds, this.jwtAlg, this.kid);
|
|
89
|
+
return WebTokenAuthenticator.create(this.openId, 'zitadel', this.authScopes, this.jwtIssuer, this.jwtSubject, this.jwtAudience, this.privateKey, this.lifetimeSeconds, this.jwtAlg, this.kid, this.transportOptions);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
//# sourceMappingURL=webtoken-authenticator-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webtoken-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/webtoken-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"webtoken-authenticator-builder.js","sourceRoot":"","sources":["../../src/auth/webtoken-authenticator-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,4BAA6B,SAAQ,yBAAyB;IAiBtD;IACA;IACA;IACA;IAnBX,MAAM,GAAW,OAAO,CAAC;IACzB,eAAe,GAAW,IAAI,CAAC;IAC/B,GAAG,CAAU;IAErB;;;;;;;;;OASG;IACH,YACE,IAAY,EACK,SAAiB,EACjB,UAAkB,EAClB,WAAmB,EACnB,UAAkB,EACnC,gBAAmC;QAEnC,KAAK,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QANb,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAQ;QACnB,eAAU,GAAV,UAAU,CAAQ;IAIrC,CAAC;IAED;;;;;OAKG;IACI,oBAAoB,CAAC,OAAe;QACzC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,SAAiB;QACnC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAa;QACxB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,qBAAqB,CAAC,MAAM,CACjC,IAAI,CAAC,MAAM,EACX,SAAS,EACT,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,gBAAgB,CACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,6 +2,7 @@ import { OAuthAuthenticator } from './oauth-authenticator.js';
|
|
|
2
2
|
import * as oauth from 'oauth4webapi';
|
|
3
3
|
import { OpenId } from './openid.js';
|
|
4
4
|
import { WebTokenAuthenticatorBuilder } from './webtoken-authenticator-builder.js';
|
|
5
|
+
import type { TransportOptions } from '../transport-options.js';
|
|
5
6
|
/**
|
|
6
7
|
* JWT-based Authenticator using the JWT Bearer Grant (RFC7523).
|
|
7
8
|
*
|
|
@@ -30,6 +31,7 @@ export declare class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
30
31
|
* @param jwtLifetimeSeconds The lifetime of the JWT in seconds.
|
|
31
32
|
* @param jwtAlgorithm The signing algorithm.
|
|
32
33
|
* @param keyId The key ID.
|
|
34
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
33
35
|
*/
|
|
34
36
|
private constructor();
|
|
35
37
|
/**
|
|
@@ -48,19 +50,21 @@ export declare class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
48
50
|
*
|
|
49
51
|
* @param host The base URL for the API endpoints.
|
|
50
52
|
* @param jsonPath The file path to the JSON configuration file.
|
|
53
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
51
54
|
* @returns A builder instance for WebTokenAuthenticator.
|
|
52
55
|
* @throws {Error} if the file cannot be read or the JSON is invalid.
|
|
53
56
|
*/
|
|
54
|
-
static fromJson(host: string, jsonPath: string): Promise<WebTokenAuthenticator>;
|
|
57
|
+
static fromJson(host: string, jsonPath: string, transportOptions?: TransportOptions): Promise<WebTokenAuthenticator>;
|
|
55
58
|
/**
|
|
56
59
|
* Returns a new builder instance for WebTokenAuthenticator.
|
|
57
60
|
*
|
|
58
61
|
* @param host The base URL for API endpoints.
|
|
59
62
|
* @param userId The user ID.
|
|
60
63
|
* @param privateKey The PEM-formatted private key.
|
|
64
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
61
65
|
* @returns A new builder instance.
|
|
62
66
|
*/
|
|
63
|
-
static builder(host: string, userId: string, privateKey: string): WebTokenAuthenticatorBuilder;
|
|
67
|
+
static builder(host: string, userId: string, privateKey: string, transportOptions?: TransportOptions): WebTokenAuthenticatorBuilder;
|
|
64
68
|
/**
|
|
65
69
|
* Normalises any PKCS-1/PKCS-8 PEM string and returns a Node KeyObject.
|
|
66
70
|
* Works with:
|
|
@@ -72,7 +76,19 @@ export declare class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
72
76
|
/**
|
|
73
77
|
* Creates an instance of WebTokenAuthenticator.
|
|
74
78
|
* @internal
|
|
79
|
+
*
|
|
80
|
+
* @param openId The OpenId configuration instance.
|
|
81
|
+
* @param clientId The OAuth2 client identifier.
|
|
82
|
+
* @param scope The scope for the token request.
|
|
83
|
+
* @param jwtIssuer The issuer claim for the JWT.
|
|
84
|
+
* @param jwtSubject The subject claim for the JWT.
|
|
85
|
+
* @param jwtAudience The audience claim for the JWT.
|
|
86
|
+
* @param privateKeyPem The PEM-formatted private key.
|
|
87
|
+
* @param jwtLifetimeSeconds The lifetime of the JWT in seconds.
|
|
88
|
+
* @param jwtAlgorithm The signing algorithm.
|
|
89
|
+
* @param keyId The key ID.
|
|
90
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
75
91
|
*/
|
|
76
|
-
static create(openId: OpenId, clientId: string, scope: string, jwtIssuer: string, jwtSubject: string, jwtAudience: string, privateKeyPem: string, jwtLifetimeSeconds: number, jwtAlgorithm: string, keyId?: string): Promise<WebTokenAuthenticator>;
|
|
92
|
+
static create(openId: OpenId, clientId: string, scope: string, jwtIssuer: string, jwtSubject: string, jwtAudience: string, privateKeyPem: string, jwtLifetimeSeconds: number, jwtAlgorithm: string, keyId?: string, transportOptions?: TransportOptions): Promise<WebTokenAuthenticator>;
|
|
77
93
|
protected performTokenRequest(authServer: oauth.AuthorizationServer, client: oauth.Client): Promise<oauth.TokenEndpointResponse>;
|
|
78
94
|
}
|
|
@@ -32,9 +32,10 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
32
32
|
* @param jwtLifetimeSeconds The lifetime of the JWT in seconds.
|
|
33
33
|
* @param jwtAlgorithm The signing algorithm.
|
|
34
34
|
* @param keyId The key ID.
|
|
35
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
35
36
|
*/
|
|
36
|
-
constructor(authServer, client, scope, privateKey, jwtIssuer, jwtSubject, jwtAudience, jwtLifetimeSeconds, jwtAlgorithm, keyId) {
|
|
37
|
-
super(authServer, client, scope);
|
|
37
|
+
constructor(authServer, client, scope, privateKey, jwtIssuer, jwtSubject, jwtAudience, jwtLifetimeSeconds, jwtAlgorithm, keyId, transportOptions) {
|
|
38
|
+
super(authServer, client, scope, transportOptions);
|
|
38
39
|
this.privateKey = privateKey;
|
|
39
40
|
this.jwtIssuer = jwtIssuer;
|
|
40
41
|
this.jwtSubject = jwtSubject;
|
|
@@ -60,10 +61,11 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
60
61
|
*
|
|
61
62
|
* @param host The base URL for the API endpoints.
|
|
62
63
|
* @param jsonPath The file path to the JSON configuration file.
|
|
64
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
63
65
|
* @returns A builder instance for WebTokenAuthenticator.
|
|
64
66
|
* @throws {Error} if the file cannot be read or the JSON is invalid.
|
|
65
67
|
*/
|
|
66
|
-
static async fromJson(host, jsonPath) {
|
|
68
|
+
static async fromJson(host, jsonPath, transportOptions) {
|
|
67
69
|
const json = fs.readFileSync(jsonPath, 'utf-8').replaceAll('\\"', '"');
|
|
68
70
|
const config = JSON.parse(json);
|
|
69
71
|
const userId = config?.userId;
|
|
@@ -72,7 +74,7 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
72
74
|
if (!userId || !privateKey || !keyId) {
|
|
73
75
|
throw new Error('Missing required configuration keys in JSON file.');
|
|
74
76
|
}
|
|
75
|
-
return WebTokenAuthenticator.builder(host, userId, privateKey)
|
|
77
|
+
return WebTokenAuthenticator.builder(host, userId, privateKey, transportOptions)
|
|
76
78
|
.keyId(keyId)
|
|
77
79
|
.build();
|
|
78
80
|
}
|
|
@@ -82,10 +84,11 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
82
84
|
* @param host The base URL for API endpoints.
|
|
83
85
|
* @param userId The user ID.
|
|
84
86
|
* @param privateKey The PEM-formatted private key.
|
|
87
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
85
88
|
* @returns A new builder instance.
|
|
86
89
|
*/
|
|
87
|
-
static builder(host, userId, privateKey) {
|
|
88
|
-
return new WebTokenAuthenticatorBuilder(host, userId, userId, host, privateKey);
|
|
90
|
+
static builder(host, userId, privateKey, transportOptions) {
|
|
91
|
+
return new WebTokenAuthenticatorBuilder(host, userId, userId, host, privateKey, transportOptions);
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
94
|
* Normalises any PKCS-1/PKCS-8 PEM string and returns a Node KeyObject.
|
|
@@ -119,12 +122,24 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
119
122
|
/**
|
|
120
123
|
* Creates an instance of WebTokenAuthenticator.
|
|
121
124
|
* @internal
|
|
125
|
+
*
|
|
126
|
+
* @param openId The OpenId configuration instance.
|
|
127
|
+
* @param clientId The OAuth2 client identifier.
|
|
128
|
+
* @param scope The scope for the token request.
|
|
129
|
+
* @param jwtIssuer The issuer claim for the JWT.
|
|
130
|
+
* @param jwtSubject The subject claim for the JWT.
|
|
131
|
+
* @param jwtAudience The audience claim for the JWT.
|
|
132
|
+
* @param privateKeyPem The PEM-formatted private key.
|
|
133
|
+
* @param jwtLifetimeSeconds The lifetime of the JWT in seconds.
|
|
134
|
+
* @param jwtAlgorithm The signing algorithm.
|
|
135
|
+
* @param keyId The key ID.
|
|
136
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
122
137
|
*/
|
|
123
|
-
static async create(openId, clientId, scope, jwtIssuer, jwtSubject, jwtAudience, privateKeyPem, jwtLifetimeSeconds, jwtAlgorithm, keyId) {
|
|
138
|
+
static async create(openId, clientId, scope, jwtIssuer, jwtSubject, jwtAudience, privateKeyPem, jwtLifetimeSeconds, jwtAlgorithm, keyId, transportOptions) {
|
|
124
139
|
const privateKey = WebTokenAuthenticator.parsePem(privateKeyPem);
|
|
125
140
|
const authServer = openId.getAuthorizationServer();
|
|
126
141
|
const client = { client_id: clientId };
|
|
127
|
-
return new WebTokenAuthenticator(authServer, client, scope, privateKey, jwtIssuer, jwtSubject, jwtAudience, jwtLifetimeSeconds, jwtAlgorithm, keyId);
|
|
142
|
+
return new WebTokenAuthenticator(authServer, client, scope, privateKey, jwtIssuer, jwtSubject, jwtAudience, jwtLifetimeSeconds, jwtAlgorithm, keyId, transportOptions);
|
|
128
143
|
}
|
|
129
144
|
async performTokenRequest(authServer, client) {
|
|
130
145
|
const protectedHeader = {
|
|
@@ -145,10 +160,12 @@ export class WebTokenAuthenticator extends OAuthAuthenticator {
|
|
|
145
160
|
assertion: assertion,
|
|
146
161
|
scope: this.scope,
|
|
147
162
|
});
|
|
163
|
+
const tokenOptions = await this.buildTokenRequestOptions();
|
|
164
|
+
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
165
|
+
tokenOptions[oauth.allowInsecureRequests] = true;
|
|
166
|
+
}
|
|
148
167
|
// noinspection JSDeprecatedSymbols
|
|
149
|
-
const response = await oauth.genericTokenEndpointRequest(authServer, client, this.clientAuth, this.grantType, parameters,
|
|
150
|
-
[oauth.allowInsecureRequests]: process.env.JEST_WORKER_ID !== undefined,
|
|
151
|
-
});
|
|
168
|
+
const response = await oauth.genericTokenEndpointRequest(authServer, client, this.clientAuth, this.grantType, parameters, tokenOptions);
|
|
152
169
|
const responseBody = (await response.clone().json());
|
|
153
170
|
// @ts-expect-error wgsg
|
|
154
171
|
const idToken = responseBody.id_token;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webtoken-authenticator.js","sourceRoot":"","sources":["../../src/auth/webtoken-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"webtoken-authenticator.js","sourceRoot":"","sources":["../../src/auth/webtoken-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAa,MAAM,aAAa,CAAC;AAE1D;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IAwBxC;IACA;IACA;IACA;IACA;IACA;IACA;IA7BF,UAAU,CAAmB;IAC7B,SAAS,GACxB,6CAA6C,CAAC;IAEhD;;;;;;;;;;;;;;OAcG;IACH,YACE,UAAqC,EACrC,MAAoB,EACpB,KAAa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dist/configuration.d.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
import type { Dispatcher } from 'undici';
|
|
1
2
|
import { HTTPHeaders } from './runtime.js';
|
|
2
3
|
import { Authenticator } from './auth/index.js';
|
|
4
|
+
import { type TransportOptions } from './transport-options.js';
|
|
5
|
+
export type { TransportOptions } from './transport-options.js';
|
|
6
|
+
export { buildDispatcher } from './transport-options.js';
|
|
3
7
|
export declare class Configuration {
|
|
4
8
|
private readonly authenticator;
|
|
5
|
-
private readonly configuration;
|
|
6
9
|
readonly userAgent: string;
|
|
10
|
+
private readonly configuration;
|
|
11
|
+
private cachedDispatcher;
|
|
7
12
|
constructor(authenticator?: Authenticator, configuration?: {
|
|
8
13
|
basePath?: string;
|
|
9
14
|
headers?: HTTPHeaders;
|
|
10
15
|
userAgent?: string;
|
|
16
|
+
transportOptions?: TransportOptions;
|
|
11
17
|
});
|
|
18
|
+
/**
|
|
19
|
+
* Returns the cached dispatcher, building it lazily on first access.
|
|
20
|
+
*/
|
|
21
|
+
getDispatcher(): Promise<Dispatcher | undefined>;
|
|
12
22
|
get basePath(): string;
|
|
13
23
|
get accessToken(): (name?: string, scopes?: string[]) => string | Promise<string>;
|
|
14
24
|
get headers(): HTTPHeaders | undefined;
|
|
25
|
+
get transportOptions(): TransportOptions | undefined;
|
|
15
26
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
import { NoAuthAuthenticator } from './auth/index.js';
|
|
2
2
|
import { arch, platform, version as nodeVersion } from 'process';
|
|
3
3
|
import { VERSION } from './version.js';
|
|
4
|
+
import { buildDispatcher } from './transport-options.js';
|
|
5
|
+
export { buildDispatcher } from './transport-options.js';
|
|
4
6
|
export class Configuration {
|
|
5
7
|
authenticator;
|
|
6
|
-
configuration;
|
|
7
8
|
userAgent;
|
|
9
|
+
configuration;
|
|
10
|
+
cachedDispatcher = null;
|
|
8
11
|
constructor(authenticator = new NoAuthAuthenticator(), configuration = {}) {
|
|
9
12
|
this.authenticator = authenticator;
|
|
10
|
-
this.configuration =
|
|
13
|
+
this.configuration = {
|
|
14
|
+
...configuration,
|
|
15
|
+
transportOptions: configuration.transportOptions
|
|
16
|
+
? {
|
|
17
|
+
...configuration.transportOptions,
|
|
18
|
+
defaultHeaders: configuration.transportOptions.defaultHeaders
|
|
19
|
+
? Object.freeze({
|
|
20
|
+
...configuration.transportOptions.defaultHeaders,
|
|
21
|
+
})
|
|
22
|
+
: undefined,
|
|
23
|
+
}
|
|
24
|
+
: undefined,
|
|
25
|
+
};
|
|
11
26
|
this.userAgent =
|
|
12
27
|
this.configuration.userAgent ??
|
|
13
28
|
`zitadel-client/${VERSION} (lang=ts; lang_version=${nodeVersion}; os=${platform}; arch=${arch})`;
|
|
14
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the cached dispatcher, building it lazily on first access.
|
|
32
|
+
*/
|
|
33
|
+
getDispatcher() {
|
|
34
|
+
if (this.cachedDispatcher === null) {
|
|
35
|
+
this.cachedDispatcher = buildDispatcher(this.configuration.transportOptions);
|
|
36
|
+
}
|
|
37
|
+
return this.cachedDispatcher;
|
|
38
|
+
}
|
|
15
39
|
get basePath() {
|
|
16
40
|
return this.authenticator.getHost().toString();
|
|
17
41
|
}
|
|
@@ -19,7 +43,15 @@ export class Configuration {
|
|
|
19
43
|
return async () => this.authenticator.getAuthToken();
|
|
20
44
|
}
|
|
21
45
|
get headers() {
|
|
22
|
-
|
|
46
|
+
const transportHeaders = this.configuration.transportOptions?.defaultHeaders;
|
|
47
|
+
const configHeaders = this.configuration.headers;
|
|
48
|
+
if (!transportHeaders && !configHeaders) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return { ...transportHeaders, ...configHeaders };
|
|
52
|
+
}
|
|
53
|
+
get transportOptions() {
|
|
54
|
+
return this.configuration.transportOptions;
|
|
23
55
|
}
|
|
24
56
|
}
|
|
25
57
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAiB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAGhF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,OAAO,aAAa;IAWL;IAVH,SAAS,CAAS;IACjB,aAAa,CAK5B;IACM,gBAAgB,GAA2C,IAAI,CAAC;IAExE,YACmB,gBAA+B,IAAI,mBAAmB,EAAE,EACzE,gBAKI,EAAE;QANW,kBAAa,GAAb,aAAa,CAA2C;QAQzE,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,aAAa;YAChB,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;gBAC9C,CAAC,CAAC;oBACE,GAAG,aAAa,CAAC,gBAAgB;oBACjC,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,cAAc;wBAC3D,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;4BACZ,GAAG,aAAa,CAAC,gBAAgB,CAAC,cAAc;yBACjD,CAAC;wBACJ,CAAC,CAAC,SAAS;iBACd;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;QACF,IAAI,CAAC,SAAS;YACZ,IAAI,CAAC,aAAa,CAAC,SAAS;gBAC5B,kBAAkB,OAAO,2BAA2B,WAAW,QAAQ,QAAQ,UAAU,IAAI,GAAG,CAAC;IACrG,CAAC;IAED;;OAEG;IACH,aAAa;QACX,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CACrC,IAAI,CAAC,aAAa,CAAC,gBAAgB,CACpC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACjD,CAAC;IAED,IAAI,WAAW;QAIb,OAAO,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;IACvD,CAAC;IAED,IAAI,OAAO;QACT,MAAM,gBAAgB,GACpB,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,cAAc,CAAC;QACtD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QACjD,IAAI,CAAC,gBAAgB,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,EAAE,GAAG,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IACnD,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { ActionServiceApi, ApplicationServiceApi, AuthorizationServiceApi, BetaActionServiceApi, BetaAppServiceApi, BetaAuthorizationServiceApi, BetaFeatureServiceApi, BetaInstanceServiceApi, BetaInternalPermissionServiceApi, BetaOIDCServiceApi, BetaOrganizationServiceApi, BetaProjectServiceApi, BetaSessionServiceApi, BetaSettingsServiceApi, BetaTelemetryServiceApi, BetaUserServiceApi, BetaWebKeyServiceApi, FeatureServiceApi, IdentityProviderServiceApi, InstanceServiceApi, InternalPermissionServiceApi, OIDCServiceApi, OrganizationServiceApi, ProjectServiceApi, SAMLServiceApi, SessionServiceApi, SettingsServiceApi, UserServiceApi, WebKeyServiceApi } from './apis/index.js';
|
|
2
2
|
import { Authenticator } from './auth/index.js';
|
|
3
3
|
import { Configuration } from './configuration.js';
|
|
4
|
+
import type { TransportOptions } from './transport-options.js';
|
|
4
5
|
export * from './zitadel-exception.js';
|
|
5
6
|
export * from './api-exception.js';
|
|
6
7
|
export * from './configuration.js';
|
|
7
8
|
export * from './models/index.js';
|
|
8
9
|
export * from './auth/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Main entry point for the Zitadel SDK.
|
|
12
|
+
*
|
|
13
|
+
* Provides access to all Zitadel API services through a single client instance.
|
|
14
|
+
*/
|
|
9
15
|
export default class Zitadel {
|
|
10
16
|
readonly actions: ActionServiceApi;
|
|
11
17
|
readonly applications: ApplicationServiceApi;
|
|
@@ -36,35 +42,45 @@ export default class Zitadel {
|
|
|
36
42
|
readonly settings: SettingsServiceApi;
|
|
37
43
|
readonly users: UserServiceApi;
|
|
38
44
|
readonly webkeys: WebKeyServiceApi;
|
|
39
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new Zitadel client instance.
|
|
47
|
+
*
|
|
48
|
+
* @param authenticator The authenticator to use for API requests.
|
|
49
|
+
* @param mutateConfig Optional callback to mutate the configuration.
|
|
50
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
51
|
+
*/
|
|
52
|
+
constructor(authenticator: Authenticator, mutateConfig?: (config: Configuration) => void, transportOptions?: TransportOptions);
|
|
40
53
|
/**
|
|
41
54
|
* Initialize the SDK with a Personal Access Token (PAT).
|
|
42
55
|
*
|
|
43
56
|
* @param host API URL (e.g. "https://api.zitadel.example.com").
|
|
44
57
|
* @param accessToken Personal Access Token for Bearer authentication.
|
|
58
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
45
59
|
* @returns Configured Zitadel client instance.
|
|
46
60
|
* @see https://zitadel.com/docs/guides/integrate/service-users/personal-access-token
|
|
47
61
|
*/
|
|
48
|
-
static withAccessToken(host: string, accessToken: string): Zitadel;
|
|
62
|
+
static withAccessToken(host: string, accessToken: string, transportOptions?: TransportOptions): Zitadel;
|
|
49
63
|
/**
|
|
50
64
|
* Initialize the SDK using OAuth2 Client Credentials flow.
|
|
51
65
|
*
|
|
52
66
|
* @param host API URL.
|
|
53
67
|
* @param clientId OAuth2 client identifier.
|
|
54
68
|
* @param clientSecret OAuth2 client secret.
|
|
69
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
55
70
|
* @returns Configured Zitadel client instance with token auto-refresh.
|
|
56
71
|
* @throws {Error} If token retrieval fails.
|
|
57
72
|
* @see https://zitadel.com/docs/guides/integrate/service-users/client-credentials
|
|
58
73
|
*/
|
|
59
|
-
static withClientCredentials(host: string, clientId: string, clientSecret: string): Promise<Zitadel>;
|
|
74
|
+
static withClientCredentials(host: string, clientId: string, clientSecret: string, transportOptions?: TransportOptions): Promise<Zitadel>;
|
|
60
75
|
/**
|
|
61
76
|
* Initialize the SDK via Private Key JWT assertion.
|
|
62
77
|
*
|
|
63
78
|
* @param host API URL.
|
|
64
79
|
* @param keyFile Path to service account JSON or PEM key file.
|
|
80
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
65
81
|
* @returns Configured Zitadel client instance using JWT assertion.
|
|
66
82
|
* @throws {Error} If key parsing or token exchange fails.
|
|
67
83
|
* @see https://zitadel.com/docs/guides/integrate/service-users/private-key-jwt
|
|
68
84
|
*/
|
|
69
|
-
static withPrivateKey(host: string, keyFile: string): Promise<Zitadel>;
|
|
85
|
+
static withPrivateKey(host: string, keyFile: string, transportOptions?: TransportOptions): Promise<Zitadel>;
|
|
70
86
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,11 @@ export * from './api-exception.js';
|
|
|
6
6
|
export * from './configuration.js';
|
|
7
7
|
export * from './models/index.js';
|
|
8
8
|
export * from './auth/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Main entry point for the Zitadel SDK.
|
|
11
|
+
*
|
|
12
|
+
* Provides access to all Zitadel API services through a single client instance.
|
|
13
|
+
*/
|
|
9
14
|
export default class Zitadel {
|
|
10
15
|
actions;
|
|
11
16
|
applications;
|
|
@@ -36,8 +41,15 @@ export default class Zitadel {
|
|
|
36
41
|
settings;
|
|
37
42
|
users;
|
|
38
43
|
webkeys;
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Constructs a new Zitadel client instance.
|
|
46
|
+
*
|
|
47
|
+
* @param authenticator The authenticator to use for API requests.
|
|
48
|
+
* @param mutateConfig Optional callback to mutate the configuration.
|
|
49
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
50
|
+
*/
|
|
51
|
+
constructor(authenticator, mutateConfig, transportOptions) {
|
|
52
|
+
const config = new Configuration(authenticator, { transportOptions });
|
|
41
53
|
if (mutateConfig) {
|
|
42
54
|
mutateConfig(config);
|
|
43
55
|
}
|
|
@@ -76,11 +88,12 @@ export default class Zitadel {
|
|
|
76
88
|
*
|
|
77
89
|
* @param host API URL (e.g. "https://api.zitadel.example.com").
|
|
78
90
|
* @param accessToken Personal Access Token for Bearer authentication.
|
|
91
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
79
92
|
* @returns Configured Zitadel client instance.
|
|
80
93
|
* @see https://zitadel.com/docs/guides/integrate/service-users/personal-access-token
|
|
81
94
|
*/
|
|
82
|
-
static withAccessToken(host, accessToken) {
|
|
83
|
-
return new this(new PersonalAccessAuthenticator(host, accessToken));
|
|
95
|
+
static withAccessToken(host, accessToken, transportOptions) {
|
|
96
|
+
return new this(new PersonalAccessAuthenticator(host, accessToken), undefined, transportOptions);
|
|
84
97
|
}
|
|
85
98
|
/**
|
|
86
99
|
* Initialize the SDK using OAuth2 Client Credentials flow.
|
|
@@ -88,26 +101,28 @@ export default class Zitadel {
|
|
|
88
101
|
* @param host API URL.
|
|
89
102
|
* @param clientId OAuth2 client identifier.
|
|
90
103
|
* @param clientSecret OAuth2 client secret.
|
|
104
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
91
105
|
* @returns Configured Zitadel client instance with token auto-refresh.
|
|
92
106
|
* @throws {Error} If token retrieval fails.
|
|
93
107
|
* @see https://zitadel.com/docs/guides/integrate/service-users/client-credentials
|
|
94
108
|
*/
|
|
95
|
-
static async withClientCredentials(host, clientId, clientSecret) {
|
|
96
|
-
const authenticator = await ClientCredentialsAuthenticator.builder(host, clientId, clientSecret).build();
|
|
97
|
-
return new this(authenticator);
|
|
109
|
+
static async withClientCredentials(host, clientId, clientSecret, transportOptions) {
|
|
110
|
+
const authenticator = await ClientCredentialsAuthenticator.builder(host, clientId, clientSecret, transportOptions).build();
|
|
111
|
+
return new this(authenticator, undefined, transportOptions);
|
|
98
112
|
}
|
|
99
113
|
/**
|
|
100
114
|
* Initialize the SDK via Private Key JWT assertion.
|
|
101
115
|
*
|
|
102
116
|
* @param host API URL.
|
|
103
117
|
* @param keyFile Path to service account JSON or PEM key file.
|
|
118
|
+
* @param transportOptions Optional transport options for TLS, proxy, and headers.
|
|
104
119
|
* @returns Configured Zitadel client instance using JWT assertion.
|
|
105
120
|
* @throws {Error} If key parsing or token exchange fails.
|
|
106
121
|
* @see https://zitadel.com/docs/guides/integrate/service-users/private-key-jwt
|
|
107
122
|
*/
|
|
108
|
-
static async withPrivateKey(host, keyFile) {
|
|
109
|
-
const authenticator = await WebTokenAuthenticator.fromJson(host, keyFile);
|
|
110
|
-
return new this(authenticator);
|
|
123
|
+
static async withPrivateKey(host, keyFile, transportOptions) {
|
|
124
|
+
const authenticator = await WebTokenAuthenticator.fromJson(host, keyFile, transportOptions);
|
|
125
|
+
return new this(authenticator, undefined, transportOptions);
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
128
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,gCAAgC,EAChC,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,gCAAgC,EAChC,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,o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P,gBAAgB,CACjB,CAAC;QAEF,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/dist/runtime.js
CHANGED
|
@@ -10,7 +10,6 @@ export class BaseAPI {
|
|
|
10
10
|
static jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
11
11
|
constructor(configuration = new Configuration()) {
|
|
12
12
|
this.configuration = configuration;
|
|
13
|
-
//
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Check if the given MIME is a JSON MIME.
|
|
@@ -83,6 +82,10 @@ export class BaseAPI {
|
|
|
83
82
|
...overriddenInit,
|
|
84
83
|
body,
|
|
85
84
|
};
|
|
85
|
+
const dispatcher = await this.configuration.getDispatcher();
|
|
86
|
+
if (dispatcher) {
|
|
87
|
+
Object.assign(init, { dispatcher });
|
|
88
|
+
}
|
|
86
89
|
return { url, init };
|
|
87
90
|
}
|
|
88
91
|
fetchApi = async (url, init) => {
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,OAAO;IAMI;IALd,MAAM,CAAU,SAAS,GAAG,IAAI,MAAM,CAC5C,mEAAmE,EACnE,GAAG,CACJ,CAAC;IAEF,YAAsB,gBAAgB,IAAI,aAAa,EAAE;QAAnC,kBAAa,GAAb,aAAa,CAAsB;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,OAAO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C,IAAI,CAAC,CAAC,MAAM,CAC7B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAChD,EAAE,CACH,CAAC;AACJ,CAAC;AAYD,MAAM,OAAO,eAAe;IAEjB;IACC;IAFV,YACS,GAAa,EACZ,cAAsC,CAAC,SAAc,EAAE,EAAE,CAAC,SAAS;QADpE,QAAG,GAAH,GAAG,CAAU;QACZ,gBAAW,GAAX,WAAW,CAAwD;IAC1E,CAAC;IAEJ,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Dispatcher } from 'undici';
|
|
2
|
+
/**
|
|
3
|
+
* Immutable transport options for configuring HTTP connections.
|
|
4
|
+
*/
|
|
5
|
+
export interface TransportOptions {
|
|
6
|
+
/** Default HTTP headers sent to the origin server with every request. */
|
|
7
|
+
defaultHeaders?: Record<string, string>;
|
|
8
|
+
/** Path to a custom CA certificate file for TLS verification. */
|
|
9
|
+
caCertPath?: string;
|
|
10
|
+
/** Whether to disable TLS certificate verification. */
|
|
11
|
+
insecure?: boolean;
|
|
12
|
+
/** Proxy URL for HTTP connections. */
|
|
13
|
+
proxyUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builds an undici dispatcher (Agent or ProxyAgent) from transport options.
|
|
17
|
+
*
|
|
18
|
+
* Returns undefined if no custom TLS or proxy settings are needed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildDispatcher(transportOptions?: TransportOptions): Promise<Dispatcher | undefined>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an undici dispatcher (Agent or ProxyAgent) from transport options.
|
|
3
|
+
*
|
|
4
|
+
* Returns undefined if no custom TLS or proxy settings are needed.
|
|
5
|
+
*/
|
|
6
|
+
export async function buildDispatcher(transportOptions) {
|
|
7
|
+
if (!transportOptions?.insecure &&
|
|
8
|
+
!transportOptions?.caCertPath &&
|
|
9
|
+
!transportOptions?.proxyUrl) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const connectOpts = {};
|
|
13
|
+
if (transportOptions.insecure) {
|
|
14
|
+
connectOpts.rejectUnauthorized = false;
|
|
15
|
+
}
|
|
16
|
+
else if (transportOptions.caCertPath) {
|
|
17
|
+
const { readFileSync } = await import('node:fs');
|
|
18
|
+
const tls = await import('node:tls');
|
|
19
|
+
const customCa = readFileSync(transportOptions.caCertPath, 'utf-8');
|
|
20
|
+
connectOpts.ca = [...(tls.rootCertificates ?? []), customCa];
|
|
21
|
+
}
|
|
22
|
+
if (transportOptions.proxyUrl) {
|
|
23
|
+
const { ProxyAgent } = await import('undici');
|
|
24
|
+
const proxyOpts = {
|
|
25
|
+
uri: transportOptions.proxyUrl,
|
|
26
|
+
};
|
|
27
|
+
if (Object.keys(connectOpts).length > 0) {
|
|
28
|
+
proxyOpts.requestTls = connectOpts;
|
|
29
|
+
}
|
|
30
|
+
return new ProxyAgent(proxyOpts);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const { Agent } = await import('undici');
|
|
34
|
+
return new Agent({ connect: connectOpts });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=transport-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-options.js","sourceRoot":"","sources":["../src/transport-options.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,gBAAmC;IAEnC,IACE,CAAC,gBAAgB,EAAE,QAAQ;QAC3B,CAAC,gBAAgB,EAAE,UAAU;QAC7B,CAAC,gBAAgB,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1.0-beta.
|
|
1
|
+
export declare const VERSION = "4.1.0-beta.15";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '4.1.0-beta.
|
|
1
|
+
export const VERSION = '4.1.0-beta.15';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zitadel/sdk",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepack": "tsc",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@codedependant/semantic-release-docker": "^5.1.1",
|
|
54
54
|
"@commitlint/config-conventional": "^20.0.0",
|
|
55
|
+
"@jest/globals": "^30.2.0",
|
|
55
56
|
"@mridang/eslint-defaults": "^1.6.1",
|
|
56
57
|
"@mridang/semantic-release-peer-version": "^1.2.0",
|
|
57
58
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
@@ -77,11 +78,8 @@
|
|
|
77
78
|
"access": "public"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
|
-
"@jest/globals": "^30.2.0",
|
|
81
81
|
"jose": "^6.1.0",
|
|
82
|
-
"oauth4webapi": "^3.8.2"
|
|
83
|
-
},
|
|
84
|
-
"overrides": {
|
|
82
|
+
"oauth4webapi": "^3.8.2",
|
|
85
83
|
"undici": "^6.23.0"
|
|
86
84
|
}
|
|
87
85
|
}
|