@libp2p/crypto 2.0.8 → 3.0.0-06e6d235f

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.
Files changed (93) hide show
  1. package/README.md +1 -9
  2. package/dist/index.min.js +11 -11
  3. package/dist/src/aes/cipher-mode.js +1 -1
  4. package/dist/src/aes/cipher-mode.js.map +1 -1
  5. package/dist/src/aes/index.d.ts +1 -1
  6. package/dist/src/aes/index.d.ts.map +1 -1
  7. package/dist/src/aes/index.js +1 -1
  8. package/dist/src/aes/index.js.map +1 -1
  9. package/dist/src/ciphers/aes-gcm.browser.js.map +1 -1
  10. package/dist/src/ciphers/aes-gcm.js +3 -3
  11. package/dist/src/ciphers/aes-gcm.js.map +1 -1
  12. package/dist/src/keys/ecdh-browser.js +2 -2
  13. package/dist/src/keys/ecdh-browser.js.map +1 -1
  14. package/dist/src/keys/ecdh.js +1 -1
  15. package/dist/src/keys/ecdh.js.map +1 -1
  16. package/dist/src/keys/ed25519-browser.d.ts +5 -4
  17. package/dist/src/keys/ed25519-browser.d.ts.map +1 -1
  18. package/dist/src/keys/ed25519-browser.js +6 -6
  19. package/dist/src/keys/ed25519-browser.js.map +1 -1
  20. package/dist/src/keys/ed25519-class.d.ts +4 -3
  21. package/dist/src/keys/ed25519-class.d.ts.map +1 -1
  22. package/dist/src/keys/ed25519-class.js +20 -9
  23. package/dist/src/keys/ed25519-class.js.map +1 -1
  24. package/dist/src/keys/ed25519.d.ts +5 -4
  25. package/dist/src/keys/ed25519.d.ts.map +1 -1
  26. package/dist/src/keys/ed25519.js +11 -19
  27. package/dist/src/keys/ed25519.js.map +1 -1
  28. package/dist/src/keys/index.d.ts +1 -1
  29. package/dist/src/keys/index.d.ts.map +1 -1
  30. package/dist/src/keys/index.js +1 -1
  31. package/dist/src/keys/index.js.map +1 -1
  32. package/dist/src/keys/key-stretcher.js +1 -1
  33. package/dist/src/keys/key-stretcher.js.map +1 -1
  34. package/dist/src/keys/keys.js.map +1 -1
  35. package/dist/src/keys/rsa-browser.d.ts +5 -4
  36. package/dist/src/keys/rsa-browser.d.ts.map +1 -1
  37. package/dist/src/keys/rsa-browser.js +4 -4
  38. package/dist/src/keys/rsa-browser.js.map +1 -1
  39. package/dist/src/keys/rsa-class.d.ts +8 -7
  40. package/dist/src/keys/rsa-class.d.ts.map +1 -1
  41. package/dist/src/keys/rsa-class.js +16 -9
  42. package/dist/src/keys/rsa-class.js.map +1 -1
  43. package/dist/src/keys/rsa-utils.js +1 -1
  44. package/dist/src/keys/rsa-utils.js.map +1 -1
  45. package/dist/src/keys/rsa.d.ts +5 -4
  46. package/dist/src/keys/rsa.d.ts.map +1 -1
  47. package/dist/src/keys/rsa.js +39 -13
  48. package/dist/src/keys/rsa.js.map +1 -1
  49. package/dist/src/keys/secp256k1-browser.d.ts +18 -0
  50. package/dist/src/keys/secp256k1-browser.d.ts.map +1 -0
  51. package/dist/src/keys/secp256k1-browser.js +78 -0
  52. package/dist/src/keys/secp256k1-browser.js.map +1 -0
  53. package/dist/src/keys/secp256k1-class.d.ts +4 -3
  54. package/dist/src/keys/secp256k1-class.d.ts.map +1 -1
  55. package/dist/src/keys/secp256k1-class.js +18 -7
  56. package/dist/src/keys/secp256k1-class.js.map +1 -1
  57. package/dist/src/keys/secp256k1.d.ts +3 -2
  58. package/dist/src/keys/secp256k1.d.ts.map +1 -1
  59. package/dist/src/keys/secp256k1.js +24 -6
  60. package/dist/src/keys/secp256k1.js.map +1 -1
  61. package/dist/src/pbkdf2.js +1 -1
  62. package/dist/src/pbkdf2.js.map +1 -1
  63. package/dist/src/random-bytes.js +1 -1
  64. package/dist/src/random-bytes.js.map +1 -1
  65. package/dist/src/util.d.ts +1 -0
  66. package/dist/src/util.d.ts.map +1 -1
  67. package/dist/src/util.js +8 -0
  68. package/dist/src/util.js.map +1 -1
  69. package/dist/src/webcrypto.js +1 -1
  70. package/dist/src/webcrypto.js.map +1 -1
  71. package/package.json +11 -6
  72. package/src/aes/cipher-mode.ts +1 -1
  73. package/src/aes/index.ts +1 -1
  74. package/src/ciphers/aes-gcm.ts +3 -3
  75. package/src/keys/ecdh-browser.ts +1 -1
  76. package/src/keys/ecdh.ts +1 -1
  77. package/src/keys/ed25519-browser.ts +7 -6
  78. package/src/keys/ed25519-class.ts +22 -9
  79. package/src/keys/ed25519.ts +12 -20
  80. package/src/keys/index.ts +2 -2
  81. package/src/keys/key-stretcher.ts +1 -1
  82. package/src/keys/rsa-browser.ts +10 -9
  83. package/src/keys/rsa-class.ts +22 -12
  84. package/src/keys/rsa-utils.ts +1 -1
  85. package/src/keys/rsa.ts +44 -17
  86. package/src/keys/secp256k1-browser.ts +87 -0
  87. package/src/keys/secp256k1-class.ts +20 -7
  88. package/src/keys/secp256k1.ts +29 -6
  89. package/src/pbkdf2.ts +1 -1
  90. package/src/random-bytes.ts +1 -1
  91. package/src/util.ts +10 -0
  92. package/src/webcrypto.ts +1 -1
  93. package/dist/typedoc-urls.json +0 -37
