@libp2p/crypto 5.1.18 → 5.1.19-a34745c01

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 (70) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/index.min.js.map +4 -4
  3. package/dist/src/ciphers/aes-gcm.browser.d.ts.map +1 -1
  4. package/dist/src/ciphers/aes-gcm.browser.js +8 -7
  5. package/dist/src/ciphers/aes-gcm.browser.js.map +1 -1
  6. package/dist/src/hmac/index.browser.d.ts.map +1 -1
  7. package/dist/src/hmac/index.browser.js +4 -3
  8. package/dist/src/hmac/index.browser.js.map +1 -1
  9. package/dist/src/keys/ecdh/index.browser.d.ts +1 -1
  10. package/dist/src/keys/ecdh/index.browser.js +2 -2
  11. package/dist/src/keys/ecdh/index.d.ts +1 -1
  12. package/dist/src/keys/ecdsa/ecdsa.js +1 -1
  13. package/dist/src/keys/ecdsa/index.d.ts +1 -1
  14. package/dist/src/keys/ecdsa/index.d.ts.map +1 -1
  15. package/dist/src/keys/ecdsa/index.js +3 -2
  16. package/dist/src/keys/ecdsa/index.js.map +1 -1
  17. package/dist/src/keys/ecdsa/utils.d.ts +1 -1
  18. package/dist/src/keys/ecdsa/utils.js +1 -1
  19. package/dist/src/keys/ed25519/ed25519.js +1 -1
  20. package/dist/src/keys/ed25519/index.browser.d.ts +1 -1
  21. package/dist/src/keys/ed25519/index.browser.d.ts.map +1 -1
  22. package/dist/src/keys/ed25519/index.browser.js +4 -3
  23. package/dist/src/keys/ed25519/index.browser.js.map +1 -1
  24. package/dist/src/keys/ed25519/index.d.ts +1 -1
  25. package/dist/src/keys/key-stretcher.js +1 -1
  26. package/dist/src/keys/rsa/index.browser.d.ts +2 -2
  27. package/dist/src/keys/rsa/index.browser.d.ts.map +1 -1
  28. package/dist/src/keys/rsa/index.browser.js +5 -4
  29. package/dist/src/keys/rsa/index.browser.js.map +1 -1
  30. package/dist/src/keys/rsa/index.d.ts +2 -2
  31. package/dist/src/keys/rsa/index.js +1 -1
  32. package/dist/src/keys/rsa/utils.d.ts +1 -1
  33. package/dist/src/keys/rsa/utils.js +1 -1
  34. package/dist/src/keys/secp256k1/index.browser.js +2 -2
  35. package/dist/src/keys/secp256k1/index.js +1 -1
  36. package/dist/src/keys/secp256k1/secp256k1.js +1 -1
  37. package/dist/src/webcrypto/index.d.ts +4 -2
  38. package/dist/src/webcrypto/index.d.ts.map +1 -1
  39. package/dist/src/webcrypto/index.js +16 -2
  40. package/dist/src/webcrypto/index.js.map +1 -1
  41. package/package.json +6 -7
  42. package/src/ciphers/aes-gcm.browser.ts +8 -7
  43. package/src/hmac/index.browser.ts +4 -3
  44. package/src/keys/ecdh/index.browser.ts +3 -3
  45. package/src/keys/ecdh/index.ts +1 -1
  46. package/src/keys/ecdsa/ecdsa.ts +1 -1
  47. package/src/keys/ecdsa/index.ts +4 -3
  48. package/src/keys/ecdsa/utils.ts +2 -2
  49. package/src/keys/ed25519/ed25519.ts +1 -1
  50. package/src/keys/ed25519/index.browser.ts +5 -4
  51. package/src/keys/ed25519/index.ts +1 -1
  52. package/src/keys/key-stretcher.ts +1 -1
  53. package/src/keys/rsa/index.browser.ts +7 -6
  54. package/src/keys/rsa/index.ts +2 -2
  55. package/src/keys/rsa/utils.ts +2 -2
  56. package/src/keys/secp256k1/index.browser.ts +2 -2
  57. package/src/keys/secp256k1/index.ts +1 -1
  58. package/src/keys/secp256k1/secp256k1.ts +1 -1
  59. package/src/webcrypto/index.ts +20 -2
  60. package/dist/src/webcrypto/webcrypto.browser.d.ts +0 -5
  61. package/dist/src/webcrypto/webcrypto.browser.d.ts.map +0 -1
  62. package/dist/src/webcrypto/webcrypto.browser.js +0 -18
  63. package/dist/src/webcrypto/webcrypto.browser.js.map +0 -1
  64. package/dist/src/webcrypto/webcrypto.d.ts +0 -6
  65. package/dist/src/webcrypto/webcrypto.d.ts.map +0 -1
  66. package/dist/src/webcrypto/webcrypto.js +0 -10
  67. package/dist/src/webcrypto/webcrypto.js.map +0 -1
  68. package/dist/typedoc-urls.json +0 -40
  69. package/src/webcrypto/webcrypto.browser.ts +0 -23
  70. package/src/webcrypto/webcrypto.ts +0 -11
