@libp2p/crypto 5.1.18-9c3c0b22a → 5.1.18-b7c6dc0f2
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/ciphers/aes-gcm.browser.d.ts.map +1 -1
- package/dist/src/ciphers/aes-gcm.browser.js +8 -7
- package/dist/src/ciphers/aes-gcm.browser.js.map +1 -1
- package/dist/src/hmac/index.browser.d.ts.map +1 -1
- package/dist/src/hmac/index.browser.js +4 -3
- package/dist/src/hmac/index.browser.js.map +1 -1
- package/dist/src/keys/ecdh/index.browser.d.ts +1 -1
- package/dist/src/keys/ecdh/index.browser.js +2 -2
- package/dist/src/keys/ecdh/index.d.ts +1 -1
- package/dist/src/keys/ecdsa/ecdsa.js +1 -1
- package/dist/src/keys/ecdsa/index.d.ts +1 -1
- package/dist/src/keys/ecdsa/index.d.ts.map +1 -1
- package/dist/src/keys/ecdsa/index.js +3 -2
- package/dist/src/keys/ecdsa/index.js.map +1 -1
- package/dist/src/keys/ecdsa/utils.d.ts +1 -1
- package/dist/src/keys/ecdsa/utils.js +1 -1
- package/dist/src/keys/ed25519/ed25519.js +1 -1
- package/dist/src/keys/ed25519/index.browser.d.ts +1 -1
- package/dist/src/keys/ed25519/index.browser.d.ts.map +1 -1
- package/dist/src/keys/ed25519/index.browser.js +4 -3
- package/dist/src/keys/ed25519/index.browser.js.map +1 -1
- package/dist/src/keys/ed25519/index.d.ts +1 -1
- package/dist/src/keys/key-stretcher.js +1 -1
- package/dist/src/keys/rsa/index.browser.d.ts +2 -2
- package/dist/src/keys/rsa/index.browser.d.ts.map +1 -1
- package/dist/src/keys/rsa/index.browser.js +5 -4
- package/dist/src/keys/rsa/index.browser.js.map +1 -1
- package/dist/src/keys/rsa/index.d.ts +2 -2
- package/dist/src/keys/rsa/index.js +1 -1
- package/dist/src/keys/rsa/utils.d.ts +1 -1
- package/dist/src/keys/rsa/utils.js +1 -1
- package/dist/src/keys/secp256k1/index.browser.js +2 -2
- package/dist/src/keys/secp256k1/index.js +1 -1
- package/dist/src/keys/secp256k1/secp256k1.js +1 -1
- package/dist/src/webcrypto/index.d.ts +4 -2
- package/dist/src/webcrypto/index.d.ts.map +1 -1
- package/dist/src/webcrypto/index.js +16 -2
- package/dist/src/webcrypto/index.js.map +1 -1
- package/package.json +5 -6
- package/src/ciphers/aes-gcm.browser.ts +8 -7
- package/src/hmac/index.browser.ts +4 -3
- package/src/keys/ecdh/index.browser.ts +3 -3
- package/src/keys/ecdh/index.ts +1 -1
- package/src/keys/ecdsa/ecdsa.ts +1 -1
- package/src/keys/ecdsa/index.ts +4 -3
- package/src/keys/ecdsa/utils.ts +2 -2
- package/src/keys/ed25519/ed25519.ts +1 -1
- package/src/keys/ed25519/index.browser.ts +5 -4
- package/src/keys/ed25519/index.ts +1 -1
- package/src/keys/key-stretcher.ts +1 -1
- package/src/keys/rsa/index.browser.ts +7 -6
- package/src/keys/rsa/index.ts +2 -2
- package/src/keys/rsa/utils.ts +2 -2
- package/src/keys/secp256k1/index.browser.ts +2 -2
- package/src/keys/secp256k1/index.ts +1 -1
- package/src/keys/secp256k1/secp256k1.ts +1 -1
- package/src/webcrypto/index.ts +20 -2
- package/dist/src/webcrypto/webcrypto.browser.d.ts +0 -5
- package/dist/src/webcrypto/webcrypto.browser.d.ts.map +0 -1
- package/dist/src/webcrypto/webcrypto.browser.js +0 -18
- package/dist/src/webcrypto/webcrypto.browser.js.map +0 -1
- package/dist/src/webcrypto/webcrypto.d.ts +0 -6
- package/dist/src/webcrypto/webcrypto.d.ts.map +0 -1
- package/dist/src/webcrypto/webcrypto.js +0 -10
- package/dist/src/webcrypto/webcrypto.js.map +0 -1
- package/src/webcrypto/webcrypto.browser.ts +0 -23
- package/src/webcrypto/webcrypto.ts +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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.
|
|
6
|
-
import webcrypto from '../../webcrypto/index.
|
|
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.
|
|
8
|
+
import type { ECDHKey, ECDHKeyPair, JWKEncodedPrivateKey, JWKEncodedPublicKey } from '../interface.ts'
|
|
9
9
|
|
|
10
10
|
const curveLengths = {
|
|
11
11
|
'P-256': 32,
|
package/src/keys/ecdh/index.ts
CHANGED
package/src/keys/ecdsa/ecdsa.ts
CHANGED
|
@@ -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.
|
|
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'
|
package/src/keys/ecdsa/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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
|
package/src/keys/ecdsa/utils.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
|
4
|
-
import
|
|
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.
|
|
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.
|
|
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
|
|
4
|
-
import
|
|
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.
|
|
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
|
|
package/src/keys/rsa/index.ts
CHANGED
|
@@ -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.
|
|
5
|
+
import randomBytes from '../../random-bytes.ts'
|
|
6
6
|
import * as utils from './utils.ts'
|
|
7
|
-
import type { JWKKeyPair } from '../interface.
|
|
7
|
+
import type { JWKKeyPair } from '../interface.ts'
|
|
8
8
|
import type { AbortOptions } from '@libp2p/interface'
|
|
9
9
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
10
10
|
|
package/src/keys/rsa/utils.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
4
|
-
import { isPromise } from '../../util.
|
|
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.
|
|
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.
|
|
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'
|
package/src/webcrypto/index.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WebCryptoMissingError } from '../errors.ts'
|
|
2
2
|
|
|
3
|
-
|
|
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 +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 +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,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
|
-
}
|