@canton-network/core-wallet-auth 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,349 +1,356 @@
1
- 'use strict';
2
-
3
- var jose = require('jose');
4
- var coreRpcErrors = require('@canton-network/core-rpc-errors');
5
- var zod = require('zod');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let jose = require("jose");
3
+ let _canton_network_core_rpc_errors = require("@canton-network/core-rpc-errors");
4
+ let zod = require("zod");
5
+ //#region src/auth-utils.ts
10
6
  function assertConnected(authContext) {
11
- if (!authContext) {
12
- throw coreRpcErrors.providerErrors.unauthorized({
13
- message: "User is not connected"
14
- });
15
- }
16
- return authContext;
7
+ if (!authContext) throw _canton_network_core_rpc_errors.providerErrors.unauthorized({ message: "User is not connected" });
8
+ return authContext;
17
9
  }
10
+ /**
11
+ * Extract a User ID from the `sub` claim of a JWT. Throws if `sub` is missing.
12
+ *
13
+ * @param token a base64 encoded JWT token
14
+ * @returns
15
+ */
18
16
  function jwtUserId(token) {
19
- const { sub } = jose.decodeJwt(token);
20
- if (!sub) {
21
- throw new Error("token did not contain a subject field");
22
- }
23
- return sub;
17
+ const { sub } = (0, jose.decodeJwt)(token);
18
+ if (!sub) throw new Error("token did not contain a subject field");
19
+ return sub;
24
20
  }
21
+ /**
22
+ * Extract the optional `email` claim from a JWT.
23
+ *
24
+ * @param token a base64 encoded JWT token
25
+ * @returns email when present, otherwise undefined
26
+ */
25
27
  function jwtUserEmail(token) {
26
- const { email } = jose.decodeJwt(token);
27
- if (typeof email !== "string" || email.length === 0) {
28
- return void 0;
29
- }
30
- return email;
28
+ const { email } = (0, jose.decodeJwt)(token);
29
+ if (typeof email !== "string" || email.length === 0) return;
30
+ return email;
31
31
  }
32
+ /**
33
+ * Fetches user claims from the OIDC UserInfo endpoint.
34
+ * Discovers the endpoint via the OIDC discovery document at configUrl.
35
+ *
36
+ * @param configUrl - The OIDC discovery document URL (/.well-known/openid-configuration)
37
+ * @param accessToken - The user's bearer access token
38
+ * @returns The UserInfo claims, or undefined if the IDP does not expose a userinfo endpoint
39
+ * @throws If any network request fails
40
+ */
32
41
  async function fetchOidcUserInfo(configUrl, accessToken) {
33
- const configResponse = await fetch(configUrl);
34
- if (!configResponse.ok) {
35
- throw new Error(
36
- `Failed to fetch OIDC discovery document: ${configResponse.status} ${configResponse.statusText}`
37
- );
38
- }
39
- const config = await configResponse.json();
40
- if (!config.userinfo_endpoint) {
41
- return void 0;
42
- }
43
- const userInfoResponse = await fetch(config.userinfo_endpoint, {
44
- headers: { Authorization: `Bearer ${accessToken}` }
45
- });
46
- if (!userInfoResponse.ok) {
47
- throw new Error(
48
- `Failed to fetch OIDC userinfo: ${userInfoResponse.status} ${userInfoResponse.statusText}`
49
- );
50
- }
51
- return await userInfoResponse.json();
42
+ const configResponse = await fetch(configUrl);
43
+ if (!configResponse.ok) throw new Error(`Failed to fetch OIDC discovery document: ${configResponse.status} ${configResponse.statusText}`);
44
+ const config = await configResponse.json();
45
+ if (!config.userinfo_endpoint) return;
46
+ const userInfoResponse = await fetch(config.userinfo_endpoint, { headers: { Authorization: `Bearer ${accessToken}` } });
47
+ if (!userInfoResponse.ok) throw new Error(`Failed to fetch OIDC userinfo: ${userInfoResponse.status} ${userInfoResponse.statusText}`);
48
+ return await userInfoResponse.json();
52
49
  }
