{"version":3,"file":"AWSIot.mjs","sources":["../../../src/Providers/AWSIot.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Signer, assertOptionalCtxArg, createCtxResolver, } from '@aws-amplify/core/internals/utils';\nimport { isAmplifyContext } from '@aws-amplify/core';\nimport { MqttOverWS } from './MqttOverWS';\nconst SERVICE_NAME = 'iotdevicegateway';\nexport class AWSIoT extends MqttOverWS {\n    constructor(ctxOrOptions, maybeOptions) {\n        if (isAmplifyContext(ctxOrOptions)) {\n            super(maybeOptions ?? {});\n            this._resolveCtx = createCtxResolver(ctxOrOptions);\n        }\n        else {\n            // When a second argument is supplied the caller used the\n            // `(ctx, options)` overload, so the first argument is required to be a\n            // branded AmplifyContext. Guard against a defined-but-unbranded value\n            // being silently swallowed as `options`. In the single-argument form\n            // `ctxOrOptions` is legitimately the options object, so no assertion.\n            if (maybeOptions !== undefined) {\n                assertOptionalCtxArg(ctxOrOptions);\n            }\n            // `ctxOrOptions` reaching this branch is either the single-argument\n            // options object or `undefined`. In the `(undefined, options)` form the\n            // caller omitted the context but still supplied options in the second\n            // slot, so fall back to `maybeOptions` rather than discarding it.\n            super(ctxOrOptions ?? maybeOptions ?? {});\n            this._resolveCtx = createCtxResolver();\n        }\n    }\n    get region() {\n        return this.options?.region;\n    }\n    get endpoint() {\n        return (async () => {\n            const { endpoint } = this.options;\n            const serviceInfo = {\n                service: SERVICE_NAME,\n                region: this.region,\n            };\n            const session = await this._resolveCtx().fetchAuthSession();\n            if (!session.credentials) {\n                throw new Error('No auth session credentials');\n            }\n            const { accessKeyId: access_key, secretAccessKey: secret_key, sessionToken: session_token, } = session.credentials;\n            const result = Signer.signUrl(endpoint, { access_key, secret_key, session_token }, serviceInfo);\n            return result;\n        })();\n    }\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA,MAAM,YAAY,GAAG,kBAAkB;AAChC,MAAM,MAAM,SAAS,UAAU,CAAC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