@naylence/runtime 0.3.5-test.910 → 0.3.5-test.913

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.
Files changed (47) hide show
  1. package/dist/browser/index.cjs +1915 -1214
  2. package/dist/browser/index.mjs +1910 -1209
  3. package/dist/cjs/naylence/fame/config/extended-fame-config.js +52 -0
  4. package/dist/cjs/naylence/fame/factory-manifest.js +2 -0
  5. package/dist/cjs/naylence/fame/http/jwks-api-router.js +16 -18
  6. package/dist/cjs/naylence/fame/http/oauth2-server.js +28 -31
  7. package/dist/cjs/naylence/fame/http/oauth2-token-router.js +901 -93
  8. package/dist/cjs/naylence/fame/http/openid-configuration-router.js +30 -32
  9. package/dist/cjs/naylence/fame/node/admission/admission-profile-factory.js +79 -0
  10. package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +171 -0
  11. package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider.js +560 -0
  12. package/dist/cjs/naylence/fame/security/crypto/providers/default-crypto-provider.js +0 -162
  13. package/dist/cjs/naylence/fame/telemetry/open-telemetry-trace-emitter-factory.js +19 -2
  14. package/dist/cjs/naylence/fame/telemetry/open-telemetry-trace-emitter.js +19 -9
  15. package/dist/cjs/naylence/fame/util/register-runtime-factories.js +6 -0
  16. package/dist/cjs/version.js +2 -2
  17. package/dist/esm/naylence/fame/config/extended-fame-config.js +52 -0
  18. package/dist/esm/naylence/fame/factory-manifest.js +2 -0
  19. package/dist/esm/naylence/fame/http/jwks-api-router.js +16 -17
  20. package/dist/esm/naylence/fame/http/oauth2-server.js +28 -31
  21. package/dist/esm/naylence/fame/http/oauth2-token-router.js +901 -93
  22. package/dist/esm/naylence/fame/http/openid-configuration-router.js +30 -31
  23. package/dist/esm/naylence/fame/node/admission/admission-profile-factory.js +79 -0
  24. package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +134 -0
  25. package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider.js +555 -0
  26. package/dist/esm/naylence/fame/security/crypto/providers/default-crypto-provider.js +0 -162
  27. package/dist/esm/naylence/fame/telemetry/open-telemetry-trace-emitter-factory.js +19 -2
  28. package/dist/esm/naylence/fame/telemetry/open-telemetry-trace-emitter.js +19 -9
  29. package/dist/esm/naylence/fame/util/register-runtime-factories.js +6 -0
  30. package/dist/esm/version.js +2 -2
  31. package/dist/node/index.cjs +1911 -1210
  32. package/dist/node/index.mjs +1910 -1209
  33. package/dist/node/node.cjs +2945 -1439
  34. package/dist/node/node.mjs +2944 -1438
  35. package/dist/types/naylence/fame/factory-manifest.d.ts +1 -1
  36. package/dist/types/naylence/fame/http/jwks-api-router.d.ts +8 -8
  37. package/dist/types/naylence/fame/http/oauth2-server.d.ts +3 -3
  38. package/dist/types/naylence/fame/http/oauth2-token-router.d.ts +75 -19
  39. package/dist/types/naylence/fame/http/openid-configuration-router.d.ts +8 -8
  40. package/dist/types/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.d.ts +27 -0
  41. package/dist/types/naylence/fame/security/auth/oauth2-pkce-token-provider.d.ts +42 -0
  42. package/dist/types/naylence/fame/security/crypto/providers/default-crypto-provider.d.ts +0 -1
  43. package/dist/types/naylence/fame/telemetry/open-telemetry-trace-emitter.d.ts +4 -0
  44. package/dist/types/version.d.ts +1 -1
  45. package/package.json +4 -4
  46. package/dist/esm/naylence/fame/fastapi/oauth2-server.js +0 -205
  47. package/dist/types/naylence/fame/fastapi/oauth2-server.d.ts +0 -22
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
  /**
3
- * OpenID Connect Discovery configuration router for Express
3
+ * OpenID Connect Discovery configuration plugin for Fastify
4
4
  *
5
5
  * Provides /.well-known/openid-configuration endpoint for OAuth2/OIDC client auto-discovery
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.createOpenIDConfigurationRouter = createOpenIDConfigurationRouter;
9
- const tslib_1 = require("tslib");
10
- const express_1 = tslib_1.__importDefault(require("express"));
11
9
  const logging_js_1 = require("../util/logging.js");
12
10
  const logger = (0, logging_js_1.getLogger)('naylence.fame.http.openid_configuration_router');
13
11
  const DEFAULT_PREFIX = '';
@@ -81,10 +79,10 @@ function getAllowedScopes(configScopes) {
81
79
  return configScopes ?? ['node.connect'];
82
80
  }
83
81
  /**
84
- * Create an Express router that implements OpenID Connect Discovery
82
+ * Create a Fastify plugin that implements OpenID Connect Discovery
85
83
  *
86
84
  * @param options - Router configuration options
87
- * @returns Express router with OpenID configuration endpoint
85
+ * @returns Fastify plugin with OpenID configuration endpoint
88
86
  *
89
87
  * Environment Variables:
90
88
  * FAME_JWT_ISSUER: JWT issuer claim (optional)
@@ -93,17 +91,16 @@ function getAllowedScopes(configScopes) {
93
91
  *
94
92
  * @example
95
93
  * ```typescript
96
- * import express from 'express';
94
+ * import Fastify from 'fastify';
97
95
  * import { createOpenIDConfigurationRouter } from '@naylence/runtime';
98
96
  *
99
- * const app = express();
100
- * app.use(createOpenIDConfigurationRouter({
97
+ * const app = Fastify();
98
+ * app.register(createOpenIDConfigurationRouter({
101
99
  * issuer: 'https://auth.example.com',
102
100
  * }));
103
101
  * ```
104
102
  */