@@ -1,4 +1,5 @@
1
- import webcrypto from '../webcrypto/index.js'
1
+ import { withArrayBuffer } from 'uint8arrays/with-array-buffer'
2
+ import webcrypto from '../webcrypto/index.ts'
2
3
  import lengths from './lengths.ts'
3
4
 
4
5
  const hashTypes = {
@@ -8,7 +9,7 @@ const hashTypes = {
8
9
  }
9
10
 
10
11
  const sign = async (key: CryptoKey, data: Uint8Array): Promise<Uint8Array> => {
11
- const buf = await webcrypto.get().subtle.sign({ name: 'HMAC' }, key, data)
12
+ const buf = await webcrypto.get().subtle.sign({ name: 'HMAC' }, key, withArrayBuffer(data))
12
13
  return new Uint8Array(buf, 0, buf.byteLength)
13
14
  }
14
15
 
@@ -17,7 +18,7 @@ export async function create (hashType: 'SHA1' | 'SHA256' | 'SHA512', secret: Ui
17
18
 
18
19
  const key = await webcrypto.get().subtle.importKey(
19
20
  'raw',
20
- secret,
21
+ withArrayBuffer(secret),
21
22
  {
22
23
  name: 'HMAC',
23
24
  hash: { name: hash }
@@ -2,10 +2,10 @@ import { InvalidParametersError } from '@libp2p/interface'
2
2
  import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
3
3
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
4
4
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
5
- import { base64urlToBuffer } from '../../util.js'
6
- import webcrypto from '../../webcrypto/index.js'
5
+ import { base64urlToBuffer } from '../../util.ts'
6
+ import webcrypto from '../../webcrypto/index.ts'
7
7
  import type { Curve } from './index.ts'
8
- import type { ECDHKey, ECDHKeyPair, JWKEncodedPrivateKey, JWKEncodedPublicKey } from '../interface.js'
8
+ import type { ECDHKey, ECDHKeyPair, JWKEncodedPrivateKey, JWKEncodedPublicKey } from '../interface.ts'
9
9
 
10
10
  const curveLengths = {
11
11
  'P-256': 32,
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto'
2
2
  import { InvalidParametersError } from '@libp2p/interface'
3
- import type { ECDHKey, ECDHKeyPair } from '../interface.js'
3
+ import type { ECDHKey, ECDHKeyPair } from '../interface.ts'
4
4
 
5
5
  export type Curve = 'P-256' | 'P-384' | 'P-521'
6
6
 
@@ -2,7 +2,7 @@ import { base58btc } from 'multiformats/bases/base58'
2
2
  import { CID } from 'multiformats/cid'
3
3
  import { identity } from 'multiformats/hashes/identity'
4
4
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5
- import { publicKeyToProtobuf } from '../index.js'
5
+ import { publicKeyToProtobuf } from '../index.ts'
6
6
  import { hashAndVerify, hashAndSign } from './index.ts'
7
7
  import { privateKeyToPKIMessage, publicKeyToPKIMessage } from './utils.ts'
8
8
  import type { ECDSAPublicKey as ECDSAPublicKeyInterface, ECDSAPrivateKey as ECDSAPrivateKeyInterface, AbortOptions } from '@libp2p/interface'
@@ -1,4 +1,5 @@
1
- import type { JWKKeyPair } from '../interface.js'
1
+ import { withArrayBuffer } from 'uint8arrays/with-array-buffer'
2
+ import type { JWKKeyPair } from '../interface.ts'
2
3
  import type { AbortOptions } from '@libp2p/interface'
3
4
  import type { Uint8ArrayList } from 'uint8arraylist'
4
5
 
@@ -32,7 +33,7 @@ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8Array
32
33
  hash: {
33
34
  name: 'SHA-256'
34
35
  }
35
- }, privateKey, msg.subarray())
36
+ }, privateKey, withArrayBuffer(msg.subarray()))
36
37
  options?.signal?.throwIfAborted()
37
38
 
38
39
  return new Uint8Array(signature, 0, signature.byteLength)
@@ -50,7 +51,7 @@ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint
50
51
  hash: {
51
52
  name: 'SHA-256'
52
53
  }
53
- }, publicKey, sig, msg.subarray())
54
+ }, publicKey, withArrayBuffer(sig), withArrayBuffer(msg.subarray()))
54
55
  options?.signal?.throwIfAborted()