@@ -1,14 +1,16 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import { CodeError } from '@libp2p/interface'
2
2
  import { sha256 } from 'multiformats/hashes/sha2'
3
3
  // @ts-expect-error types are missing
4
4
  import forge from 'node-forge/lib/forge.js'
5
5
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
6
6
  import 'node-forge/lib/sha512.js'
7
7
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
8
+ import { isPromise } from '../util.js'
8
9
  import { exporter } from './exporter.js'
9
10
  import * as pbm from './keys.js'
10
11
  import * as crypto from './rsa.js'
11
12
  import type { Multibase } from 'multiformats'
13
+ import type { Uint8ArrayList } from 'uint8arraylist'
12
14
 
13
15
  export const MAX_KEY_SIZE = 8192
14
16
 
@@ -19,7 +21,7 @@ export class RsaPublicKey {
19
21
  this._key = key
20
22
  }
21
23
 
22
- async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> {
24
+ verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean> {
23
25
  return crypto.hashAndVerify(this._key, sig, data)
24
26
  }
25
27
 
@@ -34,18 +36,22 @@ export class RsaPublicKey {
34
36
  }).subarray()
35
37
  }
36
38
 
37
- encrypt (bytes: Uint8Array): Uint8Array {
39
+ encrypt (bytes: Uint8Array | Uint8ArrayList): Uint8Array {
38
40
  return crypto.encrypt(this._key, bytes)
39
41
  }
40
42
 
41
- equals (key: any): boolean {
43
+ equals (key: any): boolean | boolean {
42
44
  return uint8ArrayEquals(this.bytes, key.bytes)
43
45
  }
44
46
 
45
- async hash (): Promise<Uint8Array> {
46
- const { bytes } = await sha256.digest(this.bytes)
47
+ hash (): Uint8Array | Promise<Uint8Array> {
48
+ const p = sha256.digest(this.bytes)
49
+
50
+ if (isPromise(p)) {
51
+ return p.then(({ bytes }) => bytes)
52
+ }
47
53
 
48
- return bytes
54
+ return p.bytes
49
55
  }
50
56
  }
51
57
 
@@ -62,7 +68,7 @@ export class RsaPrivateKey {
62
68
  return crypto.getRandomValues(16)
63
69
  }
64
70
 
65
- async sign (message: Uint8Array): Promise<Uint8Array> {
71
+ sign (message: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
66
72
  return crypto.hashAndSign(this._key, message)
67
73
  }
68
74
 
@@ -74,7 +80,7 @@ export class RsaPrivateKey {
74
80
  return new RsaPublicKey(this._publicKey)
75
81
  }
76
82
 
77
- decrypt (bytes: Uint8Array): Uint8Array {
83
+ decrypt (bytes: Uint8Array | Uint8ArrayList): Uint8Array {
78
84
  return crypto.decrypt(this._key, bytes)
79
85
  }
80
86
 
@@ -93,10 +99,14 @@ export class RsaPrivateKey {
93
99
  return uint8ArrayEquals(this.bytes, key.bytes)
94
100
  }
95
101
 
96
- async hash (): Promise<Uint8Array> {
97
- const { bytes } = await sha256.digest(this.bytes)
102
+ hash (): Uint8Array | Promise<Uint8Array> {
103
+ const p = sha256.digest(this.bytes)
104
+
105
+ if (isPromise(p)) {
106
+ return p.then(({ bytes }) => bytes)
107
+ }
98
108
 
99
- return bytes
109
+ return p.bytes
100
110
  }
101
111
 
102
112
  /**
@@ -1,6 +1,6 @@
1
1
  import 'node-forge/lib/asn1.js'
2
2
  import 'node-forge/lib/rsa.js'
3
- import { CodeError } from '@libp2p/interface/errors'
3
+ import { CodeError } from '@libp2p/interface'
4
4
  // @ts-expect-error types are missing
5
5
  import forge from 'node-forge/lib/forge.js'
6
6
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
package/src/keys/rsa.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import crypto from 'crypto'
2
2
  import { promisify } from 'util'
3
- import { CodeError } from '@libp2p/interface/errors'
3
+ import { CodeError } from '@libp2p/interface'
4
4
  import randomBytes from '../random-bytes.js'
5
5
  import * as utils from './rsa-utils.js'
6
6
  import type { JWKKeyPair } from './interface.js'
7
+ import type { Uint8ArrayList } from 'uint8arraylist'
7
8
 
8
9
  const keypair = promisify(crypto.generateKeyPair)
9
10
 
@@ -42,30 +43,56 @@ export async function unmarshalPrivateKey (key: JsonWebKey): Promise<JWKKeyPair>
42
43
 
43
44
  export { randomBytes as getRandomValues }
44
45
 
45
- export async function hashAndSign (key: JsonWebKey, msg: Uint8Array): Promise<Uint8Array> {
46
- return crypto.createSign('RSA-SHA256')
47
- .update(msg)
48
- // @ts-expect-error node types are missing jwk as a format
49
- .sign({ format: 'jwk', key })
46
+ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList): Promise<Uint8Array> {
47
+ const hash = crypto.createSign('RSA-SHA256')
48
+
49
+ if (msg instanceof Uint8Array) {
50
+ hash.update(msg)
51
+ } else {
52
+ for (const buf of msg) {
53
+ hash.update(buf)
54
+ }
55
+ }
56
+
57
+ // @ts-expect-error node types are missing jwk as a format
58
+ return hash.sign({ format: 'jwk', key })
50
59
  }
51
60
 
52
- export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array): Promise<boolean> {
53
- return crypto.createVerify('RSA-SHA256')
54
- .update(msg)
55
- // @ts-expect-error node types are missing jwk as a format
56
- .verify({ format: 'jwk', key }, sig)
61
+ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): Promise<boolean> {
62
+ const hash = crypto.createVerify('RSA-SHA256')
63
+
64
+ if (msg instanceof Uint8Array) {
65
+ hash.update(msg)
66
+ } else {
67
+ for (const buf of msg) {
68
+ hash.update(buf)
69
+ }
70
+ }
71
+
72
+ // @ts-expect-error node types are missing jwk as a format
73
+ return hash.verify({ format: 'jwk', key }, sig)
57
74
  }
58
75
 
59
76
  const padding = crypto.constants.RSA_PKCS1_PADDING
60
77
 
61
- export function encrypt (key: JsonWebKey, bytes: Uint8Array): Uint8Array {
62
- // @ts-expect-error node types are missing jwk as a format
63
- return crypto.publicEncrypt({ format: 'jwk', key, padding }, bytes)
78
+ export function encrypt (key: JsonWebKey, bytes: Uint8Array | Uint8ArrayList): Uint8Array {
79
+ if (bytes instanceof Uint8Array) {
80
+ // @ts-expect-error node types are missing jwk as a format
81
+ return crypto.publicEncrypt({ format: 'jwk', key, padding }, bytes)
82
+ } else {
83
+ // @ts-expect-error node types are missing jwk as a format
84
+ return crypto.publicEncrypt({ format: 'jwk', key, padding }, bytes.subarray())
85
+ }
64
86
  }
65
87
 
66
- export function decrypt (key: JsonWebKey, bytes: Uint8Array): Uint8Array {
67
- // @ts-expect-error node types are missing jwk as a format
68
- return crypto.privateDecrypt({ format: 'jwk', key, padding }, bytes)
88
+ export function decrypt (key: JsonWebKey, bytes: Uint8Array | Uint8ArrayList): Uint8Array {
89
+ if (bytes instanceof Uint8Array) {
90
+ // @ts-expect-error node types are missing jwk as a format
91
+ return crypto.privateDecrypt({ format: 'jwk', key, padding }, bytes)
92
+ } else {
93
+ // @ts-expect-error node types are missing jwk as a format
94
+ return crypto.privateDecrypt({ format: 'jwk', key, padding }, bytes.subarray())
95
+ }
69
96
  }
70
97
 
71
98
  export function keySize (jwk: JsonWebKey): number {
@@ -0,0 +1,87 @@
1
+ import { CodeError } from '@libp2p/interface'
2
+ import { secp256k1 as secp } from '@noble/curves/secp256k1'
3
+ import { sha256 } from 'multiformats/hashes/sha2'
4
+ import { isPromise } from '../util.js'
5
+ import type { Uint8ArrayList } from 'uint8arraylist'
6
+
7
+ const PRIVATE_KEY_BYTE_LENGTH = 32
8
+
9
+ export { PRIVATE_KEY_BYTE_LENGTH as privateKeyLength }
10
+
11
+ export function generateKey (): Uint8Array {
12
+ return secp.utils.randomPrivateKey()
13
+ }
14
+
15
+ /**
16
+ * Hash and sign message with private key
17
+ */
18
+ export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
19
+ const p = sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray())
20
+
21
+ if (isPromise(p)) {
22
+ return p.then(({ digest }) => secp.sign(digest, key).toDERRawBytes())
23
+ .catch(err => {
24
+ throw new CodeError(String(err), 'ERR_INVALID_INPUT')
25
+ })
26
+ }
27
+
28
+ try {
29
+ return secp.sign(p.digest, key).toDERRawBytes()
30
+ } catch (err) {
31
+ throw new CodeError(String(err), 'ERR_INVALID_INPUT')
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Hash message and verify signature with public key
37
+ */
38
+ export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): boolean | Promise<boolean> {
39
+ const p = sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray())
40
+
41
+ if (isPromise(p)) {
42
+ return p.then(({ digest }) => secp.verify(sig, digest, key))
43
+ .catch(err => {
44
+ throw new CodeError(String(err), 'ERR_INVALID_INPUT')
45
+ })
46
+ }
47
+
48
+ try {
49
+ return secp.verify(sig, p.digest, key)
50
+ } catch (err) {
51
+ throw new CodeError(String(err), 'ERR_INVALID_INPUT')
52
+ }
53
+ }
54
+
55
+ export function compressPublicKey (key: Uint8Array): Uint8Array {
56
+ const point = secp.ProjectivePoint.fromHex(key).toRawBytes(true)
57
+ return point
58
+ }
59
+
60
+ export function decompressPublicKey (key: Uint8Array): Uint8Array {
61
+ const point = secp.ProjectivePoint.fromHex(key).toRawBytes(false)
62
+ return point
63
+ }
64
+
65
+ export function validatePrivateKey (key: Uint8Array): void {
66
+ try {
67
+ secp.getPublicKey(key, true)
68
+ } catch (err) {
69
+ throw new CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY')
70
+ }
71
+ }
72
+
73
+ export function validatePublicKey (key: Uint8Array): void {
74
+ try {
75
+ secp.ProjectivePoint.fromHex(key)
76
+ } catch (err) {
77
+ throw new CodeError(String(err), 'ERR_INVALID_PUBLIC_KEY')
78
+ }
79
+ }
80
+
81
+ export function computePublicKey (privateKey: Uint8Array): Uint8Array {
82
+ try {
83
+ return secp.getPublicKey(privateKey, true)
84
+ } catch (err) {
85
+ throw new CodeError(String(err), 'ERR_INVALID_PRIVATE_KEY')
86
+ }
87
+ }
@@ -1,11 +1,13 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import { CodeError } from '@libp2p/interface'
2
2
  import { sha256 } from 'multiformats/hashes/sha2'
3
3
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
4
4
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
5
+ import { isPromise } from '../util.js'
5
6
  import { exporter } from './exporter.js'
6
7
  import * as keysProtobuf from './keys.js'
7
8
  import * as crypto from './secp256k1.js'
8
9
  import type { Multibase } from 'multiformats'
10
+ import type { Uint8ArrayList } from 'uint8arraylist'
9
11
 
10
12
  export class Secp256k1PublicKey {
11
13
  private readonly _key: Uint8Array
@@ -15,7 +17,7 @@ export class Secp256k1PublicKey {
15
17
  this._key = key
16
18
  }
17
19
 
18
- async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> {
20
+ verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean {
19
21
  return crypto.hashAndVerify(this._key, sig, data)
20
22
  }
21
23
 
@@ -35,7 +37,14 @@ export class Secp256k1PublicKey {
35
37
  }
36
38
 
37
39
  async hash (): Promise<Uint8Array> {
38
- const { bytes } = await sha256.digest(this.bytes)
40
+ const p = sha256.digest(this.bytes)
41
+ let bytes: Uint8Array
42
+
43
+ if (isPromise(p)) {
44
+ ({ bytes } = await p)
45
+ } else {
46
+ bytes = p.bytes
47
+ }
39
48
 
40
49
  return bytes
41
50
  }
@@ -52,7 +61,7 @@ export class Secp256k1PrivateKey {
52
61
  crypto.validatePublicKey(this._publicKey)
53
62
  }
54
63
 
55
- async sign (message: Uint8Array): Promise<Uint8Array> {
64
+ sign (message: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
56
65
  return crypto.hashAndSign(this._key, message)
57
66
  }
58
67
 
@@ -75,10 +84,14 @@ export class Secp256k1PrivateKey {
75
84
  return uint8ArrayEquals(this.bytes, key.bytes)
76
85
  }
77
86
 
78
- async hash (): Promise<Uint8Array> {
79
- const { bytes } = await sha256.digest(this.bytes)
87
+ hash (): Uint8Array | Promise<Uint8Array> {
88
+ const p = sha256.digest(this.bytes)
80
89
 
81
- return bytes
90
+ if (isPromise(p)) {
91
+ return p.then(({ bytes }) => bytes)
92
+ }
93
+
94
+ return p.bytes
82
95
  }
83
96
 
84
97
  /**
@@ -1,6 +1,7 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import crypto from 'node:crypto'
2
+ import { CodeError } from '@libp2p/interface'
2
3
  import { secp256k1 as secp } from '@noble/curves/secp256k1'
3
- import { sha256 } from 'multiformats/hashes/sha2'
4
+ import type { Uint8ArrayList } from 'uint8arraylist'
4
5
 
5
6
  const PRIVATE_KEY_BYTE_LENGTH = 32
6
7
 
@@ -13,8 +14,19 @@ export function generateKey (): Uint8Array {
13
14
  /**
14
15
  * Hash and sign message with private key
15
16
  */
16
- export async function hashAndSign (key: Uint8Array, msg: Uint8Array): Promise<Uint8Array> {
17
- const { digest } = await sha256.digest(msg)
17
+ export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList): Uint8Array {
18
+ const hash = crypto.createHash('sha256')
19
+
20
+ if (msg instanceof Uint8Array) {
21
+ hash.update(msg)
22
+ } else {
23
+ for (const buf of msg) {
24
+ hash.update(buf)
25
+ }
26
+ }
27
+
28
+ const digest = hash.digest()
29
+
18
30
  try {
19
31
  const signature = secp.sign(digest, key)
20
32
  return signature.toDERRawBytes()
@@ -26,9 +38,20 @@ export async function hashAndSign (key: Uint8Array, msg: Uint8Array): Promise<Ui
26
38
  /**
27
39
  * Hash message and verify signature with public key
28
40
  */
29
- export async function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array): Promise<boolean> {
41
+ export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): boolean {
42
+ const hash = crypto.createHash('sha256')
43
+
44
+ if (msg instanceof Uint8Array) {
45
+ hash.update(msg)
46
+ } else {
47
+ for (const buf of msg) {
48
+ hash.update(buf)
49
+ }
50
+ }
51
+
52
+ const digest = hash.digest()
53
+
30
54
  try {
31
- const { digest } = await sha256.digest(msg)
32
55
  return secp.verify(sig, digest, key)
33
56
  } catch (err) {
34
57
  throw new CodeError(String(err), 'ERR_INVALID_INPUT')
package/src/pbkdf2.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import { CodeError } from '@libp2p/interface'
2
2
  // @ts-expect-error types are missing
3
3
  import forgePbkdf2 from 'node-forge/lib/pbkdf2.js'
4
4
  // @ts-expect-error types are missing
@@ -1,4 +1,4 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import { CodeError } from '@libp2p/interface'
2
2
  import { randomBytes as randB } from '@noble/hashes/utils'
3
3
 
4
4
  /**
package/src/util.ts CHANGED
@@ -40,3 +40,13 @@ export function base64urlToBuffer (str: string, len?: number): Uint8Array {
40
40
 
41
41
  return buf
42
42
  }
43
+
44
+ export function isPromise <T = unknown> (thing: any): thing is Promise<T> {
45
+ if (thing == null) {
46
+ return false
47
+ }
48
+
49
+ return typeof thing.then === 'function' &&
50
+ typeof thing.catch === 'function' &&
51
+ typeof thing.finally === 'function'
52
+ }
package/src/webcrypto.ts CHANGED
@@ -13,7 +13,7 @@ export default {
13
13
  'The most likely cause of this error is that this page is being accessed ' +
14
14
  'from an insecure context (i.e. not HTTPS). For more information and ' +
15
15
  'possible resolutions see ' +
16
- 'https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api'
16
+ 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api'
17
17
  ),
18
18
  { code: 'ERR_MISSING_WEB_CRYPTO' }
19
19
  )
@@ -1,37 +0,0 @@
1
- {
2
- "AESCipher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.aes.AESCipher.html",
3
- "./aes:AESCipher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.aes.AESCipher.html",
4
- "create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.aes.create.html",
5
- "./aes:create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.aes.create.html",
6
- "HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
7
- "./hmac:HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
8
- "./hmac:create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.hmac.create.html",
9
- "pbkdf2": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.pbkdf2.html",
10
- "randomBytes": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.randomBytes.html",
11
- "codec": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keysPBM.KeyType.codec.html",
12
- "decode": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keysPBM.PrivateKey.decode.html",
13
- "encode": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keysPBM.PrivateKey.encode.html",
14
- "KeyType": "https://libp2p.github.io/js-libp2p/enums/_libp2p_crypto.keys.keysPBM.KeyType-1.html",
15
- "PrivateKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.keysPBM.PrivateKey-1.html",
16
- "PublicKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.keysPBM.PublicKey-1.html",
17
- "KeyTypes": "https://libp2p.github.io/js-libp2p/types/_libp2p_crypto.keys.KeyTypes.html",
18
- "./keys:KeyTypes": "https://libp2p.github.io/js-libp2p/types/_libp2p_crypto.keys.KeyTypes.html",
19
- "supportedKeys": "https://libp2p.github.io/js-libp2p/variables/_libp2p_crypto.keys.supportedKeys.html",
20
- "./keys:supportedKeys": "https://libp2p.github.io/js-libp2p/variables/_libp2p_crypto.keys.supportedKeys.html",
21
- "generateEphemeralKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateEphemeralKeyPair.html",
22
- "generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
23
- "./keys:generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
24
- "generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
25
- "./keys:generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
26
- "importKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.importKey.html",
27
- "./keys:importKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.importKey.html",
28
- "keyStretcher": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keyStretcher.html",
29
- "marshalPrivateKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.marshalPrivateKey.html",
30
- "./keys:marshalPrivateKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.marshalPrivateKey.html",
31
- "marshalPublicKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.marshalPublicKey.html",
32
- "./keys:marshalPublicKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.marshalPublicKey.html",
33
- "unmarshalPrivateKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.unmarshalPrivateKey.html",
34
- "./keys:unmarshalPrivateKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.unmarshalPrivateKey.html",
35
- "unmarshalPublicKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.unmarshalPublicKey.html",
36
- "./keys:unmarshalPublicKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.unmarshalPublicKey.html"
37
- }