@ethernity-cloud/sdk-js 1.5.18 → 1.5.20

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.
@@ -35,11 +35,22 @@ function sleep(ms) { return new Promise((r) => setTimeout(r, ms)); }
35
35
  enclave pushes for the trustedzone is SIGNED with its identity key, so the
36
36
  trustedzone authors metadata rows only from verified securelock material;
37
37
  everything read from the trustedzone is verified against the trustedzone's
38
- registry certificate before it is trusted. */
38
+ registry certificate before it is trusted. Each signature covers
39
+ "<challenge>:<order_id>:<object>:" ahead of the data -- the task binding
40
+ the trustedzone forwarded in task.securelock, extended with the object's
41
+ own name -- so the trustedzone can refuse a session object captured from
42
+ another order, another run, or another sequence position. Without a
43
+ binding (older trustedzone) the bare data is signed, which that trustedzone
44
+ verifies. */
45
+
46
+ function sessionBinding(app, baseName) {
47
+ return app.task_binding
48
+ ? `${app.task_binding.challenge}:${app.task_binding.order_id}:${baseName}:` : '';
49
+ }
39
50
 
40
51
  async function pushSignedForTrustedzone(app, data, baseName) {
41
52
  await app.encryptFileAndPushToSwiftStream(data, baseName);
42
- const sigHex = etny_crypto.signData(app.privateKeyMaterial(), data);
53
+ const sigHex = etny_crypto.signData(app.privateKeyMaterial(), sessionBinding(app, baseName) + data);
43
54
  await app.encryptFileAndPushToSwiftStream(sigHex, baseName + '.sig');
44
55
  }
45
56
 
@@ -515,7 +515,23 @@ class EtnySecureLock {
515
515
  // input carries no checksum (has_checksum === false) and is skipped. Kept
516
516
  // identical across securelock / trustedzone / validator so all three agree.
517
517
  async validateClientPayload(payload_data, input_data) {
518
- await this.getDORequestMetadata();
518
+ // The order metadata comes from the chain; a transient RPC failure
519
+ // must end in a signed failure result the trustedzone can hand over,
520
+ // not in a task that produces nothing until the trustedzone times out.
521
+ const maxRetries = 5;
522
+ for (let attempt = 1; ; attempt++) {
523
+ try {
524
+ await this.getDORequestMetadata();
525
+ break;
526
+ } catch (e) {
527
+ if (attempt === maxRetries) {
528
+ this.task_code = TaskStatus.SYSTEM_ERROR;
529
+ this.task_result = `Failed to fetch metadata after ${maxRetries} attempts: ${e && e.message ? e.message : e}`;
530
+ this.is_valid_client_data = false;
531
+ return;
532
+ }
533
+ }
534
+ }
519
535
 
520
536
  const pmeta = this._metadata.payload_metadata_obj;
521
537
  if (pmeta.has_checksum) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethernity-cloud/sdk-js",
3
- "version": "1.5.18",
3
+ "version": "1.5.20",
4
4
  "description": "A package to run ethernity cloud build scripts",
5
5
  "scripts": {
6
6
  "ecld-build": "cross-env node ./node_modules/@ethernity-cloud/sdk-js/build.js",