@cloudsignal/pwa-sdk 1.2.4 → 2.1.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 +24 -22
- package/README.md +45 -509
- 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 +77 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +31 -35
- package/dist/index.d.ts +31 -35
- package/dist/index.global.js +6 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +76 -85
- 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
|
/**
|
|
@@ -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>;
|
|
@@ -1364,6 +1364,20 @@ declare class PushNotificationManager {
|
|
|
1364
1364
|
* Register for push notifications
|
|
1365
1365
|
*/
|
|
1366
1366
|
register(options?: RegisterOptions): Promise<Registration | null>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Register a PWA installation without a push subscription.
|
|
1369
|
+
*
|
|
1370
|
+
* Tracks users who installed the PWA (standalone display mode) but
|
|
1371
|
+
* haven't granted notification permission yet. A subsequent
|
|
1372
|
+
* ``registerForPush()`` call upgrades the same row to a full push
|
|
1373
|
+
* registration (matched server-side by browser fingerprint).
|
|
1374
|
+
*
|
|
1375
|
+
* Guarded by a localStorage flag so repeat ``initialize()`` calls in
|
|
1376
|
+
* the same storage session are no-ops.
|
|
1377
|
+
*/
|
|
1378
|
+
registerInstallation(): Promise<{
|
|
1379
|
+
registrationId: string;
|
|
1380
|
+
} | null>;
|
|
1367
1381
|
/**
|
|
1368
1382
|
* Unregister from push notifications
|
|
1369
1383
|
*/
|
|
@@ -1376,24 +1390,6 @@ declare class PushNotificationManager {
|
|
|
1376
1390
|
* Check registration status
|
|
1377
1391
|
*/
|
|
1378
1392
|
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
1393
|
/**
|
|
1398
1394
|
* Request notification permission
|
|
1399
1395
|
*/
|
|
@@ -1420,9 +1416,9 @@ declare class PushNotificationManager {
|
|
|
1420
1416
|
interface HeartbeatManagerOptions {
|
|
1421
1417
|
serviceUrl: string;
|
|
1422
1418
|
organizationId: string;
|
|
1423
|
-
/**
|
|
1424
|
-
|
|
1425
|
-
/** JWT token for authenticated user mode
|
|
1419
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1420
|
+
organizationPublishableKey?: string;
|
|
1421
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1426
1422
|
userToken?: string;
|
|
1427
1423
|
/** Callback to refresh JWT when expired */
|
|
1428
1424
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1959,7 +1955,7 @@ declare class NotificationPermissionPrompt {
|
|
|
1959
1955
|
/**
|
|
1960
1956
|
* Generate HMAC signature for CloudSignal API requests
|
|
1961
1957
|
*
|
|
1962
|
-
* @param secret -
|
|
1958
|
+
* @param secret - Signing key (organization publishable key, pk_*)
|
|
1963
1959
|
* @param organizationId - Organization UUID
|
|
1964
1960
|
* @param timestamp - Unix timestamp string
|
|
1965
1961
|
* @param method - HTTP method (GET, POST, etc.)
|
|
@@ -1972,24 +1968,24 @@ declare function generateHMACSignature(secret: string, organizationId: string, t
|
|
|
1972
1968
|
* Generate authentication headers for CloudSignal API requests
|
|
1973
1969
|
*
|
|
1974
1970
|
* @param organizationId - Organization UUID
|
|
1975
|
-
* @param
|
|
1971
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1976
1972
|
* @param method - HTTP method
|
|
1977
1973
|
* @param url - Request URL
|
|
1978
1974
|
* @param body - Request body (optional)
|
|
1979
1975
|
* @returns Headers object with authentication headers
|
|
1980
1976
|
*/
|
|
1981
|
-
declare function generateAuthHeaders(organizationId: string,
|
|
1977
|
+
declare function generateAuthHeaders(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: string): Promise<Record<string, string>>;
|
|
1982
1978
|
/**
|
|
1983
1979
|
* Make an authenticated request to CloudSignal API
|
|
1984
1980
|
*
|
|
1985
1981
|
* @param organizationId - Organization UUID
|
|
1986
|
-
* @param
|
|
1982
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1987
1983
|
* @param method - HTTP method
|
|
1988
1984
|
* @param url - Request URL
|
|
1989
1985
|
* @param body - Request body (optional)
|
|
1990
1986
|
* @returns Fetch Response
|
|
1991
1987
|
*/
|
|
1992
|
-
declare function makeAuthenticatedRequest(organizationId: string,
|
|
1988
|
+
declare function makeAuthenticatedRequest(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: Record<string, any>): Promise<Response>;
|
|
1993
1989
|
/**
|
|
1994
1990
|
* Validate UUID format
|
|
1995
1991
|
*
|
|
@@ -2042,7 +2038,7 @@ declare function makeJWTAuthenticatedRequest(config: JWTAuthConfig, method: stri
|
|
|
2042
2038
|
interface AuthContext {
|
|
2043
2039
|
mode: AuthMode;
|
|
2044
2040
|
organizationId: string;
|
|
2045
|
-
|
|
2041
|
+
organizationPublishableKey?: string;
|
|
2046
2042
|
userToken?: string;
|
|
2047
2043
|
onTokenExpired?: () => Promise<string>;
|
|
2048
2044
|
}
|
|
@@ -2055,7 +2051,7 @@ interface AuthContext {
|
|
|
2055
2051
|
*/
|
|
2056
2052
|
declare function createAuthContext(config: {
|
|
2057
2053
|
organizationId: string;
|
|
2058
|
-
|
|
2054
|
+
organizationPublishableKey?: string;
|
|
2059
2055
|
userToken?: string;
|
|
2060
2056
|
onTokenExpired?: () => Promise<string>;
|
|
2061
2057
|
}): 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
|
/**
|
|
@@ -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>;
|
|
@@ -1364,6 +1364,20 @@ declare class PushNotificationManager {
|
|
|
1364
1364
|
* Register for push notifications
|
|
1365
1365
|
*/
|
|
1366
1366
|
register(options?: RegisterOptions): Promise<Registration | null>;
|
|
1367
|
+
/**
|
|
1368
|
+
* Register a PWA installation without a push subscription.
|
|
1369
|
+
*
|
|
1370
|
+
* Tracks users who installed the PWA (standalone display mode) but
|
|
1371
|
+
* haven't granted notification permission yet. A subsequent
|
|
1372
|
+
* ``registerForPush()`` call upgrades the same row to a full push
|
|
1373
|
+
* registration (matched server-side by browser fingerprint).
|
|
1374
|
+
*
|
|
1375
|
+
* Guarded by a localStorage flag so repeat ``initialize()`` calls in
|
|
1376
|
+
* the same storage session are no-ops.
|
|
1377
|
+
*/
|
|
1378
|
+
registerInstallation(): Promise<{
|
|
1379
|
+
registrationId: string;
|
|
1380
|
+
} | null>;
|
|
1367
1381
|
/**
|
|
1368
1382
|
* Unregister from push notifications
|
|
1369
1383
|
*/
|
|
@@ -1376,24 +1390,6 @@ declare class PushNotificationManager {
|
|
|
1376
1390
|
* Check registration status
|
|
1377
1391
|
*/
|
|
1378
1392
|
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
1393
|
/**
|
|
1398
1394
|
* Request notification permission
|
|
1399
1395
|
*/
|
|
@@ -1420,9 +1416,9 @@ declare class PushNotificationManager {
|
|
|
1420
1416
|
interface HeartbeatManagerOptions {
|
|
1421
1417
|
serviceUrl: string;
|
|
1422
1418
|
organizationId: string;
|
|
1423
|
-
/**
|
|
1424
|
-
|
|
1425
|
-
/** JWT token for authenticated user mode
|
|
1419
|
+
/** Publishable key (pk_*) for HMAC auth — optional if userToken provided */
|
|
1420
|
+
organizationPublishableKey?: string;
|
|
1421
|
+
/** JWT token for authenticated user mode — optional if organizationPublishableKey provided */
|
|
1426
1422
|
userToken?: string;
|
|
1427
1423
|
/** Callback to refresh JWT when expired */
|
|
1428
1424
|
onTokenExpired?: () => Promise<string>;
|
|
@@ -1959,7 +1955,7 @@ declare class NotificationPermissionPrompt {
|
|
|
1959
1955
|
/**
|
|
1960
1956
|
* Generate HMAC signature for CloudSignal API requests
|
|
1961
1957
|
*
|
|
1962
|
-
* @param secret -
|
|
1958
|
+
* @param secret - Signing key (organization publishable key, pk_*)
|
|
1963
1959
|
* @param organizationId - Organization UUID
|
|
1964
1960
|
* @param timestamp - Unix timestamp string
|
|
1965
1961
|
* @param method - HTTP method (GET, POST, etc.)
|
|
@@ -1972,24 +1968,24 @@ declare function generateHMACSignature(secret: string, organizationId: string, t
|
|
|
1972
1968
|
* Generate authentication headers for CloudSignal API requests
|
|
1973
1969
|
*
|
|
1974
1970
|
* @param organizationId - Organization UUID
|
|
1975
|
-
* @param
|
|
1971
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1976
1972
|
* @param method - HTTP method
|
|
1977
1973
|
* @param url - Request URL
|
|
1978
1974
|
* @param body - Request body (optional)
|
|
1979
1975
|
* @returns Headers object with authentication headers
|
|
1980
1976
|
*/
|
|
1981
|
-
declare function generateAuthHeaders(organizationId: string,
|
|
1977
|
+
declare function generateAuthHeaders(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: string): Promise<Record<string, string>>;
|
|
1982
1978
|
/**
|
|
1983
1979
|
* Make an authenticated request to CloudSignal API
|
|
1984
1980
|
*
|
|
1985
1981
|
* @param organizationId - Organization UUID
|
|
1986
|
-
* @param
|
|
1982
|
+
* @param organizationPublishableKey - Organization publishable key (pk_*)
|
|
1987
1983
|
* @param method - HTTP method
|
|
1988
1984
|
* @param url - Request URL
|
|
1989
1985
|
* @param body - Request body (optional)
|
|
1990
1986
|
* @returns Fetch Response
|
|
1991
1987
|
*/
|
|
1992
|
-
declare function makeAuthenticatedRequest(organizationId: string,
|
|
1988
|
+
declare function makeAuthenticatedRequest(organizationId: string, organizationPublishableKey: string, method: string, url: string, body?: Record<string, any>): Promise<Response>;
|
|
1993
1989
|
/**
|
|
1994
1990
|
* Validate UUID format
|
|
1995
1991
|
*
|
|
@@ -2042,7 +2038,7 @@ declare function makeJWTAuthenticatedRequest(config: JWTAuthConfig, method: stri
|
|
|
2042
2038
|
interface AuthContext {
|
|
2043
2039
|
mode: AuthMode;
|
|
2044
2040
|
organizationId: string;
|
|
2045
|
-
|
|
2041
|
+
organizationPublishableKey?: string;
|
|
2046
2042
|
userToken?: string;
|
|
2047
2043
|
onTokenExpired?: () => Promise<string>;
|
|
2048
2044
|
}
|
|
@@ -2055,7 +2051,7 @@ interface AuthContext {
|
|
|
2055
2051
|
*/
|
|
2056
2052
|
declare function createAuthContext(config: {
|
|
2057
2053
|
organizationId: string;
|
|
2058
|
-
|
|
2054
|
+
organizationPublishableKey?: string;
|
|
2059
2055
|
userToken?: string;
|
|
2060
2056
|
onTokenExpired?: () => Promise<string>;
|
|
2061
2057
|
}): AuthContext;
|