@cloudsignal/pwa-sdk 1.0.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/CHANGELOG.md +42 -0
- package/README.md +383 -0
- package/dist/index.cjs +2051 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +1197 -0
- package/dist/index.d.ts +1197 -0
- package/dist/index.global.js +9 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2026 -0
- package/dist/index.js.map +1 -0
- package/dist/service-worker.js +291 -0
- package/dist/service-worker.js.map +1 -0
- package/package.json +72 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudSignal PWA SDK Device Types
|
|
3
|
+
* Comprehensive device and platform detection types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Complete device information (35+ fields)
|
|
7
|
+
*/
|
|
8
|
+
interface DeviceInfo {
|
|
9
|
+
/** Operating system name: iOS, Android, Windows, macOS, Linux */
|
|
10
|
+
os: string;
|
|
11
|
+
/** OS version (e.g., "17.2", "14.0", "Windows 10/11") */
|
|
12
|
+
osVersion: string;
|
|
13
|
+
/** Device type: iPhone, iPad, Phone, Tablet, Desktop */
|
|
14
|
+
deviceType: string;
|
|
15
|
+
/** Specific device model (e.g., "iPhone 15 Pro", "Samsung Galaxy S23") */
|
|
16
|
+
deviceModel: string;
|
|
17
|
+
/** Whether device is mobile */
|
|
18
|
+
isMobile: boolean;
|
|
19
|
+
/** Whether device is tablet */
|
|
20
|
+
isTablet: boolean;
|
|
21
|
+
/** Whether device is desktop */
|
|
22
|
+
isDesktop: boolean;
|
|
23
|
+
/** Whether running in WebView (Facebook, Instagram, etc.) */
|
|
24
|
+
isWebView: boolean;
|
|
25
|
+
/** Browser name: Chrome, Safari, Firefox, Edge, Samsung Internet */
|
|
26
|
+
browser: string;
|
|
27
|
+
/** Browser version number */
|
|
28
|
+
browserVersion: string;
|
|
29
|
+
/** iOS device detected */
|
|
30
|
+
isIOS: boolean;
|
|
31
|
+
/** Android device detected */
|
|
32
|
+
isAndroid: boolean;
|
|
33
|
+
/** macOS device detected */
|
|
34
|
+
isMacOS: boolean;
|
|
35
|
+
/** Windows device detected */
|
|
36
|
+
isWindows: boolean;
|
|
37
|
+
/** Linux device detected */
|
|
38
|
+
isLinux: boolean;
|
|
39
|
+
/** Screen width in pixels */
|
|
40
|
+
screenWidth: number;
|
|
41
|
+
/** Screen height in pixels */
|
|
42
|
+
screenHeight: number;
|
|
43
|
+
/** Device pixel ratio (1-3) */
|
|
44
|
+
pixelRatio: number;
|
|
45
|
+
/** PWA support level: "full", "partial", "basic", "none" */
|
|
46
|
+
supportLevel: PWASupportLevel;
|
|
47
|
+
/** Whether Notification API is available */
|
|
48
|
+
hasNotificationPermission: boolean;
|
|
49
|
+
/** Whether Push Manager is supported */
|
|
50
|
+
hasPushManager: boolean;
|
|
51
|
+
/** Whether service workers are supported */
|
|
52
|
+
hasServiceWorker: boolean;
|
|
53
|
+
/** Whether Web Share API is available */
|
|
54
|
+
hasShareAPI: boolean;
|
|
55
|
+
/** Whether Badge API is available */
|
|
56
|
+
hasBadgeAPI: boolean;
|
|
57
|
+
/** Notification permission: "granted", "denied", "default" */
|
|
58
|
+
notificationPermission: NotificationPermissionState;
|
|
59
|
+
/** Current online/offline status */
|
|
60
|
+
isOnline: boolean;
|
|
61
|
+
/** Connection type: "4g", "3g", "2g", "slow-2g", "unknown" */
|
|
62
|
+
connectionType: string;
|
|
63
|
+
/** Platform emoji icon: 📱, 🤖, 💻, 🖥️ */
|
|
64
|
+
platformIcon: string;
|
|
65
|
+
/** Full user agent string for debugging */
|
|
66
|
+
userAgent: string;
|
|
67
|
+
/** Unique tracking ID combining device info */
|
|
68
|
+
trackingId: string;
|
|
69
|
+
/** Browser fingerprint (if generated) */
|
|
70
|
+
browserFingerprint?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* PWA support level
|
|
74
|
+
*/
|
|
75
|
+
type PWASupportLevel = 'full' | 'partial' | 'basic' | 'none';
|
|
76
|
+
/**
|
|
77
|
+
* Notification permission state
|
|
78
|
+
*/
|
|
79
|
+
type NotificationPermissionState = 'granted' | 'denied' | 'default';
|
|
80
|
+
/**
|
|
81
|
+
* PWA installation state
|
|
82
|
+
*/
|
|
83
|
+
interface InstallationState {
|
|
84
|
+
/** Whether PWA is currently installed */
|
|
85
|
+
isInstalled: boolean;
|
|
86
|
+
/** Whether browser can show install prompt */
|
|
87
|
+
canBeInstalled: boolean;
|
|
88
|
+
/** Whether manual installation is needed (iOS Safari) */
|
|
89
|
+
needsManualInstall: boolean;
|
|
90
|
+
/** Whether to show manual installation instructions */
|
|
91
|
+
showManualInstructions: boolean;
|
|
92
|
+
/** Installation steps for current platform */
|
|
93
|
+
installSteps: string[];
|
|
94
|
+
/** Display mode: 'browser' | 'standalone' | 'minimal-ui' | 'fullscreen' */
|
|
95
|
+
displayMode: DisplayMode;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Display mode for PWA
|
|
99
|
+
*/
|
|
100
|
+
type DisplayMode = 'browser' | 'standalone' | 'minimal-ui' | 'fullscreen';
|
|
101
|
+
/**
|
|
102
|
+
* Install prompt result
|
|
103
|
+
*/
|
|
104
|
+
interface InstallResult {
|
|
105
|
+
/** Whether installation was accepted */
|
|
106
|
+
accepted: boolean;
|
|
107
|
+
/** User's choice: 'accepted' | 'dismissed' */
|
|
108
|
+
outcome: 'accepted' | 'dismissed';
|
|
109
|
+
/** Platform that was installed on */
|
|
110
|
+
platform?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Platform-specific information
|
|
114
|
+
*/
|
|
115
|
+
interface PlatformInfo {
|
|
116
|
+
os: string;
|
|
117
|
+
osVersion: string;
|
|
118
|
+
browser: string;
|
|
119
|
+
browserVersion: string;
|
|
120
|
+
deviceType: string;
|
|
121
|
+
deviceModel: string;
|
|
122
|
+
isWebView: boolean;
|
|
123
|
+
userAgent: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Screen information
|
|
127
|
+
*/
|
|
128
|
+
interface ScreenInfo {
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
pixelRatio: number;
|
|
132
|
+
orientation: 'portrait' | 'landscape';
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Network information
|
|
136
|
+
*/
|
|
137
|
+
interface NetworkInfo {
|
|
138
|
+
isOnline: boolean;
|
|
139
|
+
connectionType: string;
|
|
140
|
+
effectiveType?: string;
|
|
141
|
+
downlink?: number;
|
|
142
|
+
rtt?: number;
|
|
143
|
+
saveData?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* PWA capabilities detection result
|
|
147
|
+
*/
|
|
148
|
+
interface PWACapabilities {
|
|
149
|
+
/** Service Worker API available */
|
|
150
|
+
serviceWorker: boolean;
|
|
151
|
+
/** Push API available */
|
|
152
|
+
push: boolean;
|
|
153
|
+
/** Notification API available */
|
|
154
|
+
notifications: boolean;
|
|
155
|
+
/** Background Sync API available */
|
|
156
|
+
backgroundSync: boolean;
|
|
157
|
+
/** Badge API available */
|
|
158
|
+
badge: boolean;
|
|
159
|
+
/** Web Share API available */
|
|
160
|
+
share: boolean;
|
|
161
|
+
/** Share Target API available */
|
|
162
|
+
shareTarget: boolean;
|
|
163
|
+
/** File System Access API available */
|
|
164
|
+
fileSystemAccess: boolean;
|
|
165
|
+
/** Contact Picker API available */
|
|
166
|
+
contactPicker: boolean;
|
|
167
|
+
/** Periodic Background Sync available */
|
|
168
|
+
periodicSync: boolean;
|
|
169
|
+
/** Overall support level */
|
|
170
|
+
supportLevel: PWASupportLevel;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* BeforeInstallPrompt event interface
|
|
174
|
+
*/
|
|
175
|
+
interface BeforeInstallPromptEvent extends Event {
|
|
176
|
+
/** Platforms the PWA can be installed on */
|
|
177
|
+
platforms: string[];
|
|
178
|
+
/** Promise that resolves with user choice */
|
|
179
|
+
userChoice: Promise<{
|
|
180
|
+
outcome: 'accepted' | 'dismissed';
|
|
181
|
+
platform: string;
|
|
182
|
+
}>;
|
|
183
|
+
/** Show the install prompt */
|
|
184
|
+
prompt(): Promise<void>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* CloudSignal PWA SDK Configuration Types
|
|
189
|
+
*/
|
|
190
|
+
/**
|
|
191
|
+
* Main SDK configuration options
|
|
192
|
+
*/
|
|
193
|
+
interface PWAConfig {
|
|
194
|
+
/** CloudSignal PWA service URL */
|
|
195
|
+
serviceUrl?: string;
|
|
196
|
+
/** Organization ID (UUID) */
|
|
197
|
+
organizationId: string;
|
|
198
|
+
/** Organization secret key for HMAC authentication */
|
|
199
|
+
organizationSecret: string;
|
|
200
|
+
/** PWA service ID (UUID) */
|
|
201
|
+
serviceId: string;
|
|
202
|
+
/** Enable debug logging */
|
|
203
|
+
debug?: boolean;
|
|
204
|
+
/** Platform preset for optimized settings */
|
|
205
|
+
preset?: 'mobile' | 'desktop' | 'auto';
|
|
206
|
+
/** Service worker configuration */
|
|
207
|
+
serviceWorker?: ServiceWorkerConfig;
|
|
208
|
+
/** Heartbeat configuration */
|
|
209
|
+
heartbeat?: HeartbeatConfig;
|
|
210
|
+
/** Custom logger function */
|
|
211
|
+
logger?: LoggerFunction;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Service worker configuration
|
|
215
|
+
*/
|
|
216
|
+
interface ServiceWorkerConfig {
|
|
217
|
+
/** Path to service worker file */
|
|
218
|
+
path?: string;
|
|
219
|
+
/** Service worker scope */
|
|
220
|
+
scope?: string;
|
|
221
|
+
/** Auto-register service worker on initialization */
|
|
222
|
+
autoRegister?: boolean;
|
|
223
|
+
/** Update behavior: 'prompt' | 'auto' | 'manual' */
|
|
224
|
+
updateBehavior?: 'prompt' | 'auto' | 'manual';
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Heartbeat configuration for online status tracking
|
|
228
|
+
*/
|
|
229
|
+
interface HeartbeatConfig {
|
|
230
|
+
/** Enable heartbeat */
|
|
231
|
+
enabled?: boolean;
|
|
232
|
+
/** Heartbeat interval in milliseconds (default: 30000) */
|
|
233
|
+
interval?: number;
|
|
234
|
+
/** Automatically start heartbeat when registered */
|
|
235
|
+
autoStart?: boolean;
|
|
236
|
+
/** Stop heartbeat when page is hidden */
|
|
237
|
+
stopOnHidden?: boolean;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Logger function signature
|
|
241
|
+
*/
|
|
242
|
+
type LoggerFunction = (level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: any) => void;
|
|
243
|
+
/**
|
|
244
|
+
* PWA service configuration returned from backend
|
|
245
|
+
*/
|
|
246
|
+
interface PWAServiceConfig {
|
|
247
|
+
/** Service identifier */
|
|
248
|
+
service_identifier: string;
|
|
249
|
+
/** Service name for display */
|
|
250
|
+
service_name: string;
|
|
251
|
+
/** VAPID public key for push subscriptions */
|
|
252
|
+
vapid_public_key: string;
|
|
253
|
+
/** Whether notifications are enabled */
|
|
254
|
+
notifications_enabled: boolean;
|
|
255
|
+
/** Service ID (UUID) */
|
|
256
|
+
service_id?: string;
|
|
257
|
+
/** Icon URL */
|
|
258
|
+
icon_url?: string;
|
|
259
|
+
/** Manifest URL */
|
|
260
|
+
manifest_url?: string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Options for registering push notifications
|
|
264
|
+
*/
|
|
265
|
+
interface RegisterOptions {
|
|
266
|
+
/** User email address */
|
|
267
|
+
userEmail?: string;
|
|
268
|
+
/** User ID (UUID) */
|
|
269
|
+
userId?: string;
|
|
270
|
+
/** Notification topics to subscribe to */
|
|
271
|
+
topics?: string[];
|
|
272
|
+
/** User's timezone */
|
|
273
|
+
timezone?: string;
|
|
274
|
+
/** User's preferred language */
|
|
275
|
+
language?: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Options for updating notification preferences
|
|
279
|
+
*/
|
|
280
|
+
interface NotificationPreferences {
|
|
281
|
+
/** Topics to subscribe to */
|
|
282
|
+
topics?: string[];
|
|
283
|
+
/** Timezone */
|
|
284
|
+
timezone?: string;
|
|
285
|
+
/** Language */
|
|
286
|
+
language?: string;
|
|
287
|
+
/** Whether registration is active */
|
|
288
|
+
isActive?: boolean;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* SDK initialization result
|
|
292
|
+
*/
|
|
293
|
+
interface InitializeResult {
|
|
294
|
+
/** Whether initialization was successful */
|
|
295
|
+
success: boolean;
|
|
296
|
+
/** Service configuration if loaded */
|
|
297
|
+
config?: PWAServiceConfig;
|
|
298
|
+
/** Device information */
|
|
299
|
+
deviceInfo?: DeviceInfo;
|
|
300
|
+
/** Installation state */
|
|
301
|
+
installationState?: InstallationState;
|
|
302
|
+
/** Error message if failed */
|
|
303
|
+
error?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* CloudSignal PWA SDK Notification Types
|
|
308
|
+
*/
|
|
309
|
+
/**
|
|
310
|
+
* Push notification registration response
|
|
311
|
+
*/
|
|
312
|
+
interface Registration {
|
|
313
|
+
/** Registration ID (UUID) */
|
|
314
|
+
registrationId: string;
|
|
315
|
+
/** Registration status */
|
|
316
|
+
status: RegistrationStatus;
|
|
317
|
+
/** When registration was created */
|
|
318
|
+
createdAt: string;
|
|
319
|
+
/** Whether registration is active */
|
|
320
|
+
isActive: boolean;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Registration status
|
|
324
|
+
*/
|
|
325
|
+
type RegistrationStatus = 'active' | 'inactive' | 'expired' | 'unregistered';
|
|
326
|
+
/**
|
|
327
|
+
* Registration status response from backend
|
|
328
|
+
*/
|
|
329
|
+
interface RegistrationStatusResponse {
|
|
330
|
+
/** Registration ID */
|
|
331
|
+
registrationId: string;
|
|
332
|
+
/** Current status */
|
|
333
|
+
status: RegistrationStatus;
|
|
334
|
+
/** Whether registration is active */
|
|
335
|
+
isActive: boolean;
|
|
336
|
+
/** Whether client is currently online */
|
|
337
|
+
isOnline: boolean;
|
|
338
|
+
/** Last activity timestamp */
|
|
339
|
+
lastActive: string;
|
|
340
|
+
/** Last seen online timestamp */
|
|
341
|
+
lastSeenOnline?: string;
|
|
342
|
+
/** Last heartbeat timestamp */
|
|
343
|
+
lastHeartbeat?: string;
|
|
344
|
+
/** When PWA was first installed */
|
|
345
|
+
installationDate?: string;
|
|
346
|
+
/** Total notifications sent to this registration */
|
|
347
|
+
notificationCount: number;
|
|
348
|
+
/** Device information */
|
|
349
|
+
deviceInfo: {
|
|
350
|
+
deviceType: string;
|
|
351
|
+
browser: string;
|
|
352
|
+
os: string;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Push subscription data sent to backend
|
|
357
|
+
*/
|
|
358
|
+
interface PushSubscriptionData {
|
|
359
|
+
/** Service ID (UUID) */
|
|
360
|
+
serviceId: string;
|
|
361
|
+
/** User email (optional) */
|
|
362
|
+
userEmail?: string;
|
|
363
|
+
/** User ID (UUID, optional) */
|
|
364
|
+
userId?: string;
|
|
365
|
+
/** Push endpoint URL */
|
|
366
|
+
endpoint: string;
|
|
367
|
+
/** Push encryption keys */
|
|
368
|
+
keys: {
|
|
369
|
+
p256dh: string;
|
|
370
|
+
auth: string;
|
|
371
|
+
};
|
|
372
|
+
/** Browser fingerprint for deduplication */
|
|
373
|
+
browserFingerprint?: string;
|
|
374
|
+
/** Device type */
|
|
375
|
+
deviceType: string;
|
|
376
|
+
/** Device model */
|
|
377
|
+
deviceModel?: string;
|
|
378
|
+
/** Browser name */
|
|
379
|
+
browserName: string;
|
|
380
|
+
/** Browser version */
|
|
381
|
+
browserVersion?: string;
|
|
382
|
+
/** OS name */
|
|
383
|
+
osName: string;
|
|
384
|
+
/** OS version */
|
|
385
|
+
osVersion?: string;
|
|
386
|
+
/** Full user agent */
|
|
387
|
+
userAgent: string;
|
|
388
|
+
/** Display mode */
|
|
389
|
+
displayMode?: string;
|
|
390
|
+
/** Whether PWA is installed */
|
|
391
|
+
isInstalled?: boolean;
|
|
392
|
+
/** User's timezone */
|
|
393
|
+
timezone?: string;
|
|
394
|
+
/** User's language */
|
|
395
|
+
language?: string;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Notification payload structure
|
|
399
|
+
*/
|
|
400
|
+
interface NotificationPayload {
|
|
401
|
+
/** Notification title */
|
|
402
|
+
title: string;
|
|
403
|
+
/** Notification body text */
|
|
404
|
+
body: string;
|
|
405
|
+
/** Icon URL */
|
|
406
|
+
icon?: string;
|
|
407
|
+
/** Badge icon URL */
|
|
408
|
+
badge?: string;
|
|
409
|
+
/** Large image URL */
|
|
410
|
+
image?: string;
|
|
411
|
+
/** Notification tag for grouping */
|
|
412
|
+
tag?: string;
|
|
413
|
+
/** Whether notification requires interaction */
|
|
414
|
+
requireInteraction?: boolean;
|
|
415
|
+
/** Custom data payload */
|
|
416
|
+
data?: Record<string, any>;
|
|
417
|
+
/** URL to open on click */
|
|
418
|
+
url?: string;
|
|
419
|
+
/** Notification actions/buttons */
|
|
420
|
+
actions?: NotificationAction[];
|
|
421
|
+
/** Vibration pattern */
|
|
422
|
+
vibrate?: number[];
|
|
423
|
+
/** Whether to renotify for same tag */
|
|
424
|
+
renotify?: boolean;
|
|
425
|
+
/** Whether notification is silent */
|
|
426
|
+
silent?: boolean;
|
|
427
|
+
/** Timestamp */
|
|
428
|
+
timestamp?: number;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Notification action button
|
|
432
|
+
*/
|
|
433
|
+
interface NotificationAction {
|
|
434
|
+
/** Action identifier */
|
|
435
|
+
action: string;
|
|
436
|
+
/** Action button title */
|
|
437
|
+
title: string;
|
|
438
|
+
/** Action icon URL */
|
|
439
|
+
icon?: string;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Event types emitted by the SDK
|
|
443
|
+
*/
|
|
444
|
+
type PWAEvent = 'install:available' | 'install:accepted' | 'install:dismissed' | 'install:completed' | 'install:error' | 'push:registered' | 'push:unregistered' | 'push:updated' | 'push:error' | 'push:received' | 'push:clicked' | 'permission:granted' | 'permission:denied' | 'permission:prompt' | 'sw:registered' | 'sw:updated' | 'sw:error' | 'sw:activated' | 'config:loaded' | 'config:error' | 'heartbeat:started' | 'heartbeat:stopped' | 'heartbeat:sent' | 'heartbeat:error' | 'network:online' | 'network:offline' | 'state:changed';
|
|
445
|
+
/**
|
|
446
|
+
* Event handler function
|
|
447
|
+
*/
|
|
448
|
+
type EventHandler<T = any> = (data: T) => void;
|
|
449
|
+
/**
|
|
450
|
+
* Event data for install:available
|
|
451
|
+
*/
|
|
452
|
+
interface InstallAvailableEvent {
|
|
453
|
+
platforms: string[];
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Event data for install:accepted/dismissed
|
|
457
|
+
*/
|
|
458
|
+
interface InstallResultEvent {
|
|
459
|
+
outcome: 'accepted' | 'dismissed';
|
|
460
|
+
platform?: string;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Event data for push:registered
|
|
464
|
+
*/
|
|
465
|
+
interface PushRegisteredEvent {
|
|
466
|
+
registrationId: string;
|
|
467
|
+
endpoint: string;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Event data for push:received
|
|
471
|
+
*/
|
|
472
|
+
interface PushReceivedEvent {
|
|
473
|
+
payload: NotificationPayload;
|
|
474
|
+
timestamp: number;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Event data for push:clicked
|
|
478
|
+
*/
|
|
479
|
+
interface PushClickedEvent {
|
|
480
|
+
action?: string;
|
|
481
|
+
data?: Record<string, any>;
|
|
482
|
+
url?: string;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Event data for permission changes
|
|
486
|
+
*/
|
|
487
|
+
interface PermissionEvent {
|
|
488
|
+
permission: 'granted' | 'denied' | 'default';
|
|
489
|
+
previousPermission?: 'granted' | 'denied' | 'default';
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Event data for service worker events
|
|
493
|
+
*/
|
|
494
|
+
interface ServiceWorkerEvent {
|
|
495
|
+
registration?: ServiceWorkerRegistration;
|
|
496
|
+
error?: Error;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Event data for config:loaded
|
|
500
|
+
*/
|
|
501
|
+
interface ConfigLoadedEvent {
|
|
502
|
+
config: PWAServiceConfig;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Event data for heartbeat events
|
|
506
|
+
*/
|
|
507
|
+
interface HeartbeatEvent {
|
|
508
|
+
registrationId?: string;
|
|
509
|
+
timestamp: number;
|
|
510
|
+
error?: string;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Event data for network events
|
|
514
|
+
*/
|
|
515
|
+
interface NetworkEvent {
|
|
516
|
+
isOnline: boolean;
|
|
517
|
+
connectionType?: string;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* CloudSignal PWA Client
|
|
522
|
+
* Main class for PWA functionality including installation, push notifications, and device tracking
|
|
523
|
+
*/
|
|
524
|
+
declare class CloudSignalPWA {
|
|
525
|
+
private config;
|
|
526
|
+
private serviceUrl;
|
|
527
|
+
private debug;
|
|
528
|
+
private initialized;
|
|
529
|
+
private serviceConfig;
|
|
530
|
+
private deviceDetector;
|
|
531
|
+
private serviceWorkerManager;
|
|
532
|
+
private installationManager;
|
|
533
|
+
private pushNotificationManager;
|
|
534
|
+
private heartbeatManager;
|
|
535
|
+
private eventHandlers;
|
|
536
|
+
constructor(config: PWAConfig);
|
|
537
|
+
/**
|
|
538
|
+
* Initialize the PWA client
|
|
539
|
+
* Downloads config, registers service worker, and sets up event listeners
|
|
540
|
+
*/
|
|
541
|
+
initialize(): Promise<InitializeResult>;
|
|
542
|
+
/**
|
|
543
|
+
* Download PWA service configuration from backend
|
|
544
|
+
*/
|
|
545
|
+
downloadConfig(): Promise<PWAServiceConfig | null>;
|
|
546
|
+
/**
|
|
547
|
+
* Show the PWA install prompt
|
|
548
|
+
*/
|
|
549
|
+
showInstallPrompt(): Promise<InstallResult>;
|
|
550
|
+
/**
|
|
551
|
+
* Get current installation state
|
|
552
|
+
*/
|
|
553
|
+
getInstallationState(): InstallationState;
|
|
554
|
+
/**
|
|
555
|
+
* Check if PWA can be installed
|
|
556
|
+
*/
|
|
557
|
+
canInstall(): boolean;
|
|
558
|
+
/**
|
|
559
|
+
* Check if PWA is installed
|
|
560
|
+
*/
|
|
561
|
+
isInstalled(): boolean;
|
|
562
|
+
/**
|
|
563
|
+
* Get installation steps for current platform
|
|
564
|
+
*/
|
|
565
|
+
getInstallSteps(): string[];
|
|
566
|
+
/**
|
|
567
|
+
* Register for push notifications
|
|
568
|
+
*/
|
|
569
|
+
registerForPush(options?: RegisterOptions): Promise<Registration | null>;
|
|
570
|
+
/**
|
|
571
|
+
* Unregister from push notifications
|
|
572
|
+
*/
|
|
573
|
+
unregisterFromPush(): Promise<boolean>;
|
|
574
|
+
/**
|
|
575
|
+
* Update notification preferences
|
|
576
|
+
*/
|
|
577
|
+
updatePreferences(preferences: NotificationPreferences): Promise<boolean>;
|
|
578
|
+
/**
|
|
579
|
+
* Check registration status
|
|
580
|
+
*/
|
|
581
|
+
checkRegistrationStatus(): Promise<RegistrationStatusResponse | null>;
|
|
582
|
+
/**
|
|
583
|
+
* Get current registration ID
|
|
584
|
+
*/
|
|
585
|
+
getRegistrationId(): string | null;
|
|
586
|
+
/**
|
|
587
|
+
* Check if registered for push notifications
|
|
588
|
+
*/
|
|
589
|
+
isRegistered(): boolean;
|
|
590
|
+
/**
|
|
591
|
+
* Request notification permission
|
|
592
|
+
*/
|
|
593
|
+
requestPermission(): Promise<NotificationPermission>;
|
|
594
|
+
/**
|
|
595
|
+
* Get comprehensive device information
|
|
596
|
+
*/
|
|
597
|
+
getDeviceInfo(): DeviceInfo;
|
|
598
|
+
/**
|
|
599
|
+
* Get PWA capabilities
|
|
600
|
+
*/
|
|
601
|
+
getCapabilities(): PWACapabilities;
|
|
602
|
+
/**
|
|
603
|
+
* Start heartbeat for online status tracking
|
|
604
|
+
*/
|
|
605
|
+
startHeartbeat(): void;
|
|
606
|
+
/**
|
|
607
|
+
* Stop heartbeat
|
|
608
|
+
*/
|
|
609
|
+
stopHeartbeat(): void;
|
|
610
|
+
/**
|
|
611
|
+
* Clear app badge
|
|
612
|
+
*/
|
|
613
|
+
clearBadge(): void;
|
|
614
|
+
/**
|
|
615
|
+
* Set app badge count
|
|
616
|
+
*/
|
|
617
|
+
setBadge(count: number): void;
|
|
618
|
+
/**
|
|
619
|
+
* Check for service worker updates
|
|
620
|
+
*/
|
|
621
|
+
checkForUpdates(): Promise<void>;
|
|
622
|
+
/**
|
|
623
|
+
* Subscribe to an event
|
|
624
|
+
*/
|
|
625
|
+
on(event: PWAEvent, handler: EventHandler): void;
|
|
626
|
+
/**
|
|
627
|
+
* Unsubscribe from an event
|
|
628
|
+
*/
|
|
629
|
+
off(event: PWAEvent, handler: EventHandler): void;
|
|
630
|
+
/**
|
|
631
|
+
* Emit an event
|
|
632
|
+
*/
|
|
633
|
+
private emit;
|
|
634
|
+
/**
|
|
635
|
+
* Get SDK version
|
|
636
|
+
*/
|
|
637
|
+
getVersion(): string;
|
|
638
|
+
/**
|
|
639
|
+
* Get service configuration
|
|
640
|
+
*/
|
|
641
|
+
getServiceConfig(): PWAServiceConfig | null;
|
|
642
|
+
/**
|
|
643
|
+
* Check if client is initialized
|
|
644
|
+
*/
|
|
645
|
+
isInitialized(): boolean;
|
|
646
|
+
/**
|
|
647
|
+
* Inject PWA manifest link
|
|
648
|
+
*/
|
|
649
|
+
private injectManifest;
|
|
650
|
+
/**
|
|
651
|
+
* Set up network status listeners
|
|
652
|
+
*/
|
|
653
|
+
private setupNetworkListeners;
|
|
654
|
+
/**
|
|
655
|
+
* Log message if debug is enabled
|
|
656
|
+
*/
|
|
657
|
+
private log;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* DeviceDetector - Comprehensive Platform and Device Detection
|
|
662
|
+
* Ported from bubble-pwa-complete-handler.js with TypeScript support
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* DeviceDetector class for comprehensive device and platform detection
|
|
667
|
+
*/
|
|
668
|
+
declare class DeviceDetector {
|
|
669
|
+
private cachedInfo;
|
|
670
|
+
/**
|
|
671
|
+
* Get comprehensive device information
|
|
672
|
+
*/
|
|
673
|
+
getDeviceInfo(): DeviceInfo;
|
|
674
|
+
/**
|
|
675
|
+
* Clear cached device info (useful when network/permissions change)
|
|
676
|
+
*/
|
|
677
|
+
clearCache(): void;
|
|
678
|
+
/**
|
|
679
|
+
* Get platform-specific information
|
|
680
|
+
*/
|
|
681
|
+
getPlatformInfo(): PlatformInfo;
|
|
682
|
+
/**
|
|
683
|
+
* Get screen information
|
|
684
|
+
*/
|
|
685
|
+
getScreenInfo(): ScreenInfo;
|
|
686
|
+
/**
|
|
687
|
+
* Get network information
|
|
688
|
+
*/
|
|
689
|
+
getNetworkInfo(): NetworkInfo;
|
|
690
|
+
/**
|
|
691
|
+
* Get PWA capabilities
|
|
692
|
+
*/
|
|
693
|
+
getCapabilities(): PWACapabilities;
|
|
694
|
+
/**
|
|
695
|
+
* Get notification permission state
|
|
696
|
+
*/
|
|
697
|
+
getNotificationPermission(): NotificationPermissionState;
|
|
698
|
+
/**
|
|
699
|
+
* Check if device is mobile
|
|
700
|
+
*/
|
|
701
|
+
isMobile(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* Check if device is tablet
|
|
704
|
+
*/
|
|
705
|
+
isTablet(): boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Check if device is desktop
|
|
708
|
+
*/
|
|
709
|
+
isDesktop(): boolean;
|
|
710
|
+
/**
|
|
711
|
+
* Get platform icon emoji
|
|
712
|
+
*/
|
|
713
|
+
private getPlatformIcon;
|
|
714
|
+
/**
|
|
715
|
+
* Detect iPhone model from user agent
|
|
716
|
+
*/
|
|
717
|
+
private detectiPhoneModel;
|
|
718
|
+
/**
|
|
719
|
+
* Detect iPad model from user agent
|
|
720
|
+
*/
|
|
721
|
+
private detectiPadModel;
|
|
722
|
+
/**
|
|
723
|
+
* Detect Android device model
|
|
724
|
+
*/
|
|
725
|
+
private detectAndroidDevice;
|
|
726
|
+
/**
|
|
727
|
+
* Get Windows version from NT version
|
|
728
|
+
*/
|
|
729
|
+
private getWindowsVersion;
|
|
730
|
+
/**
|
|
731
|
+
* Detect if running in WebView
|
|
732
|
+
*/
|
|
733
|
+
private detectWebView;
|
|
734
|
+
}
|
|
735
|
+
declare const deviceDetector: DeviceDetector;
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* ServiceWorkerManager - Service Worker Registration and Management
|
|
739
|
+
*/
|
|
740
|
+
|
|
741
|
+
interface ServiceWorkerManagerOptions {
|
|
742
|
+
config?: ServiceWorkerConfig;
|
|
743
|
+
onRegistered?: (registration: ServiceWorkerRegistration) => void;
|
|
744
|
+
onUpdated?: (registration: ServiceWorkerRegistration) => void;
|
|
745
|
+
onError?: (error: Error) => void;
|
|
746
|
+
debug?: boolean;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* ServiceWorkerManager handles service worker registration, updates, and communication
|
|
750
|
+
*/
|
|
751
|
+
declare class ServiceWorkerManager {
|
|
752
|
+
private registration;
|
|
753
|
+
private config;
|
|
754
|
+
private debug;
|
|
755
|
+
private onRegistered?;
|
|
756
|
+
private onUpdated?;
|
|
757
|
+
private onError?;
|
|
758
|
+
constructor(options?: ServiceWorkerManagerOptions);
|
|
759
|
+
/**
|
|
760
|
+
* Check if service workers are supported
|
|
761
|
+
*/
|
|
762
|
+
isSupported(): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* Get the current service worker registration
|
|
765
|
+
*/
|
|
766
|
+
getRegistration(): ServiceWorkerRegistration | null;
|
|
767
|
+
/**
|
|
768
|
+
* Register the service worker
|
|
769
|
+
*/
|
|
770
|
+
register(): Promise<ServiceWorkerRegistration | null>;
|
|
771
|
+
/**
|
|
772
|
+
* Unregister the service worker
|
|
773
|
+
*/
|
|
774
|
+
unregister(): Promise<boolean>;
|
|
775
|
+
/**
|
|
776
|
+
* Check for service worker updates
|
|
777
|
+
*/
|
|
778
|
+
checkForUpdate(): Promise<void>;
|
|
779
|
+
/**
|
|
780
|
+
* Wait for service worker to be ready
|
|
781
|
+
*/
|
|
782
|
+
waitForReady(timeout?: number): Promise<ServiceWorkerRegistration | null>;
|
|
783
|
+
/**
|
|
784
|
+
* Send a message to the service worker
|
|
785
|
+
*/
|
|
786
|
+
postMessage(message: any): void;
|
|
787
|
+
/**
|
|
788
|
+
* Clear app badge via service worker
|
|
789
|
+
*/
|
|
790
|
+
clearBadge(): void;
|
|
791
|
+
/**
|
|
792
|
+
* Set app badge via service worker
|
|
793
|
+
*/
|
|
794
|
+
setBadge(count: number): void;
|
|
795
|
+
/**
|
|
796
|
+
* Handle service worker update found
|
|
797
|
+
*/
|
|
798
|
+
private handleUpdateFound;
|
|
799
|
+
/**
|
|
800
|
+
* Get service worker path and scope based on environment
|
|
801
|
+
* Handles Bubble.io version-live/version-test paths
|
|
802
|
+
*/
|
|
803
|
+
private getPathAndScope;
|
|
804
|
+
/**
|
|
805
|
+
* Log message if debug is enabled
|
|
806
|
+
*/
|
|
807
|
+
private log;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* InstallationManager - PWA Installation Detection and Prompts
|
|
812
|
+
*/
|
|
813
|
+
|
|
814
|
+
interface InstallationManagerOptions {
|
|
815
|
+
onInstallAvailable?: (event: BeforeInstallPromptEvent) => void;
|
|
816
|
+
onInstallAccepted?: (result: InstallResult) => void;
|
|
817
|
+
onInstallDismissed?: (result: InstallResult) => void;
|
|
818
|
+
onInstalled?: () => void;
|
|
819
|
+
debug?: boolean;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* InstallationManager handles PWA installation detection and prompts
|
|
823
|
+
*/
|
|
824
|
+
declare class InstallationManager {
|
|
825
|
+
private deferredPrompt;
|
|
826
|
+
private isInstalled;
|
|
827
|
+
private debug;
|
|
828
|
+
private onInstallAvailable?;
|
|
829
|
+
private onInstallAccepted?;
|
|
830
|
+
private onInstallDismissed?;
|
|
831
|
+
private onInstalled?;
|
|
832
|
+
constructor(options?: InstallationManagerOptions);
|
|
833
|
+
/**
|
|
834
|
+
* Initialize event listeners
|
|
835
|
+
*/
|
|
836
|
+
initialize(): void;
|
|
837
|
+
/**
|
|
838
|
+
* Get current installation state
|
|
839
|
+
*/
|
|
840
|
+
getState(): InstallationState;
|
|
841
|
+
/**
|
|
842
|
+
* Show the install prompt
|
|
843
|
+
*/
|
|
844
|
+
showInstallPrompt(): Promise<InstallResult>;
|
|
845
|
+
/**
|
|
846
|
+
* Check if install prompt is available
|
|
847
|
+
*/
|
|
848
|
+
canInstall(): boolean;
|
|
849
|
+
/**
|
|
850
|
+
* Check if PWA is installed
|
|
851
|
+
*/
|
|
852
|
+
isPWAInstalled(): boolean;
|
|
853
|
+
/**
|
|
854
|
+
* Get current display mode
|
|
855
|
+
*/
|
|
856
|
+
getDisplayMode(): DisplayMode;
|
|
857
|
+
/**
|
|
858
|
+
* Get installation steps for current platform
|
|
859
|
+
*/
|
|
860
|
+
getInstallSteps(): string[];
|
|
861
|
+
/**
|
|
862
|
+
* Detect initial installation status
|
|
863
|
+
*/
|
|
864
|
+
private detectInstallationStatus;
|
|
865
|
+
/**
|
|
866
|
+
* Check if device is iOS
|
|
867
|
+
*/
|
|
868
|
+
private isIOSDevice;
|
|
869
|
+
/**
|
|
870
|
+
* Check if device is Android
|
|
871
|
+
*/
|
|
872
|
+
private isAndroidDevice;
|
|
873
|
+
/**
|
|
874
|
+
* Check if browser is Safari
|
|
875
|
+
*/
|
|
876
|
+
private isSafariBrowser;
|
|
877
|
+
/**
|
|
878
|
+
* Log message if debug is enabled
|
|
879
|
+
*/
|
|
880
|
+
private log;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* PushNotificationManager - Push Notification Registration and Management
|
|
885
|
+
*/
|
|
886
|
+
|
|
887
|
+
interface PushNotificationManagerOptions {
|
|
888
|
+
serviceUrl: string;
|
|
889
|
+
organizationId: string;
|
|
890
|
+
organizationSecret: string;
|
|
891
|
+
serviceId: string;
|
|
892
|
+
debug?: boolean;
|
|
893
|
+
onRegistered?: (registration: Registration) => void;
|
|
894
|
+
onUnregistered?: () => void;
|
|
895
|
+
onError?: (error: Error) => void;
|
|
896
|
+
onPermissionDenied?: () => void;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* PushNotificationManager handles push notification registration with CloudSignal backend
|
|
900
|
+
*/
|
|
901
|
+
declare class PushNotificationManager {
|
|
902
|
+
private serviceUrl;
|
|
903
|
+
private organizationId;
|
|
904
|
+
private organizationSecret;
|
|
905
|
+
private serviceId;
|
|
906
|
+
private debug;
|
|
907
|
+
private deviceDetector;
|
|
908
|
+
private serviceWorkerRegistration;
|
|
909
|
+
private pushSubscription;
|
|
910
|
+
private registrationId;
|
|
911
|
+
private vapidPublicKey;
|
|
912
|
+
private onRegistered?;
|
|
913
|
+
private onUnregistered?;
|
|
914
|
+
private onError?;
|
|
915
|
+
private onPermissionDenied?;
|
|
916
|
+
constructor(options: PushNotificationManagerOptions);
|
|
917
|
+
/**
|
|
918
|
+
* Set service worker registration
|
|
919
|
+
*/
|
|
920
|
+
setServiceWorkerRegistration(registration: ServiceWorkerRegistration): void;
|
|
921
|
+
/**
|
|
922
|
+
* Set VAPID public key from config
|
|
923
|
+
*/
|
|
924
|
+
setVapidPublicKey(key: string): void;
|
|
925
|
+
/**
|
|
926
|
+
* Get current registration ID
|
|
927
|
+
*/
|
|
928
|
+
getRegistrationId(): string | null;
|
|
929
|
+
/**
|
|
930
|
+
* Check if registered for push notifications
|
|
931
|
+
*/
|
|
932
|
+
isRegistered(): boolean;
|
|
933
|
+
/**
|
|
934
|
+
* Register for push notifications
|
|
935
|
+
*/
|
|
936
|
+
register(options?: RegisterOptions): Promise<Registration | null>;
|
|
937
|
+
/**
|
|
938
|
+
* Unregister from push notifications
|
|
939
|
+
*/
|
|
940
|
+
unregister(): Promise<boolean>;
|
|
941
|
+
/**
|
|
942
|
+
* Update notification preferences
|
|
943
|
+
*/
|
|
944
|
+
updatePreferences(preferences: NotificationPreferences): Promise<boolean>;
|
|
945
|
+
/**
|
|
946
|
+
* Check registration status
|
|
947
|
+
*/
|
|
948
|
+
checkStatus(): Promise<RegistrationStatusResponse | null>;
|
|
949
|
+
/**
|
|
950
|
+
* Request notification permission
|
|
951
|
+
*/
|
|
952
|
+
requestPermission(): Promise<NotificationPermission>;
|
|
953
|
+
/**
|
|
954
|
+
* Subscribe to push notifications
|
|
955
|
+
*/
|
|
956
|
+
private subscribeToPush;
|
|
957
|
+
/**
|
|
958
|
+
* Convert base64 VAPID key to Uint8Array
|
|
959
|
+
*/
|
|
960
|
+
private urlBase64ToUint8Array;
|
|
961
|
+
/**
|
|
962
|
+
* Log message if debug is enabled
|
|
963
|
+
*/
|
|
964
|
+
private log;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* HeartbeatManager - Online Status Tracking via Periodic Heartbeat
|
|
969
|
+
*/
|
|
970
|
+
|
|
971
|
+
interface HeartbeatManagerOptions {
|
|
972
|
+
serviceUrl: string;
|
|
973
|
+
organizationId: string;
|
|
974
|
+
organizationSecret: string;
|
|
975
|
+
config?: HeartbeatConfig;
|
|
976
|
+
debug?: boolean;
|
|
977
|
+
onHeartbeatSent?: () => void;
|
|
978
|
+
onHeartbeatError?: (error: Error) => void;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* HeartbeatManager sends periodic heartbeats to track online status
|
|
982
|
+
*/
|
|
983
|
+
declare class HeartbeatManager {
|
|
984
|
+
private serviceUrl;
|
|
985
|
+
private organizationId;
|
|
986
|
+
private organizationSecret;
|
|
987
|
+
private config;
|
|
988
|
+
private debug;
|
|
989
|
+
private registrationId;
|
|
990
|
+
private intervalId;
|
|
991
|
+
private isRunning;
|
|
992
|
+
private visibilityHandler;
|
|
993
|
+
private onHeartbeatSent?;
|
|
994
|
+
private onHeartbeatError?;
|
|
995
|
+
constructor(options: HeartbeatManagerOptions);
|
|
996
|
+
/**
|
|
997
|
+
* Set the registration ID for heartbeat requests
|
|
998
|
+
*/
|
|
999
|
+
setRegistrationId(registrationId: string): void;
|
|
1000
|
+
/**
|
|
1001
|
+
* Start sending heartbeats
|
|
1002
|
+
*/
|
|
1003
|
+
start(): void;
|
|
1004
|
+
/**
|
|
1005
|
+
* Stop sending heartbeats
|
|
1006
|
+
*/
|
|
1007
|
+
stop(): void;
|
|
1008
|
+
/**
|
|
1009
|
+
* Check if heartbeat is running
|
|
1010
|
+
*/
|
|
1011
|
+
isHeartbeatRunning(): boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
* Send a single heartbeat
|
|
1014
|
+
*/
|
|
1015
|
+
sendHeartbeat(): Promise<boolean>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Update heartbeat configuration
|
|
1018
|
+
*/
|
|
1019
|
+
updateConfig(config: Partial<HeartbeatConfig>): void;
|
|
1020
|
+
/**
|
|
1021
|
+
* Set up visibility change handler
|
|
1022
|
+
*/
|
|
1023
|
+
private setupVisibilityHandler;
|
|
1024
|
+
/**
|
|
1025
|
+
* Log message if debug is enabled
|
|
1026
|
+
*/
|
|
1027
|
+
private log;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* HMAC Authentication Utilities
|
|
1032
|
+
* Implements CloudSignal's HMAC signature scheme for API authentication
|
|
1033
|
+
*/
|
|
1034
|
+
/**
|
|
1035
|
+
* Generate HMAC signature for CloudSignal API requests
|
|
1036
|
+
*
|
|
1037
|
+
* @param secret - Organization secret key
|
|
1038
|
+
* @param organizationId - Organization UUID
|
|
1039
|
+
* @param timestamp - Unix timestamp string
|
|
1040
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
1041
|
+
* @param url - Full URL or path
|
|
1042
|
+
* @param body - Request body (optional)
|
|
1043
|
+
* @returns Base64-encoded HMAC signature
|
|
1044
|
+
*/
|
|
1045
|
+
declare function generateHMACSignature(secret: string, organizationId: string, timestamp: string, method: string, url: string, body?: string): Promise<string>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Generate authentication headers for CloudSignal API requests
|
|
1048
|
+
*
|
|
1049
|
+
* @param organizationId - Organization UUID
|
|
1050
|
+
* @param organizationSecret - Organization secret key
|
|
1051
|
+
* @param method - HTTP method
|
|
1052
|
+
* @param url - Request URL
|
|
1053
|
+
* @param body - Request body (optional)
|
|
1054
|
+
* @returns Headers object with authentication headers
|
|
1055
|
+
*/
|
|
1056
|
+
declare function generateAuthHeaders(organizationId: string, organizationSecret: string, method: string, url: string, body?: string): Promise<Record<string, string>>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Make an authenticated request to CloudSignal API
|
|
1059
|
+
*
|
|
1060
|
+
* @param organizationId - Organization UUID
|
|
1061
|
+
* @param organizationSecret - Organization secret key
|
|
1062
|
+
* @param method - HTTP method
|
|
1063
|
+
* @param url - Request URL
|
|
1064
|
+
* @param body - Request body (optional)
|
|
1065
|
+
* @returns Fetch Response
|
|
1066
|
+
*/
|
|
1067
|
+
declare function makeAuthenticatedRequest(organizationId: string, organizationSecret: string, method: string, url: string, body?: Record<string, any>): Promise<Response>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Validate UUID format
|
|
1070
|
+
*
|
|
1071
|
+
* @param value - String to validate
|
|
1072
|
+
* @returns Whether the string is a valid UUID
|
|
1073
|
+
*/
|
|
1074
|
+
declare function isValidUUID(value: string | null | undefined): boolean;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Browser Fingerprinting Utilities
|
|
1078
|
+
* Generate unique device identifiers for registration deduplication
|
|
1079
|
+
*/
|
|
1080
|
+
/**
|
|
1081
|
+
* Generate a browser fingerprint using multiple signals
|
|
1082
|
+
* This is used to identify the same browser across sessions
|
|
1083
|
+
*
|
|
1084
|
+
* @returns Fingerprint string or null if generation fails
|
|
1085
|
+
*/
|
|
1086
|
+
declare function generateBrowserFingerprint(): Promise<string | null>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Generate a simple tracking ID from device info
|
|
1089
|
+
* Less privacy-invasive than full fingerprinting
|
|
1090
|
+
*/
|
|
1091
|
+
declare function generateTrackingId(os: string, osVersion: string, browser: string, browserVersion: string, deviceModel: string): string;
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Storage Utilities
|
|
1095
|
+
* LocalStorage and IndexedDB helpers with type safety
|
|
1096
|
+
*/
|
|
1097
|
+
/**
|
|
1098
|
+
* Get item from localStorage with type safety
|
|
1099
|
+
*/
|
|
1100
|
+
declare function getStorageItem<T>(key: string, defaultValue?: T): T | null;
|
|
1101
|
+
/**
|
|
1102
|
+
* Set item in localStorage
|
|
1103
|
+
*/
|
|
1104
|
+
declare function setStorageItem<T>(key: string, value: T): boolean;
|
|
1105
|
+
/**
|
|
1106
|
+
* Remove item from localStorage
|
|
1107
|
+
*/
|
|
1108
|
+
declare function removeStorageItem(key: string): boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* Get registration ID from storage
|
|
1111
|
+
*/
|
|
1112
|
+
declare function getRegistrationId(organizationId: string, serviceId: string): string | null;
|
|
1113
|
+
/**
|
|
1114
|
+
* Set registration ID in storage
|
|
1115
|
+
*/
|
|
1116
|
+
declare function setRegistrationId(organizationId: string, serviceId: string, registrationId: string): boolean;
|
|
1117
|
+
/**
|
|
1118
|
+
* Remove registration ID from storage
|
|
1119
|
+
*/
|
|
1120
|
+
declare function removeRegistrationId(organizationId: string, serviceId: string): boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
* IndexedDB Storage for Service Worker
|
|
1123
|
+
* Provides persistent storage for badge counts, notifications, etc.
|
|
1124
|
+
*/
|
|
1125
|
+
declare class IndexedDBStorage {
|
|
1126
|
+
private dbName;
|
|
1127
|
+
private dbVersion;
|
|
1128
|
+
private db;
|
|
1129
|
+
constructor(dbName?: string, dbVersion?: number);
|
|
1130
|
+
/**
|
|
1131
|
+
* Initialize the database
|
|
1132
|
+
*/
|
|
1133
|
+
init(): Promise<IDBDatabase>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Ensure database connection
|
|
1136
|
+
*/
|
|
1137
|
+
private ensureConnection;
|
|
1138
|
+
/**
|
|
1139
|
+
* Promisify IDBRequest
|
|
1140
|
+
*/
|
|
1141
|
+
private promisifyRequest;
|
|
1142
|
+
/**
|
|
1143
|
+
* Get badge count
|
|
1144
|
+
*/
|
|
1145
|
+
getBadgeCount(): Promise<number>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Set badge count
|
|
1148
|
+
*/
|
|
1149
|
+
setBadgeCount(count: number): Promise<void>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Increment badge count
|
|
1152
|
+
*/
|
|
1153
|
+
incrementBadgeCount(increment?: number): Promise<number>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Save notification to history
|
|
1156
|
+
*/
|
|
1157
|
+
saveNotification(notification: Record<string, any>): Promise<number>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Get recent notifications
|
|
1160
|
+
*/
|
|
1161
|
+
getRecentNotifications(limit?: number): Promise<any[]>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Mark notification as read
|
|
1164
|
+
*/
|
|
1165
|
+
markNotificationAsRead(notificationId: number): Promise<void>;
|
|
1166
|
+
/**
|
|
1167
|
+
* Get user preference
|
|
1168
|
+
*/
|
|
1169
|
+
getUserPreference<T>(key: string): Promise<T | null>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Set user preference
|
|
1172
|
+
*/
|
|
1173
|
+
setUserPreference<T>(key: string, value: T): Promise<void>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Add item to sync queue
|
|
1176
|
+
*/
|
|
1177
|
+
addToSyncQueue(action: Record<string, any>): Promise<number>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Get sync queue items
|
|
1180
|
+
*/
|
|
1181
|
+
getSyncQueue(): Promise<any[]>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Remove item from sync queue
|
|
1184
|
+
*/
|
|
1185
|
+
removeFromSyncQueue(id: number): Promise<void>;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* CloudSignal PWA SDK
|
|
1190
|
+
* Progressive Web App features with push notifications, installation management, and device tracking
|
|
1191
|
+
*
|
|
1192
|
+
* @packageDocumentation
|
|
1193
|
+
*/
|
|
1194
|
+
|
|
1195
|
+
declare const VERSION = "1.0.0";
|
|
1196
|
+
|
|
1197
|
+
export { type BeforeInstallPromptEvent, CloudSignalPWA, type ConfigLoadedEvent, DeviceDetector, type DeviceInfo, type DisplayMode, type EventHandler, type HeartbeatConfig, type HeartbeatEvent, HeartbeatManager, IndexedDBStorage, type InitializeResult, type InstallAvailableEvent, type InstallResult, type InstallResultEvent, InstallationManager, type InstallationState, type LoggerFunction, type NetworkEvent, type NetworkInfo, type NotificationAction, type NotificationPayload, type NotificationPermissionState, type NotificationPreferences, type PWACapabilities, type PWAConfig, type PWAEvent, type PWAServiceConfig, type PWASupportLevel, type PermissionEvent, type PlatformInfo, type PushClickedEvent, PushNotificationManager, type PushReceivedEvent, type PushRegisteredEvent, type PushSubscriptionData, type RegisterOptions, type Registration, type RegistrationStatus, type RegistrationStatusResponse, type ScreenInfo, type ServiceWorkerConfig, type ServiceWorkerEvent, ServiceWorkerManager, VERSION, CloudSignalPWA as default, deviceDetector, generateAuthHeaders, generateBrowserFingerprint, generateHMACSignature, generateTrackingId, getRegistrationId, getStorageItem, isValidUUID, makeAuthenticatedRequest, removeRegistrationId, removeStorageItem, setRegistrationId, setStorageItem };
|