@codexhost/cli-linux-arm64 0.18.0-beta.5 → 0.18.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/app/web/sw.js CHANGED
@@ -145,6 +145,46 @@ function offlineResponse() {
145
145
  );
146
146
  }
147
147
 
148
+ async function pushRequest(method, args) {
149
+ const response = await fetch(new URL(`api/${method}`, self.registration.scope).href, {
150
+ method: "POST",
151
+ credentials: "same-origin",
152
+ headers: { "content-type": "application/json" },
153
+ body: JSON.stringify({
154
+ type: "client-request",
155
+ rpcId: crypto.randomUUID(),
156
+ method,
157
+ payload: { args },
158
+ }),
159
+ });
160
+ if (!response.ok) throw new Error(`HTTP ${String(response.status)}`);
161
+ const envelope = await response.json();
162
+ if (!envelope.result.ok) throw new Error(envelope.result.error.message);
163
+ return envelope.result.value;
164
+ }
165
+
166
+ self.addEventListener("pushsubscriptionchange", (event) => {
167
+ event.waitUntil(
168
+ (async () => {
169
+ let applicationServerKey = event.oldSubscription?.options?.applicationServerKey;
170
+ if (!applicationServerKey) {
171
+ const { publicKey } = await pushRequest("codexhost/pushConfig", {});
172
+ const padding = "=".repeat((4 - (publicKey.length % 4)) % 4);
173
+ const raw = atob((publicKey + padding).replace(/-/gu, "+").replace(/_/gu, "/"));
174
+ applicationServerKey = Uint8Array.from(raw, (character) => character.charCodeAt(0));
175
+ }
176
+ const subscription = await self.registration.pushManager.subscribe({
177
+ userVisibleOnly: true,
178
+ applicationServerKey,
179
+ });
180
+ await pushRequest("codexhost/pushSubscribe", {
181
+ subscription: subscription.toJSON(),
182
+ userAgent: navigator.userAgent,
183
+ });
184
+ })(),
185
+ );
186
+ });
187
+
148
188
  self.addEventListener("push", (event) => {
149
189
  let message = {};
150
190
  try {
package/bin/codexhost CHANGED
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexhost/cli-linux-arm64",
3
- "version": "0.18.0-beta.5",
3
+ "version": "0.18.0",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [