@devtion/actions 0.0.0-eb3bb7d → 0.0.0-f3ea056

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/actions
3
- * @version 1.0.5
2
+ * @module @devtion/actions
3
+ * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -17,8 +17,7 @@ import crypto from 'crypto';
17
17
  import blake from 'blakejs';
18
18
  import { utils } from 'ffjavascript';
19
19
  import winston from 'winston';
20
- import { S3Client, HeadObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
21
- import { pipeline, Readable } from 'stream';
20
+ import { pipeline } from 'stream';
22
21
  import { promisify } from 'util';
23
22
  import { initializeApp } from 'firebase/app';
24
23
  import { signInWithCredential, initializeAuth, getAuth } from 'firebase/auth';
@@ -1091,42 +1090,26 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1091
1090
  circuitArtifacts.push({
1092
1091
  artifacts: artifacts
1093
1092
  });
1094
- const r1csPath = artifacts.r1csStoragePath;
1095
- const wasmPath = artifacts.wasmStoragePath;
1096
1093
  // where we storing the r1cs downloaded
1097
1094
  const localR1csPath = `./${circuitData.name}.r1cs`;
1098
- // check that the artifacts exist in S3
1099
- // we don't need any privileges to download this
1100
- // just the correct region
1101
- const s3 = new S3Client({ region: artifacts.region });
1102
- try {
1103
- await s3.send(new HeadObjectCommand({
1104
- Bucket: artifacts.bucket,
1105
- Key: r1csPath
1106
- }));
1107
- }
1108
- catch (error) {
1109
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1110
- }
1111
- try {
1112
- await s3.send(new HeadObjectCommand({
1113
- Bucket: artifacts.bucket,
1114
- Key: wasmPath
1115
- }));
1116
- }
1117
- catch (error) {
1118
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1119
- }
1095
+ // where we storing the wasm downloaded
1096
+ const localWasmPath = `./${circuitData.name}.wasm`;
1120
1097
  // download the r1cs to extract the metadata
1121
- const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1122
- const response = await s3.send(command);
1123
1098
  const streamPipeline = promisify(pipeline);
1124
- if (response.$metadata.httpStatusCode !== 200)
1125
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.");
1126
- if (response.Body instanceof Readable)
1127
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1099
+ // Make the call.
1100
+ const responseR1CS = await fetch(artifacts.r1csStoragePath);
1101
+ // Handle errors.
1102
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
1103
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1104
+ await streamPipeline(responseR1CS.body, createWriteStream(localR1csPath));
1105
+ // Write the file locally
1128
1106
  // extract the metadata from the r1cs
1129
1107
  const metadata = getR1CSInfo(localR1csPath);
1108
+ // download wasm too to ensure it's available
1109
+ const responseWASM = await fetch(artifacts.wasmStoragePath);
1110
+ if (!responseWASM.ok && responseWASM.status !== 200)
1111
+ throw new Error(`There was an error while trying to download the WASM file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1112
+ await streamPipeline(responseWASM.body, createWriteStream(localWasmPath));
1130
1113
  // validate that the circuit hash and template links are valid
1131
1114
  const template = circuitData.template;
1132
1115
  const URLMatch = template.source.match(urlPattern);
@@ -1222,9 +1205,10 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1222
1205
  };
1223
1206
  }
1224
1207
  circuits.push(circuit);
1225
- // remove the local r1cs download (if used for verifying the config only vs setup)
1208
+ // remove the local r1cs and wasm downloads (if used for verifying the config only vs setup)
1226
1209
  if (cleanup)
1227
1210
  fs.unlinkSync(localR1csPath);
1211
+ fs.unlinkSync(localWasmPath);
1228
1212
  }
1229
1213
  const setupData = {
1230
1214
  ceremonyInputData: {
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/actions
3
- * @version 1.0.5
2
+ * @module @devtion/actions
3
+ * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -19,7 +19,6 @@ var crypto = require('crypto');
19
19
  var blake = require('blakejs');
20
20
  var ffjavascript = require('ffjavascript');
21
21
  var winston = require('winston');
22
- var clientS3 = require('@aws-sdk/client-s3');
23
22
  var stream = require('stream');
24
23
  var util = require('util');
25
24
  var app = require('firebase/app');
@@ -1093,42 +1092,26 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1093
1092
  circuitArtifacts.push({
1094
1093
  artifacts: artifacts
1095
1094
  });
1096
- const r1csPath = artifacts.r1csStoragePath;
1097
- const wasmPath = artifacts.wasmStoragePath;
1098
1095
  // where we storing the r1cs downloaded
1099
1096
  const localR1csPath = `./${circuitData.name}.r1cs`;
1100
- // check that the artifacts exist in S3
1101
- // we don't need any privileges to download this
1102
- // just the correct region
1103
- const s3 = new clientS3.S3Client({ region: artifacts.region });
1104
- try {
1105
- await s3.send(new clientS3.HeadObjectCommand({
1106
- Bucket: artifacts.bucket,
1107
- Key: r1csPath
1108
- }));
1109
- }
1110
- catch (error) {
1111
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1112
- }
1113
- try {
1114
- await s3.send(new clientS3.HeadObjectCommand({
1115
- Bucket: artifacts.bucket,
1116
- Key: wasmPath
1117
- }));
1118
- }
1119
- catch (error) {
1120
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1121
- }
1097
+ // where we storing the wasm downloaded
1098
+ const localWasmPath = `./${circuitData.name}.wasm`;
1122
1099
  // download the r1cs to extract the metadata
1123
- const command = new clientS3.GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1124
- const response = await s3.send(command);
1125
1100
  const streamPipeline = util.promisify(stream.pipeline);
1126
- if (response.$metadata.httpStatusCode !== 200)
1127
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.");
1128
- if (response.Body instanceof stream.Readable)
1129
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1101
+ // Make the call.
1102
+ const responseR1CS = await fetch(artifacts.r1csStoragePath);
1103
+ // Handle errors.
1104
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
1105
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1106
+ await streamPipeline(responseR1CS.body, fs.createWriteStream(localR1csPath));
1107
+ // Write the file locally
1130
1108
  // extract the metadata from the r1cs
1131
1109
  const metadata = getR1CSInfo(localR1csPath);
1110
+ // download wasm too to ensure it's available
1111
+ const responseWASM = await fetch(artifacts.wasmStoragePath);
1112
+ if (!responseWASM.ok && responseWASM.status !== 200)
1113
+ throw new Error(`There was an error while trying to download the WASM file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1114
+ await streamPipeline(responseWASM.body, fs.createWriteStream(localWasmPath));
1132
1115
  // validate that the circuit hash and template links are valid
1133
1116
  const template = circuitData.template;
1134
1117
  const URLMatch = template.source.match(urlPattern);
@@ -1224,9 +1207,10 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1224
1207
  };
1225
1208
  }
