Skip to content

Commit bc8274c

Browse files
Last minute v2 fixes (#2007)
* Delete tests.yml * keep checking if it's loaded in the case of persistent layouts * Update package-lock.json * warn when crypto subtle is not available * update composer playground dependencies * dependency updates * publish inertia configs in playground * handle when crypto key is possibly null
1 parent 9b73c32 commit bc8274c

File tree

11 files changed

+1366
-1051
lines changed

11 files changed

+1366
-1051
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

packages/core/src/encryption.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export const encryptHistory = async (data: any): Promise<ArrayBuffer> => {
88
const iv = getIv()
99
const storedKey = await getKeyFromSessionStorage()
1010
const key = await getOrCreateKey(storedKey)
11+
12+
if (!key) {
13+
throw new Error('Unable to encrypt history')
14+
}
15+
1116
const encrypted = await encryptData(iv, key, data)
1217

1318
return encrypted
@@ -34,6 +39,12 @@ const encryptData = async (iv: Uint8Array, key: CryptoKey, data: any) => {
3439
throw new Error('Unable to encrypt history')
3540
}
3641

42+
if (typeof window.crypto.subtle === 'undefined') {
43+
console.warn('Encryption is not supported in this environment. SSL is required.')
44+
45+
return Promise.resolve(data)
46+
}
47+
3748
const textEncoder = new TextEncoder()
3849
const str = JSON.stringify(data)
3950
const encoded = new Uint8Array(str.length)
@@ -51,6 +62,12 @@ const encryptData = async (iv: Uint8Array, key: CryptoKey, data: any) => {
5162
}
5263

5364
const decryptData = async (iv: Uint8Array, key: CryptoKey, data: any) => {
65+
if (typeof window.crypto.subtle === 'undefined') {
66+
console.warn('Decryption is not supported in this environment. SSL is required.')
67+
68+
return Promise.resolve(data)
69+
}
70+
5471
const decrypted = await window.crypto.subtle.decrypt(
5572
{
5673
name: 'AES-GCM',
@@ -78,6 +95,12 @@ const getIv = () => {
7895
}
7996

8097
const createKey = async () => {
98+
if (typeof window.crypto.subtle === 'undefined') {
99+
console.warn('Encryption is not supported in this environment. SSL is required.')
100+
101+
return Promise.resolve(null)
102+
}
103+
81104
return window.crypto.subtle.generateKey(
82105
{
83106
name: 'AES-GCM',
@@ -89,6 +112,12 @@ const createKey = async () => {
89112
}
90113

91114
const saveKey = async (key: CryptoKey) => {
115+
if (typeof window.crypto.subtle === 'undefined') {
116+
console.warn('Encryption is not supported in this environment. SSL is required.')
117+
118+
return Promise.resolve()
119+
}
120+
92121
const keyData = await window.crypto.subtle.exportKey('raw', key)
93122

94123
SessionStorage.set(historySessionStorageKeys.key, Array.from(new Uint8Array(keyData)))
@@ -101,6 +130,10 @@ const getOrCreateKey = async (key: CryptoKey | null) => {
101130

102131
const newKey = await createKey()
103132

133+
if (!newKey) {
134+
return null
135+
}
136+
104137
await saveKey(newKey)
105138

106139
return newKey

packages/react/src/Deferred.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Deferred = ({ children, data, fallback }: DeferredProps) => {
1717
const keys = Array.isArray(data) ? data : [data]
1818

1919
useEffect(() => {
20-
setLoaded(loaded || keys.every((key) => pageProps[key] !== undefined))
20+
setLoaded(keys.every((key) => pageProps[key] !== undefined))
2121
}, [pageProps, keys])
2222

2323
return loaded ? children : fallback

playgrounds/react/composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
"name": "laravel/laravel",
33
"type": "project",
44
"description": "The Laravel Framework.",
5-
"keywords": ["framework", "laravel"],
5+
"keywords": [
6+
"framework",
7+
"laravel"
8+
],
69
"license": "MIT",
710
"require": {
811
"php": "^8.0.2",
912
"guzzlehttp/guzzle": "^7.2",
10-
"inertiajs/inertia-laravel": "^1.2",
11-
"laravel/framework": "^9.19",
12-
"laravel/sanctum": "^3.0",
13+
"inertiajs/inertia-laravel": "2.x-dev",
14+
"laravel/framework": "^10.0",
15+
"laravel/sanctum": "^3.2",
1316
"laravel/tinker": "^2.7"
1417
},
1518
"require-dev": {
@@ -19,7 +22,7 @@
1922
"mockery/mockery": "^1.4.4",
2023
"nunomaduro/collision": "^6.1",
2124
"phpunit/phpunit": "^9.5.10",
22-
"spatie/laravel-ignition": "^1.0"
25+
"spatie/laravel-ignition": "^2.0"
2326
},
2427
"autoload": {
2528
"psr-4": {

0 commit comments

Comments
 (0)