@take-out/native 0.0.59
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/package.json +17 -0
- package/src/setup-crypto.native.ts +35 -0
- package/src/setup-crypto.ts +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@take-out/native",
|
|
3
|
+
"version": "0.0.59",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./setup-crypto": {
|
|
7
|
+
"react-native": "./src/setup-crypto.native.ts",
|
|
8
|
+
"default": "./src/setup-crypto.ts"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"expo-crypto": "*"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// we need to make this into a module not only for easy re-use, but also
|
|
2
|
+
// to workaround the issue of imports being hoisted above other code, so
|
|
3
|
+
// something like this can work:
|
|
4
|
+
//
|
|
5
|
+
// ```
|
|
6
|
+
// import '@take-out/native/setup-crypto'
|
|
7
|
+
// import * as utils from '@better-auth/utils' // a module that is using crypto from global scope
|
|
8
|
+
// ```
|
|
9
|
+
//
|
|
10
|
+
// while this cannot:
|
|
11
|
+
//
|
|
12
|
+
// ```
|
|
13
|
+
// import * as Crypto from 'expo-crypto'
|
|
14
|
+
// if (typeof crypto === 'undefined') {
|
|
15
|
+
// globalThis.crypto = Crypto
|
|
16
|
+
// }
|
|
17
|
+
// import * as utils from '@better-auth/utils' // a module that is using crypto from global scope
|
|
18
|
+
// ```
|
|
19
|
+
//
|
|
20
|
+
// since the above code will be transformed to something equivalent to:
|
|
21
|
+
//
|
|
22
|
+
// ```
|
|
23
|
+
// import * as Crypto from 'expo-crypto'
|
|
24
|
+
// import * as utils from '@better-auth/utils' // a module that is using crypto from global scope
|
|
25
|
+
// if (typeof crypto === 'undefined') {
|
|
26
|
+
// globalThis.crypto = Crypto
|
|
27
|
+
// }
|
|
28
|
+
// ```
|
|
29
|
+
|
|
30
|
+
import * as Crypto from 'expo-crypto'
|
|
31
|
+
|
|
32
|
+
if (typeof crypto === 'undefined') {
|
|
33
|
+
// polyfill crypto for better-auth
|
|
34
|
+
globalThis.crypto = Crypto as any
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// web - no polyfill needed
|