UNPKG

@ew-did-registry/did-s3-store

Version:

S3-based implementation of IDidStore

1 lines 5.7 kB
"use strict";exports.id=720,exports.ids=[720],exports.modules={720:(e,n,r)=>{r.d(n,{fromIni:()=>g});var o=r(7073),t=r(3631),i=r(8455);const s=e=>(0,i.g)(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p"),a=e=>!e.role_arn&&!!e.credential_source,l=e=>Boolean(e)&&"object"==typeof e&&"string"==typeof e.aws_access_key_id&&"string"==typeof e.aws_secret_access_key&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,c=async(e,n)=>{n?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");const r={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return(0,i.g)(r,"CREDENTIALS_PROFILE","n")},d=async(e,n,g,f={},_=!1)=>{const u=n[e];if(Object.keys(f).length>0&&l(u))return c(u,g);if(_||((e,{profile:n="default",logger:r}={})=>Boolean(e)&&"object"==typeof e&&"string"==typeof e.role_arn&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(((e,{profile:n,logger:r})=>{const o="string"==typeof e.source_profile&&void 0===e.credential_source;return o&&r?.debug?.(` ${n} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`),o})(e,{profile:n,logger:r})||((e,{profile:n,logger:r})=>{const o="string"==typeof e.credential_source&&void 0===e.source_profile;return o&&r?.debug?.(` ${n} isCredentialSourceProfile credential_source=${e.credential_source}`),o})(e,{profile:n,logger:r})))(u,{profile:e,logger:g.logger}))return(async(e,n,l,c={})=>{l.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");const g=n[e],{source_profile:f,region:_}=g;if(!l.roleAssumer){const{getDefaultRoleAssumer:e}=await r.e(547).then(r.bind(r,4547));l.roleAssumer=e({...l.clientConfig,credentialProviderLogger:l.logger,parentClientConfig:{...l?.parentClientConfig,region:_??l?.parentClientConfig?.region}},l.clientPlugins)}if(f&&f in c)throw new t.C1(`Detected a cycle attempting to resolve credentials for profile ${(0,o.Bz)(l)}. Profiles visited: `+Object.keys(c).join(", "),{logger:l.logger});l.logger?.debug("@aws-sdk/credential-provider-ini - finding credential resolver using "+(f?`source_profile=[${f}]`:`profile=[${e}]`));const u=f?d(f,n,l,{...c,[f]:!0},a(n[f]??{})):(await((e,n,o)=>{const i={EcsContainer:async e=>{const{fromHttp:n}=await r.e(705).then(r.bind(r,705)),{fromContainerMetadata:i}=await r.e(728).then(r.bind(r,728));return o?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>(0,t.cy)(n(e??{}),i(e))().then(s)},Ec2InstanceMetadata:async e=>{o?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");const{fromInstanceMetadata:n}=await r.e(728).then(r.bind(r,728));return async()=>n(e)().then(s)},Environment:async e=>{o?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");const{fromEnv:n}=await Promise.resolve().then(r.bind(r,5905));return async()=>n(e)().then(s)}};if(e in i)return i[e];throw new t.C1(`Unsupported credential source in profile ${n}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:o})})(g.credential_source,e,l.logger)(l))();if(a(g))return u.then((e=>(0,i.g)(e,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o")));{const n={RoleArn:g.role_arn,RoleSessionName:g.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:g.external_id,DurationSeconds:parseInt(g.duration_seconds||"3600",10)},{mfa_serial:r}=g;if(r){if(!l.mfaCodeProvider)throw new t.C1(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:l.logger,tryNextLink:!1});n.SerialNumber=r,n.TokenCode=await l.mfaCodeProvider(r)}const o=await u;return l.roleAssumer(o,n).then((e=>(0,i.g)(e,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o")))}})(e,n,g,f);if(l(u))return c(u,g);if(p=u,Boolean(p)&&"object"==typeof p&&"string"==typeof p.web_identity_token_file&&"string"==typeof p.role_arn&&["undefined","string"].indexOf(typeof p.role_session_name)>-1)return(async(e,n)=>r.e(624).then(r.bind(r,4624)).then((({fromTokenFile:r})=>r({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:n.roleAssumerWithWebIdentity,logger:n.logger,parentClientConfig:n.parentClientConfig})().then((e=>(0,i.g)(e,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q"))))))(u,g);var p;if((e=>Boolean(e)&&"object"==typeof e&&"string"==typeof e.credential_process)(u))return(async(e,n)=>r.e(828).then(r.bind(r,3828)).then((({fromProcess:r})=>r({...e,profile:n})().then((e=>(0,i.g)(e,"CREDENTIALS_PROFILE_PROCESS","v"))))))(g,e);if((e=>e&&("string"==typeof e.sso_start_url||"string"==typeof e.sso_account_id||"string"==typeof e.sso_session||"string"==typeof e.sso_region||"string"==typeof e.sso_role_name))(u))return await(async(e,n,o={})=>{const{fromSSO:t}=await r.e(978).then(r.bind(r,3978));return t({profile:e,logger:o.logger,parentClientConfig:o.parentClientConfig,clientConfig:o.clientConfig})().then((e=>n.sso_session?(0,i.g)(e,"CREDENTIALS_PROFILE_SSO","r"):(0,i.g)(e,"CREDENTIALS_PROFILE_SSO_LEGACY","t")))})(e,u,g);throw new t.C1(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:g.logger})},g=(e={})=>async({callerClientConfig:n}={})=>{const r={...e,parentClientConfig:{...n,...e.parentClientConfig}};r.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");const t=await(0,o.YU)(r);return d((0,o.Bz)({profile:e.profile??n?.profile}),t,r)}}};