@dxos/crypto 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/crypto",
3
- "version": "0.8.4-main.f9ba587",
3
+ "version": "0.8.4-main.fd6878d",
4
4
  "description": "Basic cross-platform crypto utils.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,20 +10,23 @@
10
10
  "type": "module",
11
11
  "imports": {
12
12
  "#hypercore-crypto": {
13
- "workerd": "./hypercore-crypto-stub.mjs",
13
+ "workerd": "./vendor/hypercore-crypto-stub.mjs",
14
14
  "default": "hypercore-crypto"
15
+ },
16
+ "#subtle": {
17
+ "types": "./vendor/subtle.d.ts",
18
+ "node": "./vendor/subtle-node.mjs",
19
+ "browser": "./vendor/subtle-browser.mjs"
15
20
  }
16
21
  },
17
22
  "exports": {
18
23
  ".": {
24
+ "source": "./src/index.ts",
19
25
  "types": "./dist/types/src/index.d.ts",
20
26
  "browser": "./dist/lib/browser/index.mjs",
21
27
  "node": "./dist/lib/node-esm/index.mjs"
22
28
  }
23
29
  },
24
- "browser": {
25
- "./src/subtle.ts": "./src/browser/subtle.ts"
26
- },
27
30
  "types": "dist/types/src/index.d.ts",
28
31
  "typesVersions": {
29
32
  "*": {}
@@ -31,13 +34,13 @@
31
34
  "files": [
32
35
  "dist",
33
36
  "src",
34
- "./hypercore-crypto-stub.mjs"
37
+ "vendor"
35
38
  ],
36
39
  "dependencies": {
37
40
  "hypercore-crypto": "^2.3.0",
38
- "@dxos/invariant": "0.8.4-main.f9ba587",
39
- "@dxos/keys": "0.8.4-main.f9ba587",
40
- "@dxos/node-std": "0.8.4-main.f9ba587"
41
+ "@dxos/keys": "0.8.4-main.fd6878d",
42
+ "@dxos/node-std": "0.8.4-main.fd6878d",
43
+ "@dxos/invariant": "0.8.4-main.fd6878d"
41
44
  },
42
45
  "devDependencies": {},
43
46
  "publishConfig": {
package/src/index.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
+ export * from '#subtle';
5
6
  export * from './keys';
6
- export * from './signer';
7
- export * from './subtle';
7
+ export type * from './signer';
8
+ export * from './uuid';
8
9
  export * from './validator';
9
10
  export * from './verify';
10
- export * from './uuid';
package/src/keys.test.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { describe, test, expect } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { createId, createKeyPair, randomBytes, sign, verify } from './keys';
8
8
 
package/src/keys.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { invariant } from '@dxos/invariant';
6
- import { type KeyPair, PublicKey, type PublicKeyLike, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH } from '@dxos/keys';
6
+ import { type KeyPair, PUBLIC_KEY_LENGTH, PublicKey, type PublicKeyLike, SECRET_KEY_LENGTH } from '@dxos/keys';
7
7
 
8
8
  import crypto from '#hypercore-crypto';
9
9
 
package/src/uuid.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { webcrypto } from './subtle';
5
+ import { webcrypto } from '#subtle';
6
6
 
7
7
  export const randomUUID = (): string => {
8
8
  return webcrypto.randomUUID();
package/src/verify.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { type PublicKey } from '@dxos/keys';
6
6
 
7
- import { subtleCrypto } from './subtle';
7
+ import { subtleCrypto } from '#subtle';
8
8
 
9
9
  /**
10
10
  * Verify a signature with the given key.
@@ -18,7 +18,9 @@ export const verifySignature = async (
18
18
  let publicKey!: CryptoKey;
19
19
 
20
20
  try {
21
- publicKey = await subtleCrypto.importKey('raw', key.asUint8Array(), algorithm, true, ['verify']);
21
+ publicKey = await subtleCrypto.importKey('raw', key.asUint8Array() as Uint8Array<ArrayBuffer>, algorithm, true, [
22
+ 'verify',
23
+ ]);
22
24
  } catch {
23
25
  return false;
24
26
  }
@@ -29,7 +31,7 @@ export const verifySignature = async (
29
31
  hash: 'SHA-256',
30
32
  },
31
33
  publicKey,
32
- signature,
33
- message,
34
+ signature as Uint8Array<ArrayBuffer>,
35
+ message as Uint8Array<ArrayBuffer>,
34
36
  );
35
37
  };
@@ -0,0 +1,3 @@
1
+ export const subtleCrypto: SubtleCrypto;
2
+
3
+ export const webcrypto: Crypto;
@@ -1,3 +0,0 @@
1
- export declare const subtleCrypto: SubtleCrypto;
2
- export declare const webcrypto: Crypto;
3
- //# sourceMappingURL=subtle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../../../src/browser/subtle.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,cAAgB,CAAC;AAE1C,eAAO,MAAM,SAAS,QAAS,CAAC"}
@@ -1,4 +0,0 @@
1
- import * as nodeCrypto from 'node:crypto';
2
- export declare const subtleCrypto: nodeCrypto.webcrypto.SubtleCrypto;
3
- export declare const webcrypto: nodeCrypto.webcrypto.Crypto;
4
- //# sourceMappingURL=subtle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../../src/subtle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAE1C,eAAO,MAAM,YAAY,mCAA8B,CAAC;AAExD,eAAO,MAAM,SAAS,6BAAuB,CAAC"}
File without changes