@takeal/cusfront-sdk 0.2.8 → 0.3.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 +76 -0
- package/README.md +367 -5
- package/dist/devices-C3JHi2Hi.d.cts +165 -0
- package/dist/devices-DP_hxwmW.d.ts +165 -0
- package/dist/{http-BkCfOCR0.d.cts → http-B-OQwMYn.d.cts} +9 -1
- package/dist/{http-BkCfOCR0.d.ts → http-B-OQwMYn.d.ts} +9 -1
- package/dist/index.cjs +280 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -9
- package/dist/index.d.ts +65 -9
- package/dist/index.js +277 -21
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +133 -6
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +62 -3
- package/dist/react/index.d.ts +62 -3
- package/dist/react/index.js +131 -8
- package/dist/react/index.js.map +1 -1
- package/dist/resources/auth.cjs +36 -11
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +57 -5
- package/dist/resources/auth.d.ts +57 -5
- package/dist/resources/auth.js +36 -11
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +33 -1
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +105 -4
- package/dist/resources/cards.d.ts +105 -4
- package/dist/resources/cards.js +33 -1
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/devices.cjs +92 -0
- package/dist/resources/devices.cjs.map +1 -0
- package/dist/resources/devices.d.cts +3 -0
- package/dist/resources/devices.d.ts +3 -0
- package/dist/resources/devices.js +89 -0
- package/dist/resources/devices.js.map +1 -0
- package/dist/resources/me.cjs +32 -0
- package/dist/resources/me.cjs.map +1 -0
- package/dist/resources/me.d.cts +40 -0
- package/dist/resources/me.d.ts +40 -0
- package/dist/resources/me.js +30 -0
- package/dist/resources/me.js.map +1 -0
- package/dist/resources/notifications.cjs +53 -0
- package/dist/resources/notifications.cjs.map +1 -0
- package/dist/resources/notifications.d.cts +109 -0
- package/dist/resources/notifications.d.ts +109 -0
- package/dist/resources/notifications.js +51 -0
- package/dist/resources/notifications.js.map +1 -0
- package/dist/resources/push.cjs +8 -4
- package/dist/resources/push.cjs.map +1 -1
- package/dist/resources/push.d.cts +14 -17
- package/dist/resources/push.d.ts +14 -17
- package/dist/resources/push.js +8 -4
- package/dist/resources/push.js.map +1 -1
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscriptions.cjs.map +1 -1
- package/dist/resources/subscriptions.d.cts +8 -1
- package/dist/resources/subscriptions.d.ts +8 -1
- package/dist/resources/subscriptions.js.map +1 -1
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +321 -23
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +62 -7
- package/dist/telegram.d.ts +62 -7
- package/dist/telegram.js +320 -24
- package/dist/telegram.js.map +1 -1
- package/package.json +17 -2
package/dist/resources/push.cjs
CHANGED
|
@@ -10,17 +10,20 @@ var PushResource = class {
|
|
|
10
10
|
return this.http.get("/me/push-subscription");
|
|
11
11
|
}
|
|
12
12
|
/** Store a subscription you created yourself.
|
|
13
|
-
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
13
|
+
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
14
|
+
* @deprecated Use `client.devices.register({ kind: "webpush", ... })`. */
|
|
14
15
|
async save(input) {
|
|
15
16
|
return this.http.put("/me/push-subscription", { body: input });
|
|
16
17
|
}
|
|
17
|
-
/** Delete the stored subscription. Safe when nothing is stored.
|
|
18
|
+
/** Delete the stored subscription. Safe when nothing is stored.
|
|
19
|
+
* @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */
|
|
18
20
|
async remove() {
|
|
19
21
|
await this.http.delete("/me/push-subscription");
|
|
20
22
|
}
|
|
21
23
|
/** Subscribe this browser and store the subscription. Ask for
|
|
22
24
|
* notification permission before calling. Throws when push isn't set up
|
|
23
|
-
* on the deployment.
|
|
25
|
+
* on the deployment.
|
|
26
|
+
* @deprecated Use `client.devices.registerWebPush(registration)`. */
|
|
24
27
|
async enable(registration) {
|
|
25
28
|
const { vapid_public_key } = await this.status();
|
|
26
29
|
if (!vapid_public_key) {
|
|
@@ -39,7 +42,8 @@ var PushResource = class {
|
|
|
39
42
|
keys: { p256dh: json.keys.p256dh, auth: json.keys.auth }
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
|
-
/** Unsubscribe this browser and delete the stored subscription.
|
|
45
|
+
/** Unsubscribe this browser and delete the stored subscription.
|
|
46
|
+
* @deprecated Use `client.devices.unregisterWebPush(registration)`. */
|
|
43
47
|
async disable(registration) {
|
|
44
48
|
const sub = await registration.pushManager.getSubscription();
|
|
45
49
|
if (sub) await sub.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";;;AAgDO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,MAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAgB,uBAAuB,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,KAAA,EAAmD;AAC5D,IAAA,OAA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;AAC/B,IAAA,MAAM,KAAK,MAAA,EAAO;AAAA,EACpB;AACF;AAGO,SAAS,iBAAiB,KAAA,EAA2B;AAC1D,EAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA;AACtD,EAAA,MAAM,MAAA,GAAS,MAAM,GAAA,CAAI,MAAA,CAAA,CAAQ,IAAK,GAAA,CAAI,MAAA,GAAS,KAAM,CAAC,CAAA;AAC1D,EAAA,MAAM,GAAA,GAAM,KAAK,MAAM,CAAA;AACvB,EAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA;AACrC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAA,EAAK,GAAA,CAAI,CAAC,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC9D,EAAA,OAAO,GAAA;AACT","file":"push.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Push resource — `client.push.*`.\n *\n * Web Push for the signed-in user, through the older single-subscription\n * endpoint. The API now keeps one device per browser (see\n * `client.devices`), and this endpoint is an alias over the Web Push\n * devices: it keeps working, but new code should call\n * `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.\n *\n * Your service worker shows the notification: the payload is JSON with\n * `title`, `body` and `url` (where a click should lead).\n */\n\nexport interface PushStatus {\n /** `true` when a subscription is stored for this user. */\n subscribed: boolean;\n /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */\n endpoint_host?: string | null;\n /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.\n * `null` when push is not set up on this deployment. */\n vapid_public_key?: string | null;\n}\n\nexport interface PushSubscriptionInput {\n /** `PushSubscription.endpoint`; must be https. */\n endpoint: string;\n keys: {\n /** URL-safe base64. */\n p256dh: string;\n /** URL-safe base64. */\n auth: string;\n };\n}\n\n/** The part of `ServiceWorkerRegistration` the SDK needs. Typed\n * structurally so the core stays free of DOM lib types. */\nexport interface PushCapableRegistration {\n pushManager: {\n getSubscription(): Promise<{ unsubscribe(): Promise<boolean> } | null>;\n subscribe(options: {\n userVisibleOnly: boolean;\n applicationServerKey: Uint8Array;\n }): Promise<{ toJSON(): { endpoint?: string; keys?: Record<string, string> } }>;\n };\n}\n\nexport class PushResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Whether the user is subscribed, plus the VAPID key to subscribe with. */\n async status(): Promise<PushStatus> {\n return this.http.get<PushStatus>(\"/me/push-subscription\");\n }\n\n /** Store a subscription you created yourself.\n * 409 `push_disabled` when the deployment has no VAPID keys.\n * @deprecated Use `client.devices.register({ kind: \"webpush\", ... })`. */\n async save(input: PushSubscriptionInput): Promise<PushStatus> {\n return this.http.put<PushStatus>(\"/me/push-subscription\", { body: input });\n }\n\n /** Delete the stored subscription. Safe when nothing is stored.\n * @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */\n async remove(): Promise<void> {\n await this.http.delete<void>(\"/me/push-subscription\");\n }\n\n /** Subscribe this browser and store the subscription. Ask for\n * notification permission before calling. Throws when push isn't set up\n * on the deployment.\n * @deprecated Use `client.devices.registerWebPush(registration)`. */\n async enable(registration: PushCapableRegistration): Promise<PushStatus> {\n const { vapid_public_key } = await this.status();\n if (!vapid_public_key) {\n throw new Error(\"@takeal/cusfront-sdk: push notifications are not enabled on this deployment\");\n }\n const sub = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: base64UrlToBytes(vapid_public_key),\n });\n const json = sub.toJSON();\n if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {\n throw new Error(\"@takeal/cusfront-sdk: the browser returned an incomplete push subscription\");\n }\n return this.save({\n endpoint: json.endpoint,\n keys: { p256dh: json.keys.p256dh, auth: json.keys.auth },\n });\n }\n\n /** Unsubscribe this browser and delete the stored subscription.\n * @deprecated Use `client.devices.unregisterWebPush(registration)`. */\n async disable(registration: PushCapableRegistration): Promise<void> {\n const sub = await registration.pushManager.getSubscription();\n if (sub) await sub.unsubscribe();\n await this.remove();\n }\n}\n\n/** URL-safe base64 (padding optional) → bytes. */\nexport function base64UrlToBytes(input: string): Uint8Array {\n const b64 = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = b64 + \"=\".repeat((4 - (b64.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n"]}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
1
|
+
import { H as HttpClient } from '../http-B-OQwMYn.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Push resource — `client.push.*`.
|
|
5
5
|
*
|
|
6
|
-
* Web Push for the signed-in user
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const reg = await navigator.serviceWorker.ready;
|
|
14
|
-
* if ((await Notification.requestPermission()) === "granted") {
|
|
15
|
-
* await client.push.enable(reg);
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
6
|
+
* Web Push for the signed-in user, through the older single-subscription
|
|
7
|
+
* endpoint. The API now keeps one device per browser (see
|
|
8
|
+
* `client.devices`), and this endpoint is an alias over the Web Push
|
|
9
|
+
* devices: it keeps working, but new code should call
|
|
10
|
+
* `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.
|
|
18
11
|
*
|
|
19
12
|
* Your service worker shows the notification: the payload is JSON with
|
|
20
13
|
* `title`, `body` and `url` (where a click should lead).
|
|
@@ -62,15 +55,19 @@ declare class PushResource {
|
|
|
62
55
|
/** Whether the user is subscribed, plus the VAPID key to subscribe with. */
|
|
63
56
|
status(): Promise<PushStatus>;
|
|
64
57
|
/** Store a subscription you created yourself.
|
|
65
|
-
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
58
|
+
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
59
|
+
* @deprecated Use `client.devices.register({ kind: "webpush", ... })`. */
|
|
66
60
|
save(input: PushSubscriptionInput): Promise<PushStatus>;
|
|
67
|
-
/** Delete the stored subscription. Safe when nothing is stored.
|
|
61
|
+
/** Delete the stored subscription. Safe when nothing is stored.
|
|
62
|
+
* @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */
|
|
68
63
|
remove(): Promise<void>;
|
|
69
64
|
/** Subscribe this browser and store the subscription. Ask for
|
|
70
65
|
* notification permission before calling. Throws when push isn't set up
|
|
71
|
-
* on the deployment.
|
|
66
|
+
* on the deployment.
|
|
67
|
+
* @deprecated Use `client.devices.registerWebPush(registration)`. */
|
|
72
68
|
enable(registration: PushCapableRegistration): Promise<PushStatus>;
|
|
73
|
-
/** Unsubscribe this browser and delete the stored subscription.
|
|
69
|
+
/** Unsubscribe this browser and delete the stored subscription.
|
|
70
|
+
* @deprecated Use `client.devices.unregisterWebPush(registration)`. */
|
|
74
71
|
disable(registration: PushCapableRegistration): Promise<void>;
|
|
75
72
|
}
|
|
76
73
|
/** URL-safe base64 (padding optional) → bytes. */
|
package/dist/resources/push.d.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
1
|
+
import { H as HttpClient } from '../http-B-OQwMYn.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Push resource — `client.push.*`.
|
|
5
5
|
*
|
|
6
|
-
* Web Push for the signed-in user
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const reg = await navigator.serviceWorker.ready;
|
|
14
|
-
* if ((await Notification.requestPermission()) === "granted") {
|
|
15
|
-
* await client.push.enable(reg);
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
6
|
+
* Web Push for the signed-in user, through the older single-subscription
|
|
7
|
+
* endpoint. The API now keeps one device per browser (see
|
|
8
|
+
* `client.devices`), and this endpoint is an alias over the Web Push
|
|
9
|
+
* devices: it keeps working, but new code should call
|
|
10
|
+
* `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.
|
|
18
11
|
*
|
|
19
12
|
* Your service worker shows the notification: the payload is JSON with
|
|
20
13
|
* `title`, `body` and `url` (where a click should lead).
|
|
@@ -62,15 +55,19 @@ declare class PushResource {
|
|
|
62
55
|
/** Whether the user is subscribed, plus the VAPID key to subscribe with. */
|
|
63
56
|
status(): Promise<PushStatus>;
|
|
64
57
|
/** Store a subscription you created yourself.
|
|
65
|
-
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
58
|
+
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
59
|
+
* @deprecated Use `client.devices.register({ kind: "webpush", ... })`. */
|
|
66
60
|
save(input: PushSubscriptionInput): Promise<PushStatus>;
|
|
67
|
-
/** Delete the stored subscription. Safe when nothing is stored.
|
|
61
|
+
/** Delete the stored subscription. Safe when nothing is stored.
|
|
62
|
+
* @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */
|
|
68
63
|
remove(): Promise<void>;
|
|
69
64
|
/** Subscribe this browser and store the subscription. Ask for
|
|
70
65
|
* notification permission before calling. Throws when push isn't set up
|
|
71
|
-
* on the deployment.
|
|
66
|
+
* on the deployment.
|
|
67
|
+
* @deprecated Use `client.devices.registerWebPush(registration)`. */
|
|
72
68
|
enable(registration: PushCapableRegistration): Promise<PushStatus>;
|
|
73
|
-
/** Unsubscribe this browser and delete the stored subscription.
|
|
69
|
+
/** Unsubscribe this browser and delete the stored subscription.
|
|
70
|
+
* @deprecated Use `client.devices.unregisterWebPush(registration)`. */
|
|
74
71
|
disable(registration: PushCapableRegistration): Promise<void>;
|
|
75
72
|
}
|
|
76
73
|
/** URL-safe base64 (padding optional) → bytes. */
|
package/dist/resources/push.js
CHANGED
|
@@ -8,17 +8,20 @@ var PushResource = class {
|
|
|
8
8
|
return this.http.get("/me/push-subscription");
|
|
9
9
|
}
|
|
10
10
|
/** Store a subscription you created yourself.
|
|
11
|
-
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
11
|
+
* 409 `push_disabled` when the deployment has no VAPID keys.
|
|
12
|
+
* @deprecated Use `client.devices.register({ kind: "webpush", ... })`. */
|
|
12
13
|
async save(input) {
|
|
13
14
|
return this.http.put("/me/push-subscription", { body: input });
|
|
14
15
|
}
|
|
15
|
-
/** Delete the stored subscription. Safe when nothing is stored.
|
|
16
|
+
/** Delete the stored subscription. Safe when nothing is stored.
|
|
17
|
+
* @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */
|
|
16
18
|
async remove() {
|
|
17
19
|
await this.http.delete("/me/push-subscription");
|
|
18
20
|
}
|
|
19
21
|
/** Subscribe this browser and store the subscription. Ask for
|
|
20
22
|
* notification permission before calling. Throws when push isn't set up
|
|
21
|
-
* on the deployment.
|
|
23
|
+
* on the deployment.
|
|
24
|
+
* @deprecated Use `client.devices.registerWebPush(registration)`. */
|
|
22
25
|
async enable(registration) {
|
|
23
26
|
const { vapid_public_key } = await this.status();
|
|
24
27
|
if (!vapid_public_key) {
|
|
@@ -37,7 +40,8 @@ var PushResource = class {
|
|
|
37
40
|
keys: { p256dh: json.keys.p256dh, auth: json.keys.auth }
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
|
-
/** Unsubscribe this browser and delete the stored subscription.
|
|
43
|
+
/** Unsubscribe this browser and delete the stored subscription.
|
|
44
|
+
* @deprecated Use `client.devices.unregisterWebPush(registration)`. */
|
|
41
45
|
async disable(registration) {
|
|
42
46
|
const sub = await registration.pushManager.getSubscription();
|
|
43
47
|
if (sub) await sub.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";
|
|
1
|
+
{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AU,IAAA,CAAK,QAAA;AAAA,MACf,IAAA,EAAM,EAAE,MAAA,EAAQ,IAAA,CAAK,KAAK,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,IAAA;AAAK,KACxD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA,EAIA,MAAM,QAAQ,YAAA,EAAsD;AAClE,IAAA,MAAM,GAAA,GAAM,MAAM,YAAA,CAAa,WAAA,CAAY,eAAA,EAAgB;AAC3D,IAAA,IAAI,GAAA,EAAK,MAAM,GAAA,CAAI,WAAA,EAAY;AAC/B,IAAA,MAAM,KAAK,MAAA,EAAO;AAAA,EACpB;AACF;AAGO,SAAS,iBAAiB,KAAA,EAA2B;AAC1D,EAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA;AACtD,EAAA,MAAM,MAAA,GAAS,MAAM,GAAA,CAAI,MAAA,CAAA,CAAQ,IAAK,GAAA,CAAI,MAAA,GAAS,KAAM,CAAC,CAAA;AAC1D,EAAA,MAAM,GAAA,GAAM,KAAK,MAAM,CAAA;AACvB,EAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA;AACrC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAA,EAAK,GAAA,CAAI,CAAC,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC9D,EAAA,OAAO,GAAA;AACT","file":"push.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Push resource — `client.push.*`.\n *\n * Web Push for the signed-in user, through the older single-subscription\n * endpoint. The API now keeps one device per browser (see\n * `client.devices`), and this endpoint is an alias over the Web Push\n * devices: it keeps working, but new code should call\n * `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.\n *\n * Your service worker shows the notification: the payload is JSON with\n * `title`, `body` and `url` (where a click should lead).\n */\n\nexport interface PushStatus {\n /** `true` when a subscription is stored for this user. */\n subscribed: boolean;\n /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */\n endpoint_host?: string | null;\n /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.\n * `null` when push is not set up on this deployment. */\n vapid_public_key?: string | null;\n}\n\nexport interface PushSubscriptionInput {\n /** `PushSubscription.endpoint`; must be https. */\n endpoint: string;\n keys: {\n /** URL-safe base64. */\n p256dh: string;\n /** URL-safe base64. */\n auth: string;\n };\n}\n\n/** The part of `ServiceWorkerRegistration` the SDK needs. Typed\n * structurally so the core stays free of DOM lib types. */\nexport interface PushCapableRegistration {\n pushManager: {\n getSubscription(): Promise<{ unsubscribe(): Promise<boolean> } | null>;\n subscribe(options: {\n userVisibleOnly: boolean;\n applicationServerKey: Uint8Array;\n }): Promise<{ toJSON(): { endpoint?: string; keys?: Record<string, string> } }>;\n };\n}\n\nexport class PushResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Whether the user is subscribed, plus the VAPID key to subscribe with. */\n async status(): Promise<PushStatus> {\n return this.http.get<PushStatus>(\"/me/push-subscription\");\n }\n\n /** Store a subscription you created yourself.\n * 409 `push_disabled` when the deployment has no VAPID keys.\n * @deprecated Use `client.devices.register({ kind: \"webpush\", ... })`. */\n async save(input: PushSubscriptionInput): Promise<PushStatus> {\n return this.http.put<PushStatus>(\"/me/push-subscription\", { body: input });\n }\n\n /** Delete the stored subscription. Safe when nothing is stored.\n * @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */\n async remove(): Promise<void> {\n await this.http.delete<void>(\"/me/push-subscription\");\n }\n\n /** Subscribe this browser and store the subscription. Ask for\n * notification permission before calling. Throws when push isn't set up\n * on the deployment.\n * @deprecated Use `client.devices.registerWebPush(registration)`. */\n async enable(registration: PushCapableRegistration): Promise<PushStatus> {\n const { vapid_public_key } = await this.status();\n if (!vapid_public_key) {\n throw new Error(\"@takeal/cusfront-sdk: push notifications are not enabled on this deployment\");\n }\n const sub = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: base64UrlToBytes(vapid_public_key),\n });\n const json = sub.toJSON();\n if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {\n throw new Error(\"@takeal/cusfront-sdk: the browser returned an incomplete push subscription\");\n }\n return this.save({\n endpoint: json.endpoint,\n keys: { p256dh: json.keys.p256dh, auth: json.keys.auth },\n });\n }\n\n /** Unsubscribe this browser and delete the stored subscription.\n * @deprecated Use `client.devices.unregisterWebPush(registration)`. */\n async disable(registration: PushCapableRegistration): Promise<void> {\n const sub = await registration.pushManager.getSubscription();\n if (sub) await sub.unsubscribe();\n await this.remove();\n }\n}\n\n/** URL-safe base64 (padding optional) → bytes. */\nexport function base64UrlToBytes(input: string): Uint8Array {\n const b64 = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = b64 + \"=\".repeat((4 - (b64.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":";;;AAkCO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA,EAEhD,MAAM,GAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,mBAAmB,CAAA;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,IAAI,QAAA,EAAsD;AAC9D,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,mBAAA,EAAqB;AAAA,MACvD,IAAA,EAAM,EAAE,QAAA;AAAS,KAClB,CAAA;AAAA,EACH;AACF","file":"subscriptions.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Subscriptions resource — `client.subscriptions.*`.\n *\n * Which channels the signed-in user agreed to receive announcements on.\n * `available` tells you which toggles to render: a deployment with no\n * Telegram bot configured can't deliver there, so offering the switch would\n * be a lie.\n *\n * ```ts\n * const { channels, available } = await client.subscriptions.get();\n * await client.subscriptions.set([...channels, \"telegram\"]);\n * ```\n *\n * Unrelated to paid/VIP tiers — this is only about announcements.\n *\n * @deprecated Announcements are now the `marketing` category of the\n * notification preferences. Read them with\n * `client.notifications.getPreferences()` and change them with\n * `client.notifications.setPreferences({ categories: { marketing: { email: true, telegram: false } } })`.\n * This endpoint keeps working as an alias over that setting.\n */\n\nexport type BroadcastChannel = \"email\" | \"telegram\" | (string & {});\n\nexport interface Subscriptions {\n /** Channels the user currently receives announcements on. */\n channels: BroadcastChannel[];\n /** Channels this deployment can actually deliver on. */\n available: BroadcastChannel[];\n}\n\n/** @deprecated See the note at the top of this module. */\nexport class SubscriptionsResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Subscriptions> {\n return this.http.get<Subscriptions>(\"/me/subscriptions\");\n }\n\n /**\n * Replace the whole set — this is a PUT, not a merge. Pass `[]` to opt out\n * of everything.\n */\n async set(channels: BroadcastChannel[]): Promise<Subscriptions> {\n return this.http.put<Subscriptions>(\"/me/subscriptions\", {\n body: { channels },\n });\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
1
|
+
import { H as HttpClient } from '../http-B-OQwMYn.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Subscriptions resource — `client.subscriptions.*`.
|
|
@@ -14,6 +14,12 @@ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Unrelated to paid/VIP tiers — this is only about announcements.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Announcements are now the `marketing` category of the
|
|
19
|
+
* notification preferences. Read them with
|
|
20
|
+
* `client.notifications.getPreferences()` and change them with
|
|
21
|
+
* `client.notifications.setPreferences({ categories: { marketing: { email: true, telegram: false } } })`.
|
|
22
|
+
* This endpoint keeps working as an alias over that setting.
|
|
17
23
|
*/
|
|
18
24
|
type BroadcastChannel = "email" | "telegram" | (string & {});
|
|
19
25
|
interface Subscriptions {
|
|
@@ -22,6 +28,7 @@ interface Subscriptions {
|
|
|
22
28
|
/** Channels this deployment can actually deliver on. */
|
|
23
29
|
available: BroadcastChannel[];
|
|
24
30
|
}
|
|
31
|
+
/** @deprecated See the note at the top of this module. */
|
|
25
32
|
declare class SubscriptionsResource {
|
|
26
33
|
private readonly http;
|
|
27
34
|
constructor(http: HttpClient);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
1
|
+
import { H as HttpClient } from '../http-B-OQwMYn.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Subscriptions resource — `client.subscriptions.*`.
|
|
@@ -14,6 +14,12 @@ import { H as HttpClient } from '../http-BkCfOCR0.js';
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Unrelated to paid/VIP tiers — this is only about announcements.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Announcements are now the `marketing` category of the
|
|
19
|
+
* notification preferences. Read them with
|
|
20
|
+
* `client.notifications.getPreferences()` and change them with
|
|
21
|
+
* `client.notifications.setPreferences({ categories: { marketing: { email: true, telegram: false } } })`.
|
|
22
|
+
* This endpoint keeps working as an alias over that setting.
|
|
17
23
|
*/
|
|
18
24
|
type BroadcastChannel = "email" | "telegram" | (string & {});
|
|
19
25
|
interface Subscriptions {
|
|
@@ -22,6 +28,7 @@ interface Subscriptions {
|
|
|
22
28
|
/** Channels this deployment can actually deliver on. */
|
|
23
29
|
available: BroadcastChannel[];
|
|
24
30
|
}
|
|
31
|
+
/** @deprecated See the note at the top of this module. */
|
|
25
32
|
declare class SubscriptionsResource {
|
|
26
33
|
private readonly http;
|
|
27
34
|
constructor(http: HttpClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":";AAkCO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA,EAEhD,MAAM,GAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,mBAAmB,CAAA;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,IAAI,QAAA,EAAsD;AAC9D,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,mBAAA,EAAqB;AAAA,MACvD,IAAA,EAAM,EAAE,QAAA;AAAS,KAClB,CAAA;AAAA,EACH;AACF","file":"subscriptions.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Subscriptions resource — `client.subscriptions.*`.\n *\n * Which channels the signed-in user agreed to receive announcements on.\n * `available` tells you which toggles to render: a deployment with no\n * Telegram bot configured can't deliver there, so offering the switch would\n * be a lie.\n *\n * ```ts\n * const { channels, available } = await client.subscriptions.get();\n * await client.subscriptions.set([...channels, \"telegram\"]);\n * ```\n *\n * Unrelated to paid/VIP tiers — this is only about announcements.\n *\n * @deprecated Announcements are now the `marketing` category of the\n * notification preferences. Read them with\n * `client.notifications.getPreferences()` and change them with\n * `client.notifications.setPreferences({ categories: { marketing: { email: true, telegram: false } } })`.\n * This endpoint keeps working as an alias over that setting.\n */\n\nexport type BroadcastChannel = \"email\" | \"telegram\" | (string & {});\n\nexport interface Subscriptions {\n /** Channels the user currently receives announcements on. */\n channels: BroadcastChannel[];\n /** Channels this deployment can actually deliver on. */\n available: BroadcastChannel[];\n}\n\n/** @deprecated See the note at the top of this module. */\nexport class SubscriptionsResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(): Promise<Subscriptions> {\n return this.http.get<Subscriptions>(\"/me/subscriptions\");\n }\n\n /**\n * Replace the whole set — this is a PUT, not a merge. Pass `[]` to opt out\n * of everything.\n */\n async set(channels: BroadcastChannel[]): Promise<Subscriptions> {\n return this.http.put<Subscriptions>(\"/me/subscriptions\", {\n body: { channels },\n });\n }\n}\n"]}
|