55
56
 
56
57
  return result
@@ -2,10 +2,10 @@ import { InvalidParametersError } from '@libp2p/interface'
2
2
  import { Uint8ArrayList } from 'uint8arraylist'
3
3
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
4
4
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
5
- import { decodeDer, encodeBitString, encodeInteger, encodeOctetString, encodeSequence } from '../rsa/der.js'
5
+ import { decodeDer, encodeBitString, encodeInteger, encodeOctetString, encodeSequence } from '../rsa/der.ts'
6
6
  import { ECDSAPrivateKey as ECDSAPrivateKeyClass, ECDSAPublicKey as ECDSAPublicKeyClass } from './ecdsa.ts'
7
7
  import { generateECDSAKey } from './index.ts'
8
- import type { Curve } from '../ecdh/index.js'
8
+ import type { Curve } from '../ecdh/index.ts'
9
9
  import type { ECDSAPublicKey, ECDSAPrivateKey } from '@libp2p/interface'
10
10
 
11
11
  // 1.2.840.10045.3.1.7 prime256v1 (ANSI X9.62 named elliptic curve)
@@ -3,7 +3,7 @@ import { CID } from 'multiformats/cid'
3
3
  import { identity } from 'multiformats/hashes/identity'
4
4
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5
5
  import { isPromise } from '../../util.ts'
6
- import { publicKeyToProtobuf } from '../index.js'
6
+ import { publicKeyToProtobuf } from '../index.ts'
7
7
  import * as crypto from './index.ts'
8
8
  import { ensureEd25519Key } from './utils.ts'
9
9
  import type { Ed25519PublicKey as Ed25519PublicKeyInterface, Ed25519PrivateKey as Ed25519PrivateKeyInterface, AbortOptions } from '@libp2p/interface'
@@ -1,7 +1,8 @@
1
1
  import { ed25519 as ed } from '@noble/curves/ed25519.js'
2
2
  import { toString as uint8arrayToString } from 'uint8arrays/to-string'
3
- import crypto from '../../webcrypto/index.js'
4
- import type { Uint8ArrayKeyPair } from '../interface.js'
3
+ import { withArrayBuffer } from 'uint8arrays/with-array-buffer'
4
+ import crypto from '../../webcrypto/index.ts'
5
+ import type { Uint8ArrayKeyPair } from '../interface.ts'
5
6
  import type { Uint8ArrayList } from 'uint8arraylist'