50
+ /**
51
+ * Resolve the user email from the OIDC userinfo endpoint.
52
+ *
53
+ * @param authContext - The authentication context
54
+ * @param idp - The IDP configuration
55
+ * @param logger - The logger
56
+ * @returns The user email, or undefined if the email is not found
57
+ */
53
58
  async function resolveUserEmail(authContext, idp, logger) {
54
- if (authContext.email) {
55
- return authContext.email;
56
- }
57
- try {
58
- if (idp.type !== "oauth") {
59
- return void 0;
60
- }
61
- const userInfo = await fetchOidcUserInfo(
62
- idp.configUrl,
63
- authContext.accessToken
64
- );
65
- return userInfo?.email;
66
- } catch (error) {
67
- logger?.warn(error, "Failed to resolve user email from OIDC userinfo");
68
- return void 0;
69
- }
59
+ if (authContext.email) return authContext.email;
60
+ try {
61
+ if (idp.type !== "oauth") return;
62
+ return (await fetchOidcUserInfo(idp.configUrl, authContext.accessToken))?.email;
63
+ } catch (error) {
64
+ logger?.warn(error, "Failed to resolve user email from OIDC userinfo");
65
+ return;
66
+ }
70
67
  }
68
+ /**
69
+ * Determine if a given JWT is still valid based on its expiry time.
70
+ *
71
+ * @param token a base64 encoded JWT token
72
+ * @returns true if the token is expired, false if not
73
+ */
71
74
  function jwtExpired(token) {
72
- try {
73
- const payload = jose.decodeJwt(token);
74
- const now = Math.floor(Date.now() / 1e3);
75
- return typeof payload.exp === "number" && payload.exp <= now;
76
- } catch {
77
- return true;
78
- }
75
+ try {
76
+ const payload = (0, jose.decodeJwt)(token);
77
+ const now = Math.floor(Date.now() / 1e3);
78
+ return typeof payload.exp === "number" && payload.exp <= now;
79
+ } catch {
80
+ return true;
81
+ }
79
82
  }
