Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: fixes getDownloadUrl function that fetches for release tags (#5)
Browse files Browse the repository at this point in the history
* fix: fix download url function to include tag

* fix: fix download url function to include tag

* fix: fix download url function to include tag

* fix: fix download url function to include tag
  • Loading branch information
dutterbutter authored Oct 10, 2023
1 parent 1061881 commit 36ffd2e
Show file tree
Hide file tree
Showing 5 changed files with 898 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/794.index.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"use strict";exports.id=794,exports.ids=[794],exports.modules={5794:(e,t,n)=>{var a=Object.defineProperty,r=(e,t)=>a(e,"name",{value:t,configurable:!0});n(7561),n(9411);const o=n(6824);n(8849),n(2286),n(5628),n(4492),n(2254),n(7261),n(1041),n(7503);let i=0;const s={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++};let d=1;const E=d,A=d*=2,l=r((e=>32|e),"lower"),h=r((()=>{}),"noop"),D=class{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=h,this.onHeaderField=h,this.onHeadersEnd=h,this.onHeaderValue=h,this.onPartBegin=h,this.onPartData=h,this.onPartEnd=h,this.boundaryChars={},e="\r\n--"+e;const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=s.START_BOUNDARY}write(e){let t=0;const n=e.length;let a=this.index,{lookbehind:o,boundary:i,boundaryChars:d,index:h,state:D,flags:c}=this;const T=this.boundary.length,f=T-1,_=e.length;let u,R;const b=r((e=>{this[e+"Mark"]=t}),"mark"),H=r((e=>{delete this[e+"Mark"]}),"clear"),p=r(((e,t,n,a)=>{(void 0===t||t!==n)&&this[e](a&&a.subarray(t,n))}),"callback"),P=r(((n,a)=>{const r=n+"Mark";r in this&&(a?(p(n,this[r],t,e),delete this[r]):(p(n,this[r],e.length,e),this[r]=0))}),"dataCallback");for(t=0;t<n;t++)switch(u=e[t],D){case s.START_BOUNDARY:if(h===i.length-2){if(45===u)c|=A;else if(13!==u)return;h++;break}if(h-1==i.length-2){if(c&A&&45===u)D=s.END,c=0;else{if(c&A||10!==u)return;h=0,p("onPartBegin"),D=s.HEADER_FIELD_START}break}u!==i[h+2]&&(h=-2),u===i[h+2]&&h++;break;case s.HEADER_FIELD_START:D=s.HEADER_FIELD,b("onHeaderField"),h=0;case s.HEADER_FIELD:if(13===u){H("onHeaderField"),D=s.HEADERS_ALMOST_DONE;break}if(h++,45===u)break;if(58===u){if(1===h)return;P("onHeaderField",!0),D=s.HEADER_VALUE_START;break}if(R=l(u),R<97||R>122)return;break;case s.HEADER_VALUE_START:if(32===u)break;b("onHeaderValue"),D=s.HEADER_VALUE;case s.HEADER_VALUE:13===u&&(P("onHeaderValue",!0),p("onHeaderEnd"),D=s.HEADER_VALUE_ALMOST_DONE);break;case s.HEADER_VALUE_ALMOST_DONE:if(10!==u)return;D=s.HEADER_FIELD_START;break;case s.HEADERS_ALMOST_DONE:if(10!==u)return;p("onHeadersEnd"),D=s.PART_DATA_START;break;case s.PART_DATA_START:D=s.PART_DATA,b("onPartData");case s.PART_DATA:if(a=h,0===h){for(t+=f;t<_&&!(e[t]in d);)t+=T;t-=f,u=e[t]}if(h<i.length)i[h]===u?(0===h&&P("onPartData",!0),h++):h=0;else if(h===i.length)h++,13===u?c|=E:45===u?c|=A:h=0;else if(h-1===i.length)if(c&E){if(h=0,10===u){c&=~E,p("onPartEnd"),p("onPartBegin"),D=s.HEADER_FIELD_START;break}}else c&A&&45===u?(p("onPartEnd"),D=s.END,c=0):h=0;if(h>0)o[h-1]=u;else if(a>0){const e=new Uint8Array(o.buffer,o.byteOffset,o.byteLength);p("onPartData",0,a,e),a=0,b("onPartData"),t--}break;case s.END:break;default:throw new Error(`Unexpected state entered: ${D}`)}P("onHeaderField"),P("onHeaderValue"),P("onPartData"),this.index=h,this.state=D,this.flags=c}end(){if(this.state===s.HEADER_FIELD_START&&0===this.index||this.state===s.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==s.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}};r(D,"MultipartParser");let c=D;function T(e){const t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;const n=t[2]||t[3]||"";let a=n.slice(n.lastIndexOf("\\")+1);return a=a.replace(/%22/g,'"'),a=a.replace(/&#(\d{4});/g,((e,t)=>String.fromCharCode(t))),a}async function f(e,t){if(!/multipart/i.test(t))throw new TypeError("Failed to fetch");const n=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new TypeError("no or bad content-type header, no multipart boundary");const a=new c(n[1]||n[2]);let i,s,d,E,A,l;const h=[],D=new o.FormData,f=r((e=>{d+=b.decode(e,{stream:!0})}),"onPartData"),_=r((e=>{h.push(e)}),"appendToFile"),u=r((()=>{const e=new o.File(h,l,{type:A});D.append(E,e)}),"appendFileToFormData"),R=r((()=>{D.append(E,d)}),"appendEntryToFormData"),b=new TextDecoder("utf-8");b.decode(),a.onPartBegin=function(){a.onPartData=f,a.onPartEnd=R,i="",s="",d="",E="",A="",l=null,h.length=0},a.onHeaderField=function(e){i+=b.decode(e,{stream:!0})},a.onHeaderValue=function(e){s+=b.decode(e,{stream:!0})},a.onHeaderEnd=function(){if(s+=b.decode(),i=i.toLowerCase(),"content-disposition"===i){const e=s.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(E=e[2]||e[3]||""),l=T(s),l&&(a.onPartData=_,a.onPartEnd=u)}else"content-type"===i&&(A=s);s="",i=""};for await(const t of e)a.write(t);return a.end(),D}r(T,"_fileName"),r(f,"toFormData"),t.toFormData=f}};
"use strict";exports.id=794,exports.ids=[794],exports.modules={5794:(e,t,n)=>{var a=Object.defineProperty,r=(e,t)=>a(e,"name",{value:t,configurable:!0});n(7561),n(9411);const o=n(6824);n(8849),n(2286),n(5628),n(4492),n(2254),n(7261),n(3020),n(7503);let i=0;const s={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++};let d=1;const E=d,A=d*=2,l=r((e=>32|e),"lower"),h=r((()=>{}),"noop"),D=class{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=h,this.onHeaderField=h,this.onHeadersEnd=h,this.onHeaderValue=h,this.onPartBegin=h,this.onPartData=h,this.onPartEnd=h,this.boundaryChars={},e="\r\n--"+e;const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=s.START_BOUNDARY}write(e){let t=0;const n=e.length;let a=this.index,{lookbehind:o,boundary:i,boundaryChars:d,index:h,state:D,flags:c}=this;const T=this.boundary.length,f=T-1,_=e.length;let u,R;const b=r((e=>{this[e+"Mark"]=t}),"mark"),H=r((e=>{delete this[e+"Mark"]}),"clear"),p=r(((e,t,n,a)=>{(void 0===t||t!==n)&&this[e](a&&a.subarray(t,n))}),"callback"),P=r(((n,a)=>{const r=n+"Mark";r in this&&(a?(p(n,this[r],t,e),delete this[r]):(p(n,this[r],e.length,e),this[r]=0))}),"dataCallback");for(t=0;t<n;t++)switch(u=e[t],D){case s.START_BOUNDARY:if(h===i.length-2){if(45===u)c|=A;else if(13!==u)return;h++;break}if(h-1==i.length-2){if(c&A&&45===u)D=s.END,c=0;else{if(c&A||10!==u)return;h=0,p("onPartBegin"),D=s.HEADER_FIELD_START}break}u!==i[h+2]&&(h=-2),u===i[h+2]&&h++;break;case s.HEADER_FIELD_START:D=s.HEADER_FIELD,b("onHeaderField"),h=0;case s.HEADER_FIELD:if(13===u){H("onHeaderField"),D=s.HEADERS_ALMOST_DONE;break}if(h++,45===u)break;if(58===u){if(1===h)return;P("onHeaderField",!0),D=s.HEADER_VALUE_START;break}if(R=l(u),R<97||R>122)return;break;case s.HEADER_VALUE_START:if(32===u)break;b("onHeaderValue"),D=s.HEADER_VALUE;case s.HEADER_VALUE:13===u&&(P("onHeaderValue",!0),p("onHeaderEnd"),D=s.HEADER_VALUE_ALMOST_DONE);break;case s.HEADER_VALUE_ALMOST_DONE:if(10!==u)return;D=s.HEADER_FIELD_START;break;case s.HEADERS_ALMOST_DONE:if(10!==u)return;p("onHeadersEnd"),D=s.PART_DATA_START;break;case s.PART_DATA_START:D=s.PART_DATA,b("onPartData");case s.PART_DATA:if(a=h,0===h){for(t+=f;t<_&&!(e[t]in d);)t+=T;t-=f,u=e[t]}if(h<i.length)i[h]===u?(0===h&&P("onPartData",!0),h++):h=0;else if(h===i.length)h++,13===u?c|=E:45===u?c|=A:h=0;else if(h-1===i.length)if(c&E){if(h=0,10===u){c&=~E,p("onPartEnd"),p("onPartBegin"),D=s.HEADER_FIELD_START;break}}else c&A&&45===u?(p("onPartEnd"),D=s.END,c=0):h=0;if(h>0)o[h-1]=u;else if(a>0){const e=new Uint8Array(o.buffer,o.byteOffset,o.byteLength);p("onPartData",0,a,e),a=0,b("onPartData"),t--}break;case s.END:break;default:throw new Error(`Unexpected state entered: ${D}`)}P("onHeaderField"),P("onHeaderValue"),P("onPartData"),this.index=h,this.state=D,this.flags=c}end(){if(this.state===s.HEADER_FIELD_START&&0===this.index||this.state===s.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==s.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}};r(D,"MultipartParser");let c=D;function T(e){const t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;const n=t[2]||t[3]||"";let a=n.slice(n.lastIndexOf("\\")+1);return a=a.replace(/%22/g,'"'),a=a.replace(/&#(\d{4});/g,((e,t)=>String.fromCharCode(t))),a}async function f(e,t){if(!/multipart/i.test(t))throw new TypeError("Failed to fetch");const n=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new TypeError("no or bad content-type header, no multipart boundary");const a=new c(n[1]||n[2]);let i,s,d,E,A,l;const h=[],D=new o.FormData,f=r((e=>{d+=b.decode(e,{stream:!0})}),"onPartData"),_=r((e=>{h.push(e)}),"appendToFile"),u=r((()=>{const e=new o.File(h,l,{type:A});D.append(E,e)}),"appendFileToFormData"),R=r((()=>{D.append(E,d)}),"appendEntryToFormData"),b=new TextDecoder("utf-8");b.decode(),a.onPartBegin=function(){a.onPartData=f,a.onPartEnd=R,i="",s="",d="",E="",A="",l=null,h.length=0},a.onHeaderField=function(e){i+=b.decode(e,{stream:!0})},a.onHeaderValue=function(e){s+=b.decode(e,{stream:!0})},a.onHeaderEnd=function(){if(s+=b.decode(),i=i.toLowerCase(),"content-disposition"===i){const e=s.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(E=e[2]||e[3]||""),l=T(s),l&&(a.onPartData=_,a.onPartEnd=u)}else"content-type"===i&&(A=s);s="",i=""};for await(const t of e)a.write(t);return a.end(),D}r(T,"_fileName"),r(f,"toFormData"),t.toFormData=f}};
2 changes: 1 addition & 1 deletion dist/index.cjs

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions dist/index.cjs.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */

/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */

/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */

/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */
9 changes: 8 additions & 1 deletion index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ const ERA_TEST_NODE_RELEASE_TAG = getInput('releaseTag') || 'latest';
const ERA_TEST_NODE_ARCH = getInput('target') || 'x86_64-unknown-linux-gnu';

async function getDownloadUrl() {
const response = await fetch(`https://api.github.com/repos/matter-labs/era-test-node/releases/${ERA_TEST_NODE_RELEASE_TAG}`);
let apiUrl;
if (ERA_TEST_NODE_RELEASE_TAG === 'latest') {
apiUrl = 'https://api.github.com/repos/matter-labs/era-test-node/releases/latest';
} else {
apiUrl = `https://api.github.com/repos/matter-labs/era-test-node/releases/tags/${ERA_TEST_NODE_RELEASE_TAG}`;
}

const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`Failed to fetch release info for tag ${ERA_TEST_NODE_RELEASE_TAG}. HTTP Status: ${response.status}`);
}
Expand Down
Loading

0 comments on commit 36ffd2e

Please sign in to comment.