@rei-standard/amsg-client 2.9.0-next.0 → 2.9.0-next.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/dist/index.cjs +20 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.mjs +20 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -150,6 +150,26 @@ var ReiClient = class {
|
|
|
150
150
|
}
|
|
151
151
|
this._userKey = this._hexToUint8Array(userKey);
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Fetch the amsg-server worker's own VAPID public key.
|
|
155
|
+
*
|
|
156
|
+
* A browser needs this as `applicationServerKey` when creating a Web Push
|
|
157
|
+
* subscription. Each self-hosted worker owns its VAPID keypair, so pull the
|
|
158
|
+
* key at runtime rather than baking it into the frontend. Sends
|
|
159
|
+
* `X-Client-Token` when a `serverToken` is configured.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Promise<string>} The base64url VAPID public key.
|
|
162
|
+
* @throws {Error} When the worker has no VAPID public key configured (503).
|
|
163
|
+
*/
|
|
164
|
+
async getVapidPublicKey() {
|
|
165
|
+
const res = await fetch(`${this._baseUrl}/vapid-public-key`, {
|
|
166
|
+
method: "GET",
|
|
167
|
+
headers: this._withServerToken({})
|
|
168
|
+
});
|
|
169
|
+
const json = await res.json();
|
|
170
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to fetch VAPID public key");
|
|
171
|
+
return json.publicKey;
|
|
172
|
+
}
|
|
153
173
|
// ─── Public API ─────────────────────────────────────────────────
|
|
154
174
|
/**
|
|
155
175
|
* Schedule a message.
|
package/dist/index.d.cts
CHANGED
|
@@ -442,6 +442,28 @@ class ReiClient {
|
|
|
442
442
|
this._userKey = this._hexToUint8Array(userKey);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Fetch the amsg-server worker's own VAPID public key.
|
|
447
|
+
*
|
|
448
|
+
* A browser needs this as `applicationServerKey` when creating a Web Push
|
|
449
|
+
* subscription. Each self-hosted worker owns its VAPID keypair, so pull the
|
|
450
|
+
* key at runtime rather than baking it into the frontend. Sends
|
|
451
|
+
* `X-Client-Token` when a `serverToken` is configured.
|
|
452
|
+
*
|
|
453
|
+
* @returns {Promise<string>} The base64url VAPID public key.
|
|
454
|
+
* @throws {Error} When the worker has no VAPID public key configured (503).
|
|
455
|
+
*/
|
|
456
|
+
async getVapidPublicKey() {
|
|
457
|
+
const res = await fetch(`${this._baseUrl}/vapid-public-key`, {
|
|
458
|
+
method: 'GET',
|
|
459
|
+
headers: this._withServerToken({})
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const json = await res.json();
|
|
463
|
+
if (!json.success) throw new Error(json.error?.message || 'Failed to fetch VAPID public key');
|
|
464
|
+
return json.publicKey;
|
|
465
|
+
}
|
|
466
|
+
|
|
445
467
|
// ─── Public API ─────────────────────────────────────────────────
|
|
446
468
|
|
|
447
469
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -442,6 +442,28 @@ class ReiClient {
|
|
|
442
442
|
this._userKey = this._hexToUint8Array(userKey);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Fetch the amsg-server worker's own VAPID public key.
|
|
447
|
+
*
|
|
448
|
+
* A browser needs this as `applicationServerKey` when creating a Web Push
|
|
449
|
+
* subscription. Each self-hosted worker owns its VAPID keypair, so pull the
|
|
450
|
+
* key at runtime rather than baking it into the frontend. Sends
|
|
451
|
+
* `X-Client-Token` when a `serverToken` is configured.
|
|
452
|
+
*
|
|
453
|
+
* @returns {Promise<string>} The base64url VAPID public key.
|
|
454
|
+
* @throws {Error} When the worker has no VAPID public key configured (503).
|
|
455
|
+
*/
|
|
456
|
+
async getVapidPublicKey() {
|
|
457
|
+
const res = await fetch(`${this._baseUrl}/vapid-public-key`, {
|
|
458
|
+
method: 'GET',
|
|
459
|
+
headers: this._withServerToken({})
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const json = await res.json();
|
|
463
|
+
if (!json.success) throw new Error(json.error?.message || 'Failed to fetch VAPID public key');
|
|
464
|
+
return json.publicKey;
|
|
465
|
+
}
|
|
466
|
+
|
|
445
467
|
// ─── Public API ─────────────────────────────────────────────────
|
|
446
468
|
|
|
447
469
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -128,6 +128,26 @@ var ReiClient = class {
|
|
|
128
128
|
}
|
|
129
129
|
this._userKey = this._hexToUint8Array(userKey);
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Fetch the amsg-server worker's own VAPID public key.
|
|
133
|
+
*
|
|
134
|
+
* A browser needs this as `applicationServerKey` when creating a Web Push
|
|
135
|
+
* subscription. Each self-hosted worker owns its VAPID keypair, so pull the
|
|
136
|
+
* key at runtime rather than baking it into the frontend. Sends
|
|
137
|
+
* `X-Client-Token` when a `serverToken` is configured.
|
|
138
|
+
*
|
|
139
|
+
* @returns {Promise<string>} The base64url VAPID public key.
|
|
140
|
+
* @throws {Error} When the worker has no VAPID public key configured (503).
|
|
141
|
+
*/
|
|
142
|
+
async getVapidPublicKey() {
|
|
143
|
+
const res = await fetch(`${this._baseUrl}/vapid-public-key`, {
|
|
144
|
+
method: "GET",
|
|
145
|
+
headers: this._withServerToken({})
|
|
146
|
+
});
|
|
147
|
+
const json = await res.json();
|
|
148
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to fetch VAPID public key");
|
|
149
|
+
return json.publicKey;
|
|
150
|
+
}
|
|
131
151
|
// ─── Public API ─────────────────────────────────────────────────
|
|
132
152
|
/**
|
|
133
153
|
* Schedule a message.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rei-standard/amsg-client",
|
|
3
|
-
"version": "2.9.0-next.
|
|
3
|
+
"version": "2.9.0-next.1",
|
|
4
4
|
"description": "ReiStandard Active Messaging browser client SDK — also re-exports shared push types, builders, and guards from @rei-standard/amsg-shared",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|