@sphereon/oid4vci-common 0.17.1-feature.esm.cjs.24 → 0.18.2
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/LICENSE +201 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -58
- package/dist/index.d.ts +58 -58
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -3,64 +3,64 @@ import { CredentialFormat, ICredentialContextType, W3CVerifiableCredential, IVer
|
|
|
3
3
|
import { DynamicRegistrationClientMetadata, SigningAlgo, JWK, BaseJWK, CreateDPoPClientOpts } from '@sphereon/oid4vc-common';
|
|
4
4
|
import { SupportedEncodings } from 'uint8arrays/to-string';
|
|
5
5
|
|
|
6
|
-
// limit of Crypto.getRandomValues()
|
|
7
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
8
|
-
const MAX_BYTES = 65536;
|
|
9
|
-
|
|
10
|
-
// Node supports requesting up to this number of bytes
|
|
11
|
-
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
|
12
|
-
const MAX_UINT32 = 4294967295;
|
|
13
|
-
|
|
14
|
-
function oldBrowser() {
|
|
15
|
-
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line no-undef
|
|
19
|
-
const _global = typeof globalThis !== 'undefined' ? globalThis : global;
|
|
20
|
-
|
|
21
|
-
let crypto = _global.crypto || _global.msCrypto;
|
|
22
|
-
if (!crypto) {
|
|
23
|
-
try {
|
|
24
|
-
// eslint-disable-next-line no-undef
|
|
25
|
-
crypto = require('crypto');
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw Error('crypto module is not available');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const randomBytes = (size) => {
|
|
33
|
-
// phantomjs needs to throw
|
|
34
|
-
if (size > MAX_UINT32) throw new Error('requested too many random bytes');
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line no-undef
|
|
37
|
-
const bytes = Buffer.allocUnsafe(size);
|
|
38
|
-
|
|
39
|
-
if (size > 0) {
|
|
40
|
-
// getRandomValues fails on IE if size == 0
|
|
41
|
-
if (size > MAX_BYTES) {
|
|
42
|
-
// this is the max bytes crypto.getRandomValues
|
|
43
|
-
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
|
44
|
-
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
45
|
-
// buffer.slice automatically checks if the end is past the end of
|
|
46
|
-
// the buffer so we don't have to here
|
|
47
|
-
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
crypto.getRandomValues(bytes);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return Uint8Array.from(bytes);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (crypto && crypto.getRandomValues) {
|
|
59
|
-
// eslint-disable-next-line no-undef
|
|
60
|
-
module.exports = randomBytes;
|
|
61
|
-
} else {
|
|
62
|
-
// eslint-disable-next-line no-undef
|
|
63
|
-
module.exports = oldBrowser;
|
|
6
|
+
// limit of Crypto.getRandomValues()
|
|
7
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
8
|
+
const MAX_BYTES = 65536;
|
|
9
|
+
|
|
10
|
+
// Node supports requesting up to this number of bytes
|
|
11
|
+
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
|
12
|
+
const MAX_UINT32 = 4294967295;
|
|
13
|
+
|
|
14
|
+
function oldBrowser() {
|
|
15
|
+
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
const _global = typeof globalThis !== 'undefined' ? globalThis : global;
|
|
20
|
+
|
|
21
|
+
let crypto = _global.crypto || _global.msCrypto;
|
|
22
|
+
if (!crypto) {
|
|
23
|
+
try {
|
|
24
|
+
// eslint-disable-next-line no-undef
|
|
25
|
+
crypto = require('crypto');
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw Error('crypto module is not available');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const randomBytes = (size) => {
|
|
33
|
+
// phantomjs needs to throw
|
|
34
|
+
if (size > MAX_UINT32) throw new Error('requested too many random bytes');
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line no-undef
|
|
37
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
38
|
+
|
|
39
|
+
if (size > 0) {
|
|
40
|
+
// getRandomValues fails on IE if size == 0
|
|
41
|
+
if (size > MAX_BYTES) {
|
|
42
|
+
// this is the max bytes crypto.getRandomValues
|
|
43
|
+
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
|
44
|
+
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
45
|
+
// buffer.slice automatically checks if the end is past the end of
|
|
46
|
+
// the buffer so we don't have to here
|
|
47
|
+
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
crypto.getRandomValues(bytes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Uint8Array.from(bytes);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if (crypto && crypto.getRandomValues) {
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
module.exports = randomBytes;
|
|
61
|
+
} else {
|
|
62
|
+
// eslint-disable-next-line no-undef
|
|
63
|
+
module.exports = oldBrowser;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,64 +3,64 @@ import { CredentialFormat, ICredentialContextType, W3CVerifiableCredential, IVer
|
|
|
3
3
|
import { DynamicRegistrationClientMetadata, SigningAlgo, JWK, BaseJWK, CreateDPoPClientOpts } from '@sphereon/oid4vc-common';
|
|
4
4
|
import { SupportedEncodings } from 'uint8arrays/to-string';
|
|
5
5
|
|
|
6
|
-
// limit of Crypto.getRandomValues()
|
|
7
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
8
|
-
const MAX_BYTES = 65536;
|
|
9
|
-
|
|
10
|
-
// Node supports requesting up to this number of bytes
|
|
11
|
-
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
|
12
|
-
const MAX_UINT32 = 4294967295;
|
|
13
|
-
|
|
14
|
-
function oldBrowser() {
|
|
15
|
-
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line no-undef
|
|
19
|
-
const _global = typeof globalThis !== 'undefined' ? globalThis : global;
|
|
20
|
-
|
|
21
|
-
let crypto = _global.crypto || _global.msCrypto;
|
|
22
|
-
if (!crypto) {
|
|
23
|
-
try {
|
|
24
|
-
// eslint-disable-next-line no-undef
|
|
25
|
-
crypto = require('crypto');
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw Error('crypto module is not available');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const randomBytes = (size) => {
|
|
33
|
-
// phantomjs needs to throw
|
|
34
|
-
if (size > MAX_UINT32) throw new Error('requested too many random bytes');
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line no-undef
|
|
37
|
-
const bytes = Buffer.allocUnsafe(size);
|
|
38
|
-
|
|
39
|
-
if (size > 0) {
|
|
40
|
-
// getRandomValues fails on IE if size == 0
|
|
41
|
-
if (size > MAX_BYTES) {
|
|
42
|
-
// this is the max bytes crypto.getRandomValues
|
|
43
|
-
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
|
44
|
-
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
45
|
-
// buffer.slice automatically checks if the end is past the end of
|
|
46
|
-
// the buffer so we don't have to here
|
|
47
|
-
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
crypto.getRandomValues(bytes);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return Uint8Array.from(bytes);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (crypto && crypto.getRandomValues) {
|
|
59
|
-
// eslint-disable-next-line no-undef
|
|
60
|
-
module.exports = randomBytes;
|
|
61
|
-
} else {
|
|
62
|
-
// eslint-disable-next-line no-undef
|
|
63
|
-
module.exports = oldBrowser;
|
|
6
|
+
// limit of Crypto.getRandomValues()
|
|
7
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
|
|
8
|
+
const MAX_BYTES = 65536;
|
|
9
|
+
|
|
10
|
+
// Node supports requesting up to this number of bytes
|
|
11
|
+
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
|
|
12
|
+
const MAX_UINT32 = 4294967295;
|
|
13
|
+
|
|
14
|
+
function oldBrowser() {
|
|
15
|
+
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
const _global = typeof globalThis !== 'undefined' ? globalThis : global;
|
|
20
|
+
|
|
21
|
+
let crypto = _global.crypto || _global.msCrypto;
|
|
22
|
+
if (!crypto) {
|
|
23
|
+
try {
|
|
24
|
+
// eslint-disable-next-line no-undef
|
|
25
|
+
crypto = require('crypto');
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw Error('crypto module is not available');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const randomBytes = (size) => {
|
|
33
|
+
// phantomjs needs to throw
|
|
34
|
+
if (size > MAX_UINT32) throw new Error('requested too many random bytes');
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line no-undef
|
|
37
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
38
|
+
|
|
39
|
+
if (size > 0) {
|
|
40
|
+
// getRandomValues fails on IE if size == 0
|
|
41
|
+
if (size > MAX_BYTES) {
|
|
42
|
+
// this is the max bytes crypto.getRandomValues
|
|
43
|
+
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
|
44
|
+
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
45
|
+
// buffer.slice automatically checks if the end is past the end of
|
|
46
|
+
// the buffer so we don't have to here
|
|
47
|
+
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
crypto.getRandomValues(bytes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Uint8Array.from(bytes);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if (crypto && crypto.getRandomValues) {
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
module.exports = randomBytes;
|
|
61
|
+
} else {
|
|
62
|
+
// eslint-disable-next-line no-undef
|
|
63
|
+
module.exports = oldBrowser;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|