@ethernity-cloud/sdk-js 1.1.0
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/LICENSE +661 -0
- package/README.md +185 -0
- package/build.js +22 -0
- package/init.js +301 -0
- package/nodenithy/build/las/Dockerfile +5 -0
- package/nodenithy/build/securelock/Dockerfile.tmpl +65 -0
- package/nodenithy/build/securelock/scripts/binary-fs-build.sh +28 -0
- package/nodenithy/build/securelock/src/.env +3 -0
- package/nodenithy/build/securelock/src/etny_crypto.js +201 -0
- package/nodenithy/build/securelock/src/etny_exec.js +65 -0
- package/nodenithy/build/securelock/src/image_registry_abi.js +808 -0
- package/nodenithy/build/securelock/src/models.js +261 -0
- package/nodenithy/build/securelock/src/package.json +40 -0
- package/nodenithy/build/securelock/src/pox_abi.js +1491 -0
- package/nodenithy/build/securelock/src/securelock.js.tmpl +421 -0
- package/nodenithy/build/securelock/src/swift_stream_service.js +147 -0
- package/nodenithy/build/securelock/src/task_status.js +15 -0
- package/nodenithy/build/securelock/src/wallet.js +29 -0
- package/nodenithy/build/squash/Dockerfile +7 -0
- package/nodenithy/build/trustedzone/Dockerfile.tmpl +57 -0
- package/nodenithy/build/trustedzone/scripts/binary-fs-build.sh +22 -0
- package/nodenithy/build/trustedzone/src/.env +3 -0
- package/nodenithy/build/trustedzone/src/etny_crypto.js +202 -0
- package/nodenithy/build/trustedzone/src/etny_exec.js +54 -0
- package/nodenithy/build/trustedzone/src/image_registry_abi.js +808 -0
- package/nodenithy/build/trustedzone/src/models.js +261 -0
- package/nodenithy/build/trustedzone/src/package.json +40 -0
- package/nodenithy/build/trustedzone/src/pox_abi.js +1491 -0
- package/nodenithy/build/trustedzone/src/swift_stream_service.js +147 -0
- package/nodenithy/build/trustedzone/src/task_status.js +15 -0
- package/nodenithy/build/trustedzone/src/test.js +44 -0
- package/nodenithy/build/trustedzone/src/trustedzone.js.tmpl +508 -0
- package/nodenithy/build/trustedzone/src/wallet.js +28 -0
- package/nodenithy/build/validator/Dockerfile +58 -0
- package/nodenithy/build/validator/package-lock.json +6 -0
- package/nodenithy/build/validator/scripts/binary-fs-build.sh +19 -0
- package/nodenithy/build/validator/src/.env +3 -0
- package/nodenithy/build/validator/src/cert.pem +5 -0
- package/nodenithy/build/validator/src/etny_crypto.js +204 -0
- package/nodenithy/build/validator/src/etny_exec.js +52 -0
- package/nodenithy/build/validator/src/image_registry_abi.js +808 -0
- package/nodenithy/build/validator/src/key.pem +6 -0
- package/nodenithy/build/validator/src/models.js +261 -0
- package/nodenithy/build/validator/src/package-lock.json +2498 -0
- package/nodenithy/build/validator/src/package.json +40 -0
- package/nodenithy/build/validator/src/pox_abi.js +1491 -0
- package/nodenithy/build/validator/src/swift_stream_service.js +147 -0
- package/nodenithy/build/validator/src/task_status.js +15 -0
- package/nodenithy/build/validator/src/test.js +44 -0
- package/nodenithy/build/validator/src/trustedzone.js +613 -0
- package/nodenithy/build/validator/src/validator_abi.js +834 -0
- package/nodenithy/build/validator/src/wallet.js +28 -0
- package/nodenithy/build.js +184 -0
- package/nodenithy/build.mjs +179 -0
- package/nodenithy/build.sh +161 -0
- package/nodenithy/ipfs.js +135 -0
- package/nodenithy/ipfs.mjs +551 -0
- package/nodenithy/public/favicon.ico +0 -0
- package/nodenithy/public/index.html +43 -0
- package/nodenithy/public/logo192.png +0 -0
- package/nodenithy/public/logo512.png +0 -0
- package/nodenithy/public/manifest.json +25 -0
- package/nodenithy/public/robots.txt +3 -0
- package/nodenithy/run/__pycache__/swift_stream_service.cpython-312.pyc +0 -0
- package/nodenithy/run/app/input.txt +4 -0
- package/nodenithy/run/app/payload.js +4 -0
- package/nodenithy/run/docker-compose-final.yml.tmpl +65 -0
- package/nodenithy/run/docker-compose-swift-stream.yml +17 -0
- package/nodenithy/run/docker-compose.yml.tmpl +76 -0
- package/nodenithy/run/etny-securelock-test.yaml.tpl +46 -0
- package/nodenithy/run/etny-trustedzone-test.yaml.tpl +45 -0
- package/nodenithy/run/git.sh +22 -0
- package/nodenithy/run/image_registry.abi +1 -0
- package/nodenithy/run/image_registry.js +372 -0
- package/nodenithy/run/image_registry.py +327 -0
- package/nodenithy/run/image_registry_runner.py +71 -0
- package/nodenithy/run/ipfs.sh +58 -0
- package/nodenithy/run/ipfs_pre.sh +75 -0
- package/nodenithy/run/public_key_service.js +90 -0
- package/nodenithy/run/public_key_service.py +107 -0
- package/nodenithy/run/swift_stream_service.py +212 -0
- package/nodenithy/run/swiftstream.py +37 -0
- package/nodenithy/run/swiftstream1.py +27 -0
- package/nodenithy/run.js +538 -0
- package/nodenithy/run.sh +277 -0
- package/nodenithy/scripts/build-ipfs-upload.sh +23 -0
- package/nodenithy/scripts/build.sh +40 -0
- package/nodenithy/scripts/ipfs-daemon.sh +7 -0
- package/nodenithy/scripts/run.sh +50 -0
- package/nodenithy/src/App.css +57 -0
- package/nodenithy/src/ec_helloworld_example.js +64 -0
- package/nodenithy/src/index.css +13 -0
- package/nodenithy/src/index.js +17 -0
- package/nodenithy/src/preStart.js +45 -0
- package/nodenithy/src/preStart.mjs +57 -0
- package/nodenithy/src/reportWebVitals.js +13 -0
- package/nodenithy/src/serverless/backend.js +5 -0
- package/package.json +48 -0
- package/postinstall.js +34 -0
- package/publish.js +126 -0
- package/pynithy/build/docker-compose.yml +68 -0
- package/pynithy/build/las/Dockerfile +11 -0
- package/pynithy/build/las/src/etny_entrypoint.sh +6 -0
- package/pynithy/build/las/src/las_entrypoint.sh +26 -0
- package/pynithy/build/scripts/binary-fs-build.sh +28 -0
- package/pynithy/build/securelock/Dockerfile.tmpl +78 -0
- package/pynithy/build/securelock/scripts/binary-fs-build.sh +41 -0
- package/pynithy/build/securelock/src/app/.env +5 -0
- package/pynithy/build/securelock/src/app/cert1-ca1-clean.crt +10 -0
- package/pynithy/build/securelock/src/app/cert1-ca1-clean.key +6 -0
- package/pynithy/build/securelock/src/app/enclave_pub_cert.pem +10 -0
- package/pynithy/build/securelock/src/app/input.txt +1 -0
- package/pynithy/build/securelock/src/app/payload.py +25 -0
- package/pynithy/build/securelock/src/app/public-cert-clean.pem +10 -0
- package/pynithy/build/securelock/src/app/result.txt +1 -0
- package/pynithy/build/securelock/src/app/transaction.txt +1 -0
- package/pynithy/build/securelock/src/etny_crypto.py +167 -0
- package/pynithy/build/securelock/src/etny_exec.py +79 -0
- package/pynithy/build/securelock/src/image_registry.abi +1 -0
- package/pynithy/build/securelock/src/key_generation.py +17 -0
- package/pynithy/build/securelock/src/models.py +176 -0
- package/pynithy/build/securelock/src/pox.abi +1489 -0
- package/pynithy/build/securelock/src/securelock.py.tmpl +411 -0
- package/pynithy/build/securelock/src/swift_stream_service.py +186 -0
- package/pynithy/build/trustedzone/Dockerfile.tmpl +56 -0
- package/pynithy/build/trustedzone/scripts/binary-fs-build.sh +32 -0
- package/pynithy/build/trustedzone/src/app/.env +5 -0
- package/pynithy/build/trustedzone/src/app/cert1-ca1-clean.crt +10 -0
- package/pynithy/build/trustedzone/src/app/cert1-ca1-clean.key +6 -0
- package/pynithy/build/trustedzone/src/app/enclave_pub_cert.pem +10 -0
- package/pynithy/build/trustedzone/src/app/input.txt +1 -0
- package/pynithy/build/trustedzone/src/app/payload.py +25 -0
- package/pynithy/build/trustedzone/src/app/public-cert-clean.pem +10 -0
- package/pynithy/build/trustedzone/src/app/result.txt +1 -0
- package/pynithy/build/trustedzone/src/app/securelock.crt +10 -0
- package/pynithy/build/trustedzone/src/app/transaction.txt +1 -0
- package/pynithy/build/trustedzone/src/app/trustedzone.crt +10 -0
- package/pynithy/build/trustedzone/src/etny_crypto.py +188 -0
- package/pynithy/build/trustedzone/src/etny_exec.py +56 -0
- package/pynithy/build/trustedzone/src/formatter.py +42 -0
- package/pynithy/build/trustedzone/src/image_registry.abi +1 -0
- package/pynithy/build/trustedzone/src/key_generation.py +17 -0
- package/pynithy/build/trustedzone/src/models.py +176 -0
- package/pynithy/build/trustedzone/src/pox.abi +1489 -0
- package/pynithy/build/trustedzone/src/swift_stream_service.py +186 -0
- package/pynithy/build/trustedzone/src/trustedzone.py.tmpl +460 -0
- package/pynithy/build.mjs +179 -0
- package/pynithy/docker-compose.yml +0 -0
- package/pynithy/ipfs.mjs +244 -0
- package/pynithy/public/favicon.ico +0 -0
- package/pynithy/public/index.html +43 -0
- package/pynithy/public/logo192.png +0 -0
- package/pynithy/public/logo512.png +0 -0
- package/pynithy/public/manifest.json +25 -0
- package/pynithy/public/robots.txt +3 -0
- package/pynithy/run/certs/cert.pem +31 -0
- package/pynithy/run/certs/challenge.crt +10 -0
- package/pynithy/run/certs/key.pem +52 -0
- package/pynithy/run/docker-compose-final.yml +59 -0
- package/pynithy/run/docker-compose-final.yml.tmpl +59 -0
- package/pynithy/run/docker-compose-swift-stream.yml +27 -0
- package/pynithy/run/docker-compose-swift-stream.yml.tmpl +27 -0
- package/pynithy/run/docker-compose.yml +55 -0
- package/pynithy/run/docker-compose.yml.tmpl +55 -0
- package/pynithy/run/etny-pynity-test.yaml.tpl +46 -0
- package/pynithy/run/etny-securelock-test.yaml.tpl +46 -0
- package/pynithy/run/etny-trustedzone-test.yaml.tpl +46 -0
- package/pynithy/run/git.sh +22 -0
- package/pynithy/run/image_registry.abi +1 -0
- package/pynithy/run/image_registry.js +372 -0
- package/pynithy/run/image_registry.py +139 -0
- package/pynithy/run/image_registry_runner.py +45 -0
- package/pynithy/run/ipfs.sh +89 -0
- package/pynithy/run/public_key_service.js +90 -0
- package/pynithy/run/swiftstream.py +28 -0
- package/pynithy/run.js +538 -0
- package/pynithy/src/App.css +57 -0
- package/pynithy/src/ec_helloworld_example.js +64 -0
- package/pynithy/src/index.css +13 -0
- package/pynithy/src/index.js +17 -0
- package/pynithy/src/preStart.mjs +57 -0
- package/pynithy/src/reportWebVitals.js +13 -0
- package/pynithy/src/serverless/__init__.py +0 -0
- package/pynithy/src/serverless/backend.py +2 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const Minio = require('minio');
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
class SwiftStreamService {
|
|
4
|
+
constructor(endpoint, port, accessKey, secretKey) {
|
|
5
|
+
this.client = new Minio.Client({
|
|
6
|
+
endPoint: endpoint,
|
|
7
|
+
port: port,
|
|
8
|
+
accessKey: accessKey,
|
|
9
|
+
secretKey: secretKey,
|
|
10
|
+
useSSL: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
createBucket(bucketName) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
this.client.bucketExists(bucketName, (err, exists) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
return reject(err);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!exists) {
|
|
22
|
+
this.client.makeBucket(bucketName, (err) => {
|
|
23
|
+
if (err) {
|
|
24
|
+
reject(err);
|
|
25
|
+
} else {
|
|
26
|
+
resolve(`Bucket ${bucketName} successfully created!`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
resolve(`Bucket ${bucketName} already exists!`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getFileContentBytes(bucketName, fileName) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const chunks = [];
|
|
39
|
+
this.client.getObject(bucketName, fileName, (err, dataStream) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
return reject(err);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
dataStream.on('data', (chunk) => {
|
|
45
|
+
chunks.push(chunk);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
dataStream.on('end', () => {
|
|
49
|
+
const fileData = Buffer.concat(chunks);
|
|
50
|
+
resolve(fileData);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
dataStream.on('error', (err) => {
|
|
54
|
+
reject(err);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getFileContent(bucketName, fileName) {
|
|
61
|
+
return this.getFileContentBytes(bucketName, fileName)
|
|
62
|
+
.then((fileData) => {
|
|
63
|
+
return fileData.toString('utf-8');
|
|
64
|
+
})
|
|
65
|
+
.catch((err) => {
|
|
66
|
+
throw err;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
putFileContent(bucketName, objectName, objectPath, objectData = null) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
this.client.bucketExists(bucketName, (err, exists) => {
|
|
73
|
+
if (err) {
|
|
74
|
+
return reject(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!exists) {
|
|
78
|
+
this.createBucket(bucketName)
|
|
79
|
+
.then(() => {
|
|
80
|
+
if (objectData) {
|
|
81
|
+
this.client.putObject(bucketName, objectName, objectData, (err) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
reject(err);
|
|
84
|
+
} else {
|
|
85
|
+
resolve(`${objectName} is successfully uploaded to bucket ${bucketName}.`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
const fileStat = fs.statSync(objectPath);
|
|
90
|
+
const fileStream = fs.createReadStream(objectPath);
|
|
91
|
+
|
|
92
|
+
this.client.putObject(bucketName, objectName, fileStream, fileStat.size, (err) => {
|
|
93
|
+
if (err) {
|
|
94
|
+
reject(err);
|
|
95
|
+
} else {
|
|
96
|
+
resolve(`${objectName} is successfully uploaded to bucket ${bucketName}.`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.catch((err) => {
|
|
102
|
+
reject(err);
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
if (objectData) {
|
|
106
|
+
this.client.putObject(bucketName, objectName, objectData, (err) => {
|
|
107
|
+
if (err) {
|
|
108
|
+
reject(err);
|
|
109
|
+
} else {
|
|
110
|
+
resolve(`${objectName} is successfully uploaded to bucket ${bucketName}.`);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
const fileStat = fs.statSync(objectPath);
|
|
115
|
+
const fileStream = fs.createReadStream(objectPath);
|
|
116
|
+
|
|
117
|
+
this.client.putObject(bucketName, objectName, fileStream, fileStat.size, (err) => {
|
|
118
|
+
if (err) {
|
|
119
|
+
reject(err);
|
|
120
|
+
} else {
|
|
121
|
+
resolve(`${objectName} is successfully uploaded to bucket ${bucketName}.`);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isObjectInBucket(bucketName, objectName) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
this.client.statObject(bucketName, objectName, (err, stat) => {
|
|
133
|
+
if (err && err.code === 'NotFound') {
|
|
134
|
+
resolve([stat, false]);
|
|
135
|
+
} else if (err) {
|
|
136
|
+
reject(err);
|
|
137
|
+
} else {
|
|
138
|
+
// resolve(`Object ${objectName} exists inside ${bucketName}.`);
|
|
139
|
+
resolve([stat, true]);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = SwiftStreamService;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class TaskStatus {
|
|
2
|
+
static SUCCESS = 0;
|
|
3
|
+
static SYSTEM_ERROR = 1;
|
|
4
|
+
static KEY_ERROR = 2;
|
|
5
|
+
static SYNTAX_WARNING = 3;
|
|
6
|
+
static BASE_EXCEPTION = 4;
|
|
7
|
+
static PAYLOAD_NOT_DEFINED = 5;
|
|
8
|
+
static PAYLOAD_CHECKSUM_ERROR = 6;
|
|
9
|
+
static INPUT_CHECKSUM_ERROR = 7;
|
|
10
|
+
static EVAL_ERROR = 8;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
TaskStatus,
|
|
15
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// const tt = require("./etny_crypto");
|
|
2
|
+
//
|
|
3
|
+
// const p = '4c351ff11a73151f3de1fc686c8bdf63c07b28cb814797d0b1dd361d9fea4008';
|
|
4
|
+
//
|
|
5
|
+
// const b = tt.encryptWithPublicKey(p, 'hello');
|
|
6
|
+
// console.log(b.toString('utf8'));
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const SwiftStreamService = require("./swift_stream_service");
|
|
12
|
+
const etny_crypto = require("./etny_crypto");
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
|
|
15
|
+
(async () => {
|
|
16
|
+
try {
|
|
17
|
+
console.log('################################');
|
|
18
|
+
console.log('Initializing SwiftStream Service...');
|
|
19
|
+
const swiftStreamClient = new SwiftStreamService(
|
|
20
|
+
"localhost",
|
|
21
|
+
9000,
|
|
22
|
+
"swiftstreamadmin",
|
|
23
|
+
"swiftstreamadmin");
|
|
24
|
+
console.log('SwiftStream Service started.');
|
|
25
|
+
console.log('################################');
|
|
26
|
+
|
|
27
|
+
const p = '4c351ff11a73151f3de1fc686c8bdf63c07b28cb814797d0b1dd361d9fea4008';
|
|
28
|
+
const message = '3';
|
|
29
|
+
const encrypted = etny_crypto.encryptWithPublicKey(p, message);
|
|
30
|
+
// console.log('Encrypted result:', encrypted.toString('utf8'));
|
|
31
|
+
console.log('Encrypted result:', encrypted.toString('hex'));
|
|
32
|
+
// console.log('Encrypted result:', Buffer.from(encrypted, 'hex'));
|
|
33
|
+
// await fs.promises.writeFile('test.txt', Buffer.from(encrypted, 'hex'));
|
|
34
|
+
await swiftStreamClient.putFileContent('etny-nodenithy-v2', 'result11.txt', 'test.txt', encrypted.toString('hex'));
|
|
35
|
+
|
|
36
|
+
const t = await swiftStreamClient.getFileContent('etny-nodenithy-v2', 'result11.txt');
|
|
37
|
+
console.log(t);
|
|
38
|
+
// await swiftStreamClient.putFileContent('etny-nodenithy-v2', 'result1.txt', '/result', Buffer.from(message, 'utf8'));
|
|
39
|
+
// await swiftStreamClient.putFileContent('etny-nodenithy-v2', 'result2.txt', '/result', Buffer.from(message, 'utf8'));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.log(e);
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
|