80
-
81
- // src/client-credentials-service.ts
83
+ //#endregion
84
+ //#region src/client-credentials-service.ts
82
85
  var ClientCredentialsService = class {
83
- constructor(configUrl, logger) {
84
- this.configUrl = configUrl;
85
- this.logger = logger;
86
- }
87
- /**
88
- * Fetches the JWT token (M2M) using client credentials.
89
- *
90
- * @returns The JWT access token as a string.
91
- * @throws If fetching the token fails or the response is invalid.
92
- */
93
- async fetchToken(credentials) {
94
- try {
95
- const oidcConfig = await this.getOIDCConfig(this.configUrl);
96
- this.logger?.debug({ oidcConfig }, "Fetched OIDC config");
97
- const res = await this.fetchTokenEndpoint(
98
- oidcConfig.token_endpoint,
99
- credentials
100
- );
101
- const json = await res.json();
102
- this.logger?.info(
103
- { response: json },
104
- `Fetched admin token for clientId: ${credentials.clientId}`
105
- );
106
- if (!json.access_token) {
107
- throw new Error("No access_token in token endpoint response");
108
- }
109
- return json.access_token;
110
- } catch (error) {
111
- this.logger?.error({ err: error }, "Failed to fetch admin token");
112
- throw error;
113
- }
114
- }
115
- async fetchTokenEndpoint(tokenEndpoint, credentials) {
116
- const params = new URLSearchParams({
117
- grant_type: "client_credentials",
118
- scope: credentials.scope ?? "",
119
- audience: credentials.audience ?? ""
120
- });
121
- const password = toClientPassword(
122
- credentials.clientId,
123
- credentials.clientSecret
124
- );
125
- const res = await fetch(tokenEndpoint, {
126
- method: "POST",
127
- headers: {
128
- "Content-Type": "application/x-www-form-urlencoded",
129
- Authorization: `Basic ${password}`
130
- },
131
- body: params.toString()
132
- });
133
- if (!res.ok) {
134
- this.logger?.error(
135
- { status: res.status, statusText: res.statusText },
136
- "Token endpoint error"
137
- );
138
- throw new Error(
139
- `Token endpoint error: ${res.status} ${res.statusText}`
140
- );
141
- }
142
- return res;
143
- }
144
- async getOIDCConfig(url) {
145
- const res = await fetch(url);
146
- if (!res.ok) {
147
- const text = await res.text();
148
- this.logger?.error(
149
- { status: res.status, statusText: res.statusText, body: text },
150
- "Failed to fetch OIDC config"
151
- );
152
- throw new Error(
153
- `OIDC config error: ${res.status} ${res.statusText}`
154
- );
155
- }
156
- return res.json();
157
- }
86
+ constructor(configUrl, logger) {
87
+ this.configUrl = configUrl;
88
+ this.logger = logger;
89
+ }
90
+ /**
91
+ * Fetches the JWT token (M2M) using client credentials.
92
+ *
93
+ * @returns The JWT access token as a string.
94
+ * @throws If fetching the token fails or the response is invalid.
95
+ */
96
+ async fetchToken(credentials) {
97
+ try {
98
+ const oidcConfig = await this.getOIDCConfig(this.configUrl);
99
+ this.logger?.debug({ oidcConfig }, "Fetched OIDC config");
100
+ const json = await (await this.fetchTokenEndpoint(oidcConfig.token_endpoint, credentials)).json();
101
+ this.logger?.info({ response: json }, `Fetched admin token for clientId: ${credentials.clientId}`);
102
+ if (!json.access_token) throw new Error("No access_token in token endpoint response");
103
+ return json.access_token;
104
+ } catch (error) {
105
+ this.logger?.error({ err: error }, "Failed to fetch admin token");
106
+ throw error;
107
+ }
108
+ }
109
+ async fetchTokenEndpoint(tokenEndpoint, credentials) {
110
+ const params = new URLSearchParams({
111
+ grant_type: "client_credentials",
112
+ scope: credentials.scope ?? "",
113
+ audience: credentials.audience ?? ""
114
+ });
115
+ const password = toClientPassword(credentials.clientId, credentials.clientSecret);
116
+ const res = await fetch(tokenEndpoint, {
117
+ method: "POST",
118
+ headers: {
119
+ "Content-Type": "application/x-www-form-urlencoded",
120
+ Authorization: `Basic ${password}`
121
+ },
122
+ body: params.toString()
123
+ });
124
+ if (!res.ok) {
125
+ this.logger?.error({
126
+ status: res.status,
127
+ statusText: res.statusText
128
+ }, "Token endpoint error");
129
+ throw new Error(`Token endpoint error: ${res.status} ${res.statusText}`);
130
+ }
131
+ return res;
132
+ }
133
+ async getOIDCConfig(url) {
134
+ const res = await fetch(url);
135
+ if (!res.ok) {
136
+ const text = await res.text();
137
+ this.logger?.error({
138
+ status: res.status,
139
+ statusText: res.statusText,
140
+ body: text
141
+ }, "Failed to fetch OIDC config");
142
+ throw new Error(`OIDC config error: ${res.status} ${res.statusText}`);
143
+ }
144
+ return res.json();
145
+ }
158
146
  };