6
7
 
7
8
  const PUBLIC_KEY_BYTE_LENGTH = 32
@@ -73,7 +74,7 @@ async function hashAndSignWebCrypto (privateKey: Uint8Array, msg: Uint8Array | U
73
74
  }
74
75
 
75
76
  const key = await crypto.get().subtle.importKey('jwk', jwk, { name: 'Ed25519' }, true, ['sign'])
76
- const sig = await crypto.get().subtle.sign({ name: 'Ed25519' }, key, msg instanceof Uint8Array ? msg : msg.subarray())
77
+ const sig = await crypto.get().subtle.sign({ name: 'Ed25519' }, key, withArrayBuffer(msg instanceof Uint8Array ? msg : msg.subarray()))
77
78
 
78
79
  return new Uint8Array(sig, 0, sig.byteLength)
79
80
  }
@@ -99,7 +100,7 @@ export async function hashAndSign (privateKey: Uint8Array, msg: Uint8Array | Uin
99
100
  async function hashAndVerifyWebCrypto (publicKey: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): Promise<boolean> {
100
101
  if (publicKey.buffer instanceof ArrayBuffer) {
101
102
  const key = await crypto.get().subtle.importKey('raw', publicKey.buffer, { name: 'Ed25519' }, false, ['verify'])
102
- const isValid = await crypto.get().subtle.verify({ name: 'Ed25519' }, key, sig, msg instanceof Uint8Array ? msg : msg.subarray())
103
+ const isValid = await crypto.get().subtle.verify({ name: 'Ed25519' }, key, withArrayBuffer(sig), withArrayBuffer(msg instanceof Uint8Array ? msg : msg.subarray()))
103
104
  return isValid
104
105
  }
105
106
 
@@ -3,7 +3,7 @@ import { ed25519 as ed } from '@noble/curves/ed25519.js'
3
3
  import { concat as uint8arrayConcat } from 'uint8arrays/concat'
4
4
  import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
5
5
  import { toString as uint8arrayToString } from 'uint8arrays/to-string'
6
- import type { Uint8ArrayKeyPair } from '../interface.js'
6
+ import type { Uint8ArrayKeyPair } from '../interface.ts'
7
7
  import type { Uint8ArrayList } from 'uint8arraylist'
8
8
 
9
9
  const keypair = crypto.generateKeyPairSync
@@ -1,7 +1,7 @@
1
1
  import { InvalidParametersError } from '@libp2p/interface'
2
2
  import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
3
3
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
4
- import * as hmac from '../hmac/index.js'
4
+ import * as hmac from '../hmac/index.ts'
5
5
  import type { EnhancedKey, EnhancedKeyPair } from './interface.ts'
6
6
 
7
7
  interface Cipher {
@@ -1,9 +1,10 @@
1
1
  import { InvalidParametersError } from '@libp2p/interface'
2
2
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
3
- import randomBytes from '../../random-bytes.js'
4
- import webcrypto from '../../webcrypto/index.js'
3
+ import { withArrayBuffer } from 'uint8arrays/with-array-buffer'
4
+ import randomBytes from '../../random-bytes.ts'
5
+ import webcrypto from '../../webcrypto/index.ts'
5
6
  import * as utils from './utils.ts'
6
- import type { JWKKeyPair } from '../interface.js'
7
+ import type { JWKKeyPair } from '../interface.ts'
7
8
  import type { AbortOptions } from '@libp2p/interface'
8
9
  import type { Uint8ArrayList } from 'uint8arraylist'
9
10
 
@@ -49,7 +50,7 @@ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8Array
49
50
  const sig = await webcrypto.get().subtle.sign(
50
51
  { name: 'RSASSA-PKCS1-v1_5' },
51
52
  privateKey,
52
- msg instanceof Uint8Array ? msg : msg.subarray()
53
+ withArrayBuffer(msg instanceof Uint8Array ? msg : msg.subarray())
53
54
  )
54
55
  options?.signal?.throwIfAborted()
55
56
 
@@ -72,8 +73,8 @@ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint
72
73
  const result = await webcrypto.get().subtle.verify(
73
74
  { name: 'RSASSA-PKCS1-v1_5' },
74
75
  publicKey,
75
- sig,
76
- msg instanceof Uint8Array ? msg : msg.subarray()
76
+ withArrayBuffer(sig),
77
+ withArrayBuffer(msg instanceof Uint8Array ? msg : msg.subarray())
77
78
  )
78
79
  options?.signal?.throwIfAborted()
79
80
 
@@ -2,9 +2,9 @@ import crypto from 'node:crypto'
2
2
  import { promisify } from 'node:util'
3
3
  import { InvalidParametersError } from '@libp2p/interface'
4
4
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
5
- import randomBytes from '../../random-bytes.js'
5
+ import randomBytes from '../../random-bytes.ts'
6
6
  import * as utils from './utils.ts'
7
- import type { JWKKeyPair } from '../interface.js'
7
+ import type { JWKKeyPair } from '../interface.ts'
8
8
  import type { AbortOptions } from '@libp2p/interface'
9
9
  import type { Uint8ArrayList } from 'uint8arraylist'
10
10
 
@@ -3,11 +3,11 @@ import { sha256 } from '@noble/hashes/sha2.js'
3
3
  import { create } from 'multiformats/hashes/digest'
4
4
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
5
5
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
6
- import * as pb from '../keys.js'
6
+ import * as pb from '../keys.ts'
7
7
  import { decodeDer, encodeBitString, encodeInteger, encodeSequence } from './der.ts'
8
8
  import { generateRSAKey, rsaKeySize } from './index.ts'
9
9
  import { RSAPrivateKey as RSAPrivateKeyClass, RSAPublicKey as RSAPublicKeyClass } from './rsa.ts'
10
- import type { JWKKeyPair } from '../interface.js'
10
+ import type { JWKKeyPair } from '../interface.ts'
11
11
  import type { RSAPrivateKey, RSAPublicKey } from '@libp2p/interface'
12
12
  import type { Digest } from 'multiformats/hashes/digest'
13
13
 
@@ -1,7 +1,7 @@
1
1
  import { secp256k1 as secp } from '@noble/curves/secp256k1.js'
2
2
  import { sha256 } from 'multiformats/hashes/sha2'
3
- import { SigningError, VerificationError } from '../../errors.js'
4
- import { isPromise } from '../../util.js'
3
+ import { SigningError, VerificationError } from '../../errors.ts'
4
+ import { isPromise } from '../../util.ts'
5
5
  import type { AbortOptions } from '@libp2p/interface'
6
6
  import type { Uint8ArrayList } from 'uint8arraylist'
7
7
 
@@ -1,6 +1,6 @@
1
1
  import crypto from 'node:crypto'
2
2
  import { secp256k1 as secp } from '@noble/curves/secp256k1.js'
3
- import { SigningError, VerificationError } from '../../errors.js'
3
+ import { SigningError, VerificationError } from '../../errors.ts'
4
4
  import type { AbortOptions } from '@libp2p/interface'
5
5
  import type { Uint8ArrayList } from 'uint8arraylist'
6
6
 
@@ -2,7 +2,7 @@ import { base58btc } from 'multiformats/bases/base58'
2
2
  import { CID } from 'multiformats/cid'
3
3
  import { identity } from 'multiformats/hashes/identity'
4
4
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5
- import { publicKeyToProtobuf } from '../index.js'
5
+ import { publicKeyToProtobuf } from '../index.ts'
6
6
  import { hashAndVerify, hashAndSign } from './index.ts'
7
7
  import { validateSecp256k1PublicKey, compressSecp256k1PublicKey, computeSecp256k1PublicKey, validateSecp256k1PrivateKey } from './utils.ts'
8
8
  import type { Secp256k1PublicKey as Secp256k1PublicKeyInterface, Secp256k1PrivateKey as Secp256k1PrivateKeyInterface, AbortOptions } from '@libp2p/interface'
@@ -1,3 +1,21 @@
1
- import webcrypto from './webcrypto.ts'
1
+ import { WebCryptoMissingError } from '../errors.ts'
2
2
 
3
- export default webcrypto
3
+ // Check native crypto exists and is enabled (in insecure browser contexts
4
+ // `globalThis.crypto` exists but `globalThis.crypto.subtle` does not).
5
+ export default {
6
+ get (win = globalThis): Crypto {
7
+ const nativeCrypto = win.crypto
8
+
9
+ if (nativeCrypto?.subtle == null) {
10
+ throw new WebCryptoMissingError(
11
+ 'Missing Web Crypto API. ' +
12
+ 'The most likely cause of this error is that this page is being accessed ' +
13
+ 'from an insecure context (i.e. not HTTPS). For more information and ' +
14
+ 'possible resolutions see ' +
15
+ 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api'
16
+ )
17
+ }
18
+
19
+ return nativeCrypto
20
+ }
21
+ }
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- get(win?: typeof globalThis): Crypto;
3
- };
4
- export default _default;
5
- //# sourceMappingURL=webcrypto.browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webcrypto.browser.d.ts","sourceRoot":"","sources":["../../../src/webcrypto/webcrypto.browser.ts"],"names":[],"mappings":";;;AAMA,wBAgBC"}
@@ -1,18 +0,0 @@
1
- /* eslint-env browser */
2
- import { WebCryptoMissingError } from '../errors.js';
3
- // Check native crypto exists and is enabled (In insecure context `self.crypto`
4
- // exists but `self.crypto.subtle` does not).
5
- export default {
6
- get(win = globalThis) {
7
- const nativeCrypto = win.crypto;
8
- if (nativeCrypto?.subtle == null) {
9
- throw new WebCryptoMissingError('Missing Web Crypto API. ' +
10
- 'The most likely cause of this error is that this page is being accessed ' +
11
- 'from an insecure context (i.e. not HTTPS). For more information and ' +
12
- 'possible resolutions see ' +
13
- 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api');
14
- }
15
- return nativeCrypto;
16
- }
17
- };
18
- //# sourceMappingURL=webcrypto.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webcrypto.browser.js","sourceRoot":"","sources":["../../../src/webcrypto/webcrypto.browser.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,+EAA+E;AAC/E,6CAA6C;AAC7C,eAAe;IACb,GAAG,CAAE,GAAG,GAAG,UAAU;QACnB,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAA;QAE/B,IAAI,YAAY,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;YACjC,MAAM,IAAI,qBAAqB,CAC7B,0BAA0B;gBAC1B,0EAA0E;gBAC1E,sEAAsE;gBACtE,2BAA2B;gBAC3B,wFAAwF,CACzF,CAAA;QACH,CAAC;QAED,OAAO,YAAY,CAAA;IACrB,CAAC;CACF,CAAA"}
@@ -1,6 +0,0 @@
1
- import { webcrypto } from 'crypto';
2
- declare const _default: {
3
- get(win?: typeof globalThis): webcrypto.Crypto;
4
- };
5
- export default _default;
6
- //# sourceMappingURL=webcrypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webcrypto.d.ts","sourceRoot":"","sources":["../../../src/webcrypto/webcrypto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;;;;AAIlC,wBAIC"}
@@ -1,10 +0,0 @@
1
- /* eslint-env browser */
2
- import { webcrypto } from 'crypto';
3
- // globalThis `SubtleCrypto` shipped in node.js 19.x, Electron currently uses
4
- // v18.x so this override file is necessary until Electron updates
5
- export default {
6
- get(win = globalThis) {
7
- return webcrypto;
8
- }
9
- };
10
- //# sourceMappingURL=webcrypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webcrypto.js","sourceRoot":"","sources":["../../../src/webcrypto/webcrypto.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,6EAA6E;AAC7E,kEAAkE;AAClE,eAAe;IACb,GAAG,CAAE,GAAG,GAAG,UAAU;QACnB,OAAO,SAAS,CAAA;IAClB,CAAC;CACF,CAAA"}
@@ -1,40 +0,0 @@
1
- {
2
- "AESCipher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.ciphers.AES_GCM.AESCipher.html",
3
- "CreateAESCipherOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.ciphers.AES_GCM.CreateAESCipherOptions.html",
4
- "create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.ciphers.AES_GCM.create.html",
5
- "HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
6
- "./hmac:HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
7
- "./hmac:create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.hmac.create.html",
8
- "pbkdf2": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.pbkdf2.html",
9
- "randomBytes": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.randomBytes.html",
10
- "ECDHKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.ECDHKey.html",
11
- "ECDHKeyPair": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.ECDHKeyPair.html",
12
- "EnhancedKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.EnhancedKey.html",
13
- "EnhancedKeyPair": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.EnhancedKeyPair.html",
14
- "Curve": "https://libp2p.github.io/js-libp2p/types/_libp2p_crypto.keys.Curve.html",
15
- "generateEphemeralKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateEphemeralKeyPair.html",
16
- "generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
17
- "./keys:generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
18
- "generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
19
- "./keys:generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
20
- "keyStretcher": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keyStretcher.html",
21
- "privateKeyFromCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromCryptoKeyPair.html",
22
- "./keys:privateKeyFromCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromCryptoKeyPair.html",
23
- "privateKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromProtobuf.html",
24
- "./keys:privateKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromProtobuf.html",
25
- "privateKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromRaw.html",
26
- "./keys:privateKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromRaw.html",
27
- "privateKeyToCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToCryptoKeyPair.html",
28
- "./keys:privateKeyToCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToCryptoKeyPair.html",
29
- "privateKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToProtobuf.html",
30
- "./keys:privateKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToProtobuf.html",
31
- "publicKeyFromMultihash": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromMultihash.html",
32
- "./keys:publicKeyFromMultihash": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromMultihash.html",
33
- "publicKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromProtobuf.html",
34
- "./keys:publicKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromProtobuf.html",
35
- "publicKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromRaw.html",
36
- "./keys:publicKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromRaw.html",
37
- "publicKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyToProtobuf.html",
38
- "./keys:publicKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyToProtobuf.html",
39
- "default": "https://libp2p.github.io/js-libp2p/variables/_libp2p_crypto.webcrypto.default.html"
40
- }
@@ -1,23 +0,0 @@
1
- /* eslint-env browser */
2
-
3
- import { WebCryptoMissingError } from '../errors.js'
4
-
5
- // Check native crypto exists and is enabled (In insecure context `self.crypto`
6
- // exists but `self.crypto.subtle` does not).
7
- export default {
8
- get (win = globalThis) {
9
- const nativeCrypto = win.crypto
10
-
11
- if (nativeCrypto?.subtle == null) {
12
- throw new WebCryptoMissingError(
13
- 'Missing Web Crypto API. ' +
14
- 'The most likely cause of this error is that this page is being accessed ' +
15
- 'from an insecure context (i.e. not HTTPS). For more information and ' +
16
- 'possible resolutions see ' +
17
- 'https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api'
18
- )
19
- }
20
-
21
- return nativeCrypto
22
- }
23
- }
@@ -1,11 +0,0 @@
1
- /* eslint-env browser */
2
-
3
- import { webcrypto } from 'crypto'
4
-
5
- // globalThis `SubtleCrypto` shipped in node.js 19.x, Electron currently uses
6
- // v18.x so this override file is necessary until Electron updates
7
- export default {
8
- get (win = globalThis) {
9
- return webcrypto
10
- }
11
- }