@cloudsignal/pwa-sdk 1.2.3 → 2.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 +15 -15
- package/README.md +7 -7
- package/dist/{chunk-IMM7VF4N.js → chunk-IQHSODT4.js} +6 -6
- package/dist/chunk-IQHSODT4.js.map +1 -0
- package/dist/hmac-WITZIX2O.js +3 -0
- package/dist/{hmac-LWLR6F7Z.js.map → hmac-WITZIX2O.js.map} +1 -1
- package/dist/index.cjs +20 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +18 -36
- package/dist/index.d.ts +18 -36
- package/dist/index.global.js +6 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -103
- package/dist/index.js.map +1 -1
- package/dist/service-worker.js +1 -1
- package/dist/service-worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-IMM7VF4N.js.map +0 -1
- package/dist/hmac-LWLR6F7Z.js +0 -3
package/dist/index.d.mts
CHANGED
|
@@ -200,14 +200,14 @@ interface PWAConfig {
|
|
|
200
200
|
/** Organization ID (UUID) */
|
|
201
201
|
organizationId: string;
|
|
202
202
|
/**
|
|
203
|
-
* Organization
|
|
204
|
-
* Required if userToken is not provided
|
|
203
|
+
* Organization publishable key (pk_*) for HMAC-signed anonymous mode.
|
|
204
|
+
* Safe to ship in browser code. Required if userToken is not provided.
|
|
205
205
|
*/
|
|
206
|
-
|
|
206
|
+
organizationPublishableKey?: string;
|
|
207
207
|
/**
|
|
208
208
|
* JWT token from identity provider for authenticated user mode
|
|
209
209
|
* Supports: Supabase, Firebase, Auth0, Clerk, custom OIDC
|
|
210
|
-
* When provided, takes precedence over
|
|
210
|
+
* When provided, takes precedence over organizationPublishableKey
|
|
211
211
|
*/
|
|
212
212
|
userToken?: string;
|
|
213
213
|
/**
|
|
@@ -521,7 +521,7 @@ interface NotificationAction {
|
|
|
521
521
|
/**
|
|
522
522
|
* Event types emitted by the SDK
|
|
523
523
|
*/
|
|
524
|
-
type PWAEvent = 'install:available' | 'install:accepted' | 'install:dismissed' | 'install:completed' | 'install:
|
|
524
|
+
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' | 'heartbeat:intervalChanged' | 'heartbeat:pausedForBattery' | 'heartbeat:resumedFromBattery' | 'network:online' | 'network:offline' | 'state:changed' | 'wakeLock:acquired' | 'wakeLock:released' | 'wakeLock:error' | 'offlineQueue:queued' | 'offlineQueue:processed' | 'offlineQueue:flushed' | 'iosBanner:shown' | 'iosBanner:dismissed' | 'iosBanner:installClicked' | 'auth:tokenUpdated';
|
|
525
525
|
/**
|
|
526
526
|
* Event handler function
|
|
527
527
|
*/
|
|
@@ -1303,9 +1303,9 @@ declare class InstallationManager {
|
|
|
1303
1303
|
interface PushNotificationManagerOptions {
|
|
1304
1304
|
serviceUrl: string;
|
|
1305
1305
|
organizationId: string;
|
|
1306
|
-
/**
|
|
1307
|
-
|
|
1308
|
-
/** JWT token for authenticated user mode
|
|
1306
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1307
|
+
organizationPublishableKey?: string;
|
|
1308
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1309
1309
|
userToken?: string;
|
|
1310
1310
|
/** Callback to refresh JWT when expired */
|
|
1311
1311
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1376,24 +1376,6 @@ declare class PushNotificationManager {
|
|
|
1376
1376
|
* Check registration status
|
|
1377
1377
|
*/
|
|
1378
1378
|
checkStatus(): Promise<RegistrationStatusResponse | null>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Register PWA installation without push subscription.
|
|
1381
|
-
* This tracks users who installed the PWA but haven't subscribed to notifications.
|
|
1382
|
-
* Called automatically when installation is detected.
|
|
1383
|
-
*
|
|
1384
|
-
* @returns Installation registration result or null if already registered/failed
|
|
1385
|
-
*/
|
|
1386
|
-
registerInstallation(): Promise<{
|
|
1387
|
-
registrationId: string;
|
|
1388
|
-
} | null>;
|
|
1389
|
-
/**
|
|
1390
|
-
* Check if installation is already registered
|
|
1391
|
-
*/
|
|
1392
|
-
isInstallationRegistered(): boolean;
|
|
1393
|
-
/**
|
|
1394
|
-
* Get stored installation registration ID
|
|
1395
|
-
*/
|
|
1396
|
-
getInstallationId(): string | null;
|
|
1397
1379
|
/**
|
|
1398
1380
|
* Request notification permission
|
|
1399
1381
|
*/
|
|
@@ -1420,9 +1402,9 @@ declare class PushNotificationManager {
|
|
|
1420
1402
|
interface HeartbeatManagerOptions {
|
|
1421
1403
|
serviceUrl: string;
|
|
1422
1404
|
organizationId: string;
|
|
1423
|
-
/**
|
|
1424
|
-
|
|
1425
|
-
/** JWT token for authenticated user mode
|
|
1405
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1406
|
+
organizationPublishableKey?: string;
|
|
1407
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1426
1408
|
userToken?: string;
|
|
1427
1409
|
/** Callback to refresh JWT when expired */
|
|
1428
1410
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1959,7 +1941,7 @@ declare class NotificationPermissionPrompt {
|
|
|
1959
1941
|
/**
|
|
1960
1942
|
* Generate HMAC signature for CloudSignal API requests
|
|
1961
1943
|
*
|
|
1962
|
-
* @param secret -
|
|
1944
|
+
* @param secret - Signing key (organization publishable key, pk_*)
|
|
1963
1945
|
* @param organizationId - Organization UUID
|
|
1964
1946
|
* @param timestamp - Unix timestamp string
|
|
1965
1947
|
* @param method - HTTP method (GET, POST, etc.)
|
|
@@ -1972,24 +1954,24 @@ declare function generateHMACSignature(secret: string, organizationId: string, t
|
|
|
1972
1954
|
* Generate authentication headers for CloudSignal API requests
|
|
1973
1955
|
*
|
|
1974
1956
|
* @param organizationId - Organization UUID
|
|
1975
|
-
* @param
|
|
1957
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1976
1958
|
* @param method - HTTP method
|
|
1977
1959
|
* @param url - Request URL
|
|
1978
1960
|
* @param body - Request body (optional)
|
|
1979
1961
|
* @returns Headers object with authentication headers
|
|
1980
1962
|
*/
|
|
1981
|
-
declare function generateAuthHeaders(organizationId: string,
|
|
1963
|
+
declare function generateAuthHeaders(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: string): Promise<Record<string, string>>;
|
|
1982
1964
|
/**
|
|
1983
1965
|
* Make an authenticated request to CloudSignal API
|
|
1984
1966
|
*
|
|
1985
1967
|
* @param organizationId - Organization UUID
|
|
1986
|
-
* @param
|
|
1968
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1987
1969
|
* @param method - HTTP method
|
|
1988
1970
|
* @param url - Request URL
|
|
1989
1971
|
* @param body - Request body (optional)
|
|
1990
1972
|
* @returns Fetch Response
|
|
1991
1973
|
*/
|
|
1992
|
-
declare function makeAuthenticatedRequest(organizationId: string,
|
|
1974
|
+
declare function makeAuthenticatedRequest(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: Record<string, any>): Promise<Response>;
|
|
1993
1975
|
/**
|
|
1994
1976
|
* Validate UUID format
|
|
1995
1977
|
*
|
|
@@ -2042,7 +2024,7 @@ declare function makeJWTAuthenticatedRequest(config: JWTAuthConfig, method: stri
|
|
|
2042
2024
|
interface AuthContext {
|
|
2043
2025
|
mode: AuthMode;
|
|
2044
2026
|
organizationId: string;
|
|
2045
|
-
|
|
2027
|
+
organizationPublishableKey?: string;
|
|
2046
2028
|
userToken?: string;
|
|
2047
2029
|
onTokenExpired?: () => Promise<string>;
|
|
2048
2030
|
}
|
|
@@ -2055,7 +2037,7 @@ interface AuthContext {
|
|
|
2055
2037
|
*/
|
|
2056
2038
|
declare function createAuthContext(config: {
|
|
2057
2039
|
organizationId: string;
|
|
2058
|
-
|
|
2040
|
+
organizationPublishableKey?: string;
|
|
2059
2041
|
userToken?: string;
|
|
2060
2042
|
onTokenExpired?: () => Promise<string>;
|
|
2061
2043
|
}): AuthContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -200,14 +200,14 @@ interface PWAConfig {
|
|
|
200
200
|
/** Organization ID (UUID) */
|
|
201
201
|
organizationId: string;
|
|
202
202
|
/**
|
|
203
|
-
* Organization
|
|
204
|
-
* Required if userToken is not provided
|
|
203
|
+
* Organization publishable key (pk_*) for HMAC-signed anonymous mode.
|
|
204
|
+
* Safe to ship in browser code. Required if userToken is not provided.
|
|
205
205
|
*/
|
|
206
|
-
|
|
206
|
+
organizationPublishableKey?: string;
|
|
207
207
|
/**
|
|
208
208
|
* JWT token from identity provider for authenticated user mode
|
|
209
209
|
* Supports: Supabase, Firebase, Auth0, Clerk, custom OIDC
|
|
210
|
-
* When provided, takes precedence over
|
|
210
|
+
* When provided, takes precedence over organizationPublishableKey
|
|
211
211
|
*/
|
|
212
212
|
userToken?: string;
|
|
213
213
|
/**
|
|
@@ -521,7 +521,7 @@ interface NotificationAction {
|
|
|
521
521
|
/**
|
|
522
522
|
* Event types emitted by the SDK
|
|
523
523
|
*/
|
|
524
|
-
type PWAEvent = 'install:available' | 'install:accepted' | 'install:dismissed' | 'install:completed' | 'install:
|
|
524
|
+
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' | 'heartbeat:intervalChanged' | 'heartbeat:pausedForBattery' | 'heartbeat:resumedFromBattery' | 'network:online' | 'network:offline' | 'state:changed' | 'wakeLock:acquired' | 'wakeLock:released' | 'wakeLock:error' | 'offlineQueue:queued' | 'offlineQueue:processed' | 'offlineQueue:flushed' | 'iosBanner:shown' | 'iosBanner:dismissed' | 'iosBanner:installClicked' | 'auth:tokenUpdated';
|
|
525
525
|
/**
|
|
526
526
|
* Event handler function
|
|
527
527
|
*/
|
|
@@ -1303,9 +1303,9 @@ declare class InstallationManager {
|
|
|
1303
1303
|
interface PushNotificationManagerOptions {
|
|
1304
1304
|
serviceUrl: string;
|
|
1305
1305
|
organizationId: string;
|
|
1306
|
-
/**
|
|
1307
|
-
|
|
1308
|
-
/** JWT token for authenticated user mode
|
|
1306
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1307
|
+
organizationPublishableKey?: string;
|
|
1308
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1309
1309
|
userToken?: string;
|
|
1310
1310
|
/** Callback to refresh JWT when expired */
|
|
1311
1311
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1376,24 +1376,6 @@ declare class PushNotificationManager {
|
|
|
1376
1376
|
* Check registration status
|
|
1377
1377
|
*/
|
|
1378
1378
|
checkStatus(): Promise<RegistrationStatusResponse | null>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Register PWA installation without push subscription.
|
|
1381
|
-
* This tracks users who installed the PWA but haven't subscribed to notifications.
|
|
1382
|
-
* Called automatically when installation is detected.
|
|
1383
|
-
*
|
|
1384
|
-
* @returns Installation registration result or null if already registered/failed
|
|
1385
|
-
*/
|
|
1386
|
-
registerInstallation(): Promise<{
|
|
1387
|
-
registrationId: string;
|
|
1388
|
-
} | null>;
|
|
1389
|
-
/**
|
|
1390
|
-
* Check if installation is already registered
|
|
1391
|
-
*/
|
|
1392
|
-
isInstallationRegistered(): boolean;
|
|
1393
|
-
/**
|
|
1394
|
-
* Get stored installation registration ID
|
|
1395
|
-
*/
|
|
1396
|
-
getInstallationId(): string | null;
|
|
1397
1379
|
/**
|
|
1398
1380
|
* Request notification permission
|
|
1399
1381
|
*/
|
|
@@ -1420,9 +1402,9 @@ declare class PushNotificationManager {
|
|
|
1420
1402
|
interface HeartbeatManagerOptions {
|
|
1421
1403
|
serviceUrl: string;
|
|
1422
1404
|
organizationId: string;
|
|
1423
|
-
/**
|
|
1424
|
-
|
|
1425
|
-
/** JWT token for authenticated user mode
|
|
1405
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1406
|
+
organizationPublishableKey?: string;
|
|
1407
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1426
1408
|
userToken?: string;
|
|
1427
1409
|
/** Callback to refresh JWT when expired */
|
|
1428
1410
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1959,7 +1941,7 @@ declare class NotificationPermissionPrompt {
|
|
|
1959
1941
|
/**
|
|
1960
1942
|
* Generate HMAC signature for CloudSignal API requests
|
|
1961
1943
|
*
|
|
1962
|
-
* @param secret -
|
|
1944
|
+
* @param secret - Signing key (organization publishable key, pk_*)
|
|
1963
1945
|
* @param organizationId - Organization UUID
|
|
1964
1946
|
* @param timestamp - Unix timestamp string
|
|
1965
1947
|
* @param method - HTTP method (GET, POST, etc.)
|
|
@@ -1972,24 +1954,24 @@ declare function generateHMACSignature(secret: string, organizationId: string, t
|
|
|
1972
1954
|
* Generate authentication headers for CloudSignal API requests
|
|
1973
1955
|
*
|
|
1974
1956
|
* @param organizationId - Organization UUID
|
|
1975
|
-
* @param
|
|
1957
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1976
1958
|
* @param method - HTTP method
|
|
1977
1959
|
* @param url - Request URL
|
|
1978
1960
|
* @param body - Request body (optional)
|
|
1979
1961
|
* @returns Headers object with authentication headers
|
|
1980
1962
|
*/
|
|
1981
|
-
declare function generateAuthHeaders(organizationId: string,
|
|
1963
|
+
declare function generateAuthHeaders(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: string): Promise<Record<string, string>>;
|
|
1982
1964
|
/**
|
|
1983
1965
|
* Make an authenticated request to CloudSignal API
|
|
1984
1966
|
*
|
|
1985
1967
|
* @param organizationId - Organization UUID
|
|
1986
|
-
* @param
|
|
1968
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1987
1969
|
* @param method - HTTP method
|
|
1988
1970
|
* @param url - Request URL
|
|
1989
1971
|
* @param body - Request body (optional)
|
|
1990
1972
|
* @returns Fetch Response
|
|
1991
1973
|
*/
|
|
1992
|
-
declare function makeAuthenticatedRequest(organizationId: string,
|
|
1974
|
+
declare function makeAuthenticatedRequest(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: Record<string, any>): Promise<Response>;
|
|
1993
1975
|
/**
|
|
1994
1976
|
* Validate UUID format
|
|
1995
1977
|
*
|
|
@@ -2042,7 +2024,7 @@ declare function makeJWTAuthenticatedRequest(config: JWTAuthConfig, method: stri
|
|
|
2042
2024
|
interface AuthContext {
|
|
2043
2025
|
mode: AuthMode;
|
|
2044
2026
|
organizationId: string;
|
|
2045
|
-
|
|
2027
|
+
organizationPublishableKey?: string;
|
|
2046
2028
|
userToken?: string;
|
|
2047
2029
|
onTokenExpired?: () => Promise<string>;
|
|
2048
2030
|
}
|
|
@@ -2055,7 +2037,7 @@ interface AuthContext {
|
|
|
2055
2037
|
*/
|
|
2056
2038
|
declare function createAuthContext(config: {
|
|
2057
2039
|
organizationId: string;
|
|
2058
|
-
|
|
2040
|
+
organizationPublishableKey?: string;
|
|
2059
2041
|
userToken?: string;
|
|
2060
2042
|
onTokenExpired?: () => Promise<string>;
|
|
2061
2043
|
}): AuthContext;
|