159
- var toClientPassword = (clientId, clientSecret) => {
160
- const credentials = `${clientId}:${clientSecret}`;
161
- return btoa(credentials);
147
+ const toClientPassword = (clientId, clientSecret) => {
148
+ const credentials = `${clientId}:${clientSecret}`;
149
+ return btoa(credentials);
162
150
  };
163
- var clientCredentialsService = (configUrl, logger) => ({
164
- fetchToken: async (credentials) => new ClientCredentialsService(configUrl, logger).fetchToken(credentials)
165
- });
151
+ const clientCredentialsService = (configUrl, logger) => ({ fetchToken: async (credentials) => new ClientCredentialsService(configUrl, logger).fetchToken(credentials) });
152
+ //#endregion
153
+ //#region src/self-signed-token-service.ts
166
154
  var SelfSignedTokenService = class {
167
- static async fetchToken(logger, credentials, issuer, expirySeconds = 3600) {
168
- const secret = new TextEncoder().encode(credentials.clientSecret);
169
- const now = Math.floor(Date.now() / 1e3);
170
- const jwt = await new jose.SignJWT({
171
- sub: credentials.clientId,
172
- aud: credentials.audience || "",
173
- scope: credentials.scope || "",
174
- iat: now,
175
- exp: now + expirySeconds,
176
- iss: issuer
177
- }).setProtectedHeader({ alg: "HS256" }).sign(secret);
178
- logger.info(`Generated self-signed JWT token: ${jwt}`);
179
- return jwt;
180
- }
155
+ static async fetchToken(logger, credentials, issuer, expirySeconds = 3600) {
156
+ const secret = new TextEncoder().encode(credentials.clientSecret);
157
+ const now = Math.floor(Date.now() / 1e3);
158
+ const jwt = await new jose.SignJWT({
159
+ sub: credentials.clientId,
160
+ aud: credentials.audience || "",
161
+ scope: credentials.scope || "",
162
+ iat: now,
163
+ exp: now + expirySeconds,
164
+ iss: issuer
165
+ }).setProtectedHeader({ alg: "HS256" }).sign(secret);
166
+ logger.info(`Generated self-signed JWT token: ${jwt}`);
167
+ return jwt;
168
+ }
181
169
  };
182
-
183
- // src/auth-token-provider.ts
184
- var AuthTokenProvider = class _AuthTokenProvider {
185
- constructor(config, logger) {
186
- this.config = config;
187
- this.logger = logger;
188
- __publicField(this, "cachedToken");
189
- }
190
- static fromToken(token, logger) {
191
- return new _AuthTokenProvider({ method: "static", token }, logger);
192
- }
193
- static fromGatewayConfig(idp, auth, logger) {
194
- if (auth.method === "self_signed") {
195
- return new _AuthTokenProvider(
196
- {
197
- method: auth.method,
198
- issuer: auth.issuer,
199
- credentials: {
200
- clientId: auth.clientId,
201
- clientSecret: auth.clientSecret,
202
- scope: auth.scope,
203
- audience: auth.audience
204
- }
205
- },
206
- logger
207
- );
208
- }
209
- if (auth.method === "client_credentials") {
210
- if (idp.type === "oauth")
211
- return new _AuthTokenProvider(
212
- {
213
- method: auth.method,
214
- configUrl: idp.configUrl,
215
- credentials: {
216
- clientId: auth.clientId,
217
- clientSecret: auth.clientSecret,
218
- scope: auth.scope,
219
- audience: auth.audience
220
- }
221
- },
222
- logger
223
- );
224
- else {
225
- throw new Error(
226
- `IDP type ${idp.type} not supported for client_credentials auth`
227
- );
228
- }
229
- }
230
- throw new Error(
231
- `Auth method ${auth.method} not supported for programmatic access token`
232
- );
233
- }
234
- async _fetchToken() {
235
- this.logger.debug("Fetching user auth token");
236
- switch (this.config.method) {
237
- case "static":
238
- return this.config.token;
239
- case "self_signed":
240
- return SelfSignedTokenService.fetchToken(
241
- this.logger,
242
- this.config.credentials,
243
- this.config.issuer
244
- );
245
- case "client_credentials":
246
- return clientCredentialsService(
247
- this.config.configUrl,
248
- this.logger
249
- ).fetchToken(this.config.credentials);
250
- }
251
- }
252
- /**
253
- *
254
- * @returns A valid JWT token retrieved according to the auth configuration given.
255
- */
256
- async getAccessToken() {
257
- if (this.cachedToken && !jwtExpired(this.cachedToken)) {
258
- return this.cachedToken;
259
- } else {
260
- const newToken = await this._fetchToken();
261
- if (jwtExpired(newToken)) {
262
- throw new Error(
263
- "Attempted to refresh a token, but it came back expired."
264
- );
265
- }
266
- this.cachedToken = newToken;
267
- return newToken;
268
- }
269
- }
270
- /**
271
- *
272
- * @returns An AuthContext containing a valid token and userId.
273
- */
274
- async getAuthContext() {
275
- const accessToken = await this.getAccessToken();
276
- const userId = jwtUserId(accessToken);
277
- const email = jwtUserEmail(accessToken);
278
- return {
279
- accessToken,
280
- userId,
281
- ...email ? { email } : {}
282
- };
283
- }
170
+ //#endregion
171
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
172
+ function _typeof(o) {
173
+ "@babel/helpers - typeof";
174
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
175
+ return typeof o;
176
+ } : function(o) {
177
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
178
+ }, _typeof(o);
179
+ }
180
+ //#endregion
181
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
182
+ function toPrimitive(t, r) {
183
+ if ("object" != _typeof(t) || !t) return t;
184
+ var e = t[Symbol.toPrimitive];
185
+ if (void 0 !== e) {
186
+ var i = e.call(t, r || "default");
187
+ if ("object" != _typeof(i)) return i;
188
+ throw new TypeError("@@toPrimitive must return a primitive value.");
189
+ }
190
+ return ("string" === r ? String : Number)(t);
191
+ }
192
+ //#endregion
193
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
194
+ function toPropertyKey(t) {
195
+ var i = toPrimitive(t, "string");
196
+ return "symbol" == _typeof(i) ? i : i + "";
197
+ }
198
+ //#endregion
199
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
200
+ function _defineProperty(e, r, t) {
201
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
202
+ value: t,
203
+ enumerable: !0,
204
+ configurable: !0,
205
+ writable: !0
206
+ }) : e[r] = t, e;
207
+ }
208
+ //#endregion
209
+ //#region src/auth-token-provider.ts
210
+ /**
211
+ * AuthTokenProvider provides some common functionality across token providers.
212
+ *
213
+ * 1. Token caching: tokens are cached in-memory, so long as the token lifespan is not expired.
214
+ * 2. Context retrieval: deriving a user context from the stored access token.
215
+ *
216
+ *
217
+ * The following programmatic methods of token fetching are supported:
218
+ *
219
+ * - `static`: a fixed, in-memory token. Only used for compatibility, it will totally break for expired tokens.
220
+ * - `self_signed`: only for development purposes, used for Canton setups that accept HMAC256 self signed tokens.
221
+ * - `client_credentials`: used to programmatically acquire tokens via oauth2, a.k.a "machine-to-machine" tokens.
222
+ */
223
+ var AuthTokenProvider = class AuthTokenProvider {
224
+ constructor(config, logger) {
225
+ this.config = config;
226
+ this.logger = logger;
227
+ _defineProperty(this, "cachedToken", void 0);
228
+ }
229
+ static fromToken(token, logger) {
230
+ return new AuthTokenProvider({
231
+ method: "static",
232
+ token
233
+ }, logger);
234
+ }
235
+ static fromGatewayConfig(idp, auth, logger) {
236
+ if (auth.method === "self_signed") return new AuthTokenProvider({
237
+ method: auth.method,
238
+ issuer: auth.issuer,
239
+ credentials: {
240
+ clientId: auth.clientId,
241
+ clientSecret: auth.clientSecret,
242
+ scope: auth.scope,
243
+ audience: auth.audience
244
+ }
245
+ }, logger);
246
+ if (auth.method === "client_credentials") if (idp.type === "oauth") return new AuthTokenProvider({
247
+ method: auth.method,
248
+ configUrl: idp.configUrl,
249
+ credentials: {
250
+ clientId: auth.clientId,
251
+ clientSecret: auth.clientSecret,
252
+ scope: auth.scope,
253
+ audience: auth.audience
254
+ }
255
+ }, logger);
256
+ else throw new Error(`IDP type ${idp.type} not supported for client_credentials auth`);
257
+ throw new Error(`Auth method ${auth.method} not supported for programmatic access token`);
258
+ }
259
+ async _fetchToken() {
260
+ this.logger.debug("Fetching user auth token");
261
+ switch (this.config.method) {
262
+ case "static": return this.config.token;
263
+ case "self_signed": return SelfSignedTokenService.fetchToken(this.logger, this.config.credentials, this.config.issuer);
264
+ case "client_credentials": return clientCredentialsService(this.config.configUrl, this.logger).fetchToken(this.config.credentials);
265
+ }
266
+ }
267
+ /**
268
+ *
269
+ * @returns A valid JWT token retrieved according to the auth configuration given.
270
+ */
271
+ async getAccessToken() {
272
+ if (this.cachedToken && !jwtExpired(this.cachedToken)) return this.cachedToken;
273
+ else {
274
+ const newToken = await this._fetchToken();
275
+ if (jwtExpired(newToken)) throw new Error("Attempted to refresh a token, but it came back expired.");
276
+ this.cachedToken = newToken;
277
+ return newToken;
278
+ }
279
+ }
280
+ /**
281
+ *
282
+ * @returns An AuthContext containing a valid token and userId.
283
+ */
284
+ async getAuthContext() {
285
+ const accessToken = await this.getAccessToken();
286
+ const userId = jwtUserId(accessToken);
287
+ const email = jwtUserEmail(accessToken);
288
+ return {
289
+ accessToken,
290
+ userId,
291
+ ...email ? { email } : {}
292
+ };
293
+ }
284
294
  };
