(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},o(e)}function i(e,t,r){return i=a()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&c(o,r.prototype),o},i.apply(null,arguments)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function s(e,t){for(var r=0;rp,InvalidAWSConfigError:()=>d,InvalidSignatureError:()=>ye,KinesisClient:()=>qe});var p=f((function e(t){if(l(this,e),y(this,"region",void 0),y(this,"accessKeyId",void 0),y(this,"secretAccessKey",void 0),y(this,"sessionToken",void 0),y(this,"scheme","https"),y(this,"endpoint","amazonaws.com"),""===t.region)throw new d("invalid AWS region; reason: should be a non empty string");if(""===t.accessKeyId)throw new d("invalid AWS access key ID; reason: should be a non empty string");if(t.accessKeyId.length<16||t.accessKeyId.length>128)throw new d("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new d("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new d("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(i,e);var t,r,o=(t=i,r=a(),function(){var e,o=u(t);if(r){var i=u(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return n(this,e)});function i(e){return l(this,i),o.call(this,e)}return f(i)}(o(Error));const v=require("k6/crypto");var b=e.n(v),m="X-Amz-Algorithm",g="X-Amz-Credential",S="X-Amz-Date",w="X-Amz-Expires",O="X-Amz-Signature",j="X-Amz-SignedHeaders",P="X-Amz-Security-Token",k="x-amz-content-sha256",R=S.toLowerCase(),C=O.toLowerCase(),_="X-Amz-Target".toLowerCase(),A=P.toLowerCase(),T="authorization",I=[T,R,"date"],E="host",N={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},x="aws4_request",q="AWS4-HMAC-SHA256",D=604800,K="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",H="UNSIGNED-PAYLOAD";const M=require("k6/html");function J(e){return J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},J(e)}function L(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function ne(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[g]}e.headers[R]=l,this.credentials.sessionToken&&(e.headers[A]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var S=K;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,a=t.unsignableHeaders,c=t.unhoistableHeaders,u=t.signableHeaders,s=t.signingRegion,f=t.signingService,l=pe(n),y=l.longDate,h=l.shortDate,p=s||this.region,d=f||this.service;if(i>D)throw new ye("Signature version 4 presigned URLs can't be valid for more than 7 days");var v="".concat(h,"/").concat(p,"/").concat(d,"/").concat(x),b=this.moveHeadersToQuery(e,{unhoistableHeaders:c});b.headers[E]=e.hostname,this.credentials.sessionToken&&(b.query[P]=this.credentials.sessionToken),b.query[m]=q,b.query[g]="".concat(this.credentials.accessKeyId,"/").concat(v),b.query[S]=y,b.query[w]=i.toString(10);var k=this.computeCanonicalHeaders(b,a,u);b.query[j]=Object.keys(k).sort().join(";");var R=this.deriveSigningKey(this.credentials,d,p,h),C=this.computePayloadHash(e),_=this.createCanonicalRequest(b,k,C);b.query[O]=this.calculateSignature(y,v,R,_);var A="".concat(b.protocol,"://").concat(b.hostname);return b.path&&(A+=b.path),b.query&&(A+="?".concat(this.serializeQueryParameters(b.query))),ie({url:A},b)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=b().sha256(r,"hex");return"".concat(q,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return b().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,i=b().hmac("sha256","AWS4"+o,n,"binary"),a=b().hmac("sha256",i,r,"binary"),c=b().hmac("sha256",a,t,"binary");return b().hmac("sha256",c,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=re(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var a=null!=t&&t.startsWith("/")?"/":"",c=n.join("/"),u=n.length>0&&null!=t&&t.endsWith("/")?"/":"",s="".concat(a).concat(c).concat(u);return encodeURIComponent(s).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},a=function(e){if(e.toLowerCase()===C)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(he(e),"=").concat(he(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(he(e),"=").concat(he(r))])}),[]).join("&"))},c=re(Object.keys(n).sort());try{for(c.s();!(t=c.n()).done;)a(t.value)}catch(e){c.e(e)}finally{c.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},a=re(Object.keys(o).sort());try{for(a.s();!(n=a.n()).done;){var c=n.value;if(null!=o[c]){var u=c.toLowerCase();(u in N||null!=t&&t.has(u))&&(!r||r&&!r.has(u))||(i[u]=o[c].trim().replace(/\s+/g," "))}}}catch(e){a.e(e)}finally{a.f()}return i}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,i=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,a=0,c=Object.keys(n);a1&&void 0!==arguments[1]?arguments[1]:{};e=e[0].toUpperCase()+e.slice(1);var r=this.signature.sign({method:"POST",protocol:this.awsConfig.scheme,hostname:this.host,path:"/",headers:je(je({},this.commonHeaders),{},Ne({},_,"".concat(this.serviceVersion,".").concat(e))),body:JSON.stringify(t)},{}),n=void 0;try{n=ve().request("POST",r.url,r.body,{headers:r.headers}),this._handle_error(e,n)}catch(e){console.log("Error with current request from k6-jslib-aws-extension"),console.log(e)}return n}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){console.log("Error with current response from k6-jslib-aws-extension"),console.log(t);var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new ye(o,n.__type);throw new Ue(o,n.__type,e)}if(1500===r)throw new Ue("An error occured on the server side","InternalServiceError",e)}}},{key:"createStream",value:function(e){this.RequestOperation("CreateStream",e)}},{key:"deleteStream",value:function(e){this.RequestOperation("DeleteStream",e)}},{key:"listStreams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.RequestOperation("ListStreams",e);return Ke.fromJson(t.json())}},{key:"putRecords",value:function(e){var t=this.RequestOperation("PutRecords",e);return He.fromJson(t.json())}},{key:"getRecords",value:function(e){var t=this.RequestOperation("GetRecords",e);return Je.fromJson(t.json())}},{key:"listShards",value:function(e){var t=this.RequestOperation("ListShards",e);return ze.fromJson(t.json())}},{key:"getShardIterator",value:function(e){var t=this.RequestOperation("GetShardIterator",e);return We.fromJson(t.json())}}]),r}(function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ge(this,"awsConfig",void 0),ge(this,"serviceName",void 0),ge(this,"_host",void 0),this.awsConfig=t,this.serviceName=r}var t,r,n;return t=e,(r=[{key:"host",get:function(){return null==this._host?"".concat(this.serviceName,".").concat(this.awsConfig.region,".").concat(this.awsConfig.endpoint):this._host},set:function(e){this._host=e}}])&&me(t.prototype,r),n&&me(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()),De=function(){function e(t,r,n,o,i){Pe(this,e),Ne(this,"StreamARN",void 0),Ne(this,"StreamCreationTimestamp",void 0),Ne(this,"StreamModeDetails",void 0),Ne(this,"StreamName",void 0),Ne(this,"StreamStatus",void 0),this.StreamARN=t,this.StreamCreationTimestamp=r,this.StreamModeDetails={StreamMode:n},this.StreamName=o,this.StreamStatus=i}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.StreamARN,t.StreamCreationTimestamp,t.StreamModeDetails.streammode,t.StreamName,t.StreamStatus)}}]),e}(),Ke=function(){function e(t,r,n,o){Pe(this,e),Ne(this,"HasMoreStreams",void 0),Ne(this,"NextToken",void 0),Ne(this,"StreamNames",void 0),Ne(this,"StreamSummaries",void 0),this.HasMoreStreams=t,this.NextToken=r,this.StreamNames=n,this.StreamSummaries=o}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.HasMoreStreams,t.NextToken?t.NextToken:"",t.StreamNames?t.StreamNames.map((function(e){return String(e)})):[],t.StreamSummaries?t.StreamSummaries.map((function(e){return De.fromJson(e)})):[])}}]),e}(),He=function(){function e(t,r){Pe(this,e),Ne(this,"FailedRecordCount",void 0),Ne(this,"Records",void 0),this.FailedRecordCount=t,this.Records=r}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.FailedRecordCount,t.Records.map((function(e){return Me.fromJson(e)})))}}]),e}(),Me=function(){function e(t,r){Pe(this,e),Ne(this,"SequenceNumber",void 0),Ne(this,"ShardId",void 0),this.SequenceNumber=t,this.ShardId=r}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.SequenceNumber,t.ShardId)}}]),e}(),Je=function(){function e(t,r){Pe(this,e),Ne(this,"NextShardIterator",void 0),Ne(this,"Records",void 0),this.NextShardIterator=t,this.Records=r}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.NextShardIterator,t.Records.map((function(e){return Le.fromJson(e)})))}}]),e}(),Le=function(){function e(t,r,n){Pe(this,e),Ne(this,"Data",void 0),Ne(this,"PartitionKey",void 0),Ne(this,"SequenceNumber",void 0),this.Data=t,this.PartitionKey=r,this.SequenceNumber=n}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.Data,t.PartitionKey,t.SequenceNumber)}}]),e}(),ze=function(){function e(t,r){Pe(this,e),Ne(this,"Shards",void 0),Ne(this,"NextToken",void 0),this.Shards=t,this.NextToken=r}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.Shards.map((function(e){return Be.fromJson(e)})),t.NextToken)}}]),e}(),Be=function(){function e(t,r,n,o,i){Pe(this,e),Ne(this,"ShardId",void 0),Ne(this,"ParentShardId",void 0),Ne(this,"AdjacentParentShardId",void 0),Ne(this,"HashKeyRange",void 0),Ne(this,"SequenceNumberRange",void 0),this.ShardId=t,this.ParentShardId=o,this.AdjacentParentShardId=i,this.HashKeyRange=r,this.SequenceNumberRange=n}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.ShardId,t.HashKeyRange,t.SequenceNumberRange,t.ParentShardId,t.AdjacentParentShardId)}}]),e}(),We=function(){function e(t){Pe(this,e),Ne(this,"ShardIterator",void 0),this.ShardIterator=t}return Re(e,null,[{key:"fromJson",value:function(t){return new e(t.ShardIterator)}}]),e}(),Ue=function(e){Ce(r,e);var t=Ae(r);function r(e,n,o){var i;return Pe(this,r),Ne(Ie(i=t.call(this,e,n)),"operation",void 0),i.name="KinesisServiceError",i.operation=o,i}return Re(r)}(G),Xe=function(e,t){return t in e},Fe=exports;for(var Qe in t)Fe[Qe]=t[Qe];t.__esModule&&Object.defineProperty(Fe,"__esModule",{value:!0})})(); //# sourceMappingURL=kinesis.js.map