105
103
  function createOpenIDConfigurationRouter(options = {}) {
106
- const router = express_1.default.Router();
107
104
  const { prefix = DEFAULT_PREFIX, issuer, baseUrl, tokenEndpointPath = '/oauth/token', jwksEndpointPath = '/.well-known/jwks.json', allowedScopes: configAllowedScopes, algorithm: configAlgorithm, } = normalizeOpenIDConfigurationRouterOptions(options);
108
105
  // Resolve configuration with environment variable priority
109
106
  const defaultIssuer = process.env[ENV_VAR_JWT_ISSUER] ?? issuer ?? 'https://auth.fame.fabric';
@@ -119,27 +116,28 @@ function createOpenIDConfigurationRouter(options = {}) {
119
116
  algorithm,
120
117
  allowedScopes,
121
118
  });
122
- // OpenID Connect Discovery endpoint
123
- router.get(`${prefix}/.well-known/openid-configuration`, (_req, res) => {
124
- // Construct absolute URLs for endpoints
125
- const tokenEndpoint = `${defaultBaseUrl.replace(/\/$/, '')}${tokenEndpointPath}`;
126
- const jwksUri = `${defaultBaseUrl.replace(/\/$/, '')}${jwksEndpointPath}`;
127
- const config = {
128
- issuer: defaultIssuer,
129
- token_endpoint: tokenEndpoint,
130
- jwks_uri: jwksUri,
131
- scopes_supported: allowedScopes,
132
- response_types_supported: ['token'],
133
- grant_types_supported: ['client_credentials'],
134
- token_endpoint_auth_methods_supported: [
135
- 'client_secret_basic',
136
- 'client_secret_post',
137
- ],
138
- subject_types_supported: ['public'],
139
- id_token_signing_alg_values_supported: [algorithm],
140
- };
141
- logger.debug('openid_config_served', { config });
142
- res.json(config);
143
- });
144
- return router;
119
+ const plugin = async (instance) => {
120
+ instance.get(`${prefix}/.well-known/openid-configuration`, async (_request, reply) => {
121
+ // Construct absolute URLs for endpoints
122
+ const tokenEndpoint = `${defaultBaseUrl.replace(/\/$/, '')}${tokenEndpointPath}`;
123
+ const jwksUri = `${defaultBaseUrl.replace(/\/$/, '')}${jwksEndpointPath}`;
124
+ const config = {
125
+ issuer: defaultIssuer,
126
+ token_endpoint: tokenEndpoint,
127
+ jwks_uri: jwksUri,
128
+ scopes_supported: allowedScopes,
129
+ response_types_supported: ['token'],
130
+ grant_types_supported: ['client_credentials'],
131
+ token_endpoint_auth_methods_supported: [
132
+ 'client_secret_basic',
133
+ 'client_secret_post',
134
+ ],
135
+ subject_types_supported: ['public'],
136
+ id_token_signing_alg_values_supported: [algorithm],
137
+ };
138
+ logger.debug('openid_config_served', { config });
139
+ reply.send(config);
140
+ });
141
+ };
142
+ return plugin;
145
143
  }
