'use strict'; var middlewareHostHeader = require('@aws-sdk/middleware-host-header'); var middlewareLogger = require('@aws-sdk/middleware-logger'); var middlewareRecursionDetection = require('@aws-sdk/middleware-recursion-detection'); var middlewareUserAgent = require('@aws-sdk/middleware-user-agent'); var configResolver = require('@smithy/config-resolver'); var core = require('@smithy/core'); var middlewareContentLength = require('@smithy/middleware-content-length'); var middlewareEndpoint = require('@smithy/middleware-endpoint'); var middlewareRetry = require('@smithy/middleware-retry'); var smithyClient = require('@smithy/smithy-client'); var httpAuthSchemeProvider = require('./auth/httpAuthSchemeProvider'); var runtimeConfig = require('./runtimeConfig'); var regionConfigResolver = require('@aws-sdk/region-config-resolver'); var protocolHttp = require('@smithy/protocol-http'); var middlewareSerde = require('@smithy/middleware-serde'); var core$1 = require('@aws-sdk/core'); const resolveClientEndpointParameters = (options) => { return Object.assign(options, { useDualstackEndpoint: options.useDualstackEndpoint ?? false, useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "sso-oauth", }); }; const commonParams = { UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, Endpoint: { type: "builtInParams", name: "endpoint" }, Region: { type: "builtInParams", name: "region" }, UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, }; const getHttpAuthExtensionConfiguration = (runtimeConfig) => { const _httpAuthSchemes = runtimeConfig.httpAuthSchemes; let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider; let _credentials = runtimeConfig.credentials; return { setHttpAuthScheme(httpAuthScheme) { const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId); if (index === -1) { _httpAuthSchemes.push(httpAuthScheme); } else { _httpAuthSchemes.splice(index, 1, httpAuthScheme); } }, httpAuthSchemes() { return _httpAuthSchemes; }, setHttpAuthSchemeProvider(httpAuthSchemeProvider) { _httpAuthSchemeProvider = httpAuthSchemeProvider; }, httpAuthSchemeProvider() { return _httpAuthSchemeProvider; }, setCredentials(credentials) { _credentials = credentials; }, credentials() { return _credentials; }, }; }; const resolveHttpAuthRuntimeConfig = (config) => { return { httpAuthSchemes: config.httpAuthSchemes(), httpAuthSchemeProvider: config.httpAuthSchemeProvider(), credentials: config.credentials(), }; }; const resolveRuntimeExtensions = (runtimeConfig, extensions) => { const extensionConfiguration = Object.assign(regionConfigResolver.getAwsRegionExtensionConfiguration(runtimeConfig), smithyClient.getDefaultExtensionConfiguration(runtimeConfig), protocolHttp.getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig)); extensions.forEach((extension) => extension.configure(extensionConfiguration)); return Object.assign(runtimeConfig, regionConfigResolver.resolveAwsRegionExtensionConfiguration(extensionConfiguration), smithyClient.resolveDefaultRuntimeConfig(extensionConfiguration), protocolHttp.resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration)); }; class SSOOIDCClient extends smithyClient.Client { config; constructor(...[configuration]) { const _config_0 = runtimeConfig.getRuntimeConfig(configuration || {}); super(_config_0); this.initConfig = _config_0; const _config_1 = resolveClientEndpointParameters(_config_0); const _config_2 = middlewareUserAgent.resolveUserAgentConfig(_config_1); const _config_3 = middlewareRetry.resolveRetryConfig(_config_2); const _config_4 = configResolver.resolveRegionConfig(_config_3); const _config_5 = middlewareHostHeader.resolveHostHeaderConfig(_config_4); const _config_6 = middlewareEndpoint.resolveEndpointConfig(_config_5); const _config_7 = httpAuthSchemeProvider.resolveHttpAuthSchemeConfig(_config_6); const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); this.config = _config_8; this.middlewareStack.use(middlewareUserAgent.getUserAgentPlugin(this.config)); this.middlewareStack.use(middlewareRetry.getRetryPlugin(this.config)); this.middlewareStack.use(middlewareContentLength.getContentLengthPlugin(this.config)); this.middlewareStack.use(middlewareHostHeader.getHostHeaderPlugin(this.config)); this.middlewareStack.use(middlewareLogger.getLoggerPlugin(this.config)); this.middlewareStack.use(middlewareRecursionDetection.getRecursionDetectionPlugin(this.config)); this.middlewareStack.use(core.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, { httpAuthSchemeParametersProvider: httpAuthSchemeProvider.defaultSSOOIDCHttpAuthSchemeParametersProvider, identityProviderConfigProvider: async (config) => new core.DefaultIdentityProviderConfig({ "aws.auth#sigv4": config.credentials, }), })); this.middlewareStack.use(core.getHttpSigningPlugin(this.config)); } destroy() { super.destroy(); } } class SSOOIDCServiceException extends smithyClient.ServiceException { constructor(options) { super(options); Object.setPrototypeOf(this, SSOOIDCServiceException.prototype); } } const AccessDeniedExceptionReason = { KMS_ACCESS_DENIED: "KMS_AccessDeniedException", }; class AccessDeniedException extends SSOOIDCServiceException { name = "AccessDeniedException"; $fault = "client"; error; reason; error_description; constructor(opts) { super({ name: "AccessDeniedException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, AccessDeniedException.prototype); this.error = opts.error; this.reason = opts.reason; this.error_description = opts.error_description; } } class AuthorizationPendingException extends SSOOIDCServiceException { name = "AuthorizationPendingException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "AuthorizationPendingException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, AuthorizationPendingException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } const CreateTokenRequestFilterSensitiveLog = (obj) => ({ ...obj, ...(obj.clientSecret && { clientSecret: smithyClient.SENSITIVE_STRING }), ...(obj.refreshToken && { refreshToken: smithyClient.SENSITIVE_STRING }), ...(obj.codeVerifier && { codeVerifier: smithyClient.SENSITIVE_STRING }), }); const CreateTokenResponseFilterSensitiveLog = (obj) => ({ ...obj, ...(obj.accessToken && { accessToken: smithyClient.SENSITIVE_STRING }), ...(obj.refreshToken && { refreshToken: smithyClient.SENSITIVE_STRING }), ...(obj.idToken && { idToken: smithyClient.SENSITIVE_STRING }), }); class ExpiredTokenException extends SSOOIDCServiceException { name = "ExpiredTokenException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "ExpiredTokenException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, ExpiredTokenException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class InternalServerException extends SSOOIDCServiceException { name = "InternalServerException"; $fault = "server"; error; error_description; constructor(opts) { super({ name: "InternalServerException", $fault: "server", ...opts, }); Object.setPrototypeOf(this, InternalServerException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class InvalidClientException extends SSOOIDCServiceException { name = "InvalidClientException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "InvalidClientException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, InvalidClientException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class InvalidGrantException extends SSOOIDCServiceException { name = "InvalidGrantException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "InvalidGrantException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, InvalidGrantException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } const InvalidRequestExceptionReason = { KMS_DISABLED_KEY: "KMS_DisabledException", KMS_INVALID_KEY_USAGE: "KMS_InvalidKeyUsageException", KMS_INVALID_STATE: "KMS_InvalidStateException", KMS_KEY_NOT_FOUND: "KMS_NotFoundException", }; class InvalidRequestException extends SSOOIDCServiceException { name = "InvalidRequestException"; $fault = "client"; error; reason; error_description; constructor(opts) { super({ name: "InvalidRequestException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, InvalidRequestException.prototype); this.error = opts.error; this.reason = opts.reason; this.error_description = opts.error_description; } } class InvalidScopeException extends SSOOIDCServiceException { name = "InvalidScopeException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "InvalidScopeException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, InvalidScopeException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class SlowDownException extends SSOOIDCServiceException { name = "SlowDownException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "SlowDownException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, SlowDownException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class UnauthorizedClientException extends SSOOIDCServiceException { name = "UnauthorizedClientException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "UnauthorizedClientException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, UnauthorizedClientException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } class UnsupportedGrantTypeException extends SSOOIDCServiceException { name = "UnsupportedGrantTypeException"; $fault = "client"; error; error_description; constructor(opts) { super({ name: "UnsupportedGrantTypeException", $fault: "client", ...opts, }); Object.setPrototypeOf(this, UnsupportedGrantTypeException.prototype); this.error = opts.error; this.error_description = opts.error_description; } } const se_CreateTokenCommand = async (input, context) => { const b = core.requestBuilder(input, context); const headers = { "content-type": "application/json", }; b.bp("/token"); let body; body = JSON.stringify(smithyClient.take(input, { clientId: [], clientSecret: [], code: [], codeVerifier: [], deviceCode: [], grantType: [], redirectUri: [], refreshToken: [], scope: (_) => smithyClient._json(_), })); b.m("POST").h(headers).b(body); return b.build(); }; const de_CreateTokenCommand = async (output, context) => { if (output.statusCode !== 200 && output.statusCode >= 300) { return de_CommandError(output, context); } const contents = smithyClient.map({ $metadata: deserializeMetadata(output), }); const data = smithyClient.expectNonNull(smithyClient.expectObject(await core$1.parseJsonBody(output.body, context)), "body"); const doc = smithyClient.take(data, { accessToken: smithyClient.expectString, expiresIn: smithyClient.expectInt32, idToken: smithyClient.expectString, refreshToken: smithyClient.expectString, tokenType: smithyClient.expectString, }); Object.assign(contents, doc); return contents; }; const de_CommandError = async (output, context) => { const parsedOutput = { ...output, body: await core$1.parseJsonErrorBody(output.body, context), }; const errorCode = core$1.loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssooidc#AccessDeniedException": throw await de_AccessDeniedExceptionRes(parsedOutput); case "AuthorizationPendingException": case "com.amazonaws.ssooidc#AuthorizationPendingException": throw await de_AuthorizationPendingExceptionRes(parsedOutput); case "ExpiredTokenException": case "com.amazonaws.ssooidc#ExpiredTokenException": throw await de_ExpiredTokenExceptionRes(parsedOutput); case "InternalServerException": case "com.amazonaws.ssooidc#InternalServerException": throw await de_InternalServerExceptionRes(parsedOutput); case "InvalidClientException": case "com.amazonaws.ssooidc#InvalidClientException": throw await de_InvalidClientExceptionRes(parsedOutput); case "InvalidGrantException": case "com.amazonaws.ssooidc#InvalidGrantException": throw await de_InvalidGrantExceptionRes(parsedOutput); case "InvalidRequestException": case "com.amazonaws.ssooidc#InvalidRequestException": throw await de_InvalidRequestExceptionRes(parsedOutput); case "InvalidScopeException": case "com.amazonaws.ssooidc#InvalidScopeException": throw await de_InvalidScopeExceptionRes(parsedOutput); case "SlowDownException": case "com.amazonaws.ssooidc#SlowDownException": throw await de_SlowDownExceptionRes(parsedOutput); case "UnauthorizedClientException": case "com.amazonaws.ssooidc#UnauthorizedClientException": throw await de_UnauthorizedClientExceptionRes(parsedOutput); case "UnsupportedGrantTypeException": case "com.amazonaws.ssooidc#UnsupportedGrantTypeException": throw await de_UnsupportedGrantTypeExceptionRes(parsedOutput); default: const parsedBody = parsedOutput.body; return throwDefaultError({ output, parsedBody, errorCode, }); } }; const throwDefaultError = smithyClient.withBaseException(SSOOIDCServiceException); const de_AccessDeniedExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, reason: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new AccessDeniedException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_AuthorizationPendingExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new AuthorizationPendingException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_ExpiredTokenExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new ExpiredTokenException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_InternalServerExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new InternalServerException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_InvalidClientExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new InvalidClientException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_InvalidGrantExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new InvalidGrantException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_InvalidRequestExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, reason: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new InvalidRequestException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_InvalidScopeExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new InvalidScopeException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_SlowDownExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new SlowDownException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_UnauthorizedClientExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new UnauthorizedClientException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const de_UnsupportedGrantTypeExceptionRes = async (parsedOutput, context) => { const contents = smithyClient.map({}); const data = parsedOutput.body; const doc = smithyClient.take(data, { error: smithyClient.expectString, error_description: smithyClient.expectString, }); Object.assign(contents, doc); const exception = new UnsupportedGrantTypeException({ $metadata: deserializeMetadata(parsedOutput), ...contents, }); return smithyClient.decorateServiceException(exception, parsedOutput.body); }; const deserializeMetadata = (output) => ({ httpStatusCode: output.statusCode, requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], extendedRequestId: output.headers["x-amz-id-2"], cfId: output.headers["x-amz-cf-id"], }); class CreateTokenCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [ middlewareSerde.getSerdePlugin(config, this.serialize, this.deserialize), middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions()), ]; }) .s("AWSSSOOIDCService", "CreateToken", {}) .n("SSOOIDCClient", "CreateTokenCommand") .f(CreateTokenRequestFilterSensitiveLog, CreateTokenResponseFilterSensitiveLog) .ser(se_CreateTokenCommand) .de(de_CreateTokenCommand) .build() { } const commands = { CreateTokenCommand, }; class SSOOIDC extends SSOOIDCClient { } smithyClient.createAggregatedClient(commands, SSOOIDC); Object.defineProperty(exports, "$Command", { enumerable: true, get: function () { return smithyClient.Command; } }); Object.defineProperty(exports, "__Client", { enumerable: true, get: function () { return smithyClient.Client; } }); exports.AccessDeniedException = AccessDeniedException; exports.AccessDeniedExceptionReason = AccessDeniedExceptionReason; exports.AuthorizationPendingException = AuthorizationPendingException; exports.CreateTokenCommand = CreateTokenCommand; exports.CreateTokenRequestFilterSensitiveLog = CreateTokenRequestFilterSensitiveLog; exports.CreateTokenResponseFilterSensitiveLog = CreateTokenResponseFilterSensitiveLog; exports.ExpiredTokenException = ExpiredTokenException; exports.InternalServerException = InternalServerException; exports.InvalidClientException = InvalidClientException; exports.InvalidGrantException = InvalidGrantException; exports.InvalidRequestException = InvalidRequestException; exports.InvalidRequestExceptionReason = InvalidRequestExceptionReason; exports.InvalidScopeException = InvalidScopeException; exports.SSOOIDC = SSOOIDC; exports.SSOOIDCClient = SSOOIDCClient; exports.SSOOIDCServiceException = SSOOIDCServiceException; exports.SlowDownException = SlowDownException; exports.UnauthorizedClientException = UnauthorizedClientException; exports.UnsupportedGrantTypeException = UnsupportedGrantTypeException;