285
- var authorizationCodeAuthSchema = zod.z.object({
286
- method: zod.z.literal("authorization_code"),
287
- audience: zod.z.string(),
288
- scope: zod.z.string(),
289
- clientId: zod.z.string()
290
- }).meta({
291
- description: "Authorization code flow authentication configuration. This is used for browser-based application login."
292
- });
293
- var clientCredentialsAuthSchema = zod.z.object({
294
- method: zod.z.literal("client_credentials"),
295
- audience: zod.z.string(),
296
- scope: zod.z.string(),
297
- clientId: zod.z.string(),
298
- clientSecret: zod.z.string()
295
+ //#endregion
296
+ //#region src/config/schema.ts
297
+ const authorizationCodeAuthSchema = zod.z.object({
298
+ method: zod.z.literal("authorization_code"),
299
+ audience: zod.z.string(),
300
+ scope: zod.z.string(),
301
+ clientId: zod.z.string()
302
+ }).meta({ description: "Authorization code flow authentication configuration. This is used for browser-based application login." });
303
+ const clientCredentialsAuthSchema = zod.z.object({
304
+ method: zod.z.literal("client_credentials"),
305
+ audience: zod.z.string(),
306
+ scope: zod.z.string(),
307
+ clientId: zod.z.string(),
308
+ clientSecret: zod.z.string()
299
309
  });
300
- var selfSignedAuthSchema = zod.z.object({
301
- method: zod.z.literal("self_signed"),
302
- issuer: zod.z.string(),
303
- audience: zod.z.string(),
304
- scope: zod.z.string(),
305
- clientId: zod.z.string(),
306
- clientSecret: zod.z.string()
310
+ const selfSignedAuthSchema = zod.z.object({
311
+ method: zod.z.literal("self_signed"),
312
+ issuer: zod.z.string(),
313
+ audience: zod.z.string(),
314
+ scope: zod.z.string(),
315
+ clientId: zod.z.string(),
316
+ clientSecret: zod.z.string()
307
317
  });
308
- var clientCredentialsEnvAuthSchema = zod.z.object({
309
- method: zod.z.literal("client_credentials"),
310
- audience: zod.z.string(),
311
- scope: zod.z.string(),
312
- clientId: zod.z.string(),
313
- clientSecretEnv: zod.z.string()
318
+ const clientCredentialsEnvAuthSchema = zod.z.object({
319
+ method: zod.z.literal("client_credentials"),
320
+ audience: zod.z.string(),
321
+ scope: zod.z.string(),
322
+ clientId: zod.z.string(),
323
+ clientSecretEnv: zod.z.string()
314
324
  });
315
- var selfSignedEnvAuthSchema = zod.z.object({
316
- method: zod.z.literal("self_signed"),
317
- issuer: zod.z.string(),
318
- audience: zod.z.string(),
319
- scope: zod.z.string(),
320
- clientId: zod.z.string(),
321
- clientSecretEnv: zod.z.string()
325
+ const selfSignedEnvAuthSchema = zod.z.object({
326
+ method: zod.z.literal("self_signed"),
327
+ issuer: zod.z.string(),
328
+ audience: zod.z.string(),
329
+ scope: zod.z.string(),
330
+ clientId: zod.z.string(),
331
+ clientSecretEnv: zod.z.string()
322
332
  });
323
- var authSchema = zod.z.discriminatedUnion("method", [
324
- authorizationCodeAuthSchema,
325
- clientCredentialsAuthSchema,
326
- selfSignedAuthSchema
333
+ const authSchema = zod.z.discriminatedUnion("method", [
334
+ authorizationCodeAuthSchema,
335
+ clientCredentialsAuthSchema,
336
+ selfSignedAuthSchema
327
337
  ]);
328
- var authFromEnvSchema = zod.z.discriminatedUnion("method", [
329
- authorizationCodeAuthSchema,
330
- clientCredentialsEnvAuthSchema,
331
- selfSignedEnvAuthSchema
338
+ const authFromEnvSchema = zod.z.discriminatedUnion("method", [
339
+ authorizationCodeAuthSchema,
340
+ clientCredentialsEnvAuthSchema,
341
+ selfSignedEnvAuthSchema
332
342
  ]);
333
- var idpSchema = zod.z.discriminatedUnion("type", [
334
- zod.z.object({
335
- id: zod.z.string(),
336
- type: zod.z.literal("self_signed"),
337
- issuer: zod.z.string()
338
- }),
339
- zod.z.object({
340
- id: zod.z.string(),
341
- type: zod.z.literal("oauth"),
342
- issuer: zod.z.string(),
343
- configUrl: zod.z.string().url()
344
- })
345
- ]);
346
-
343
+ const idpSchema = zod.z.discriminatedUnion("type", [zod.z.object({
344
+ id: zod.z.string(),
345
+ type: zod.z.literal("self_signed"),
346
+ issuer: zod.z.string()
347
+ }), zod.z.object({
348
+ id: zod.z.string(),
349
+ type: zod.z.literal("oauth"),
350
+ issuer: zod.z.string(),
351
+ configUrl: zod.z.string().url()
352
+ })]);
353
+ //#endregion
347
354
  exports.AuthTokenProvider = AuthTokenProvider;
348
355
  exports.ClientCredentialsService = ClientCredentialsService;
349
356
  exports.assertConnected = assertConnected;
@@ -356,5 +363,5 @@ exports.jwtExpired = jwtExpired;
356
363
  exports.jwtUserEmail = jwtUserEmail;
357
364
  exports.jwtUserId = jwtUserId;
358
365
  exports.resolveUserEmail = resolveUserEmail;
359
- //# sourceMappingURL=index.cjs.map
366
+
360
367
  //# sourceMappingURL=index.cjs.map