@@ -11,18 +11,28 @@ const ENV_VAR_JWT_AUDIENCE = 'FAME_JWT_AUDIENCE';
11
11
  const ENV_VAR_ADMISSION_TOKEN_URL = 'FAME_ADMISSION_TOKEN_URL';
12
12
  const ENV_VAR_ADMISSION_CLIENT_ID = 'FAME_ADMISSION_CLIENT_ID';
13
13
  const ENV_VAR_ADMISSION_CLIENT_SECRET = 'FAME_ADMISSION_CLIENT_SECRET';
14
+ const ENV_VAR_ADMISSION_AUTHORIZE_URL = 'FAME_ADMISSION_AUTHORIZE_URL';
15
+ const ENV_VAR_ADMISSION_REDIRECT_URL = 'FAME_ADMISSION_REDIRECT_URL';
16
+ const ENV_VAR_ADMISSION_LOGIN_HINT_PARAM = 'FAME_ADMISSION_LOGIN_HINT_PARAM';
17
+ const ENV_VAR_ADMISSION_CODE_CHALLENGE_METHOD = 'FAME_ADMISSION_CODE_CHALLENGE_METHOD';
18
+ const ENV_VAR_ADMISSION_CODE_VERIFIER_LENGTH = 'FAME_ADMISSION_CODE_VERIFIER_LENGTH';
19
+ const ENV_VAR_ADMISSION_CLOCK_SKEW_SECONDS = 'FAME_ADMISSION_CLOCK_SKEW_SECONDS';
14
20
  const ENV_VAR_DIRECT_ADMISSION_URL = 'FAME_DIRECT_ADMISSION_URL';
15
21
  const ENV_VAR_DIRECT_INPAGE_CHANNEL = 'FAME_DIRECT_INPAGE_CHANNEL';
16
22
  const ENV_VAR_ADMISSION_SERVICE_URL = 'FAME_ADMISSION_SERVICE_URL';
17
23
  const DEFAULT_INPAGE_CHANNEL = 'naylence-fabric';
18
24
  const PROFILE_NAME_WELCOME = 'welcome';
25
+ const PROFILE_NAME_WELCOME_PKCE = 'welcome-pkce';
26
+ const PROFILE_NAME_WELCOME_PKCE_ALIAS = 'welcome_pkce';
19
27
  const PROFILE_NAME_DIRECT = 'direct';
20
28
  const PROFILE_NAME_DIRECT_HTTP = 'direct-http';
21
29
  const PROFILE_NAME_DIRECT_INPAGE = 'direct-inpage';
30
+ const PROFILE_NAME_DIRECT_PKCE = 'direct-pkce';
22
31
  const PROFILE_NAME_OPEN = 'open';
23
32
  const PROFILE_NAME_NOOP = 'noop';
24
33
  const PROFILE_NAME_NONE = 'none';
25
34
  const PROFILE_NAME_DIRECT_INPAGE_ALIAS = 'direct_inpage';
35
+ const PROFILE_NAME_DIRECT_PKCE_ALIAS = 'direct_pkce';
26
36
  function createOAuthTokenProviderConfig() {
27
37
  const tokenUrl = factory_1.Expressions.env(ENV_VAR_ADMISSION_TOKEN_URL);
28
38
  const clientId = factory_1.Expressions.env(ENV_VAR_ADMISSION_CLIENT_ID);
@@ -40,8 +50,41 @@ function createOAuthTokenProviderConfig() {
40
50
  audience,
41
51
  };
42
52
  }
