@takeal/cusfront-sdk 0.1.0 → 0.2.8

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/README.md +29 -12
  3. package/dist/{http-BkZZZI8K.d.cts → http-BkCfOCR0.d.cts} +4 -1
  4. package/dist/{http-BkZZZI8K.d.ts → http-BkCfOCR0.d.ts} +4 -1
  5. package/dist/index.cjs +150 -10
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +16 -3
  8. package/dist/index.d.ts +16 -3
  9. package/dist/index.js +150 -10
  10. package/dist/index.js.map +1 -1
  11. package/dist/react/index.d.cts +4 -1
  12. package/dist/react/index.d.ts +4 -1
  13. package/dist/resources/auth.cjs +37 -4
  14. package/dist/resources/auth.cjs.map +1 -1
  15. package/dist/resources/auth.d.cts +45 -6
  16. package/dist/resources/auth.d.ts +45 -6
  17. package/dist/resources/auth.js +37 -4
  18. package/dist/resources/auth.js.map +1 -1
  19. package/dist/resources/balance.cjs +4 -3
  20. package/dist/resources/balance.cjs.map +1 -1
  21. package/dist/resources/balance.d.cts +8 -9
  22. package/dist/resources/balance.d.ts +8 -9
  23. package/dist/resources/balance.js +4 -3
  24. package/dist/resources/balance.js.map +1 -1
  25. package/dist/resources/blog.d.cts +1 -1
  26. package/dist/resources/blog.d.ts +1 -1
  27. package/dist/resources/branding.cjs.map +1 -1
  28. package/dist/resources/branding.d.cts +8 -2
  29. package/dist/resources/branding.d.ts +8 -2
  30. package/dist/resources/branding.js.map +1 -1
  31. package/dist/resources/cards.d.cts +1 -1
  32. package/dist/resources/cards.d.ts +1 -1
  33. package/dist/resources/deposits.d.cts +1 -1
  34. package/dist/resources/deposits.d.ts +1 -1
  35. package/dist/resources/push.cjs +61 -0
  36. package/dist/resources/push.cjs.map +1 -0
  37. package/dist/resources/push.d.cts +79 -0
  38. package/dist/resources/push.d.ts +79 -0
  39. package/dist/resources/push.js +58 -0
  40. package/dist/resources/push.js.map +1 -0
  41. package/dist/resources/sessions.cjs +26 -0
  42. package/dist/resources/sessions.cjs.map +1 -0
  43. package/dist/resources/sessions.d.cts +43 -0
  44. package/dist/resources/sessions.d.ts +43 -0
  45. package/dist/resources/sessions.js +24 -0
  46. package/dist/resources/sessions.js.map +1 -0
  47. package/dist/resources/subscriptions.d.cts +1 -1
  48. package/dist/resources/subscriptions.d.ts +1 -1
  49. package/dist/resources/wallet.cjs +24 -0
  50. package/dist/resources/wallet.cjs.map +1 -0
  51. package/dist/resources/wallet.d.cts +39 -0
  52. package/dist/resources/wallet.d.ts +39 -0
  53. package/dist/resources/wallet.js +22 -0
  54. package/dist/resources/wallet.js.map +1 -0
  55. package/dist/telegram.cjs +150 -10
  56. package/dist/telegram.cjs.map +1 -1
  57. package/dist/telegram.d.cts +4 -1
  58. package/dist/telegram.d.ts +4 -1
  59. package/dist/telegram.js +150 -10
  60. package/dist/telegram.js.map +1 -1
  61. package/package.json +22 -3
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.cjs';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
2
  import { C as CustomerInfo } from '../customer-CoxPwe5o.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.js';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
2
  import { C as CustomerInfo } from '../customer-CoxPwe5o.js';
3
3
 
