@markwharton/pwa-push 1.3.0 → 1.5.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.
@@ -2,7 +2,7 @@
2
2
  * IndexedDB utilities for service worker data persistence
3
3
  * Service workers cannot access localStorage, so we use IndexedDB
4
4
  */
5
- import { SubscriptionData } from '../types';
5
+ import { SubscriptionData } from '../shared';
6
6
  /**
7
7
  * Saves subscription data to IndexedDB for service worker access.
8
8
  * This data is used for subscription renewal when the browser rotates keys.
@@ -2,7 +2,7 @@
2
2
  * Push subscription renewal handler for service worker
3
3
  * Handles the 'pushsubscriptionchange' event when browser rotates subscriptions
4
4
  */
5
- import { PushSubscription } from '../types';
5
+ import { PushSubscription } from '../shared';
6
6
  /**
7
7
  * Handles the pushsubscriptionchange event in a service worker.
8
8
  * Call this from your service worker's event listener when the browser
@@ -2,7 +2,7 @@
2
2
  * Push subscription helpers for main thread
3
3
  */
4
4
  import { Result } from '@markwharton/pwa-core/types';
5
- import { PushSubscription, SubscriptionRequest, PushPermissionState } from '../types';
5
+ import { PushSubscription, SubscriptionRequest, PushPermissionState } from '../shared';
6
6
  /**
7
7
  * Gets the current notification permission state.
8
8
  * @returns The current permission state ('granted', 'denied', or 'default')
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './types';
1
+ export * from './shared';
2
2
  export * from './server';
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- // Re-export types
18
- __exportStar(require("./types"), exports);
17
+ // Re-export shared types
18
+ __exportStar(require("./shared"), exports);
19
19
  // Re-export server utilities (for backend)
20
20
  __exportStar(require("./server"), exports);
21
21
  // Note: Client utilities should be imported from '@markwharton/pwa-push/client'
@@ -1,5 +1,5 @@
1
1
  import { Result } from '@markwharton/pwa-core/types';
2
- import { PushSubscription, NotificationPayload } from '../types';
2
+ import { PushSubscription, NotificationPayload } from '../shared';
3
3
  /**
4
4
  * Initializes VAPID configuration for Web Push. Call once at application startup.
5
5
  * @param config - VAPID configuration
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Push notification types - shared between server and client
3
+ */
4
+ export { Result, ok, okVoid, err } from '@markwharton/pwa-core/types';
5
+ export interface PushSubscription {
6
+ endpoint: string;
7
+ keys: {
8
+ p256dh: string;
9
+ auth: string;
10
+ };
11
+ basePath?: string;
12
+ }
13
+ export interface NotificationPayload {
14
+ title: string;
15
+ body: string;
16
+ type?: string;
17
+ url?: string;
18
+ tag?: string;
19
+ data?: Record<string, unknown>;
20
+ id?: string;
21
+ timestamp?: string;
22
+ basePath?: string;
23
+ }
24
+ export interface VapidConfig {
25
+ publicKey: string;
26
+ privateKey: string;
27
+ subject: string;
28
+ }
29
+ export interface SubscriptionRequest {
30
+ subscription: PushSubscription;
31
+ deviceId: string;
32
+ basePath?: string;
33
+ }
34
+ export interface SubscriptionData {
35
+ publicKey: string;
36
+ deviceId: string;
37
+ basePath: string;
38
+ }
39
+ export type PushPermissionState = 'granted' | 'denied' | 'default';
package/dist/shared.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Push notification types - shared between server and client
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.err = exports.okVoid = exports.ok = void 0;
7
+ // Re-export Result from pwa-core for convenience
8
+ var types_1 = require("@markwharton/pwa-core/types");
9
+ Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return types_1.ok; } });
10
+ Object.defineProperty(exports, "okVoid", { enumerable: true, get: function () { return types_1.okVoid; } });
11
+ Object.defineProperty(exports, "err", { enumerable: true, get: function () { return types_1.err; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markwharton/pwa-push",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Web push notifications for Azure PWA projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,8 +8,22 @@
8
8
  ".": "./dist/index.js",
9
9
  "./server": "./dist/server/index.js",
10
10
  "./client": "./dist/client/index.js",
11
+ "./shared": "./dist/shared.js",
11
12
  "./sw": "./dist/pwa-push-sw.js"
12
13
  },
14
+ "typesVersions": {
15
+ "*": {
16
+ "server": [
17
+ "dist/server/index.d.ts"
18
+ ],
19
+ "client": [
20
+ "dist/client/index.d.ts"
21
+ ],
22
+ "shared": [
23
+ "dist/shared.d.ts"
24
+ ]
25
+ }
26
+ },
13
27
  "scripts": {
14
28
  "build": "tsc && npm run build:sw",
15
29
  "build:sw": "esbuild src/sw.ts --bundle --outfile=dist/pwa-push-sw.js --format=iife --global-name=PwaPush",