@devtion/actions 0.0.0-101d43f → 0.0.0-36caea1

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,5 +1,5 @@
1
1
  /**
2
- * @module @p0tion/actions
2
+ * @module @devtion/actions
3
3
  * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
@@ -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, 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';
@@ -1095,30 +1094,22 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1095
1094
  const localR1csPath = `./${circuitData.name}.r1cs`;
1096
1095
  // where we storing the wasm downloaded
1097
1096
  const localWasmPath = `./${circuitData.name}.wasm`;
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({
1102
- region: artifacts.region,
1103
- credentials: undefined
1104
- });
1105
1097
  // download the r1cs to extract the metadata
1106
- const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1107
- const response = await s3.send(command);
1108
1098
  const streamPipeline = promisify(pipeline);
1109
- if (response.$metadata.httpStatusCode !== 200)
1099
+ // Make the call.
1100
+ const responseR1CS = await fetch(artifacts.r1csStoragePath);
1101
+ // Handle errors.
1102
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
1110
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.`);
1111
- if (response.Body instanceof Readable)
1112
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1104
+ await streamPipeline(responseR1CS.body, createWriteStream(localR1csPath));
1105
+ // Write the file locally
1113
1106
  // extract the metadata from the r1cs
1114
1107
  const metadata = getR1CSInfo(localR1csPath);
1115
1108
  // download wasm too to ensure it's available
1116
- const wasmCommand = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath });
1117
- const wasmResponse = await s3.send(wasmCommand);
1118
- if (wasmResponse.$metadata.httpStatusCode !== 200)
1119
- 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.`);
1120
- if (wasmResponse.Body instanceof Readable)
1121
- await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath));
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));
1122
1113
  // validate that the circuit hash and template links are valid
1123
1114
  const template = circuitData.template;
1124
1115
  const URLMatch = template.source.match(urlPattern);
@@ -1214,9 +1205,10 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1214
1205
  };
1215
1206
  }
1216
1207
  circuits.push(circuit);
1217
- // 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)
1218
1209
  if (cleanup)
1219
1210
  fs.unlinkSync(localR1csPath);
1211
+ fs.unlinkSync(localWasmPath);
1220
1212
  }
1221
1213
  const setupData = {
1222
1214
  ceremonyInputData: {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module @p0tion/actions
2
+ * @module @devtion/actions
3
3
  * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
@@ -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');
@@ -1097,30 +1096,22 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1097
1096
  const localR1csPath = `./${circuitData.name}.r1cs`;
1098
1097
  // where we storing the wasm downloaded
1099
1098
  const localWasmPath = `./${circuitData.name}.wasm`;
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({
1104
- region: artifacts.region,
1105
- credentials: undefined
1106
- });
1107
1099
  // download the r1cs to extract the metadata
1108
- const command = new clientS3.GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1109
- const response = await s3.send(command);
1110
1100
  const streamPipeline = util.promisify(stream.pipeline);
1111
- if (response.$metadata.httpStatusCode !== 200)
1101
+ // Make the call.
1102
+ const responseR1CS = await fetch(artifacts.r1csStoragePath);
1103
+ // Handle errors.
1104
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
1112
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.`);
1113
- if (response.Body instanceof stream.Readable)
1114
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1106
+ await streamPipeline(responseR1CS.body, fs.createWriteStream(localR1csPath));
1107
+ // Write the file locally
1115
1108
  // extract the metadata from the r1cs
1116
1109
  const metadata = getR1CSInfo(localR1csPath);
1117
1110
  // download wasm too to ensure it's available
1118
- const wasmCommand = new clientS3.GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath });
1119
- const wasmResponse = await s3.send(wasmCommand);
1120
- if (wasmResponse.$metadata.httpStatusCode !== 200)
1121
- 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.`);
1122
- if (wasmResponse.Body instanceof stream.Readable)
1123
- await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath));
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));
1124
1115
  // validate that the circuit hash and template links are valid
1125
1116
  const template = circuitData.template;
1126
1117
  const URLMatch = template.source.match(urlPattern);
@@ -1216,9 +1207,10 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1216
1207
  };
1217
1208
  }
1218
1209
  circuits.push(circuit);
1219
- // 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)
1220
1211
  if (cleanup)
1221
1212
  fs.unlinkSync(localR1csPath);
1213
+ fs.unlinkSync(localWasmPath);
1222
1214
  }
1223
1215
  const setupData = {
1224
1216
  ceremonyInputData: {
@@ -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,CA+NzG,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,WAU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AM,oBAAoB,CAAC,cACzB,MAAM,iBACH,MAAM,gBACP,OAAO,KACtB,QAAQ,MAAM,oBAAoB,CAAC,CAmCrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0CAA0C,0BAC5B,MAAM,gBACf,MAAM,gBACN,OAAO,WAImF,CAAA;AAE5G;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qCAAqC,sBAC3B,SAAS,YAClB,MAAM,oBAAoB,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-101d43f",
3
+ "version": "0.0.0-36caea1",
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": "2e6569587be6eeb1bbc2e65563eb247c100e9d66"
86
+ "gitHead": "2390beae56f741cf791760fbc5e84775e7bc7474"
87
87
  }
@@ -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
  /**
@@ -93,37 +93,27 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
93
93
  // where we storing the wasm downloaded
94
94
  const localWasmPath = `./${circuitData.name}.wasm`
95
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({
100
- region: artifacts.region,
101
- credentials: undefined
102
- })
103
-
104
96
  // download the r1cs to extract the metadata
105
- const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath })
106
- const response = await s3.send(command)
107
97
  const streamPipeline = promisify(pipeline)
108
98
 
109
- if (response.$metadata.httpStatusCode !== 200)
99
+ // Make the call.
100
+ const responseR1CS = await fetch(artifacts.r1csStoragePath)
101
+
102
+ // Handle errors.
103
+ if (!responseR1CS.ok && responseR1CS.status !== 200)
110
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.`)
111
105
 
112
- if (response.Body instanceof Readable)
113
- await streamPipeline(response.Body, fs.createWriteStream(localR1csPath))
114
-
106
+ await streamPipeline(responseR1CS.body!, createWriteStream(localR1csPath))
107
+ // Write the file locally
108
+
115
109
  // extract the metadata from the r1cs
116
110
  const metadata = getR1CSInfo(localR1csPath)
117
111
 
118
112
  // download wasm too to ensure it's available
119
- const wasmCommand = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath })
120
- const wasmResponse = await s3.send(wasmCommand)
121
-
122
- if (wasmResponse.$metadata.httpStatusCode !== 200)
123
- 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.`)
124
-
125
- if (wasmResponse.Body instanceof Readable)
126
- await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath))
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))
127
117
 
128
118
  // validate that the circuit hash and template links are valid
129
119
  const template = circuitData.template
@@ -239,8 +229,10 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
239
229
 
240
230
  circuits.push(circuit)
241
231
 
242
- // remove the local r1cs download (if used for verifying the config only vs setup)
243
- 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)
244
236
  }
245
237
 
246
238
  const setupData: SetupCeremonyData = {