tempest-react-sdk 0.28.0 → 0.28.1

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 CHANGED
@@ -1105,7 +1105,7 @@ export function PushToggle() {
1105
1105
  const push = usePushSubscription({
1106
1106
  vapidPublicKey: import.meta.env.VITE_VAPID_PUBLIC_KEY,
1107
1107
  onSubscribe: (subscription) => api.post("/webpush/subscribe", { body: subscription }),
1108
- onUnsubscribe: () => api.delete("/webpush/my"),
1108
+ onUnsubscribe: (sub) => api.delete("/webpush/subscribe", { body: { endpoint: sub.endpoint } }),
1109
1109
  });
1110
1110
 
1111
1111
  if (!push.supported) return <p>Push não suportado neste navegador.</p>;
@@ -1130,7 +1130,7 @@ import { WebPushClient } from "tempest-react-sdk";
1130
1130
  const push = new WebPushClient({
1131
1131
  vapidPublicKey: VAPID_PUBLIC_KEY,
1132
1132
  onSubscribe: (sub) => api.post("/webpush/subscribe", { body: sub }),
1133
- onUnsubscribe: () => api.delete("/webpush/my"),
1133
+ onUnsubscribe: (sub) => api.delete("/webpush/subscribe", { body: { endpoint: sub.endpoint } }),
1134
1134
  });
1135
1135
 
1136
1136
  await push.subscribe();
@@ -1,2 +1,2 @@
1
- function e(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=window.atob(t),r=new ArrayBuffer(n.length),i=new Uint8Array(r);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i}function t(){return typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}exports.isPushSupported=t,exports.urlBase64ToUint8Array=e;
1
+ function e(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new ArrayBuffer(n.length),i=new Uint8Array(r);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i}function t(){return typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}exports.isPushSupported=t,exports.urlBase64ToUint8Array=e;
2
2
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":[],"sources":["../../src/push/utils.ts"],"sourcesContent":["/**\n * Convert a base64url-encoded VAPID public key into the `Uint8Array` format\n * required by `PushManager.subscribe({ applicationServerKey })`.\n *\n * @param base64String - VAPID public key (URL-safe base64).\n * @returns The decoded key as bytes.\n */\nexport function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {\n const padding = \"=\".repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, \"+\").replace(/_/g, \"/\");\n const rawData = window.atob(base64);\n const buffer = new ArrayBuffer(rawData.length);\n const output = new Uint8Array(buffer);\n for (let i = 0; i < rawData.length; i++) {\n output[i] = rawData.charCodeAt(i);\n }\n return output;\n}\n\n/**\n * Convenience check for environments where the Push API is unavailable\n * (Safari iOS without PWA install, older browsers, SSR, etc.).\n */\nexport function isPushSupported(): boolean {\n return (\n typeof window !== \"undefined\" &&\n \"serviceWorker\" in navigator &&\n \"PushManager\" in window &&\n \"Notification\" in window\n );\n}\n"],"mappings":"AAOA,SAAgB,EAAsB,EAA+C,CAEjF,IAAM,GAAU,EADA,IAAI,QAAQ,EAAK,EAAa,OAAS,GAAM,CAC9B,EAAA,CAAS,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EACtE,EAAU,OAAO,KAAK,CAAM,EAC5B,EAAS,IAAI,YAAY,EAAQ,MAAM,EACvC,EAAS,IAAI,WAAW,CAAM,EACpC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAChC,EAAO,GAAK,EAAQ,WAAW,CAAC,EAEpC,OAAO,CACX,CAMA,SAAgB,GAA2B,CACvC,OACI,OAAO,OAAW,KAClB,kBAAmB,WACnB,gBAAiB,QACjB,iBAAkB,MAE1B"}
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../../src/push/utils.ts"],"sourcesContent":["/**\n * Convert a base64url-encoded VAPID public key into the `Uint8Array` format\n * required by `PushManager.subscribe({ applicationServerKey })`.\n *\n * Calls `atob` as a bare global rather than `window.atob` because this runs in a\n * **service worker** too: re-subscribing from a `pushsubscriptionchange` handler\n * needs the same conversion, and there is no `window` in a worker scope — the\n * qualified call threw `ReferenceError` there while working fine on the page.\n *\n * @param base64String - VAPID public key (URL-safe base64).\n * @returns The decoded key as bytes.\n */\nexport function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {\n const padding = \"=\".repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, \"+\").replace(/_/g, \"/\");\n const rawData = atob(base64);\n const buffer = new ArrayBuffer(rawData.length);\n const output = new Uint8Array(buffer);\n for (let i = 0; i < rawData.length; i++) {\n output[i] = rawData.charCodeAt(i);\n }\n return output;\n}\n\n/**\n * Convenience check for environments where the Push API is unavailable\n * (Safari iOS without PWA install, older browsers, SSR, etc.).\n */\nexport function isPushSupported(): boolean {\n return (\n typeof window !== \"undefined\" &&\n \"serviceWorker\" in navigator &&\n \"PushManager\" in window &&\n \"Notification\" in window\n );\n}\n"],"mappings":"AAYA,SAAgB,EAAsB,EAA+C,CAEjF,IAAM,GAAU,EADA,IAAI,QAAQ,EAAK,EAAa,OAAS,GAAM,CAC9B,EAAA,CAAS,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EACtE,EAAU,KAAK,CAAM,EACrB,EAAS,IAAI,YAAY,EAAQ,MAAM,EACvC,EAAS,IAAI,WAAW,CAAM,EACpC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAChC,EAAO,GAAK,EAAQ,WAAW,CAAC,EAEpC,OAAO,CACX,CAMA,SAAgB,GAA2B,CACvC,OACI,OAAO,OAAW,KAClB,kBAAmB,WACnB,gBAAiB,QACjB,iBAAkB,MAE1B"}
@@ -1,6 +1,6 @@
1
1
  //#region src/push/utils.ts