4
4
  /**
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ // src/resources/push.ts
4
+ var PushResource = class {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** Whether the user is subscribed, plus the VAPID key to subscribe with. */
9
+ async status() {
10
+ return this.http.get("/me/push-subscription");
11
+ }
12
+ /** Store a subscription you created yourself.
13
+ * 409 `push_disabled` when the deployment has no VAPID keys. */
14
+ async save(input) {
15
+ return this.http.put("/me/push-subscription", { body: input });
16
+ }
17
+ /** Delete the stored subscription. Safe when nothing is stored. */
18
+ async remove() {
19
+ await this.http.delete("/me/push-subscription");
20
+ }
21
+ /** Subscribe this browser and store the subscription. Ask for
22
+ * notification permission before calling. Throws when push isn't set up
23
+ * on the deployment. */
24
+ async enable(registration) {
25
+ const { vapid_public_key } = await this.status();
26
+ if (!vapid_public_key) {
27
+ throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
28
+ }
29
+ const sub = await registration.pushManager.subscribe({
30
+ userVisibleOnly: true,
31
+ applicationServerKey: base64UrlToBytes(vapid_public_key)
32
+ });
33
+ const json = sub.toJSON();
34
+ if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {
35
+ throw new Error("@takeal/cusfront-sdk: the browser returned an incomplete push subscription");
36
+ }
37
+ return this.save({
38
+ endpoint: json.endpoint,
39
+ keys: { p256dh: json.keys.p256dh, auth: json.keys.auth }
40
+ });
41
+ }
42
+ /** Unsubscribe this browser and delete the stored subscription. */
43
+ async disable(registration) {
44
+ const sub = await registration.pushManager.getSubscription();
45
+ if (sub) await sub.unsubscribe();
46
+ await this.remove();
47
+ }
48
+ };
49
+ function base64UrlToBytes(input) {
50
+ const b64 = input.replace(/-/g, "+").replace(/_/g, "/");
51
+ const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
52
+ const bin = atob(padded);
53
+ const out = new Uint8Array(bin.length);
54
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
55
+ return out;
56
+ }
57
+
58
+ exports.PushResource = PushResource;
59
+ exports.base64UrlToBytes = base64UrlToBytes;
60
+ //# sourceMappingURL=push.cjs.map
61
+ //# sourceMappingURL=push.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";;;AAuDO,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,EAIA,MAAM,KAAK,KAAA,EAAmD;AAC5D,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAgB,yBAAyB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC3E;AAAA;AAAA,EAGA,MAAM,MAAA,GAAwB;AAC5B,IAAA,MAAM,IAAA,CAAK,IAAA,CAAK,MAAA,CAAa,uBAAuB,CAAA;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,YAAA,EAA4D;AACvE,IAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,MAAM,KAAK,MAAA,EAAO;AAC/C,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,MAAM,IAAI,MAAM,6EAA6E,CAAA;AAAA,IAC/F;AACA,IAAA,MAAM,GAAA,GAAM,MAAM,YAAA,CAAa,WAAA,CAAY,SAAA,CAAU;AAAA,MACnD,eAAA,EAAiB,IAAA;AAAA,MACjB,oBAAA,EAAsB,iBAAiB,gBAAgB;AAAA,KACxD,CAAA;AACD,IAAA,MAAM,IAAA,GAAO,IAAI,MAAA,EAAO;AACxB,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,IAAY,CAAC,IAAA,CAAK,MAAM,MAAA,IAAU,CAAC,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM;AAC3D,MAAA,MAAM,IAAI,MAAM,4EAA4E,CAAA;AAAA,IAC9F;AACA,IAAA,OAAO,KAAK,IAAA,CAAK;AAAA,MACf,UAAU,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,EAGA,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.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Push resource — `client.push.*`.\n *\n * Web Push for the signed-in user. The API keeps one subscription per user\n * (the newest wins) and sends a notification for the user's own events:\n * a confirmed deposit, a card transaction and so on.\n *\n * The usual browser flow is one call:\n *\n * ```ts\n * const reg = await navigator.serviceWorker.ready;\n * if ((await Notification.requestPermission()) === \"granted\") {\n * await client.push.enable(reg);\n * }\n * ```\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 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 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 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 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"]}
@@ -0,0 +1,79 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
+
3
+ /**
4
+ * Push resource — `client.push.*`.
5
+ *
6
+ * Web Push for the signed-in user. The API keeps one subscription per user
7
+ * (the newest wins) and sends a notification for the user's own events:
8
+ * a confirmed deposit, a card transaction and so on.
9
+ *
10
+ * The usual browser flow is one call:
11
+ *
12
+ * ```ts
13
+ * const reg = await navigator.serviceWorker.ready;
14
+ * if ((await Notification.requestPermission()) === "granted") {
15
+ * await client.push.enable(reg);
16
+ * }
17
+ * ```
18
+ *
19
+ * Your service worker shows the notification: the payload is JSON with
20
+ * `title`, `body` and `url` (where a click should lead).
21
+ */
22
+ interface PushStatus {
23
+ /** `true` when a subscription is stored for this user. */
24
+ subscribed: boolean;
25
+ /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */
26
+ endpoint_host?: string | null;
27
+ /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.
28
+ * `null` when push is not set up on this deployment. */
29
+ vapid_public_key?: string | null;
30
+ }
31
+ interface PushSubscriptionInput {
32
+ /** `PushSubscription.endpoint`; must be https. */
33
+ endpoint: string;
34
+ keys: {
35
+ /** URL-safe base64. */
36
+ p256dh: string;
37
+ /** URL-safe base64. */
38
+ auth: string;
39
+ };
40
+ }
41
+ /** The part of `ServiceWorkerRegistration` the SDK needs. Typed
42
+ * structurally so the core stays free of DOM lib types. */
43
+ interface PushCapableRegistration {
44
+ pushManager: {
45
+ getSubscription(): Promise<{
46
+ unsubscribe(): Promise<boolean>;
47
+ } | null>;
48
+ subscribe(options: {
49
+ userVisibleOnly: boolean;
50
+ applicationServerKey: Uint8Array;
51
+ }): Promise<{
52
+ toJSON(): {
53
+ endpoint?: string;
54
+ keys?: Record<string, string>;
55
+ };
56
+ }>;
57
+ };
58
+ }
59
+ declare class PushResource {
60
+ private readonly http;
61
+ constructor(http: HttpClient);
62
+ /** Whether the user is subscribed, plus the VAPID key to subscribe with. */
63
+ status(): Promise<PushStatus>;
64
+ /** Store a subscription you created yourself.
65
+ * 409 `push_disabled` when the deployment has no VAPID keys. */
66
+ save(input: PushSubscriptionInput): Promise<PushStatus>;
67
+ /** Delete the stored subscription. Safe when nothing is stored. */
68
+ remove(): Promise<void>;
69
+ /** Subscribe this browser and store the subscription. Ask for
70
+ * notification permission before calling. Throws when push isn't set up
71
+ * on the deployment. */
72
+ enable(registration: PushCapableRegistration): Promise<PushStatus>;
73
+ /** Unsubscribe this browser and delete the stored subscription. */
74
+ disable(registration: PushCapableRegistration): Promise<void>;
75
+ }
76
+ /** URL-safe base64 (padding optional) → bytes. */
77
+ declare function base64UrlToBytes(input: string): Uint8Array;
78
+
79
+ export { type PushCapableRegistration, PushResource, type PushStatus, type PushSubscriptionInput, base64UrlToBytes };
@@ -0,0 +1,79 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
+
3
+ /**
4
+ * Push resource — `client.push.*`.
5
+ *
6
+ * Web Push for the signed-in user. The API keeps one subscription per user
7
+ * (the newest wins) and sends a notification for the user's own events:
8
+ * a confirmed deposit, a card transaction and so on.
9
+ *
10
+ * The usual browser flow is one call:
11
+ *
12
+ * ```ts
13
+ * const reg = await navigator.serviceWorker.ready;
14
+ * if ((await Notification.requestPermission()) === "granted") {
15
+ * await client.push.enable(reg);
16
+ * }
17
+ * ```
18
+ *
19
+ * Your service worker shows the notification: the payload is JSON with
20
+ * `title`, `body` and `url` (where a click should lead).
21
+ */
22
+ interface PushStatus {
23
+ /** `true` when a subscription is stored for this user. */
24
+ subscribed: boolean;
25
+ /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */
26
+ endpoint_host?: string | null;
27
+ /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.
28
+ * `null` when push is not set up on this deployment. */
29
+ vapid_public_key?: string | null;
30
+ }
31
+ interface PushSubscriptionInput {
32
+ /** `PushSubscription.endpoint`; must be https. */
33
+ endpoint: string;
34
+ keys: {
35
+ /** URL-safe base64. */
36
+ p256dh: string;
37
+ /** URL-safe base64. */
38
+ auth: string;
39
+ };
40
+ }
41
+ /** The part of `ServiceWorkerRegistration` the SDK needs. Typed
42
+ * structurally so the core stays free of DOM lib types. */
43
+ interface PushCapableRegistration {
44
+ pushManager: {
45
+ getSubscription(): Promise<{
46
+ unsubscribe(): Promise<boolean>;
47
+ } | null>;
48
+ subscribe(options: {
49
+ userVisibleOnly: boolean;
50
+ applicationServerKey: Uint8Array;
51
+ }): Promise<{
52
+ toJSON(): {
53
+ endpoint?: string;
54
+ keys?: Record<string, string>;
55
+ };
56
+ }>;
57
+ };
58
+ }
59
+ declare class PushResource {
60
+ private readonly http;
61
+ constructor(http: HttpClient);
62
+ /** Whether the user is subscribed, plus the VAPID key to subscribe with. */
63
+ status(): Promise<PushStatus>;
64
+ /** Store a subscription you created yourself.
65
+ * 409 `push_disabled` when the deployment has no VAPID keys. */
66
+ save(input: PushSubscriptionInput): Promise<PushStatus>;
67
+ /** Delete the stored subscription. Safe when nothing is stored. */
68
+ remove(): Promise<void>;
69
+ /** Subscribe this browser and store the subscription. Ask for
70
+ * notification permission before calling. Throws when push isn't set up
71
+ * on the deployment. */
72
+ enable(registration: PushCapableRegistration): Promise<PushStatus>;
73
+ /** Unsubscribe this browser and delete the stored subscription. */
74
+ disable(registration: PushCapableRegistration): Promise<void>;
75
+ }
76
+ /** URL-safe base64 (padding optional) → bytes. */
77
+ declare function base64UrlToBytes(input: string): Uint8Array;
78
+
79
+ export { type PushCapableRegistration, PushResource, type PushStatus, type PushSubscriptionInput, base64UrlToBytes };
@@ -0,0 +1,58 @@
1
+ // src/resources/push.ts
2
+ var PushResource = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** Whether the user is subscribed, plus the VAPID key to subscribe with. */
7
+ async status() {
8
+ return this.http.get("/me/push-subscription");
9
+ }
10
+ /** Store a subscription you created yourself.
11
+ * 409 `push_disabled` when the deployment has no VAPID keys. */
12
+ async save(input) {
13
+ return this.http.put("/me/push-subscription", { body: input });
14
+ }
15
+ /** Delete the stored subscription. Safe when nothing is stored. */
16
+ async remove() {
17
+ await this.http.delete("/me/push-subscription");
18
+ }
19
+ /** Subscribe this browser and store the subscription. Ask for
20
+ * notification permission before calling. Throws when push isn't set up
21
+ * on the deployment. */
22
+ async enable(registration) {
23
+ const { vapid_public_key } = await this.status();
24
+ if (!vapid_public_key) {
25
+ throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
26
+ }
27
+ const sub = await registration.pushManager.subscribe({
28
+ userVisibleOnly: true,
29
+ applicationServerKey: base64UrlToBytes(vapid_public_key)
30
+ });
31
+ const json = sub.toJSON();
32
+ if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {
33
+ throw new Error("@takeal/cusfront-sdk: the browser returned an incomplete push subscription");
34
+ }
35
+ return this.save({
36
+ endpoint: json.endpoint,
37
+ keys: { p256dh: json.keys.p256dh, auth: json.keys.auth }
38
+ });
39
+ }
40
+ /** Unsubscribe this browser and delete the stored subscription. */
41
+ async disable(registration) {
42
+ const sub = await registration.pushManager.getSubscription();
43
+ if (sub) await sub.unsubscribe();
44
+ await this.remove();
45
+ }
46
+ };
47
+ function base64UrlToBytes(input) {
48
+ const b64 = input.replace(/-/g, "+").replace(/_/g, "/");
49
+ const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
50
+ const bin = atob(padded);
51
+ const out = new Uint8Array(bin.length);
52
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
53
+ return out;
54
+ }
55
+
56
+ export { PushResource, base64UrlToBytes };
57
+ //# sourceMappingURL=push.js.map
58
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";AAuDO,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,EAIA,MAAM,KAAK,KAAA,EAAmD;AAC5D,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAgB,yBAAyB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC3E;AAAA;AAAA,EAGA,MAAM,MAAA,GAAwB;AAC5B,IAAA,MAAM,IAAA,CAAK,IAAA,CAAK,MAAA,CAAa,uBAAuB,CAAA;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,YAAA,EAA4D;AACvE,IAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,MAAM,KAAK,MAAA,EAAO;AAC/C,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,MAAM,IAAI,MAAM,6EAA6E,CAAA;AAAA,IAC/F;AACA,IAAA,MAAM,GAAA,GAAM,MAAM,YAAA,CAAa,WAAA,CAAY,SAAA,CAAU;AAAA,MACnD,eAAA,EAAiB,IAAA;AAAA,MACjB,oBAAA,EAAsB,iBAAiB,gBAAgB;AAAA,KACxD,CAAA;AACD,IAAA,MAAM,IAAA,GAAO,IAAI,MAAA,EAAO;AACxB,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,IAAY,CAAC,IAAA,CAAK,MAAM,MAAA,IAAU,CAAC,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM;AAC3D,MAAA,MAAM,IAAI,MAAM,4EAA4E,CAAA;AAAA,IAC9F;AACA,IAAA,OAAO,KAAK,IAAA,CAAK;AAAA,MACf,UAAU,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,EAGA,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. The API keeps one subscription per user\n * (the newest wins) and sends a notification for the user's own events:\n * a confirmed deposit, a card transaction and so on.\n *\n * The usual browser flow is one call:\n *\n * ```ts\n * const reg = await navigator.serviceWorker.ready;\n * if ((await Notification.requestPermission()) === \"granted\") {\n * await client.push.enable(reg);\n * }\n * ```\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 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 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 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 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"]}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ // src/resources/sessions.ts
4
+ var SessionsResource = class {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** All live sessions of the account, this one included. */
9
+ async list() {
10
+ return this.http.get("/me/sessions");
11
+ }
12
+ /** Sign out one session. Works on the current one too; the stored JWT
13
+ * stops working, so follow with `client.auth.signOut()`.
14
+ * 404 when the session is unknown or already signed out. */
15
+ async revoke(jti) {
16
+ await this.http.delete(`/me/sessions/${encodeURIComponent(jti)}`);
17
+ }
18
+ /** Sign out every session except this one. */
19
+ async revokeOthers() {
20
+ return this.http.post("/me/sessions/terminate-others");
21
+ }
22
+ };
23
+
24
+ exports.SessionsResource = SessionsResource;
25
+ //# sourceMappingURL=sessions.cjs.map
26
+ //# sourceMappingURL=sessions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/sessions.ts"],"names":[],"mappings":";;;AA6BO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,GAA+B;AACnC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,cAAc,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,GAAA,EAA4B;AACvC,IAAA,MAAM,KAAK,IAAA,CAAK,MAAA,CAAa,gBAAgB,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,YAAA,GAAsD;AAC1D,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAmC,+BAA+B,CAAA;AAAA,EACrF;AACF","file":"sessions.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Sessions resource — `client.sessions.*`.\n *\n * Every device or browser the user is signed in on. Lets a settings screen\n * show \"where you're signed in\" and sign one or all of them out.\n *\n * ```ts\n * const sessions = await client.sessions.list();\n * const others = sessions.filter((s) => !s.current);\n * await client.sessions.revokeOthers();\n * ```\n */\n\nexport interface UserSession {\n /** Session id; pass it to `revoke`. */\n jti: string;\n issued_at: string;\n expires_at: string;\n last_seen_at: string;\n /** Client IP recorded for the session, if known. */\n remote_ip?: string | null;\n /** Browser or app that opened the session, if known. */\n user_agent?: string | null;\n /** `true` for the session this client is using. */\n current: boolean;\n}\n\nexport class SessionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** All live sessions of the account, this one included. */\n async list(): Promise<UserSession[]> {\n return this.http.get<UserSession[]>(\"/me/sessions\");\n }\n\n /** Sign out one session. Works on the current one too; the stored JWT\n * stops working, so follow with `client.auth.signOut()`.\n * 404 when the session is unknown or already signed out. */\n async revoke(jti: string): Promise<void> {\n await this.http.delete<void>(`/me/sessions/${encodeURIComponent(jti)}`);\n }\n\n /** Sign out every session except this one. */\n async revokeOthers(): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/me/sessions/terminate-others\");\n }\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
+
3
+ /**
4
+ * Sessions resource — `client.sessions.*`.
5
+ *
6
+ * Every device or browser the user is signed in on. Lets a settings screen
7
+ * show "where you're signed in" and sign one or all of them out.
8
+ *
9
+ * ```ts
10
+ * const sessions = await client.sessions.list();
11
+ * const others = sessions.filter((s) => !s.current);
12
+ * await client.sessions.revokeOthers();
13
+ * ```
14
+ */
15
+ interface UserSession {
16
+ /** Session id; pass it to `revoke`. */
17
+ jti: string;
18
+ issued_at: string;
19
+ expires_at: string;
20
+ last_seen_at: string;
21
+ /** Client IP recorded for the session, if known. */
22
+ remote_ip?: string | null;
23
+ /** Browser or app that opened the session, if known. */
24
+ user_agent?: string | null;
25
+ /** `true` for the session this client is using. */
26
+ current: boolean;
27
+ }
28
+ declare class SessionsResource {
29
+ private readonly http;
30
+ constructor(http: HttpClient);
31
+ /** All live sessions of the account, this one included. */
32
+ list(): Promise<UserSession[]>;
33
+ /** Sign out one session. Works on the current one too; the stored JWT
34
+ * stops working, so follow with `client.auth.signOut()`.
35
+ * 404 when the session is unknown or already signed out. */
36
+ revoke(jti: string): Promise<void>;
37
+ /** Sign out every session except this one. */
38
+ revokeOthers(): Promise<{
39
+ revoked_sessions: number;
40
+ }>;
41
+ }
42
+
43
+ export { SessionsResource, type UserSession };
@@ -0,0 +1,43 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
+
3
+ /**
4
+ * Sessions resource — `client.sessions.*`.
5
+ *
6
+ * Every device or browser the user is signed in on. Lets a settings screen
7
+ * show "where you're signed in" and sign one or all of them out.
8
+ *
9
+ * ```ts
10
+ * const sessions = await client.sessions.list();
11
+ * const others = sessions.filter((s) => !s.current);
12
+ * await client.sessions.revokeOthers();
13
+ * ```
14
+ */
15
+ interface UserSession {
16
+ /** Session id; pass it to `revoke`. */
17
+ jti: string;
18
+ issued_at: string;
19
+ expires_at: string;
20
+ last_seen_at: string;
21
+ /** Client IP recorded for the session, if known. */
22
+ remote_ip?: string | null;
23
+ /** Browser or app that opened the session, if known. */
24
+ user_agent?: string | null;
25
+ /** `true` for the session this client is using. */
26
+ current: boolean;
27
+ }
28
+ declare class SessionsResource {
29
+ private readonly http;
30
+ constructor(http: HttpClient);
31
+ /** All live sessions of the account, this one included. */
32
+ list(): Promise<UserSession[]>;
33
+ /** Sign out one session. Works on the current one too; the stored JWT
34
+ * stops working, so follow with `client.auth.signOut()`.
35
+ * 404 when the session is unknown or already signed out. */
36
+ revoke(jti: string): Promise<void>;
37
+ /** Sign out every session except this one. */
38
+ revokeOthers(): Promise<{
39
+ revoked_sessions: number;
40
+ }>;
41
+ }
42
+
43
+ export { SessionsResource, type UserSession };
@@ -0,0 +1,24 @@
1
+ // src/resources/sessions.ts
2
+ var SessionsResource = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** All live sessions of the account, this one included. */
7
+ async list() {
8
+ return this.http.get("/me/sessions");
9
+ }
10
+ /** Sign out one session. Works on the current one too; the stored JWT
11
+ * stops working, so follow with `client.auth.signOut()`.
12
+ * 404 when the session is unknown or already signed out. */
13
+ async revoke(jti) {
14
+ await this.http.delete(`/me/sessions/${encodeURIComponent(jti)}`);
15
+ }
16
+ /** Sign out every session except this one. */
17
+ async revokeOthers() {
18
+ return this.http.post("/me/sessions/terminate-others");
19
+ }
20
+ };
21
+
22
+ export { SessionsResource };
23
+ //# sourceMappingURL=sessions.js.map
24
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/sessions.ts"],"names":[],"mappings":";AA6BO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,GAA+B;AACnC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAmB,cAAc,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,GAAA,EAA4B;AACvC,IAAA,MAAM,KAAK,IAAA,CAAK,MAAA,CAAa,gBAAgB,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,YAAA,GAAsD;AAC1D,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAmC,+BAA+B,CAAA;AAAA,EACrF;AACF","file":"sessions.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Sessions resource — `client.sessions.*`.\n *\n * Every device or browser the user is signed in on. Lets a settings screen\n * show \"where you're signed in\" and sign one or all of them out.\n *\n * ```ts\n * const sessions = await client.sessions.list();\n * const others = sessions.filter((s) => !s.current);\n * await client.sessions.revokeOthers();\n * ```\n */\n\nexport interface UserSession {\n /** Session id; pass it to `revoke`. */\n jti: string;\n issued_at: string;\n expires_at: string;\n last_seen_at: string;\n /** Client IP recorded for the session, if known. */\n remote_ip?: string | null;\n /** Browser or app that opened the session, if known. */\n user_agent?: string | null;\n /** `true` for the session this client is using. */\n current: boolean;\n}\n\nexport class SessionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** All live sessions of the account, this one included. */\n async list(): Promise<UserSession[]> {\n return this.http.get<UserSession[]>(\"/me/sessions\");\n }\n\n /** Sign out one session. Works on the current one too; the stored JWT\n * stops working, so follow with `client.auth.signOut()`.\n * 404 when the session is unknown or already signed out. */\n async revoke(jti: string): Promise<void> {\n await this.http.delete<void>(`/me/sessions/${encodeURIComponent(jti)}`);\n }\n\n /** Sign out every session except this one. */\n async revokeOthers(): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/me/sessions/terminate-others\");\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.cjs';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
2
 