53
+ function createOAuthPkceTokenProviderConfig() {
54
+ const authorizeUrl = factory_1.Expressions.env(ENV_VAR_ADMISSION_AUTHORIZE_URL);
55
+ const tokenUrl = factory_1.Expressions.env(ENV_VAR_ADMISSION_TOKEN_URL);
56
+ const redirectUri = factory_1.Expressions.env(ENV_VAR_ADMISSION_REDIRECT_URL);
57
+ const clientId = factory_1.Expressions.env(ENV_VAR_ADMISSION_CLIENT_ID);
58
+ const loginHintParam = factory_1.Expressions.env(ENV_VAR_ADMISSION_LOGIN_HINT_PARAM, 'login_hint');
59
+ const audience = factory_1.Expressions.env(ENV_VAR_JWT_AUDIENCE);
60
+ const codeChallengeMethod = factory_1.Expressions.env(ENV_VAR_ADMISSION_CODE_CHALLENGE_METHOD, 'S256');
61
+ const codeVerifierLength = factory_1.Expressions.env(ENV_VAR_ADMISSION_CODE_VERIFIER_LENGTH, '64');
62
+ const clockSkewSeconds = factory_1.Expressions.env(ENV_VAR_ADMISSION_CLOCK_SKEW_SECONDS, '30');
63
+ return {
64
+ type: 'OAuth2PkceTokenProvider',
65
+ authorizeUrl,
66
+ authorize_url: authorizeUrl,
67
+ tokenUrl,
68
+ token_url: tokenUrl,
69
+ redirectUri,
70
+ redirect_uri: redirectUri,
71
+ clientId,
72
+ client_id: clientId,
73
+ loginHintParam,
74
+ login_hint_param: loginHintParam,
75
+ scopes: ['node.connect'],
76
+ audience,
77
+ codeChallengeMethod,
78
+ code_challenge_method: codeChallengeMethod,
79
+ codeVerifierLength,
80
+ code_verifier_length: codeVerifierLength,
81
+ clockSkewSeconds,
82
+ clock_skew_seconds: clockSkewSeconds,
83
+ };
84
+ }
43
85
  const welcomeIsRoot = factory_1.Expressions.env(ENV_VAR_IS_ROOT, 'false');
44
86
  const welcomeTokenProvider = createOAuthTokenProviderConfig();
87
+ const welcomePkceTokenProvider = createOAuthPkceTokenProviderConfig();
45
88
  const WELCOME_SERVICE_PROFILE = {
46
89
  type: 'WelcomeServiceClient',
47
90
  is_root: welcomeIsRoot,
@@ -55,6 +98,19 @@ const WELCOME_SERVICE_PROFILE = {
55
98
  tokenProvider: welcomeTokenProvider,
56
99
  },
57
100
  };
101
+ const WELCOME_SERVICE_PKCE_PROFILE = {
102
+ type: 'WelcomeServiceClient',
103
+ is_root: welcomeIsRoot,
104
+ isRoot: welcomeIsRoot,
105
+ url: factory_1.Expressions.env(ENV_VAR_ADMISSION_SERVICE_URL),
106
+ supported_transports: ['websocket'],
107
+ supportedTransports: ['websocket'],
108
+ auth: {
109
+ type: 'BearerTokenHeaderAuth',
110
+ token_provider: welcomePkceTokenProvider,
111
+ tokenProvider: welcomePkceTokenProvider,
112
+ },
113
+ };
58
114
  const directGrantTokenProvider = createOAuthTokenProviderConfig();
