@symbiote-native/standard-web-crypto 3.0.2 → 3.0.3

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 (2) hide show
  1. package/README.md +27 -17
  2. package/package.json +15 -15
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # @symbiote-native/standard-web-crypto
2
2
 
3
3
  A wrapper package for [SymbioteNative](../../README.md) that makes
4
- [`expo-standard-web-crypto`](https://github.com/expo/expo/tree/main/packages/expo-standard-web-crypto)
5
- — a partial W3C [Web Crypto API](https://www.w3.org/TR/WebCryptoAPI/) polyfill exposing
6
- `crypto.getRandomValues` — usable from **every** adapter, React, Vue, Svelte, Solid, and Angular,
4
+ [`expo-standard-web-crypto`](https://github.com/expo/expo/tree/main/packages/expo-standard-web-crypto):
5
+ a partial W3C [Web Crypto API](https://www.w3.org/TR/WebCryptoAPI/) polyfill exposing
6
+ `crypto.getRandomValues` - usable from **every** adapter, React, Vue, Svelte, Solid, and Angular,
7
7
  not just React.
8
- Unlike this repo's other Expo ports, this package needs **no native module of its own** — upstream
8
+ Unlike this repo's other Expo ports, this package needs **no native module of its own** - upstream
9
9
  is a ~15-line pure-JS shim that delegates straight to `expo-crypto`'s own `getRandomValues`; this
10
10
  port delegates to [`@symbiote-native/crypto`](../crypto)'s `getRandomValues` instead, since this
11
11
  repo already ships that native random source as a sibling package. Like `@symbiote-native/crypto`,
12
12
  every export here is a plain function/object with no per-instance state or event stream, so there
13
- is no hook/composable/service to wrap — the React, Vue, Svelte, Solid, and Angular entry points are
13
+ is no hook/composable/service to wrap - the React, Vue, Svelte, Solid, and Angular entry points are
14
14
  plain re-exports of the same `core`.
15
15
 
16
16
  ## Install
@@ -28,36 +28,36 @@ npx @symbiote-native/cli add --standard-web-crypto
28
28
  ```
29
29
 
30
30
  Either way: installs `@symbiote-native/standard-web-crypto` + `@symbiote-native/crypto` and wires
31
- the latter's native autolinking automatically — see [`@symbiote-native/cli`](../cli). This package
31
+ the latter's native autolinking automatically - see [`@symbiote-native/cli`](../cli). This package
32
32
  has no native module of its own; `@symbiote-native/crypto` does the actual native random-byte
33
33
  generation.
34
34
 
35
35
  <details>
36
- <summary>Manual install (no CLI — installing and wiring native autolinking by hand)</summary>
36
+ <summary>Manual install (no CLI - installing and wiring native autolinking by hand)</summary>
37
37
 
38
38
  ```bash
39
39
  npm install @symbiote-native/standard-web-crypto @symbiote-native/crypto
40
40
  ```
41
41
 
42
42
  `@symbiote-native/crypto` comes along as a regular dependency and does the actual native random-byte
43
- generation — see [its README](../crypto/README.md) for `expo-crypto`'s own native autolinking
43
+ generation - see [its README](../crypto/README.md) for `expo-crypto`'s own native autolinking
44
44
  requirements (already satisfied in any app that already wires up `@symbiote-native/crypto` or
45
45
  `@symbiote-native/device`).
46
46
 
47
- No further native wiring is needed for this package itself — it has no native module of its own.
47
+ No further native wiring is needed for this package itself - it has no native module of its own.
48
48
 
49
49
  </details>
50
50
 
51
51
  ## Shape
52
52
 
53
53
  ```
54
- src/core/ web-crypto.ts — the Crypto class + webCrypto singleton (default export, also
54
+ src/core/ web-crypto.ts - the Crypto class + webCrypto singleton (default export, also
55
55
  re-exported as the named `webCrypto`) and polyfillWebCrypto(), delegating to
56
56
  @symbiote-native/crypto's getRandomValues.
57
- src/angular/ @symbiote-native/standard-web-crypto/angular — export * from '../core'
57
+ src/angular/ @symbiote-native/standard-web-crypto/angular - export * from '../core'
58
58
  ```
59
59
 
60
- `./react`, `./vue`, `./svelte`, and `./solid` are `exports`-map aliases straight onto `src/core/` —
60
+ `./react`, `./vue`, `./svelte`, and `./solid` are `exports`-map aliases straight onto `src/core/`:
61
61
  no physical per-framework file, since there's nothing to subscribe to or clean up. (The `webCrypto`
62
62
  named re-export used to be duplicated across those per-framework barrels; it now lives once in
63
63
  `src/core/index.ts` instead.) `./angular` stays a physical file/subpath since Angular ships
@@ -75,7 +75,7 @@ const bytes = new Uint8Array(16);
75
75
  webCrypto.getRandomValues(bytes);
76
76
 
77
77
  // Or install it as globalThis.crypto for any library that expects the Web Crypto API to
78
- // already be present — a no-op if globalThis.crypto is already defined:
78
+ // already be present - a no-op if globalThis.crypto is already defined:
79
79
  polyfillWebCrypto();
80
80
  crypto.getRandomValues(bytes);
81
81
  ```
@@ -121,14 +121,24 @@ Plus the `IWebCrypto` type describing the shape above.
121
121
  `window` global, so this port checks/defines `globalThis.crypto` rather than upstream's `window`.
122
122
  - **`getRandomValues` only accepts the integer TypedArrays `@symbiote-native/crypto` can hand to
123
123
  its native module** (`Int8Array`/`Uint8Array`/`Int16Array`/`Uint16Array`/`Int32Array`/
124
- `Uint32Array`) — passing any other `ArrayBufferView` (a `DataView`, `Uint8ClampedArray`, a
124
+ `Uint32Array`) - passing any other `ArrayBufferView` (a `DataView`, `Uint8ClampedArray`, a
125
125
  `Float32Array`, …) throws a `TypeError`, the same way upstream's own `getRandomValues` rejects an
126
126
  unsupported view.
127
- - `polyfillWebCrypto()` is a no-op when `globalThis.crypto` is already defined — it never
127
+ - `polyfillWebCrypto()` is a no-op when `globalThis.crypto` is already defined - it never
128
128
  overwrites an existing implementation.
129
129
 
130
+ ## Common questions
131
+
132
+ - **`crypto.getRandomValues is not a function` under Hermes.** Hermes ships no Web Crypto; install
133
+ this polyfill before `uuid` or `nanoid` load.
134
+ - **Where to import?** In the entry file, before React and your app.
135
+ - **`crypto.subtle` or `randomUUID`?** Not polyfilled; use `@symbiote-native/crypto`.
136
+
137
+ Sources: [expo/expo#7209](https://github.com/expo/expo/issues/7209),
138
+ [Fix crypto.getRandomValues with Hermes](https://medium.com/@manthankaslemk/how-to-fix-crypto-getrandomvalues-error-in-react-native-with-hermes-engine-8637cdf58e65).
139
+
130
140
  ## Test it
131
141
 
132
- Every export here is a pure function/object surface, never a view or per-instance state — no
142
+ Every export here is a pure function/object surface, never a view or per-instance state - no
133
143
  Fabric/Descriptor angle at all. Tests mock `@symbiote-native/crypto`'s `getRandomValues` directly
134
- (`src/core/web-crypto.test.ts`, `vitest`) — no `installFabric()`, no ViewConfig.
144
+ (`src/core/web-crypto.test.ts`, `vitest`) - no `installFabric()`, no ViewConfig.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/standard-web-crypto",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "expo-standard-web-crypto ported for SymbioteNative — a Web Crypto API getRandomValues polyfill built on @symbiote-native/crypto's native random source.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@symbiote-native/crypto": "3.0.2"
71
+ "@symbiote-native/crypto": "3.0.3"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@angular/core": ">=20",
@@ -78,12 +78,12 @@
78
78
  "solid-js": ">=1.9.0",
79
79
  "svelte": ">=5.56.0",
80
80
  "vue": ">=3.5.0",
81
- "@symbiote-native/angular": "^3.1.2",
82
- "@symbiote-native/engine": "^1.3.1",
83
- "@symbiote-native/react": "^3.0.4",
84
- "@symbiote-native/solid": "^3.0.4",
85
- "@symbiote-native/svelte": "^3.0.4",
86
- "@symbiote-native/vue": "^3.0.4"
81
+ "@symbiote-native/angular": "^3.2.0",
82
+ "@symbiote-native/engine": "^1.5.0",
83
+ "@symbiote-native/react": "^3.2.0",
84
+ "@symbiote-native/solid": "^3.1.0",
85
+ "@symbiote-native/svelte": "^3.1.0",
86
+ "@symbiote-native/vue": "^3.2.0"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@symbiote-native/angular": {
@@ -131,13 +131,13 @@
131
131
  "solid-js": "^1.9.14",
132
132
  "svelte": "^5.56.0",
133
133
  "typescript": "~6.0.0",
134
- "@symbiote-native/angular": "3.1.2",
135
- "@symbiote-native/engine": "1.3.1",
136
- "@symbiote-native/react": "3.0.4",
137
- "@symbiote-native/solid": "3.0.4",
138
- "@symbiote-native/svelte": "3.0.4",
139
- "@symbiote-native/test-utils": "0.4.4",
140
- "@symbiote-native/vue": "3.0.4"
134
+ "@symbiote-native/angular": "3.2.0",
135
+ "@symbiote-native/engine": "1.5.0",
136
+ "@symbiote-native/react": "3.2.0",
137
+ "@symbiote-native/solid": "3.1.0",
138
+ "@symbiote-native/svelte": "3.1.0",
139
+ "@symbiote-native/test-utils": "0.4.6",
140
+ "@symbiote-native/vue": "3.2.0"
141
141
  },
142
142
  "scripts": {
143
143
  "typecheck": "tsc --build",