@symbiote-native/standard-web-crypto 0.0.1 → 0.2.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.
- package/build/angular/index.js +2 -2
- package/build/core/index.js +1 -1
- package/build/react/index.js +2 -2
- package/build/svelte/index.d.ts +2 -0
- package/build/svelte/index.js +8 -0
- package/build/vue/index.js +2 -2
- package/package.json +31 -14
- package/src/svelte/index.ts +8 -0
- package/src/core/web-crypto.test.ts +0 -91
package/build/angular/index.js
CHANGED
|
@@ -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';
|
package/build/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default, polyfillWebCrypto } from './web-crypto';
|
|
1
|
+
export { default, polyfillWebCrypto } from './web-crypto.js';
|
package/build/react/index.js
CHANGED
|
@@ -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';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @symbiote-native/standard-web-crypto/svelte: the Svelte entry over the framework-agnostic
|
|
2
|
+
// core. The polyfill has no per-instance state or event stream — nothing for a rune to wrap —
|
|
3
|
+
// so this is a plain re-export. Svelte's lifecycle bucket is `runes/` (adapters/svelte/src/runes
|
|
4
|
+
// — never React's `hooks` or Vue's `composables`), and this package has none to fill.
|
|
5
|
+
// `export *` never forwards a default export (ES module semantics), so `webCrypto` needs its own
|
|
6
|
+
// explicit named re-export alongside it.
|
|
7
|
+
export * from '../core/index.js';
|
|
8
|
+
export { default as webCrypto } from '../core/index.js';
|
package/build/vue/index.js
CHANGED
|
@@ -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
|
|
3
|
+
"version": "0.2.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": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./build/react/index.d.ts",
|
|
31
31
|
"default": "./build/react/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./svelte": {
|
|
34
|
+
"types": "./build/svelte/index.d.ts",
|
|
35
|
+
"default": "./build/svelte/index.js"
|
|
36
|
+
},
|
|
33
37
|
"./angular": {
|
|
34
38
|
"types": "./build-ngc/angular/index.d.ts",
|
|
35
39
|
"react-native": "./build-ngc/angular/index.js",
|
|
@@ -39,24 +43,29 @@
|
|
|
39
43
|
"files": [
|
|
40
44
|
"src",
|
|
41
45
|
"build",
|
|
42
|
-
"build-ngc"
|
|
46
|
+
"build-ngc",
|
|
47
|
+
"!src/**/*.test.*",
|
|
48
|
+
"!src/**/*.spec.*",
|
|
49
|
+
"!src/**/*.detox.*"
|
|
43
50
|
],
|
|
44
51
|
"publishConfig": {
|
|
45
52
|
"access": "public"
|
|
46
53
|
},
|
|
47
54
|
"dependencies": {
|
|
48
|
-
"@symbiote-native/crypto": "0.0
|
|
55
|
+
"@symbiote-native/crypto": "0.2.0"
|
|
49
56
|
},
|
|
50
57
|
"peerDependencies": {
|
|
58
|
+
"@symbiote-native/angular": ">=0.6.2",
|
|
51
59
|
"@symbiote-native/engine": ">=0.1.7",
|
|
60
|
+
"@symbiote-native/react": ">=0.2.8",
|
|
61
|
+
"@symbiote-native/svelte": ">=0.1.0",
|
|
62
|
+
"@symbiote-native/vue": ">=0.3.8",
|
|
52
63
|
"@angular/core": ">=20",
|
|
53
64
|
"@vue/runtime-core": "^3.5.13",
|
|
54
65
|
"react": ">=19.0.0",
|
|
55
66
|
"react-native": ">=0.86",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"@symbiote-native/react": "0.2.8",
|
|
59
|
-
"@symbiote-native/vue": "0.3.8"
|
|
67
|
+
"svelte": ">=5.56.0",
|
|
68
|
+
"vue": ">=3.5.0"
|
|
60
69
|
},
|
|
61
70
|
"peerDependenciesMeta": {
|
|
62
71
|
"@symbiote-native/angular": {
|
|
@@ -65,6 +74,9 @@
|
|
|
65
74
|
"@symbiote-native/react": {
|
|
66
75
|
"optional": true
|
|
67
76
|
},
|
|
77
|
+
"@symbiote-native/svelte": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
68
80
|
"@symbiote-native/vue": {
|
|
69
81
|
"optional": true
|
|
70
82
|
},
|
|
@@ -77,24 +89,29 @@
|
|
|
77
89
|
"react": {
|
|
78
90
|
"optional": true
|
|
79
91
|
},
|
|
92
|
+
"svelte": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
80
95
|
"vue": {
|
|
81
96
|
"optional": true
|
|
82
97
|
}
|
|
83
98
|
},
|
|
84
99
|
"devDependencies": {
|
|
85
|
-
"@angular/compiler": "
|
|
86
|
-
"@angular/compiler-cli": "
|
|
87
|
-
"@angular/core": "
|
|
100
|
+
"@angular/compiler": "~22.0.8",
|
|
101
|
+
"@angular/compiler-cli": "~22.0.8",
|
|
102
|
+
"@angular/core": "~22.0.8",
|
|
88
103
|
"@types/node": "^26.0.0",
|
|
89
104
|
"@types/react": "^19.2.0",
|
|
90
105
|
"@vue/runtime-core": "^3.5.13",
|
|
91
106
|
"react": "19.2.3",
|
|
107
|
+
"svelte": "^5.56.0",
|
|
92
108
|
"typescript": "~6.0.0",
|
|
109
|
+
"@symbiote-native/angular": "0.7.0",
|
|
110
|
+
"@symbiote-native/engine": "0.2.0",
|
|
111
|
+
"@symbiote-native/react": "0.3.0",
|
|
112
|
+
"@symbiote-native/svelte": "0.2.0",
|
|
93
113
|
"@symbiote-native/test-utils": "0.1.6",
|
|
94
|
-
"@symbiote-native/
|
|
95
|
-
"@symbiote-native/react": "0.2.8",
|
|
96
|
-
"@symbiote-native/angular": "0.6.1",
|
|
97
|
-
"@symbiote-native/vue": "0.3.8"
|
|
114
|
+
"@symbiote-native/vue": "0.4.0"
|
|
98
115
|
},
|
|
99
116
|
"scripts": {
|
|
100
117
|
"typecheck": "tsc --build",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @symbiote-native/standard-web-crypto/svelte: the Svelte entry over the framework-agnostic
|
|
2
|
+
// core. The polyfill has no per-instance state or event stream — nothing for a rune to wrap —
|
|
3
|
+
// so this is a plain re-export. Svelte's lifecycle bucket is `runes/` (adapters/svelte/src/runes
|
|
4
|
+
// — never React's `hooks` or Vue's `composables`), and this package has none to fill.
|
|
5
|
+
// `export *` never forwards a default export (ES module semantics), so `webCrypto` needs its own
|
|
6
|
+
// explicit named re-export alongside it.
|
|
7
|
+
export * from '../core';
|
|
8
|
+
export { default as webCrypto } from '../core';
|
|
@@ -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
|
-
});
|