expo-standard-web-crypto 2.1.0 → 2.1.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRandomValues.js","sourceRoot":"","sources":["../src/getRandomValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE3E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAW/B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAiC,MAAc;IACpF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"getRandomValues.js","sourceRoot":"","sources":["../src/getRandomValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE3E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAW/B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAiC,MAAc;IACpF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,SAAS,CACjB,gFAAgF,CACjF,CAAC;IACJ,CAAC;IAED,IACE,CAAC,CAAC,MAAM,YAAY,SAAS,CAAC;QAC9B,CAAC,CAAC,MAAM,YAAY,UAAU,CAAC;QAC/B,CAAC,CAAC,MAAM,YAAY,UAAU,CAAC;QAC/B,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC;QAChC,CAAC,CAAC,MAAM,YAAY,UAAU,CAAC;QAC/B,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC;QAChC,CAAC,CAAC,MAAM,YAAY,iBAAiB,CAAC,EACtC,CAAC;QACD,MAAM,IAAI,SAAS,CAAC,6DAA6D,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,GAAG,gBAAgB,EAAE,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAC1B,uCAAuC,MAAM,CAAC,UAAU,oEAAoE,gBAAgB,GAAG,CAChJ,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,0FAA0F;QAC1F,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;QAC7F,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAA8B,MAAc;IACjF,sEAAsE;IACtE,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACrF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,sFAAsF;QACtF,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,kBAAmB,SAAQ,KAAK;IACpC,IAAI,GAAG,oBAAoB,CAAC;IAC5B,IAAI,GAAG,EAAE,CAAC,CAAC,qBAAqB;CACjC","sourcesContent":["import { getRandomValues as expoCryptoGetRandomValues } from 'expo-crypto';\n\nconst MAX_RANDOM_BYTES = 65536;\n\ntype IntegerArray =\n | Int8Array\n | Uint8Array\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Uint8ClampedArray;\n\n/**\n * An implementation of Crypto.getRandomValues that uses expo-random's secure random generator if\n * available and falls back to Math.random (cryptographically insecure) when synchronous bridged\n * methods are unavailable.\n *\n * See https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues\n */\nexport default function getRandomValues<TArray extends ArrayBufferView>(values: TArray): TArray {\n if (arguments.length < 1) {\n throw new TypeError(\n `An ArrayBuffer view must be specified as the destination for the random values`\n );\n }\n\n if (\n !(values instanceof Int8Array) &&\n !(values instanceof Uint8Array) &&\n !(values instanceof Int16Array) &&\n !(values instanceof Uint16Array) &&\n !(values instanceof Int32Array) &&\n !(values instanceof Uint32Array) &&\n !(values instanceof Uint8ClampedArray)\n ) {\n throw new TypeError(`The provided ArrayBuffer view is not an integer-typed array`);\n }\n\n if (values.byteLength > MAX_RANDOM_BYTES) {\n throw new QuotaExceededError(\n `The ArrayBuffer view's byte length (${values.byteLength}) exceeds the number of bytes of entropy available via this API (${MAX_RANDOM_BYTES})`\n );\n }\n\n try {\n // NOTE: Consider implementing `fillRandomBytes` to populate the given TypedArray directly\n expoCryptoGetRandomValues(values);\n } catch {\n // TODO: rethrow the error if it's not due to a lack of synchronous methods\n console.warn(`Random.getRandomBytes is not supported; falling back to insecure Math.random`);\n return getRandomValuesInsecure(values);\n }\n\n return values;\n}\n\nexport function getRandomValuesInsecure<TArray extends IntegerArray>(values: TArray): TArray {\n // Write random bytes to the given TypedArray's underlying ArrayBuffer\n const byteView = new Uint8Array(values.buffer, values.byteOffset, values.byteLength);\n for (let i = 0; i < byteView.length; i++) {\n // The range of Math.random() is [0, 1) and the ToUint8 abstract operation rounds down\n byteView[i] = Math.random() * 256;\n }\n return values;\n}\n\nclass QuotaExceededError extends Error {\n name = 'QuotaExceededError';\n code = 22; // QUOTA_EXCEEDED_ERR\n}\n"]}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM;IACV,eAAe,CAAiC,MAAc;QAC5D,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AAED,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;AAExE,eAAe,SAAS,CAAC;AAEzB,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM;IACV,eAAe,CAAiC,MAAc;QAC5D,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AAED,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;AAExE,eAAe,SAAS,CAAC;AAEzB,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;YACtC,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;SACrB,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["/*global crypto*/\nimport getRandomValues from './getRandomValues';\n\nclass Crypto {\n getRandomValues<TArray extends ArrayBufferView>(values: TArray): TArray {\n return getRandomValues(values);\n }\n}\n\nconst webCrypto = typeof crypto !== 'undefined' ? crypto : new Crypto();\n\nexport default webCrypto;\n\nexport function polyfillWebCrypto(): void {\n if (typeof crypto === 'undefined') {\n Object.defineProperty(window, 'crypto', {\n configurable: true,\n enumerable: true,\n get: () => webCrypto,\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-standard-web-crypto",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A partial implementation of the W3C Crypto API for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"author": "650 Industries, Inc.",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"expo-crypto": "^14.1.
|
|
34
|
-
"expo-module-scripts": "^4.1.
|
|
33
|
+
"expo-crypto": "^14.1.2",
|
|
34
|
+
"expo-module-scripts": "^4.1.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"expo-crypto": "^14.1.
|
|
37
|
+
"expo-crypto": "^14.1.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "cb9fdd93f76f28e2ace4f66080b2386d87239553"
|
|
41
41
|
}
|