@symbiote-native/standard-web-crypto 0.0.1 → 0.1.0

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.
@@ -2,5 +2,5 @@
2
2
  // core. Same reasoning as the React/Vue entries — no per-instance state or event stream to wrap in
3
3
  // a service, so this is a plain re-export. `export *` never forwards a default export (ES module
4
4
  // semantics), so `webCrypto` needs its own explicit named re-export alongside it.
5
- export * from '../core';
6
- export { default as webCrypto } from '../core';
5
+ export * from '../core/index.js';
6
+ export { default as webCrypto } from '../core/index.js';
@@ -1 +1 @@
1
- export { default, polyfillWebCrypto } from './web-crypto';
1
+ export { default, polyfillWebCrypto } from './web-crypto.js';
@@ -3,5 +3,5 @@
3
3
  // is a plain re-export, mirroring @symbiote-native/device's and @symbiote-native/crypto's React
4
4
  // entries. `export *` never forwards a default export (ES module semantics), so `webCrypto` needs
5
5
  // its own explicit named re-export alongside it.
6
- export * from '../core';
7
- export { default as webCrypto } from '../core';
6
+ export * from '../core/index.js';
7
+ export { default as webCrypto } from '../core/index.js';
@@ -2,5 +2,5 @@
2
2
  // reasoning as the React entry — no per-instance state or event stream to wire onto Vue's
3
3
  // reactivity, so this is a plain re-export. `export *` never forwards a default export (ES module
4
4
  // semantics), so `webCrypto` needs its own explicit named re-export alongside it.
5
- export * from '../core';
6
- export { default as webCrypto } from '../core';
5
+ export * from '../core/index.js';
6
+ export { default as webCrypto } from '../core/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/standard-web-crypto",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
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
  "repository": {
@@ -39,13 +39,16 @@
39
39
  "files": [
40
40
  "src",
41
41
  "build",
42
- "build-ngc"
42
+ "build-ngc",
43
+ "!src/**/*.test.*",
44
+ "!src/**/*.spec.*",
45
+ "!src/**/*.detox.*"
43
46
  ],
44
47
  "publishConfig": {
45
48
  "access": "public"
46
49
  },
47
50
  "dependencies": {
48
- "@symbiote-native/crypto": "0.0.1"
51
+ "@symbiote-native/crypto": "0.1.0"
49
52
  },
50
53
  "peerDependencies": {
51
54
  "@symbiote-native/engine": ">=0.1.7",
@@ -54,7 +57,7 @@
54
57
  "react": ">=19.0.0",
55
58
  "react-native": ">=0.86",
56
59
  "vue": ">=3.5.0",
57
- "@symbiote-native/angular": "0.6.1",
60
+ "@symbiote-native/angular": "0.6.2",
58
61
  "@symbiote-native/react": "0.2.8",
59
62
  "@symbiote-native/vue": "0.3.8"
60
63
  },
@@ -90,10 +93,10 @@
90
93
  "@vue/runtime-core": "^3.5.13",
91
94
  "react": "19.2.3",
92
95
  "typescript": "~6.0.0",
93
- "@symbiote-native/test-utils": "0.1.6",
96
+ "@symbiote-native/angular": "0.6.2",
94
97
  "@symbiote-native/engine": "0.1.7",
95
98
  "@symbiote-native/react": "0.2.8",
96
- "@symbiote-native/angular": "0.6.1",
99
+ "@symbiote-native/test-utils": "0.1.6",
97
100
  "@symbiote-native/vue": "0.3.8"
98
101
  },
99
102
  "scripts": {
@@ -1,91 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
-
3
- const getRandomValues = vi.fn((typedArray: Uint8Array) => {
4
- typedArray.fill(7);
5
- return typedArray;
6
- });
7
-
8
- // @symbiote-native/crypto resolves the real native module via requireNativeModule() at import
9
- // time, which would throw in this headless test run — faked here in place of the sibling
10
- // package, the same pattern packages/crypto/src/core/crypto.test.ts uses for expo-modules-core.
11
- vi.mock('@symbiote-native/crypto', () => ({
12
- getRandomValues,
13
- }));
14
-
15
- // Node (unlike React Native) ships its own native `globalThis.crypto` — deleted before every test
16
- // so `web-crypto.ts`'s module-load-time feature detection sees the same "no crypto global" state
17
- // it would on-device, not Node's own WebCrypto implementation.
18
- beforeEach(() => {
19
- Reflect.deleteProperty(globalThis, 'crypto');
20
- });
21
-
22
- afterEach(() => {
23
- vi.clearAllMocks();
24
- Reflect.deleteProperty(globalThis, 'crypto');
25
- vi.resetModules();
26
- });
27
-
28
- describe('webCrypto.getRandomValues', () => {
29
- it('delegates a supported typed array to @symbiote-native/crypto', async () => {
30
- const { default: webCrypto } = await import('./web-crypto');
31
- const typedArray = new Uint8Array(4);
32
-
33
- const result = webCrypto.getRandomValues(typedArray);
34
-
35
- expect(result).toBe(typedArray);
36
- expect(getRandomValues).toHaveBeenCalledWith(typedArray);
37
- expect(Array.from(typedArray)).toEqual([7, 7, 7, 7]);
38
- });
39
-
40
- it('throws a TypeError for a view outside the supported integer TypedArrays', async () => {
41
- const { default: webCrypto } = await import('./web-crypto');
42
-
43
- expect(() => webCrypto.getRandomValues(new DataView(new ArrayBuffer(4)))).toThrow(TypeError);
44
- expect(getRandomValues).not.toHaveBeenCalled();
45
- });
46
- });
47
-
48
- describe('webCrypto singleton', () => {
49
- it('is the polyfill instance when globalThis.crypto is absent', async () => {
50
- const { default: webCrypto } = await import('./web-crypto');
51
-
52
- expect(typeof webCrypto.getRandomValues).toBe('function');
53
- });
54
-
55
- it('reuses an existing globalThis.crypto instead of the polyfill', async () => {
56
- const existingCrypto = { getRandomValues: vi.fn() };
57
- Object.defineProperty(globalThis, 'crypto', {
58
- configurable: true,
59
- value: existingCrypto,
60
- });
61
-
62
- const { default: webCrypto } = await import('./web-crypto');
63
-
64
- expect(webCrypto).toBe(existingCrypto);
65
- });
66
- });
67
-
68
- describe('polyfillWebCrypto', () => {
69
- it('defines globalThis.crypto when it is absent', async () => {
70
- const { default: webCrypto, polyfillWebCrypto } = await import('./web-crypto');
71
-
72
- expect(Reflect.get(globalThis, 'crypto')).toBeUndefined();
73
-
74
- polyfillWebCrypto();
75
-
76
- expect(Reflect.get(globalThis, 'crypto')).toBe(webCrypto);
77
- });
78
-
79
- it('does not overwrite an existing globalThis.crypto', async () => {
80
- const existingCrypto = { getRandomValues: vi.fn() };
81
- Object.defineProperty(globalThis, 'crypto', {
82
- configurable: true,
83
- value: existingCrypto,
84
- });
85
-
86
- const { polyfillWebCrypto } = await import('./web-crypto');
87
- polyfillWebCrypto();
88
-
89
- expect(Reflect.get(globalThis, 'crypto')).toBe(existingCrypto);
90
- });
91
- });