2
2
  function e(e) {
3
- let t = (e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"), n = window.atob(t), r = new ArrayBuffer(n.length), i = new Uint8Array(r);
3
+ let t = (e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"), n = atob(t), r = new ArrayBuffer(n.length), i = new Uint8Array(r);
4
4
  for (let e = 0; e < n.length; e++) i[e] = n.charCodeAt(e);
5
5
  return i;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/push/utils.ts"],"sourcesContent":["/**\n * Convert a base64url-encoded VAPID public key into the `Uint8Array` format\n * required by `PushManager.subscribe({ applicationServerKey })`.\n *\n * @param base64String - VAPID public key (URL-safe base64).\n * @returns The decoded key as bytes.\n */\nexport function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {\n const padding = \"=\".repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, \"+\").replace(/_/g, \"/\");\n const rawData = window.atob(base64);\n const buffer = new ArrayBuffer(rawData.length);\n const output = new Uint8Array(buffer);\n for (let i = 0; i < rawData.length; i++) {\n output[i] = rawData.charCodeAt(i);\n }\n return output;\n}\n\n/**\n * Convenience check for environments where the Push API is unavailable\n * (Safari iOS without PWA install, older browsers, SSR, etc.).\n */\nexport function isPushSupported(): boolean {\n return (\n typeof window !== \"undefined\" &&\n \"serviceWorker\" in navigator &&\n \"PushManager\" in window &&\n \"Notification\" in window\n );\n}\n"],"mappings":";AAOA,SAAgB,EAAsB,GAA+C;CAEjF,IAAM,KAAU,IADA,IAAI,QAAQ,IAAK,EAAa,SAAS,KAAM,CAC9B,EAAA,CAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,GACtE,IAAU,OAAO,KAAK,CAAM,GAC5B,IAAS,IAAI,YAAY,EAAQ,MAAM,GACvC,IAAS,IAAI,WAAW,CAAM;CACpC,KAAK,IAAI,IAAI,GAAG,IAAI,EAAQ,QAAQ,KAChC,EAAO,KAAK,EAAQ,WAAW,CAAC;CAEpC,OAAO;AACX;AAMA,SAAgB,IAA2B;CACvC,OACI,OAAO,SAAW,OAClB,mBAAmB,aACnB,iBAAiB,UACjB,kBAAkB;AAE1B"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/push/utils.ts"],"sourcesContent":["/**\n * Convert a base64url-encoded VAPID public key into the `Uint8Array` format\n * required by `PushManager.subscribe({ applicationServerKey })`.\n *\n * Calls `atob` as a bare global rather than `window.atob` because this runs in a\n * **service worker** too: re-subscribing from a `pushsubscriptionchange` handler\n * needs the same conversion, and there is no `window` in a worker scope — the\n * qualified call threw `ReferenceError` there while working fine on the page.\n *\n * @param base64String - VAPID public key (URL-safe base64).\n * @returns The decoded key as bytes.\n */\nexport function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {\n const padding = \"=\".repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, \"+\").replace(/_/g, \"/\");\n const rawData = atob(base64);\n const buffer = new ArrayBuffer(rawData.length);\n const output = new Uint8Array(buffer);\n for (let i = 0; i < rawData.length; i++) {\n output[i] = rawData.charCodeAt(i);\n }\n return output;\n}\n\n/**\n * Convenience check for environments where the Push API is unavailable\n * (Safari iOS without PWA install, older browsers, SSR, etc.).\n */\nexport function isPushSupported(): boolean {\n return (\n typeof window !== \"undefined\" &&\n \"serviceWorker\" in navigator &&\n \"PushManager\" in window &&\n \"Notification\" in window\n );\n}\n"],"mappings":";AAYA,SAAgB,EAAsB,GAA+C;CAEjF,IAAM,KAAU,IADA,IAAI,QAAQ,IAAK,EAAa,SAAS,KAAM,CAC9B,EAAA,CAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,GACtE,IAAU,KAAK,CAAM,GACrB,IAAS,IAAI,YAAY,EAAQ,MAAM,GACvC,IAAS,IAAI,WAAW,CAAM;CACpC,KAAK,IAAI,IAAI,GAAG,IAAI,EAAQ,QAAQ,KAChC,EAAO,KAAK,EAAQ,WAAW,CAAC;CAEpC,OAAO;AACX;AAMA,SAAgB,IAA2B;CACvC,OACI,OAAO,SAAW,OAClB,mBAAmB,aACnB,iBAAiB,UACjB,kBAAkB;AAE1B"}
@@ -8495,6 +8495,11 @@ export declare function upsertById<T>(idField?: keyof T): (current: T[] | undefi
8495
8495
  * Convert a base64url-encoded VAPID public key into the `Uint8Array` format
8496
8496
  * required by `PushManager.subscribe({ applicationServerKey })`.
8497
8497
  *
8498
+ * Calls `atob` as a bare global rather than `window.atob` because this runs in a
8499
+ * **service worker** too: re-subscribing from a `pushsubscriptionchange` handler
8500
+ * needs the same conversion, and there is no `window` in a worker scope — the
8501
+ * qualified call threw `ReferenceError` there while working fine on the page.
8502
+ *
8498
8503
  * @param base64String - VAPID public key (URL-safe base64).
8499
8504
  * @returns The decoded key as bytes.
8500
8505
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tempest-react-sdk",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "SDK público da Tempest com componentes, hooks e integrações para projetos React.",
5
5
  "type": "module",
6
6
  "license": "MIT",