3
3
  /**
4
4
  * Subscriptions resource — `client.subscriptions.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.js';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
2
 
3
3
  /**
4
4
  * Subscriptions resource — `client.subscriptions.*`.
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ // src/resources/wallet.ts
4
+ var WalletResource = class {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** Current wallet currency + the currencies the user may switch to. */
9
+ async get(opts = {}) {
10
+ return this.http.get("/me/wallet", { signal: opts.signal });
11
+ }
12
+ /**
13
+ * Switch the wallet currency. Fails with `409 wallet_not_empty` while any
14
+ * balance is non-zero, and `400 currency_not_allowed` for a currency the
15
+ * deployment does not offer.
16
+ */
17
+ async set(currency, opts = {}) {
18
+ return this.http.put("/me/wallet", { body: { currency }, signal: opts.signal });
19
+ }
20
+ };
21
+
22
+ exports.WalletResource = WalletResource;
23
+ //# sourceMappingURL=wallet.cjs.map
24
+ //# sourceMappingURL=wallet.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/wallet.ts"],"names":[],"mappings":";;;AAuBO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAoB;AAC9D,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAY,YAAA,EAAc,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,GAAA,CAAI,QAAA,EAAkB,IAAA,GAAiC,EAAC,EAAoB;AAChF,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAY,YAAA,EAAc,EAAE,IAAA,EAAM,EAAE,QAAA,EAAS,EAAG,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACxF;AACF","file":"wallet.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Wallet resource — `client.wallet.*`.\n *\n * Which currency the user's wallet is held in. Deposits in any other\n * currency are converted on funding (quote first, see `client.deposits`);\n * cards issued in another currency are paid from the wallet with an FX leg\n * at issuance. A user may switch currency only while every balance is zero\n * and only to a currency the deployment offers (`allowed`).\n */\n\n/** The user's wallet currency and what they may switch to. */\nexport interface Wallet {\n /** ISO 4217 code the wallet is held in. */\n currency: string;\n /** `true` when chosen by the user (or set by an operator), `false` when it\n * is the deployment default. */\n explicit: boolean;\n /** Currencies accepted by `set()`. */\n allowed: string[];\n}\n\nexport class WalletResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Current wallet currency + the currencies the user may switch to. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Wallet> {\n return this.http.get<Wallet>(\"/me/wallet\", { signal: opts.signal });\n }\n\n /**\n * Switch the wallet currency. Fails with `409 wallet_not_empty` while any\n * balance is non-zero, and `400 currency_not_allowed` for a currency the\n * deployment does not offer.\n */\n async set(currency: string, opts: { signal?: AbortSignal } = {}): Promise<Wallet> {\n return this.http.put<Wallet>(\"/me/wallet\", { body: { currency }, signal: opts.signal });\n }\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
+
3
+ /**
4
+ * Wallet resource — `client.wallet.*`.
5
+ *
6
+ * Which currency the user's wallet is held in. Deposits in any other
7
+ * currency are converted on funding (quote first, see `client.deposits`);
8
+ * cards issued in another currency are paid from the wallet with an FX leg
9
+ * at issuance. A user may switch currency only while every balance is zero
10
+ * and only to a currency the deployment offers (`allowed`).
11
+ */
12
+ /** The user's wallet currency and what they may switch to. */
13
+ interface Wallet {
14
+ /** ISO 4217 code the wallet is held in. */
15
+ currency: string;
16
+ /** `true` when chosen by the user (or set by an operator), `false` when it
17
+ * is the deployment default. */
18
+ explicit: boolean;
19
+ /** Currencies accepted by `set()`. */
20
+ allowed: string[];
21
+ }
22
+ declare class WalletResource {
23
+ private readonly http;
24
+ constructor(http: HttpClient);
25
+ /** Current wallet currency + the currencies the user may switch to. */
26
+ get(opts?: {
27
+ signal?: AbortSignal;
28
+ }): Promise<Wallet>;
29
+ /**
30
+ * Switch the wallet currency. Fails with `409 wallet_not_empty` while any
31
+ * balance is non-zero, and `400 currency_not_allowed` for a currency the
32
+ * deployment does not offer.
33
+ */
34
+ set(currency: string, opts?: {
35
+ signal?: AbortSignal;
36
+ }): Promise<Wallet>;
37
+ }
38
+
39
+ export { type Wallet, WalletResource };
@@ -0,0 +1,39 @@
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
+
3
+ /**
4
+ * Wallet resource — `client.wallet.*`.
5
+ *
6
+ * Which currency the user's wallet is held in. Deposits in any other
7
+ * currency are converted on funding (quote first, see `client.deposits`);
8
+ * cards issued in another currency are paid from the wallet with an FX leg
9
+ * at issuance. A user may switch currency only while every balance is zero
10
+ * and only to a currency the deployment offers (`allowed`).
11
+ */
12
+ /** The user's wallet currency and what they may switch to. */
13
+ interface Wallet {
14
+ /** ISO 4217 code the wallet is held in. */
15
+ currency: string;
16
+ /** `true` when chosen by the user (or set by an operator), `false` when it
17
+ * is the deployment default. */
18
+ explicit: boolean;
19
+ /** Currencies accepted by `set()`. */
20
+ allowed: string[];
21
+ }
22
+ declare class WalletResource {
23
+ private readonly http;
24
+ constructor(http: HttpClient);
25
+ /** Current wallet currency + the currencies the user may switch to. */
26
+ get(opts?: {
27
+ signal?: AbortSignal;
28
+ }): Promise<Wallet>;
29
+ /**
30
+ * Switch the wallet currency. Fails with `409 wallet_not_empty` while any
31
+ * balance is non-zero, and `400 currency_not_allowed` for a currency the
32
+ * deployment does not offer.
33
+ */
34
+ set(currency: string, opts?: {
35
+ signal?: AbortSignal;
36
+ }): Promise<Wallet>;
37
+ }
38
+
39
+ export { type Wallet, WalletResource };
@@ -0,0 +1,22 @@
1
+ // src/resources/wallet.ts
2
+ var WalletResource = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** Current wallet currency + the currencies the user may switch to. */
7
+ async get(opts = {}) {
8
+ return this.http.get("/me/wallet", { signal: opts.signal });
9
+ }
10
+ /**
11
+ * Switch the wallet currency. Fails with `409 wallet_not_empty` while any
12
+ * balance is non-zero, and `400 currency_not_allowed` for a currency the
13
+ * deployment does not offer.
14
+ */
15
+ async set(currency, opts = {}) {
16
+ return this.http.put("/me/wallet", { body: { currency }, signal: opts.signal });
17
+ }
18
+ };
19
+
20
+ export { WalletResource };
21
+ //# sourceMappingURL=wallet.js.map
22
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/wallet.ts"],"names":[],"mappings":";AAuBO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAoB;AAC9D,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAY,YAAA,EAAc,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,GAAA,CAAI,QAAA,EAAkB,IAAA,GAAiC,EAAC,EAAoB;AAChF,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAY,YAAA,EAAc,EAAE,IAAA,EAAM,EAAE,QAAA,EAAS,EAAG,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACxF;AACF","file":"wallet.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Wallet resource — `client.wallet.*`.\n *\n * Which currency the user's wallet is held in. Deposits in any other\n * currency are converted on funding (quote first, see `client.deposits`);\n * cards issued in another currency are paid from the wallet with an FX leg\n * at issuance. A user may switch currency only while every balance is zero\n * and only to a currency the deployment offers (`allowed`).\n */\n\n/** The user's wallet currency and what they may switch to. */\nexport interface Wallet {\n /** ISO 4217 code the wallet is held in. */\n currency: string;\n /** `true` when chosen by the user (or set by an operator), `false` when it\n * is the deployment default. */\n explicit: boolean;\n /** Currencies accepted by `set()`. */\n allowed: string[];\n}\n\nexport class WalletResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Current wallet currency + the currencies the user may switch to. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Wallet> {\n return this.http.get<Wallet>(\"/me/wallet\", { signal: opts.signal });\n }\n\n /**\n * Switch the wallet currency. Fails with `409 wallet_not_empty` while any\n * balance is non-zero, and `400 currency_not_allowed` for a currency the\n * deployment does not offer.\n */\n async set(currency: string, opts: { signal?: AbortSignal } = {}): Promise<Wallet> {\n return this.http.put<Wallet>(\"/me/wallet\", { body: { currency }, signal: opts.signal });\n }\n}\n"]}