UNPKG

aws-secrets-manager-wrapper

Version:

A TypeScript wrapper for AWS Secrets Manager that simplifies common operations and provides a more user-friendly interface.

1 lines 15.7 kB
"use strict";exports.id=526,exports.ids=[526],exports.modules={9526:(e,t,r)=>{r.d(t,{CreateTokenCommand:()=>Je,SSOOIDCClient:()=>de});var o=r(1095),s=r(9359),n=r(8377),i=r(6961),a=r(1487),c=r(3847),d=r(649),p=r(9389),l=r(3594),u=r(1540),h=r(3448),m=r(7135);const y=async(e,t,r)=>({operation:(0,m.u)(t).operation,region:await(0,m.t)(e.region)()||(()=>{throw new Error("expected `region` to be configured for `aws.auth#sigv4`")})()}),w=e=>{const t=[];switch(e.operation){case"CreateToken":case"RegisterClient":case"StartDeviceAuthorization":t.push({schemeId:"smithy.api#noAuth"});break;default:t.push(function(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(e,t)=>({signingProperties:{config:e,context:t}})}}(e))}return t},f={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}};var x=r(5122),g=r(8257),b=r(3410),v=r(1701),E=r(9987),S=r(4029),I=r(7809),P=r(3323),O=r(6228),$=r(2641),k=r(4572),j=r(3197),T=r(6652),C=r(8545);const _="required",D="fn",A="argv",K="ref",R=!0,z="isSet",M="booleanEquals",U="error",q="endpoint",F="tree",H="PartitionResult",G="getAttr",V={[_]:!1,type:"String"},Z={[_]:!0,default:!1,type:"Boolean"},B={[K]:"Endpoint"},N={[D]:M,[A]:[{[K]:"UseFIPS"},!0]},J={[D]:M,[A]:[{[K]:"UseDualStack"},!0]},L={},Y={[D]:G,[A]:[{[K]:H},"supportsFIPS"]},W={[K]:H},X={[D]:M,[A]:[!0,{[D]:G,[A]:[W,"supportsDualStack"]}]},Q=[N],ee=[J],te=[{[K]:"Region"}],re={version:"1.0",parameters:{Region:V,UseDualStack:Z,UseFIPS:Z,Endpoint:V},rules:[{conditions:[{[D]:z,[A]:[B]}],rules:[{conditions:Q,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:U},{conditions:ee,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:U},{endpoint:{url:B,properties:L,headers:L},type:q}],type:F},{conditions:[{[D]:z,[A]:te}],rules:[{conditions:[{[D]:"aws.partition",[A]:te,assign:H}],rules:[{conditions:[N,J],rules:[{conditions:[{[D]:M,[A]:[R,Y]},X],rules:[{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:L,headers:L},type:q}],type:F},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:U}],type:F},{conditions:Q,rules:[{conditions:[{[D]:M,[A]:[Y,R]}],rules:[{conditions:[{[D]:"stringEquals",[A]:[{[D]:G,[A]:[W,"name"]},"aws-us-gov"]}],endpoint:{url:"https://oidc.{Region}.amazonaws.com",properties:L,headers:L},type:q},{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",properties:L,headers:L},type:q}],type:F},{error:"FIPS is enabled but this partition does not support FIPS",type:U}],type:F},{conditions:ee,rules:[{conditions:[X],rules:[{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:L,headers:L},type:q}],type:F},{error:"DualStack is enabled but this partition does not support DualStack",type:U}],type:F},{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dnsSuffix}",properties:L,headers:L},type:q}],type:F}],type:F},{error:"Invalid Configuration: Missing Region",type:U}]},oe=new C.kS({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),se=(e,t={})=>oe.get(e,(()=>(0,C.sO)(re,{endpointParams:e,logger:t.logger})));C.mw.aws=T.UF;var ne=r(4321);var ie=r(6928),ae=r(5479);const ce=e=>{const t=e.httpAuthSchemes;let r=e.httpAuthSchemeProvider,o=e.credentials;return{setHttpAuthScheme(e){const r=t.findIndex((t=>t.schemeId===e.schemeId));-1===r?t.push(e):t.splice(r,1,e)},httpAuthSchemes:()=>t,setHttpAuthSchemeProvider(e){r=e},httpAuthSchemeProvider:()=>r,setCredentials(e){o=e},credentials:()=>o}};class de extends u.Kj{constructor(...[e]){const t=(e=>{(0,u.I9)(process.version);const t=(0,ne.I)(e),r=()=>t().then(u.lT),o=(e=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??k.E,base64Encoder:e?.base64Encoder??k.n,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??se,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??w,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:e=>e.getIdentityProvider("aws.auth#sigv4"),signer:new O.f2},{schemeId:"smithy.api#noAuth",identityProvider:e=>e.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new c.mR}],logger:e?.logger??new u.N4,serviceId:e?.serviceId??"SSO OIDC",urlParser:e?.urlParser??$.D,utf8Decoder:e?.utf8Decoder??j.ar,utf8Encoder:e?.utf8Encoder??j.Pq}))(e);return(0,x.I)(process.version),{...o,...e,runtime:"node",defaultsMode:t,bodyLengthChecker:e?.bodyLengthChecker??I.n,credentialDefaultProvider:e?.credentialDefaultProvider??g.v6,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,b.pf)({serviceId:o.serviceId,clientVersion:"3.670.0"}),maxAttempts:e?.maxAttempts??(0,E.Z)(l.qs),region:e?.region??(0,E.Z)(a.GG,a.zH),requestHandler:S.$c.create(e?.requestHandler??r),retryMode:e?.retryMode??(0,E.Z)({...l.kN,default:async()=>(await r()).retryMode||P.L0}),sha256:e?.sha256??v.V.bind(null,"sha256"),streamCollector:e?.streamCollector??S.kv,useDualstackEndpoint:e?.useDualstackEndpoint??(0,E.Z)(a.e$),useFipsEndpoint:e?.useFipsEndpoint??(0,E.Z)(a.Ko),userAgentAppId:e?.userAgentAppId??(0,E.Z)(b.hV)}})(e||{}),r=(m=t,{...m,useDualstackEndpoint:m.useDualstackEndpoint??!1,useFipsEndpoint:m.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"});var m;const f=(0,i.Dc)(r),T=(0,l.$z)(f),C=(0,a.TD)(T),_=(0,o.OV)(C);var D;const A=((e,t)=>{const r={...(0,ie.Rq)(e),...(0,u.xA)(e),...(0,ae.eS)(e),...ce(e)};return t.forEach((e=>e.configure(r))),{...e,...(0,ie.$3)(r),...(0,u.uv)(r),...(0,ae.jt)(r),...(o=r,{httpAuthSchemes:o.httpAuthSchemes(),httpAuthSchemeProvider:o.httpAuthSchemeProvider(),credentials:o.credentials()})};var o})((D=(0,p.Co)(_),{...(0,h.h)(D)}),e?.extensions||[]);super(A),this.config=A,this.middlewareStack.use((0,i.sM)(this.config)),this.middlewareStack.use((0,l.ey)(this.config)),this.middlewareStack.use((0,d.vK)(this.config)),this.middlewareStack.use((0,o.TC)(this.config)),this.middlewareStack.use((0,s.Y7)(this.config)),this.middlewareStack.use((0,n.n4)(this.config)),this.middlewareStack.use((0,c.wB)(this.config,{httpAuthSchemeParametersProvider:y,identityProviderConfigProvider:async e=>new c.h$({"aws.auth#sigv4":e.credentials})})),this.middlewareStack.use((0,c.lW)(this.config))}destroy(){super.destroy()}}var pe=r(1208);class le extends u.TJ{constructor(e){super(e),Object.setPrototypeOf(this,le.prototype)}}class ue extends le{constructor(e){super({name:"AccessDeniedException",$fault:"client",...e}),this.name="AccessDeniedException",this.$fault="client",Object.setPrototypeOf(this,ue.prototype),this.error=e.error,this.error_description=e.error_description}}class he extends le{constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e}),this.name="AuthorizationPendingException",this.$fault="client",Object.setPrototypeOf(this,he.prototype),this.error=e.error,this.error_description=e.error_description}}class me extends le{constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e}),this.name="ExpiredTokenException",this.$fault="client",Object.setPrototypeOf(this,me.prototype),this.error=e.error,this.error_description=e.error_description}}class ye extends le{constructor(e){super({name:"InternalServerException",$fault:"server",...e}),this.name="InternalServerException",this.$fault="server",Object.setPrototypeOf(this,ye.prototype),this.error=e.error,this.error_description=e.error_description}}class we extends le{constructor(e){super({name:"InvalidClientException",$fault:"client",...e}),this.name="InvalidClientException",this.$fault="client",Object.setPrototypeOf(this,we.prototype),this.error=e.error,this.error_description=e.error_description}}class fe extends le{constructor(e){super({name:"InvalidGrantException",$fault:"client",...e}),this.name="InvalidGrantException",this.$fault="client",Object.setPrototypeOf(this,fe.prototype),this.error=e.error,this.error_description=e.error_description}}class xe extends le{constructor(e){super({name:"InvalidRequestException",$fault:"client",...e}),this.name="InvalidRequestException",this.$fault="client",Object.setPrototypeOf(this,xe.prototype),this.error=e.error,this.error_description=e.error_description}}class ge extends le{constructor(e){super({name:"InvalidScopeException",$fault:"client",...e}),this.name="InvalidScopeException",this.$fault="client",Object.setPrototypeOf(this,ge.prototype),this.error=e.error,this.error_description=e.error_description}}class be extends le{constructor(e){super({name:"SlowDownException",$fault:"client",...e}),this.name="SlowDownException",this.$fault="client",Object.setPrototypeOf(this,be.prototype),this.error=e.error,this.error_description=e.error_description}}class ve extends le{constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e}),this.name="UnauthorizedClientException",this.$fault="client",Object.setPrototypeOf(this,ve.prototype),this.error=e.error,this.error_description=e.error_description}}class Ee extends le{constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e}),this.name="UnsupportedGrantTypeException",this.$fault="client",Object.setPrototypeOf(this,Ee.prototype),this.error=e.error,this.error_description=e.error_description}}class Se extends le{constructor(e){super({name:"InvalidRequestRegionException",$fault:"client",...e}),this.name="InvalidRequestRegionException",this.$fault="client",Object.setPrototypeOf(this,Se.prototype),this.error=e.error,this.error_description=e.error_description,this.endpoint=e.endpoint,this.region=e.region}}class Ie extends le{constructor(e){super({name:"InvalidClientMetadataException",$fault:"client",...e}),this.name="InvalidClientMetadataException",this.$fault="client",Object.setPrototypeOf(this,Ie.prototype),this.error=e.error,this.error_description=e.error_description}}class Pe extends le{constructor(e){super({name:"InvalidRedirectUriException",$fault:"client",...e}),this.name="InvalidRedirectUriException",this.$fault="client",Object.setPrototypeOf(this,Pe.prototype),this.error=e.error,this.error_description=e.error_description}}const Oe=e=>({...e,...e.clientSecret&&{clientSecret:u.$H},...e.refreshToken&&{refreshToken:u.$H},...e.codeVerifier&&{codeVerifier:u.$H}}),$e=e=>({...e,...e.accessToken&&{accessToken:u.$H},...e.refreshToken&&{refreshToken:u.$H},...e.idToken&&{idToken:u.$H}});var ke=r(1919);const je=async(e,t)=>{const r=(0,c.lI)(e,t);let o;return r.bp("/token"),o=JSON.stringify((0,u.s)(e,{clientId:[],clientSecret:[],code:[],codeVerifier:[],deviceCode:[],grantType:[],redirectUri:[],refreshToken:[],scope:e=>(0,u.Ss)(e)})),r.m("POST").h({"content-type":"application/json"}).b(o),r.build()},Te=async(e,t)=>{if(200!==e.statusCode&&e.statusCode>=300)return Ce(e,t);const r=(0,u.Tj)({$metadata:Ne(e)}),o=(0,u.Y0)((0,u.Xk)(await(0,ke.Y2)(e.body,t)),"body"),s=(0,u.s)(o,{accessToken:u.lK,expiresIn:u.ET,idToken:u.lK,refreshToken:u.lK,tokenType:u.lK});return Object.assign(r,s),r},Ce=async(e,t)=>{const r={...e,body:await(0,ke.CG)(e.body,t)},o=(0,ke.cJ)(e,r.body);switch(o){case"AccessDeniedException":case"com.amazonaws.ssooidc#AccessDeniedException":throw await De(r,t);case"AuthorizationPendingException":case"com.amazonaws.ssooidc#AuthorizationPendingException":throw await Ae(r,t);case"ExpiredTokenException":case"com.amazonaws.ssooidc#ExpiredTokenException":throw await Ke(r,t);case"InternalServerException":case"com.amazonaws.ssooidc#InternalServerException":throw await Re(r,t);case"InvalidClientException":case"com.amazonaws.ssooidc#InvalidClientException":throw await ze(r,t);case"InvalidGrantException":case"com.amazonaws.ssooidc#InvalidGrantException":throw await Ue(r,t);case"InvalidRequestException":case"com.amazonaws.ssooidc#InvalidRequestException":throw await Fe(r,t);case"InvalidScopeException":case"com.amazonaws.ssooidc#InvalidScopeException":throw await Ge(r,t);case"SlowDownException":case"com.amazonaws.ssooidc#SlowDownException":throw await Ve(r,t);case"UnauthorizedClientException":case"com.amazonaws.ssooidc#UnauthorizedClientException":throw await Ze(r,t);case"UnsupportedGrantTypeException":case"com.amazonaws.ssooidc#UnsupportedGrantTypeException":throw await Be(r,t);case"InvalidRequestRegionException":case"com.amazonaws.ssooidc#InvalidRequestRegionException":throw await He(r,t);case"InvalidClientMetadataException":case"com.amazonaws.ssooidc#InvalidClientMetadataException":throw await Me(r,t);case"InvalidRedirectUriException":case"com.amazonaws.ssooidc#InvalidRedirectUriException":throw await qe(r,t);default:const s=r.body;return _e({output:e,parsedBody:s,errorCode:o})}},_e=(0,u.jr)(le),De=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new ue({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ae=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new he({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ke=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new me({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Re=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new ye({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},ze=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new we({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Me=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new Ie({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ue=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new fe({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},qe=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new Pe({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Fe=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new xe({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},He=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{endpoint:u.lK,error:u.lK,error_description:u.lK,region:u.lK});Object.assign(r,s);const n=new Se({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ge=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new ge({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ve=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new be({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ze=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new ve({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Be=async(e,t)=>{const r=(0,u.Tj)({}),o=e.body,s=(0,u.s)(o,{error:u.lK,error_description:u.lK});Object.assign(r,s);const n=new Ee({$metadata:Ne(e),...r});return(0,u.Mw)(n,e.body)},Ne=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]});class Je extends(u.uB.classBuilder().ep(f).m((function(e,t,r,o){return[(0,pe.TM)(r,this.serialize,this.deserialize),(0,p.rD)(r,e.getEndpointParameterInstructions())]})).s("AWSSSOOIDCService","CreateToken",{}).n("SSOOIDCClient","CreateTokenCommand").f(Oe,$e).ser(je).de(Te).build()){}}};