@autonomys/auto-dag-data 1.0.11 → 1.0.12

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.
@@ -2,6 +2,7 @@ import { AwaitIterable } from 'interface-store';
2
2
  import { EncryptionOptions } from '../metadata/index.js';
3
3
  import type { PickPartial } from '../utils/types.js';
4
4
  import { PasswordGenerationOptions } from './types.js';
5
+ export declare const crypto: globalThis.Crypto;
5
6
  export declare const ENCRYPTING_CHUNK_SIZE: number;
6
7
  export declare const getKeyFromPassword: ({ password, salt }: PasswordGenerationOptions) => Promise<CryptoKey>;
7
8
  export declare const encryptFile: (file: AwaitIterable<Buffer>, password: string, { chunkSize, algorithm }: PickPartial<EncryptionOptions, "algorithm">) => AsyncIterable<Buffer>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAuB,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAItD,eAAO,MAAM,qBAAqB,QAAc,CAAA;AAMhD,eAAO,MAAM,kBAAkB,uBAA8B,yBAAyB,uBAyBrF,CAAA;AAED,eAAO,MAAM,WAAW,SAChB,aAAa,CAAC,MAAM,CAAC,YACjB,MAAM,4BACkC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,KAC5F,aAAa,CAAC,MAAM,CAetB,CAAA;AAED,eAAO,MAAM,WAAW,SAChB,aAAa,CAAC,MAAM,CAAC,YACjB,MAAM,4BACiC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,KAC3F,aAAa,CAAC,MAAM,CA+BtB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAuB,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAEtD,eAAO,MAAM,MAAM,mBAA+D,CAAA;AAElF,eAAO,MAAM,qBAAqB,QAAc,CAAA;AAMhD,eAAO,MAAM,kBAAkB,uBAA8B,yBAAyB,uBAyBrF,CAAA;AAED,eAAO,MAAM,WAAW,SAChB,aAAa,CAAC,MAAM,CAAC,YACjB,MAAM,4BACkC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,KAC5F,aAAa,CAAC,MAAM,CAetB,CAAA;AAED,eAAO,MAAM,WAAW,SAChB,aAAa,CAAC,MAAM,CAAC,YACjB,MAAM,4BACiC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,KAC3F,aAAa,CAAC,MAAM,CA+BtB,CAAA"}
@@ -28,10 +28,9 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
28
28
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
29
29
  };
30
30
  import { Crypto } from '@peculiar/webcrypto';
31
- import { randomBytes } from 'crypto';
32
31
  import { EncryptionAlgorithm } from '../metadata/index.js';
33
32
  import { asyncByChunk } from '../utils/async.js';
34
- const crypto = new Crypto();
33
+ export const crypto = typeof window === 'undefined' ? new Crypto() : window.crypto;
35
34
  export const ENCRYPTING_CHUNK_SIZE = 1024 * 1024;
36
35
  const IV_SIZE = 16;
37
36
  const TAG_SIZE = 16;
@@ -54,7 +53,7 @@ export const encryptFile = function (file_1, password_1, _a) {
54
53
  if (algorithm !== EncryptionAlgorithm.AES_256_GCM) {
55
54
  throw new Error('Unsupported encryption algorithm');
56
55
  }
57
- const salt = randomBytes(SALT_SIZE);
56
+ const salt = crypto.getRandomValues(Buffer.alloc(SALT_SIZE));
58
57
  const key = yield __await(getKeyFromPassword({ password, salt }));
59
58
  yield yield __await(salt);
60
59
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@autonomys/auto-dag-data",
3
3
  "packageManager": "yarn@4.1.1",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "repository": {
@@ -48,5 +48,5 @@
48
48
  "protons": "^7.6.0",
49
49
  "protons-runtime": "^5.5.0"
50
50
  },
51
- "gitHead": "da525e758bc0dadd3e79bd369f18b10a39d2cf84"
51
+ "gitHead": "aead187672e1a487b54d0f6b973b6a546e2f7e99"
52
52
  }
@@ -1,12 +1,11 @@
1
1
  import { Crypto } from '@peculiar/webcrypto'
2
- import { randomBytes } from 'crypto'
3
2
  import { AwaitIterable } from 'interface-store'
4
3
  import { EncryptionAlgorithm, EncryptionOptions } from '../metadata/index.js'
5
4
  import { asyncByChunk } from '../utils/async.js'
6
5
  import type { PickPartial } from '../utils/types.js'
7
6
  import { PasswordGenerationOptions } from './types.js'
8
7
 
9
- const crypto = new Crypto()
8
+ export const crypto = typeof window === 'undefined' ? new Crypto() : window.crypto
10
9
 
11
10
  export const ENCRYPTING_CHUNK_SIZE = 1024 * 1024
12
11
  const IV_SIZE = 16
@@ -50,7 +49,7 @@ export const encryptFile = async function* (
50
49
  throw new Error('Unsupported encryption algorithm')
51
50
  }
52
51
 
53
- const salt = randomBytes(SALT_SIZE)
52
+ const salt = crypto.getRandomValues(Buffer.alloc(SALT_SIZE))
54
53
  const key = await getKeyFromPassword({ password, salt })
55
54
 
56
55
  yield salt