59
115
  const directGrant = {
60
116
  type: 'WebSocketConnectionGrant',
@@ -74,6 +130,25 @@ const DIRECT_PROFILE = {
74
130
  connection_grants: directGrants,
75
131
  connectionGrants: directGrants,
76
132
  };
133
+ const directPkceTokenProvider = createOAuthPkceTokenProviderConfig();
134
+ const directPkceGrant = {
135
+ type: 'WebSocketConnectionGrant',
136
+ purpose: grant_js_1.GRANT_PURPOSE_NODE_ATTACH,
137
+ url: factory_1.Expressions.env(ENV_VAR_DIRECT_ADMISSION_URL),
138
+ auth: {
139
+ type: 'WebSocketSubprotocolAuth',
140
+ token_provider: directPkceTokenProvider,
141
+ tokenProvider: directPkceTokenProvider,
142
+ },
143
+ ttl: 0,
144
+ durable: false,
145
+ };
146
+ const directPkceGrants = [directPkceGrant];
147
+ const DIRECT_PKCE_PROFILE = {
148
+ type: 'DirectAdmissionClient',
149
+ connection_grants: directPkceGrants,
150
+ connectionGrants: directPkceGrants,
151
+ };
77
152
  const directHttpTokenProvider = createOAuthTokenProviderConfig();
78
153
  const directHttpGrant = {
79
154
  type: 'HttpConnectionGrant',
@@ -141,7 +216,11 @@ const NOOP_PROFILE = {
141
216
  };
142
217
  const PROFILE_MAP = {
143
218
  [PROFILE_NAME_WELCOME]: WELCOME_SERVICE_PROFILE,
219
+ [PROFILE_NAME_WELCOME_PKCE]: WELCOME_SERVICE_PKCE_PROFILE,
220
+ [PROFILE_NAME_WELCOME_PKCE_ALIAS]: WELCOME_SERVICE_PKCE_PROFILE,
144
221
  [PROFILE_NAME_DIRECT]: DIRECT_PROFILE,
222
+ [PROFILE_NAME_DIRECT_PKCE]: DIRECT_PKCE_PROFILE,
223
+ [PROFILE_NAME_DIRECT_PKCE_ALIAS]: DIRECT_PKCE_PROFILE,
145
224
  [PROFILE_NAME_DIRECT_HTTP]: DIRECT_HTTP_PROFILE,
146
225
  [PROFILE_NAME_DIRECT_INPAGE]: DIRECT_INPAGE_PROFILE,
147
226
  [PROFILE_NAME_DIRECT_INPAGE_ALIAS]: DIRECT_INPAGE_PROFILE,
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.OAuth2PkceTokenProviderFactory = exports.FACTORY_META = void 0;
37
+ const credential_provider_factory_js_1 = require("../credential/credential-provider-factory.js");
38
+ const secret_source_js_1 = require("../credential/secret-source.js");
39
+ const lazy_import_js_1 = require("../../util/lazy-import.js");
40
+ const token_provider_factory_js_1 = require("./token-provider-factory.js");
41
+ let oauth2PkceTokenProviderModulePromise = null;
42
+ async function getOAuth2PkceTokenProviderModule() {
43
+ if (!oauth2PkceTokenProviderModulePromise) {
44
+ oauth2PkceTokenProviderModulePromise = (0, lazy_import_js_1.safeImport)(() => Promise.resolve().then(() => __importStar(require('./oauth2-pkce-token-provider.js'))), 'oauth2-pkce-token-provider');
45
+ }
46
+ return oauth2PkceTokenProviderModulePromise;
47
+ }
48
+ function ensureNonEmptyString(value, field) {
49
+ if (typeof value !== 'string' || value.trim().length === 0) {
50
+ throw new Error(`OAuth2PkceTokenProvider ${field} must be a non-empty string`);
51
+ }
52
+ return value.trim();
53
+ }
54
+ function normalizeScopes(value) {
55
+ if (Array.isArray(value)) {
56
+ const scopes = value
57
+ .map((scope) => (typeof scope === 'string' ? scope.trim() : ''))
58
+ .filter((scope) => scope.length > 0);
59
+ return scopes;
60
+ }
61
+ if (typeof value === 'string' && value.trim().length > 0) {
62
+ return value
63
+ .split(/[\s,]+/u)
64
+ .map((scope) => scope.trim())
65
+ .filter((scope) => scope.length > 0);
66
+ }
67
+ return [];
68
+ }
69
+ function normalizeConfig(config) {
70
+ if (!config) {
71
+ throw new Error('OAuth2PkceTokenProvider requires configuration');
72
+ }
73
+ const candidate = config;
74
+ const authorizeUrl = ensureNonEmptyString(candidate.authorizeUrl ?? candidate.authorize_url, 'authorizeUrl');
75
+ const tokenUrl = ensureNonEmptyString(candidate.tokenUrl ?? candidate.token_url, 'tokenUrl');
76
+ const redirectUri = ensureNonEmptyString(candidate.redirectUri ?? candidate.redirect_uri, 'redirectUri');
77
+ const clientId = ensureNonEmptyString(candidate.clientId ?? candidate.client_id, 'clientId');
78
+ const usernameSource = (candidate.username ??
79
+ candidate.username_source);
80
+ const clientSecretSource = (candidate.clientSecret ??
81
+ candidate.client_secret);
82
+ const scopes = normalizeScopes(candidate.scopes ?? candidate.scope);
83
+ const normalized = {
84
+ authorizeUrl,
85
+ tokenUrl,
86
+ redirectUri,
87
+ clientId,
88
+ scopes,
89
+ };
90
+ if (usernameSource) {
91
+ normalized.usernameConfig = (0, secret_source_js_1.normalizeSecretSource)(usernameSource);
92
+ }
93
+ if (clientSecretSource) {
94
+ normalized.clientSecretConfig = (0, secret_source_js_1.normalizeSecretSource)(clientSecretSource);
95
+ }
96
+ const audienceCandidate = candidate.audience ?? candidate.aud;
97
+ if (typeof audienceCandidate === 'string' && audienceCandidate.trim().length > 0) {
98
+ normalized.audience = audienceCandidate.trim();
99
+ }
100
+ const codeChallengeMethod = candidate.codeChallengeMethod ?? candidate.code_challenge_method;
101
+ if (typeof codeChallengeMethod === 'string' && codeChallengeMethod.trim().length > 0) {
102
+ normalized.codeChallengeMethod = codeChallengeMethod.trim();
103
+ }
104
+ const codeVerifierLength = candidate.codeVerifierLength ?? candidate.code_verifier_length;
105
+ if (typeof codeVerifierLength === 'number' && Number.isFinite(codeVerifierLength)) {
106
+ normalized.codeVerifierLength = codeVerifierLength;
107
+ }
108
+ const clockSkewSeconds = candidate.clockSkewSeconds ?? candidate.clock_skew_seconds;
109
+ if (typeof clockSkewSeconds === 'number' && Number.isFinite(clockSkewSeconds)) {
110
+ normalized.clockSkewSeconds = clockSkewSeconds;
111
+ }
112
+ const loginHintParam = candidate.loginHintParam ?? candidate.login_hint_param;
113
+ if (typeof loginHintParam === 'string' && loginHintParam.trim().length > 0) {
114
+ normalized.loginHintParam = loginHintParam.trim();
115
+ }
116
+ return normalized;
117
+ }
118
+ exports.FACTORY_META = {
119
+ base: token_provider_factory_js_1.TOKEN_PROVIDER_FACTORY_BASE_TYPE,
120
+ key: 'OAuth2PkceTokenProvider',
121
+ };
122
+ class OAuth2PkceTokenProviderFactory extends token_provider_factory_js_1.TokenProviderFactory {
123
+ constructor() {
124
+ super(...arguments);
125
+ this.type = 'OAuth2PkceTokenProvider';
126
+ }
127
+ async create(config) {
128
+ const normalized = normalizeConfig(config);
129
+ const [usernameProvider, clientSecretProvider] = await Promise.all([
130
+ normalized.usernameConfig
131
+ ? credential_provider_factory_js_1.CredentialProviderFactory.createCredentialProvider(normalized.usernameConfig)
132
+ : Promise.resolve(undefined),
133
+ normalized.clientSecretConfig
134
+ ? credential_provider_factory_js_1.CredentialProviderFactory.createCredentialProvider(normalized.clientSecretConfig)
135
+ : Promise.resolve(undefined),
136
+ ]);
137
+ const options = {
138
+ authorizeUrl: normalized.authorizeUrl,
139
+ tokenUrl: normalized.tokenUrl,
140
+ redirectUri: normalized.redirectUri,
141
+ clientId: normalized.clientId,
142
+ scopes: normalized.scopes,
143
+ };
144
+ if (usernameProvider) {
145
+ options.usernameProvider = usernameProvider;
146
+ }
147
+ if (clientSecretProvider) {
148
+ options.clientSecretProvider = clientSecretProvider;
149
+ }
150
+ if (normalized.audience) {
151
+ options.audience = normalized.audience;
152
+ }
153
+ if (normalized.codeChallengeMethod) {
154
+ options.codeChallengeMethod = normalized.codeChallengeMethod
155
+ .toUpperCase();
156
+ }
157
+ if (normalized.codeVerifierLength) {
158
+ options.codeVerifierLength = normalized.codeVerifierLength;
159
+ }
160
+ if (normalized.clockSkewSeconds) {
161
+ options.clockSkewSeconds = normalized.clockSkewSeconds;
162
+ }
163
+ if (normalized.loginHintParam) {
164
+ options.loginHintParam = normalized.loginHintParam;
165
+ }
166
+ const { OAuth2PkceTokenProvider } = await getOAuth2PkceTokenProviderModule();
167
+ return new OAuth2PkceTokenProvider(options);
168
+ }
169
+ }
170
+ exports.OAuth2PkceTokenProviderFactory = OAuth2PkceTokenProviderFactory;
171
+ exports.default = OAuth2PkceTokenProviderFactory;