1226
1209
  circuits.push(circuit);
1227
- // remove the local r1cs download (if used for verifying the config only vs setup)
1210
+ // remove the local r1cs and wasm downloads (if used for verifying the config only vs setup)
1228
1211
  if (cleanup)
1229
1212
  fs.unlinkSync(localR1csPath);
1213
+ fs.unlinkSync(localWasmPath);
1230
1214
  }
1231
1215
  const setupData = {
1232
1216
  ceremonyInputData: {
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../../src/helpers/security.ts"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,cACd,MAAM,4BACS,MAAM,4BACN,MAAM,8BACJ,MAAM,KACnC,QAAQ,GAAG,CAsBb,CAAA"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../../src/helpers/security.ts"],"names":[],"mappings":"AA4BA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,cACd,MAAM,4BACS,MAAM,4BACN,MAAM,8BACJ,MAAM,KACnC,QAAQ,GAAG,CAsBb,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/helpers/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAW,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAErC,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EACH,eAAe,EACf,YAAY,EAGZ,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EAGpB,MAAM,gBAAgB,CAAA;AAmBvB;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAgB,MAAM,YAAW,OAAO,KAAW,QAAQ,iBAAiB,CAoOzG,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,iBAAkB,MAAM,UAAU,MAAM,KAAG,MAgBtF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,gBAAiB,MAAM,WAAW,MAAM,WAUxF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,MASlD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,wBAAyB,MAAM,KAAG,MACH,CAAA;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,MAEsC,CAAA;AAElF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,cAAsE,CAAA;A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CAAC,cACzB,MAAM,iBACH,MAAM,4BACK,MAAM,YAAY,CAAC,yBACtB,MAAM,gBACf,MAAM,gBACN,OAAO,KACtB,QAAQ,MAAM,CA2DhB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,aAAc,MAAM,UAAS,QAAQ,aAAa,CAAC,OAAO,CAAC,KAAY,MAQvG,CAAA;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,kBACX,MAAM,UACb,MAAM,UACN,MAAM,YACJ,YAAY,KACvB,MAYF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,sBAAuB,MAAM,KAAG,eA0IvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,KAAG,MAA0D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtion/actions",
3
- "version": "0.0.0-eb3bb7d",
3
+ "version": "0.0.0-f3ea056",
4
4
  "description": "A set of actions and helpers for CLI commands",
5
5
  "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
6
6
  "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "d21d2002b8d020289595aaea83be0202d28486cb"
86
+ "gitHead": "7abc6a0bd781de4a52c12f6b557f27a579291a41"
87
87
  }
@@ -1,5 +1,4 @@
1
1
  import fetch from "@adobe/node-fetch-retry"
2
-
3
2
  /**
4
3
  * This function queries the GitHub API to fetch users statistics
5
4
  * @param user {string} the user uid
@@ -12,7 +11,6 @@ const getGitHubStats = async (user: string): Promise<any> => {
12
11
  Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN!}`
13
12
  }
14
13
  })
15
-
16
14
  if (response.status !== 200)
17
15
  throw new Error("It was not possible to retrieve the user's statistic. Please try again.")
18
16
 
@@ -1,8 +1,8 @@
1
1
  import { Firestore } from "firebase/firestore"
2
- import fs, { ReadPosition } from "fs"
2
+ import fs, { ReadPosition, createWriteStream } from "fs"
3
3
  import { utils as ffUtils } from "ffjavascript"
4
4
  import winston, { Logger } from "winston"
5
- import { S3Client, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3"
5
+ import fetch from "@adobe/node-fetch-retry"
6
6
  import {
7
7
  CircuitMetadata,
8
8
  Contribution,
@@ -29,7 +29,7 @@ import {
29
29
  getZkeyStorageFilePath
30
30
  } from "./storage"
31
31
  import { blake512FromPath } from "./crypto"
32
- import { Readable, pipeline } from "stream"
32
+ import { pipeline } from "stream"
33
33
  import { promisify } from "util"
34
34
 
35
35
  /**
@@ -87,49 +87,34 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
87
87
  circuitArtifacts.push({
88
88
  artifacts: artifacts
89
89
  })
90
- const r1csPath = artifacts.r1csStoragePath
91
- const wasmPath = artifacts.wasmStoragePath
92
90
 
93
91
  // where we storing the r1cs downloaded
94
92
  const localR1csPath = `./${circuitData.name}.r1cs`
95
-
96
- // check that the artifacts exist in S3
97
- // we don't need any privileges to download this
98
- // just the correct region
99
- const s3 = new S3Client({region: artifacts.region})
100
-
101
- try {
102
- await s3.send(new HeadObjectCommand({
103
- Bucket: artifacts.bucket,
104
- Key: r1csPath
105
- }))
106
- } catch (error: any) {
107
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`)
108
- }
109
-
110
- try {
111
- await s3.send(new HeadObjectCommand({
112
- Bucket: artifacts.bucket,
113
- Key: wasmPath
114
- }))
115
- } catch (error: any) {
116
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`)
117
- }
93
+ // where we storing the wasm downloaded
94
+ const localWasmPath = `./${circuitData.name}.wasm`
118
95
 
119
96
  // download the r1cs to extract the metadata
120
- const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath })
121
- const response = await s3.send(command)
122
97
  const streamPipeline = promisify(pipeline)
123
98
 
124
- if (response.$metadata.httpStatusCode !== 200)
125
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.")
99
+ // Make the call.
100
+ const responseR1CS = await fetch(artifacts.r1csStoragePath)
126
101
 
127
- if (response.Body instanceof Readable)
128
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath))
129
-
102
+ // Handle errors.
103
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
104
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`)
105
+
106
+ await streamPipeline(responseR1CS.body!, createWriteStream(localR1csPath))
107
+ // Write the file locally
108
+
130
109
  // extract the metadata from the r1cs
131
110
  const metadata = getR1CSInfo(localR1csPath)
132
111
 
112
+ // download wasm too to ensure it's available
113
+ const responseWASM = await fetch(artifacts.wasmStoragePath)
114
+ if (!responseWASM.ok && responseWASM.status !== 200)
115
+ throw new Error(`There was an error while trying to download the WASM file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`)
116
+ await streamPipeline(responseWASM.body!, createWriteStream(localWasmPath))
117
+
133
118
  // validate that the circuit hash and template links are valid
134
119
  const template = circuitData.template
135
120
 
@@ -244,8 +229,10 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
244
229
 
245
230
  circuits.push(circuit)
246
231
 
247
- // remove the local r1cs download (if used for verifying the config only vs setup)
248
- if (cleanup) fs.unlinkSync(localR1csPath)
232
+ // remove the local r1cs and wasm downloads (if used for verifying the config only vs setup)
233
+ if (cleanup)
234
+ fs.unlinkSync(localR1csPath)
235
+ fs.unlinkSync(localWasmPath)
249
236
  }
250
237
 
251
238
  const setupData: SetupCeremonyData = {