@dytsou/calendar-build 2.1.0 ā 2.1.4
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/README.md +17 -4
- package/package.json +2 -3
- package/scripts/build.js +10 -7
- package/scripts/encrypt-urls.js +0 -1
- package/worker.js +595 -180
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ wrangler secret put ENCRYPTION_KEY
|
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
**Getting Google Calendar iCal URLs:**
|
|
33
|
+
|
|
33
34
|
- Go to your Google Calendar settings
|
|
34
35
|
- Find the calendar you want to share
|
|
35
36
|
- Click "Integrate calendar" or "Get shareable link"
|
|
@@ -193,12 +194,15 @@ This project uses a Cloudflare Worker to manage calendar URLs securely. Calendar
|
|
|
193
194
|
### Setup Instructions
|
|
194
195
|
|
|
195
196
|
1. **Copy wrangler.toml.example to wrangler.toml:**
|
|
197
|
+
|
|
196
198
|
```bash
|
|
197
199
|
cp wrangler.toml.example wrangler.toml
|
|
198
200
|
```
|
|
201
|
+
|
|
199
202
|
Then edit `wrangler.toml` and customize it for your environment (e.g., add custom domain routes).
|
|
200
203
|
|
|
201
204
|
2. **Install Wrangler CLI:**
|
|
205
|
+
|
|
202
206
|
```bash
|
|
203
207
|
npm install -g wrangler
|
|
204
208
|
# or
|
|
@@ -206,46 +210,55 @@ This project uses a Cloudflare Worker to manage calendar URLs securely. Calendar
|
|
|
206
210
|
```
|
|
207
211
|
|
|
208
212
|
3. **Login to Cloudflare:**
|
|
213
|
+
|
|
209
214
|
```bash
|
|
210
215
|
wrangler login
|
|
211
216
|
```
|
|
212
217
|
|
|
213
218
|
4. **Set Calendar URLs Secret:**
|
|
219
|
+
|
|
214
220
|
```bash
|
|
215
221
|
wrangler secret put CALENDAR_URL
|
|
216
222
|
```
|
|
223
|
+
|
|
217
224
|
When prompted, enter your calendar URLs (comma-separated):
|
|
225
|
+
|
|
218
226
|
```
|
|
219
227
|
https://calendar.google.com/calendar/ical/example%40gmail.com/public/basic.ics,https://calendar.google.com/calendar/ical/another%40gmail.com/public/basic.ics
|
|
220
228
|
```
|
|
221
|
-
|
|
229
|
+
|
|
222
230
|
**Note:** URLs can be plain or `fernet://` encrypted. If using encrypted URLs, you'll also need to set `ENCRYPTION_KEY`.
|
|
223
231
|
|
|
224
232
|
5. **Set Encryption Key Secret (if using fernet:// encrypted URLs):**
|
|
233
|
+
|
|
225
234
|
```bash
|
|
226
235
|
wrangler secret put ENCRYPTION_KEY
|
|
227
236
|
```
|
|
237
|
+
|
|
228
238
|
When prompted, enter your Fernet encryption key (base64url-encoded 32-byte key).
|
|
229
|
-
|
|
239
|
+
|
|
230
240
|
Generate one with:
|
|
241
|
+
|
|
231
242
|
```bash
|
|
232
243
|
node -e "console.log(require('crypto').randomBytes(32).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''))"
|
|
233
244
|
```
|
|
234
245
|
|
|
235
246
|
6. **Deploy the Worker:**
|
|
247
|
+
|
|
236
248
|
```bash
|
|
237
249
|
wrangler deploy
|
|
238
250
|
```
|
|
239
251
|
|
|
240
|
-
|
|
252
|
+
7. **Update your .env file:**
|
|
241
253
|
After deployment, update the `WORKER_URL` in your `.env` file with your worker URL:
|
|
254
|
+
|
|
242
255
|
```
|
|
243
256
|
WORKER_URL=https://your-worker.your-subdomain.workers.dev
|
|
244
257
|
# or if using custom domain:
|
|
245
258
|
WORKER_URL=https://your-domain.com
|
|
246
259
|
```
|
|
247
260
|
|
|
248
|
-
|
|
261
|
+
8. **Rebuild your project:**
|
|
249
262
|
```bash
|
|
250
263
|
pnpm run build
|
|
251
264
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dytsou/calendar-build",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Build script for calendar HTML from template and environment variables",
|
|
5
5
|
"main": "scripts/build.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,9 +34,8 @@
|
|
|
34
34
|
"node": ">=12.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"browserify": "^17.0.1",
|
|
38
37
|
"prettier": "^3.7.4",
|
|
39
|
-
"wrangler": "4.
|
|
38
|
+
"wrangler": "4.58.0"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
41
|
"fernet": "^0.3.3",
|
package/scripts/build.js
CHANGED
|
@@ -26,7 +26,7 @@ if (needsWorkerUrl || hasPlaceholders) {
|
|
|
26
26
|
console.error('Error: .env file not found (required for placeholders)');
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
if (fs.existsSync(envPath)) {
|
|
31
31
|
const envContent = fs.readFileSync(envPath, 'utf-8');
|
|
32
32
|
const envLines = envContent.split('\n');
|
|
@@ -58,7 +58,6 @@ if (needsWorkerUrl || hasPlaceholders) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (hasPlaceholders) {
|
|
61
|
-
|
|
62
61
|
// Replace CALENDAR_SOURCES placeholder
|
|
63
62
|
if (html.includes('{{CALENDAR_SOURCES}}')) {
|
|
64
63
|
if (calendarSources.length === 0) {
|
|
@@ -119,7 +118,7 @@ if (hasPlaceholders) {
|
|
|
119
118
|
console.log(
|
|
120
119
|
`ā Replaced {{CALENDAR_URLS}} with ${encryptedUrls.length} Fernet-encrypted calendar URL(s)`
|
|
121
120
|
);
|
|
122
|
-
|
|
121
|
+
|
|
123
122
|
// Output encrypted URLs for copying to .env
|
|
124
123
|
console.log('\nš Encrypted URLs (for .env file):');
|
|
125
124
|
console.log('CALENDAR_URL_ENCRYPTED=' + encryptedUrls.join(','));
|
|
@@ -137,17 +136,20 @@ if (hasPlaceholders) {
|
|
|
137
136
|
'[\n' + calendarUrls.map(url => ` "${url}"`).join(',\n') + '\n ]';
|
|
138
137
|
html = html.replace('{{ENCRYPTION_METHOD}}', 'none');
|
|
139
138
|
html = html.replace('{{ENCRYPTION_KEY}}', '');
|
|
140
|
-
html = html.replace(
|
|
139
|
+
html = html.replace(
|
|
140
|
+
'{{WORKER_URL}}',
|
|
141
|
+
'https://open-web-calendar.hosted.quelltext.eu/calendar.html'
|
|
142
|
+
);
|
|
141
143
|
console.log(
|
|
142
144
|
`ā Replaced {{CALENDAR_URLS}} with ${calendarUrls.length} calendar URL(s) (no encryption)`
|
|
143
145
|
);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
html = html.replace('{{CALENDAR_URLS}}', calendarUrlsArrayCode);
|
|
147
|
-
|
|
149
|
+
|
|
148
150
|
// Remove encryption key placeholder (not needed with Worker)
|
|
149
151
|
html = html.replace('{{ENCRYPTION_KEY}}', '');
|
|
150
|
-
|
|
152
|
+
|
|
151
153
|
// Clean up fernet-bundle.js if it exists (no longer needed with Worker)
|
|
152
154
|
const bundleFile = path.join(__dirname, '..', 'fernet-bundle.js');
|
|
153
155
|
if (fs.existsSync(bundleFile)) {
|
|
@@ -159,7 +161,8 @@ if (hasPlaceholders) {
|
|
|
159
161
|
|
|
160
162
|
// Always replace WORKER_URL placeholder if it exists (regardless of other placeholders)
|
|
161
163
|
if (html.includes('{{WORKER_URL}}')) {
|
|
162
|
-
const finalWorkerUrl =
|
|
164
|
+
const finalWorkerUrl =
|
|
165
|
+
workerUrl || process.env.WORKER_URL || 'https://open-web-calendar.hosted.quelltext.eu';
|
|
163
166
|
html = html.replace('{{WORKER_URL}}', finalWorkerUrl);
|
|
164
167
|
if (finalWorkerUrl !== 'https://open-web-calendar.hosted.quelltext.eu') {
|
|
165
168
|
console.log(`ā Using Cloudflare Worker: ${finalWorkerUrl}`);
|
package/scripts/encrypt-urls.js
CHANGED