@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
@@ -38,6 +38,40 @@ var AuthResource = class {
38
38
  await Promise.resolve(this.tokens.set(resp.access_token));
39
39
  return resp;
40
40
  }
41
+ /** Create an end-user account and sign it in. The JWT is stored.
42
+ * `wallet_currency` must be one the deployment offers; omit it to take
43
+ * the deployment default (it can be switched later via `client.wallet`
44
+ * while the wallet is empty).
45
+ * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
46
+ async register(input) {
47
+ const resp = await this.http.post("/auth/register", {
48
+ body: input,
49
+ skipAuth: true
50
+ });
51
+ await Promise.resolve(this.tokens.set(resp.access_token));
52
+ return resp;
53
+ }
54
+ /** Finish a `totp_setup_required` login: send the first code from the
55
+ * authenticator app. The JWT is stored. The response carries ten
56
+ * one-time `backup_codes` that are never returned again, so show them to
57
+ * the user right away and don't keep them on the device. */
58
+ async completeTotpSetup(input) {
59
+ const resp = await this.http.post("/auth/login/totp-setup", {
60
+ body: input,
61
+ skipAuth: true
62
+ });
63
+ await Promise.resolve(this.tokens.set(resp.access_token));
64
+ return resp;
65
+ }
66
+ /** Change the signed-in user's password. Every other session of the
67
+ * account is signed out; this one stays valid.
68
+ * Errors: 400 when the new password fails the policy, 401 when the
69
+ * current one is wrong. */
70
+ async changePassword(input) {
71
+ return this.http.post("/auth/password", {
72
+ body: input
73
+ });
74
+ }
41
75
  /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
42
76
  * telegram/email; for TOTP it short-circuits back to the challenge. */
43
77
  async switchMethod(input) {
@@ -74,10 +108,9 @@ var AuthResource = class {
74
108
  async me() {
75
109
  return this.http.get("/auth/me");
76
110
  }
77
- /** Local sign-out. The SDK doesn't currently call a server-side
78
- * endpoint (the Takeal API issues stateless JWTs); clearing the
79
- * store is enough. Server-side session invalidation may land
80
- * with a future session table. */
111
+ /** Local sign-out: forgets the stored JWT. To end the session on the
112
+ * server as well, revoke it first with `client.sessions.revoke(jti)`
113
+ * (the current one is marked `current: true` in `client.sessions.list()`). */
81
114
  async signOut() {
82
115
  await Promise.resolve(this.tokens.clear());
83
116
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/auth.ts"],"names":[],"mappings":";;;AAoGO,IAAM,eAAN,MAAmB;AAAA,EACxB,WAAA,CACmB,MACA,MAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA,EAIH,MAAM,MAAM,KAAA,EAA2C;AACrD,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAoB,aAAA,EAAe;AAAA,MAC9D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,IAAI,IAAA,CAAK,UAAU,KAAA,EAAO;AACxB,MAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AAAA,IAC1D;AAC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,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU,KAAA,EAAyC;AACvD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,WAAA,EAAa,EAAE,IAAA,EAAM,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,EAAM,EAAG,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA,EAIA,MAAM,EAAA,GAAoB;AACxB,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAU,UAAU,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA;AAAA,EAC3C;AACF","file":"auth.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n ) {}\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: input,\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await Promise.resolve(this.tokens.set(resp.access_token));\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then find-or-creates the end-user. First-time Telegram users are\n * auto-provisioned with `user.email_pending === true` — prompt them for a\n * real email and call {@link linkEmail}. Stores the JWT on success.\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n async exchangeTelegram(input: { initData: string }): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body: { init_data: input.initData },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach a real email to the current user (and clear `email_pending`).\n * Used after a Telegram exchange to satisfy the email requirement; also\n * works for a password user changing their address. 409 if taken. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Local sign-out. The SDK doesn't currently call a server-side\n * endpoint (the Takeal API issues stateless JWTs); clearing the\n * store is enough. Server-side session invalidation may land\n * with a future session table. */\n async signOut(): Promise<void> {\n await Promise.resolve(this.tokens.clear());\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/auth.ts"],"names":[],"mappings":";;;AA8HO,IAAM,eAAN,MAAmB;AAAA,EACxB,WAAA,CACmB,MACA,MAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA,EAIH,MAAM,MAAM,KAAA,EAA2C;AACrD,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAoB,aAAA,EAAe;AAAA,MAC9D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,IAAI,IAAA,CAAK,UAAU,KAAA,EAAO;AACxB,MAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AAAA,IAC1D;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA,EAIA,MAAM,WAAW,KAAA,EAA4C;AAC3D,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAgB,kBAAA,EAAoB;AAAA,MAC/D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA,EAIA,MAAM,UAAU,KAAA,EAA2C;AACzD,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA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wBAAA,EAA0B;AAAA,MAC/D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,iBAAiB,KAAA,EAAiD;AACtE,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAgB,yBAAA,EAA2B;AAAA,MACtE,IAAA,EAAM,EAAE,SAAA,EAAW,KAAA,CAAM,QAAA,EAAS;AAAA,MAClC,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU,KAAA,EAAyC;AACvD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,WAAA,EAAa,EAAE,IAAA,EAAM,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,EAAM,EAAG,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA,EAIA,MAAM,EAAA,GAAoB;AACxB,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAU,UAAU,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA;AAAA,EAC3C;AACF","file":"auth.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n /** ISO 4217 code the user's wallet is held in (their own choice, else the\n * deployment default). Present on `GET /auth/me`. */\n wallet_currency?: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface RegisterInput {\n email: string;\n password: string;\n /** ISO 4217 code for the new wallet; must be offered by the deployment. */\n wallet_currency?: string;\n}\n\n/** A signed-in session without the login `stage` marker — what\n * `register` returns. */\nexport type Session = Omit<JwtIssued, \"stage\">;\n\nexport interface TotpSetupComplete extends Session {\n /** Ten one-time `XXXX-XXXX` codes, returned only this once. */\n backup_codes: string[];\n}\n\nexport interface ChangePasswordInput {\n current_password: string;\n /** At least 12 characters with a lower-case letter, an upper-case letter\n * and a digit; must differ from the current password. */\n new_password: string;\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n ) {}\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: input,\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await Promise.resolve(this.tokens.set(resp.access_token));\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Create an end-user account and sign it in. The JWT is stored.\n * `wallet_currency` must be one the deployment offers; omit it to take\n * the deployment default (it can be switched later via `client.wallet`\n * while the wallet is empty).\n * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */\n async register(input: RegisterInput): Promise<Session> {\n const resp = await this.http.post<Session>(\"/auth/register\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Finish a `totp_setup_required` login: send the first code from the\n * authenticator app. The JWT is stored. The response carries ten\n * one-time `backup_codes` that are never returned again, so show them to\n * the user right away and don't keep them on the device. */\n async completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete> {\n const resp = await this.http.post<TotpSetupComplete>(\"/auth/login/totp-setup\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Change the signed-in user's password. Every other session of the\n * account is signed out; this one stays valid.\n * Errors: 400 when the new password fails the policy, 401 when the\n * current one is wrong. */\n async changePassword(input: ChangePasswordInput): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/auth/password\", {\n body: input,\n });\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then find-or-creates the end-user. First-time Telegram users are\n * auto-provisioned with `user.email_pending === true` — prompt them for a\n * real email and call {@link linkEmail}. Stores the JWT on success.\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n async exchangeTelegram(input: { initData: string }): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body: { init_data: input.initData },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach a real email to the current user (and clear `email_pending`).\n * Used after a Telegram exchange to satisfy the email requirement; also\n * works for a password user changing their address. 409 if taken. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Local sign-out: forgets the stored JWT. To end the session on the\n * server as well, revoke it first with `client.sessions.revoke(jti)`\n * (the current one is marked `current: true` in `client.sessions.list()`). */\n async signOut(): Promise<void> {\n await Promise.resolve(this.tokens.clear());\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { H as HttpClient, T as TokenStore } from '../http-BkZZZI8K.cjs';
1
+ import { H as HttpClient, T as TokenStore } from '../http-BkCfOCR0.cjs';
2
2
 
3
3
  /**
4
4
  * Auth resource — `client.auth.*`.
@@ -26,6 +26,9 @@ interface User {
26
26
  email_pending?: boolean;
27
27
  created_at: string;
28
28
  updated_at: string;
29
+ /** ISO 4217 code the user's wallet is held in (their own choice, else the
30
+ * deployment default). Present on `GET /auth/me`. */
31
+ wallet_currency?: string;
29
32
  }
30
33
  interface LoginInput {
31
34
  email: string;
@@ -77,6 +80,25 @@ interface SwitchMethodInput {
77
80
  challenge_token: string;
78
81
  method: AvailableMethod["kind"];
79
82
  }
83
+ interface RegisterInput {
84
+ email: string;
85
+ password: string;
86
+ /** ISO 4217 code for the new wallet; must be offered by the deployment. */
87
+ wallet_currency?: string;
88
+ }
89
+ /** A signed-in session without the login `stage` marker — what
90
+ * `register` returns. */
91
+ type Session = Omit<JwtIssued, "stage">;
92
+ interface TotpSetupComplete extends Session {
93
+ /** Ten one-time `XXXX-XXXX` codes, returned only this once. */
94
+ backup_codes: string[];
95
+ }
96
+ interface ChangePasswordInput {
97
+ current_password: string;
98
+ /** At least 12 characters with a lower-case letter, an upper-case letter
99
+ * and a digit; must differ from the current password. */
100
+ new_password: string;
101
+ }
80
102
  interface OtpSentResponse {
81
103
  stage: "otp_sent";
82
104
  challenge_token: string;
@@ -98,6 +120,24 @@ declare class AuthResource {
98
120
  /** Verify a 6-digit OTP code (Telegram / email) against an
99
121
  * `otp_sent` challenge. */
100
122
  verifyOtp(input: OtpVerifyInput): Promise<JwtIssued>;
123
+ /** Create an end-user account and sign it in. The JWT is stored.
124
+ * `wallet_currency` must be one the deployment offers; omit it to take
125
+ * the deployment default (it can be switched later via `client.wallet`
126
+ * while the wallet is empty).
127
+ * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
128
+ register(input: RegisterInput): Promise<Session>;
129
+ /** Finish a `totp_setup_required` login: send the first code from the
130
+ * authenticator app. The JWT is stored. The response carries ten
131
+ * one-time `backup_codes` that are never returned again, so show them to
132
+ * the user right away and don't keep them on the device. */
133
+ completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete>;
134
+ /** Change the signed-in user's password. Every other session of the
135
+ * account is signed out; this one stays valid.
136
+ * Errors: 400 when the new password fails the policy, 401 when the
137
+ * current one is wrong. */
138
+ changePassword(input: ChangePasswordInput): Promise<{
139
+ revoked_sessions: number;
140
+ }>;
101
141
  /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
102
142
  * telegram/email; for TOTP it short-circuits back to the challenge. */
103
143
  switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse>;
@@ -122,11 +162,10 @@ declare class AuthResource {
122
162
  /** Current user — fails 401 when the stored JWT is expired or
123
163
  * missing. Useful as a "do I have a session" probe on app boot. */
124
164
  me(): Promise<User>;
125
- /** Local sign-out. The SDK doesn't currently call a server-side
126
- * endpoint (the Takeal API issues stateless JWTs); clearing the
127
- * store is enough. Server-side session invalidation may land
128
- * with a future session table. */
165
+ /** Local sign-out: forgets the stored JWT. To end the session on the
166
+ * server as well, revoke it first with `client.sessions.revoke(jti)`
167
+ * (the current one is marked `current: true` in `client.sessions.list()`). */
129
168
  signOut(): Promise<void>;
130
169
  }
131
170
 
132
- export { AuthResource, type AvailableMethod, type JwtIssued, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type SwitchMethodInput, type TotpRequired, type TotpSetupRequired, type TotpVerifyInput, type User };
171
+ export { AuthResource, type AvailableMethod, type ChangePasswordInput, type JwtIssued, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type RegisterInput, type Session, type SwitchMethodInput, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User };
@@ -1,4 +1,4 @@
1
- import { H as HttpClient, T as TokenStore } from '../http-BkZZZI8K.js';
1
+ import { H as HttpClient, T as TokenStore } from '../http-BkCfOCR0.js';
2
2
 
3
3
  /**
4
4
  * Auth resource — `client.auth.*`.
@@ -26,6 +26,9 @@ interface User {
26
26
  email_pending?: boolean;
27
27
  created_at: string;
28
28
  updated_at: string;
29
+ /** ISO 4217 code the user's wallet is held in (their own choice, else the
30
+ * deployment default). Present on `GET /auth/me`. */
31
+ wallet_currency?: string;
29
32
  }
30
33
  interface LoginInput {
31
34
  email: string;
@@ -77,6 +80,25 @@ interface SwitchMethodInput {
77
80
  challenge_token: string;
78
81
  method: AvailableMethod["kind"];
79
82
  }
83
+ interface RegisterInput {
84
+ email: string;
85
+ password: string;
86
+ /** ISO 4217 code for the new wallet; must be offered by the deployment. */
87
+ wallet_currency?: string;
88
+ }
89
+ /** A signed-in session without the login `stage` marker — what
90
+ * `register` returns. */
91
+ type Session = Omit<JwtIssued, "stage">;
92
+ interface TotpSetupComplete extends Session {
93
+ /** Ten one-time `XXXX-XXXX` codes, returned only this once. */
94
+ backup_codes: string[];
95
+ }
96
+ interface ChangePasswordInput {
97
+ current_password: string;
98
+ /** At least 12 characters with a lower-case letter, an upper-case letter
99
+ * and a digit; must differ from the current password. */
100
+ new_password: string;
101
+ }
80
102
  interface OtpSentResponse {
81
103
  stage: "otp_sent";
82
104
  challenge_token: string;
@@ -98,6 +120,24 @@ declare class AuthResource {
98
120
  /** Verify a 6-digit OTP code (Telegram / email) against an
99
121
  * `otp_sent` challenge. */
100
122
  verifyOtp(input: OtpVerifyInput): Promise<JwtIssued>;
123
+ /** Create an end-user account and sign it in. The JWT is stored.
124
+ * `wallet_currency` must be one the deployment offers; omit it to take
125
+ * the deployment default (it can be switched later via `client.wallet`
126
+ * while the wallet is empty).
127
+ * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
128
+ register(input: RegisterInput): Promise<Session>;
129
+ /** Finish a `totp_setup_required` login: send the first code from the
130
+ * authenticator app. The JWT is stored. The response carries ten
131
+ * one-time `backup_codes` that are never returned again, so show them to
132
+ * the user right away and don't keep them on the device. */
133
+ completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete>;
134
+ /** Change the signed-in user's password. Every other session of the
135
+ * account is signed out; this one stays valid.
136
+ * Errors: 400 when the new password fails the policy, 401 when the
137
+ * current one is wrong. */
138
+ changePassword(input: ChangePasswordInput): Promise<{
139
+ revoked_sessions: number;
140
+ }>;
101
141
  /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
102
142
  * telegram/email; for TOTP it short-circuits back to the challenge. */
103
143
  switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse>;
@@ -122,11 +162,10 @@ declare class AuthResource {
122
162
  /** Current user — fails 401 when the stored JWT is expired or
123
163
  * missing. Useful as a "do I have a session" probe on app boot. */
124
164
  me(): Promise<User>;
125
- /** Local sign-out. The SDK doesn't currently call a server-side
126
- * endpoint (the Takeal API issues stateless JWTs); clearing the
127
- * store is enough. Server-side session invalidation may land
128
- * with a future session table. */
165
+ /** Local sign-out: forgets the stored JWT. To end the session on the
166
+ * server as well, revoke it first with `client.sessions.revoke(jti)`
167
+ * (the current one is marked `current: true` in `client.sessions.list()`). */
129
168
  signOut(): Promise<void>;
130
169
  }
131
170
 
132
- export { AuthResource, type AvailableMethod, type JwtIssued, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type SwitchMethodInput, type TotpRequired, type TotpSetupRequired, type TotpVerifyInput, type User };
171
+ export { AuthResource, type AvailableMethod, type ChangePasswordInput, type JwtIssued, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type RegisterInput, type Session, type SwitchMethodInput, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User };
@@ -36,6 +36,40 @@ var AuthResource = class {
36
36
  await Promise.resolve(this.tokens.set(resp.access_token));
37
37
  return resp;
38
38
  }
39
+ /** Create an end-user account and sign it in. The JWT is stored.
40
+ * `wallet_currency` must be one the deployment offers; omit it to take
41
+ * the deployment default (it can be switched later via `client.wallet`
42
+ * while the wallet is empty).
43
+ * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
44
+ async register(input) {
45
+ const resp = await this.http.post("/auth/register", {
46
+ body: input,
47
+ skipAuth: true
48
+ });
49
+ await Promise.resolve(this.tokens.set(resp.access_token));
50
+ return resp;
51
+ }
52
+ /** Finish a `totp_setup_required` login: send the first code from the
53
+ * authenticator app. The JWT is stored. The response carries ten
54
+ * one-time `backup_codes` that are never returned again, so show them to
55
+ * the user right away and don't keep them on the device. */
56
+ async completeTotpSetup(input) {
57
+ const resp = await this.http.post("/auth/login/totp-setup", {
58
+ body: input,
59
+ skipAuth: true
60
+ });
61
+ await Promise.resolve(this.tokens.set(resp.access_token));
62
+ return resp;
63
+ }
64
+ /** Change the signed-in user's password. Every other session of the
65
+ * account is signed out; this one stays valid.
66
+ * Errors: 400 when the new password fails the policy, 401 when the
67
+ * current one is wrong. */
68
+ async changePassword(input) {
69
+ return this.http.post("/auth/password", {
70
+ body: input
71
+ });
72
+ }
39
73
  /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
40
74
  * telegram/email; for TOTP it short-circuits back to the challenge. */
41
75
  async switchMethod(input) {
@@ -72,10 +106,9 @@ var AuthResource = class {
72
106
  async me() {
73
107
  return this.http.get("/auth/me");
74
108
  }
75
- /** Local sign-out. The SDK doesn't currently call a server-side
76
- * endpoint (the Takeal API issues stateless JWTs); clearing the
77
- * store is enough. Server-side session invalidation may land
78
- * with a future session table. */
109
+ /** Local sign-out: forgets the stored JWT. To end the session on the
110
+ * server as well, revoke it first with `client.sessions.revoke(jti)`
111
+ * (the current one is marked `current: true` in `client.sessions.list()`). */
79
112
  async signOut() {
80
113
  await Promise.resolve(this.tokens.clear());
81
114
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/auth.ts"],"names":[],"mappings":";AAoGO,IAAM,eAAN,MAAmB;AAAA,EACxB,WAAA,CACmB,MACA,MAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA,EAIH,MAAM,MAAM,KAAA,EAA2C;AACrD,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAoB,aAAA,EAAe;AAAA,MAC9D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,IAAI,IAAA,CAAK,UAAU,KAAA,EAAO;AACxB,MAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AAAA,IAC1D;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA,EAIA,MAAM,WAAW,KAAA,EAA4C;AAC3D,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,KAAgB,kBAAA,EAAoB;AAAA,MAC/D,IAAA,EAAM,KAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAA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AM,EAAA,GAAoB;AACxB,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAU,UAAU,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA;AAAA,EAC3C;AACF","file":"auth.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n ) {}\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: input,\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await Promise.resolve(this.tokens.set(resp.access_token));\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then find-or-creates the end-user. First-time Telegram users are\n * auto-provisioned with `user.email_pending === true` — prompt them for a\n * real email and call {@link linkEmail}. Stores the JWT on success.\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n async exchangeTelegram(input: { initData: string }): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body: { init_data: input.initData },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach a real email to the current user (and clear `email_pending`).\n * Used after a Telegram exchange to satisfy the email requirement; also\n * works for a password user changing their address. 409 if taken. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Local sign-out. The SDK doesn't currently call a server-side\n * endpoint (the Takeal API issues stateless JWTs); clearing the\n * store is enough. Server-side session invalidation may land\n * with a future session table. */\n async signOut(): Promise<void> {\n await Promise.resolve(this.tokens.clear());\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/auth.ts"],"names":[],"mappings":";AA8HO,IAAM,eAAN,MAAmB;AAAA,EACxB,WAAA,CACmB,MACA,MAAA,EACjB;AAFi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AM,QAAA,EAAS;AAAA,MAClC,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,CAAK,OAAO,GAAA,CAAI,IAAA,CAAK,YAAY,CAAC,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU,KAAA,EAAyC;AACvD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAW,WAAA,EAAa,EAAE,IAAA,EAAM,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,EAAM,EAAG,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA,EAIA,MAAM,EAAA,GAAoB;AACxB,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAU,UAAU,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA;AAAA,EAC3C;AACF","file":"auth.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { TokenStore } from \"../token-store.js\";\n\n/**\n * Auth resource — `client.auth.*`.\n *\n * Covers the end-user-facing staged auth flow: password login\n * with optional TOTP/OTP step-up. The shape mirrors the responses\n * the Takeal API returns from `/auth/login`, `/auth/login/totp`,\n * `/auth/login/otp/verify`, `/auth/login/2fa/switch`, and `/auth/me`.\n *\n * The login methods stash the JWT in the configured `TokenStore` on\n * success so subsequent `client.*` calls authenticate automatically.\n * Step-up responses (TotpRequired / OtpSent) carry their own short-\n * lived challenge token which the caller passes to the next method\n * — those tokens DO NOT go through the TokenStore (they're not the\n * end-state JWT).\n */\n\nexport interface User {\n id: string;\n email: string;\n role: string;\n is_active: boolean;\n /** True for users auto-provisioned via the Telegram Mini App who still hold\n * a synthetic placeholder email. The client should prompt for a real email\n * and attach it via `auth.linkEmail` — this flips the flag to false. */\n email_pending?: boolean;\n created_at: string;\n updated_at: string;\n /** ISO 4217 code the user's wallet is held in (their own choice, else the\n * deployment default). Present on `GET /auth/me`. */\n wallet_currency?: string;\n}\n\nexport interface LoginInput {\n email: string;\n password: string;\n}\n\n/** Discriminated union — `stage` is the discriminator. */\nexport type LoginResponse = JwtIssued | TotpRequired | TotpSetupRequired;\n\nexport interface JwtIssued {\n stage: \"jwt\";\n access_token: string;\n expires_at: string;\n user: User;\n /** True iff the user's role grants `system.view_hub`.\n * Cusfront ignores this; the operator console uses it to gate `/dashboard`. */\n hub_access?: boolean;\n}\n\nexport interface TotpRequired {\n stage: \"totp_required\";\n challenge_token: string;\n expires_at: string;\n /** Alternate second factors. Pick one with `/2fa/switch`. */\n available_methods: AvailableMethod[];\n}\n\nexport interface TotpSetupRequired {\n stage: \"totp_setup_required\";\n challenge_token: string;\n expires_at: string;\n /** OTPAuth URI rendered as a QR by the consumer. */\n otpauth_url: string;\n /** Same secret base32-encoded — for manual entry alongside QR. */\n secret_base32: string;\n}\n\nexport interface AvailableMethod {\n kind: \"totp\" | \"telegram_otp\" | \"email_otp\";\n /** Short user-facing hint, e.g. `\"Telegram (@user)\"` or `\"e****@example.com\"`. */\n hint?: string;\n}\n\nexport interface TotpVerifyInput {\n challenge_token: string;\n /** 6-digit TOTP code OR `XXXX-XXXX` backup code. */\n code: string;\n}\n\nexport interface OtpVerifyInput {\n challenge_token: string;\n /** 6-digit one-time code delivered via the selected channel. */\n code: string;\n}\n\nexport interface SwitchMethodInput {\n challenge_token: string;\n method: AvailableMethod[\"kind\"];\n}\n\nexport interface RegisterInput {\n email: string;\n password: string;\n /** ISO 4217 code for the new wallet; must be offered by the deployment. */\n wallet_currency?: string;\n}\n\n/** A signed-in session without the login `stage` marker — what\n * `register` returns. */\nexport type Session = Omit<JwtIssued, \"stage\">;\n\nexport interface TotpSetupComplete extends Session {\n /** Ten one-time `XXXX-XXXX` codes, returned only this once. */\n backup_codes: string[];\n}\n\nexport interface ChangePasswordInput {\n current_password: string;\n /** At least 12 characters with a lower-case letter, an upper-case letter\n * and a digit; must differ from the current password. */\n new_password: string;\n}\n\nexport interface OtpSentResponse {\n stage: \"otp_sent\";\n challenge_token: string;\n expires_at: string;\n method: AvailableMethod[\"kind\"];\n hint?: string;\n available_methods: AvailableMethod[];\n}\n\nexport class AuthResource {\n constructor(\n private readonly http: HttpClient,\n private readonly tokens: TokenStore,\n ) {}\n\n /** Password-auth entry. May resolve to a JWT, or to a step-up\n * challenge that needs `verifyTotp` / `verifyOtp` next. */\n async login(input: LoginInput): Promise<LoginResponse> {\n const resp = await this.http.post<LoginResponse>(\"/auth/login\", {\n body: input,\n skipAuth: true,\n });\n if (resp.stage === \"jwt\") {\n await Promise.resolve(this.tokens.set(resp.access_token));\n }\n return resp;\n }\n\n /** Verify a TOTP code (or XXXX-XXXX backup code) against a\n * `totp_required` challenge. On success the JWT is stored. */\n async verifyTotp(input: TotpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/totp\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Verify a 6-digit OTP code (Telegram / email) against an\n * `otp_sent` challenge. */\n async verifyOtp(input: OtpVerifyInput): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/login/otp/verify\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Create an end-user account and sign it in. The JWT is stored.\n * `wallet_currency` must be one the deployment offers; omit it to take\n * the deployment default (it can be switched later via `client.wallet`\n * while the wallet is empty).\n * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */\n async register(input: RegisterInput): Promise<Session> {\n const resp = await this.http.post<Session>(\"/auth/register\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Finish a `totp_setup_required` login: send the first code from the\n * authenticator app. The JWT is stored. The response carries ten\n * one-time `backup_codes` that are never returned again, so show them to\n * the user right away and don't keep them on the device. */\n async completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete> {\n const resp = await this.http.post<TotpSetupComplete>(\"/auth/login/totp-setup\", {\n body: input,\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Change the signed-in user's password. Every other session of the\n * account is signed out; this one stays valid.\n * Errors: 400 when the new password fails the policy, 401 when the\n * current one is wrong. */\n async changePassword(input: ChangePasswordInput): Promise<{ revoked_sessions: number }> {\n return this.http.post<{ revoked_sessions: number }>(\"/auth/password\", {\n body: input,\n });\n }\n\n /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for\n * telegram/email; for TOTP it short-circuits back to the challenge. */\n async switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse> {\n return this.http.post<OtpSentResponse>(\"/auth/login/2fa/switch\", {\n body: input,\n skipAuth: true,\n });\n }\n\n /** Exchange a signed Telegram Mini App `initData` payload for a session\n * JWT. The server validates the initData HMAC against the deployment's bot\n * token, then find-or-creates the end-user. First-time Telegram users are\n * auto-provisioned with `user.email_pending === true` — prompt them for a\n * real email and call {@link linkEmail}. Stores the JWT on success.\n *\n * Most consumers use the higher-level `fromInitData` / `fromTelegramWebApp`\n * helpers in `@takeal/cusfront-sdk/telegram`; reach for this directly when\n * you already hold a configured client. */\n async exchangeTelegram(input: { initData: string }): Promise<JwtIssued> {\n const resp = await this.http.post<JwtIssued>(\"/auth/telegram/exchange\", {\n body: { init_data: input.initData },\n skipAuth: true,\n });\n await Promise.resolve(this.tokens.set(resp.access_token));\n return resp;\n }\n\n /** Attach a real email to the current user (and clear `email_pending`).\n * Used after a Telegram exchange to satisfy the email requirement; also\n * works for a password user changing their address. 409 if taken. */\n async linkEmail(input: { email: string }): Promise<User> {\n return this.http.post<User>(\"/me/email\", { body: { email: input.email } });\n }\n\n /** Current user — fails 401 when the stored JWT is expired or\n * missing. Useful as a \"do I have a session\" probe on app boot. */\n async me(): Promise<User> {\n return this.http.get<User>(\"/auth/me\");\n }\n\n /** Local sign-out: forgets the stored JWT. To end the session on the\n * server as well, revoke it first with `client.sessions.revoke(jti)`\n * (the current one is marked `current: true` in `client.sessions.list()`). */\n async signOut(): Promise<void> {\n await Promise.resolve(this.tokens.clear());\n }\n}\n"]}
@@ -6,11 +6,12 @@ var BalanceResource = class {
6
6
  this.http = http;
7
7
  }
8
8
  /**
9
- * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `"USD"`).
10
- * Required the ledger holds a separate balance per currency, so there is
11
- * no "total" without one.
9
+ * Fetch the user's wallet balance. Omit `currency` for the wallet's own
10
+ * currency; pass an ISO 4217 code (e.g. `"USD"`) to read another one
11
+ * the ledger holds a separate balance per currency.
12
12
  */
13
13
  async get(currency) {
14
+ if (!currency) return this.http.get("/me/balance");
14
15
  const q = new URLSearchParams({ currency }).toString();
15
16
  return this.http.get(`/me/balance?${q}`);
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/balance.ts"],"names":[],"mappings":";;;AAiBO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,MAAM,IAAI,QAAA,EAAoC;AAC5C,IAAA,MAAM,IAAI,IAAI,eAAA,CAAgB,EAAE,QAAA,EAAU,EAAE,QAAA,EAAS;AACrD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAa,CAAA,YAAA,EAAe,CAAC,CAAA,CAAE,CAAA;AAAA,EAClD;AACF","file":"balance.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Balance resource — `client.balance.*`.\n *\n * The user's wallet balance, tracked in the ledger. Mirrors\n * the Takeal API's `GET /me/balance?currency=<code>` route. Balance is per-currency:\n * the endpoint requires a `currency` query param and returns the amount held\n * in that currency.\n */\n\n/** Wallet balance for one currency. `amount` is a decimal string. */\nexport interface Balance {\n amount: string;\n currency: string;\n}\n\nexport class BalanceResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `\"USD\"`).\n * Required — the ledger holds a separate balance per currency, so there is\n * no \"total\" without one.\n */\n async get(currency: string): Promise<Balance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<Balance>(`/me/balance?${q}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/balance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,MAAM,IAAI,QAAA,EAAqC;AAC7C,IAAA,IAAI,CAAC,QAAA,EAAU,OAAO,IAAA,CAAK,IAAA,CAAK,IAAa,aAAa,CAAA;AAC1D,IAAA,MAAM,IAAI,IAAI,eAAA,CAAgB,EAAE,QAAA,EAAU,EAAE,QAAA,EAAS;AACrD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAa,CAAA,YAAA,EAAe,CAAC,CAAA,CAAE,CAAA;AAAA,EAClD;AACF","file":"balance.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Balance resource — `client.balance.*`.\n *\n * The user's wallet balance, tracked in the ledger. Mirrors the Takeal API's\n * `GET /me/balance[?currency=<code>]` route. Balances are per-currency; with\n * no `currency` the wallet's own currency is returned (see `client.wallet`).\n */\n\n/** Wallet balance for one currency. `amount` is a decimal string. */\nexport interface Balance {\n amount: string;\n currency: string;\n}\n\nexport class BalanceResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Fetch the user's wallet balance. Omit `currency` for the wallet's own\n * currency; pass an ISO 4217 code (e.g. `\"USD\"`) to read another one —\n * the ledger holds a separate balance per currency.\n */\n async get(currency?: string): Promise<Balance> {\n if (!currency) return this.http.get<Balance>(\"/me/balance\");\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<Balance>(`/me/balance?${q}`);\n }\n}\n"]}
@@ -1,12 +1,11 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.cjs';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
2
 
3
3
  /**
4
4
  * Balance resource — `client.balance.*`.
5
5
  *
6
- * The user's wallet balance, tracked in the ledger. Mirrors
7
- * the Takeal API's `GET /me/balance?currency=<code>` route. Balance is per-currency:
8
- * the endpoint requires a `currency` query param and returns the amount held
9
- * in that currency.
6
+ * The user's wallet balance, tracked in the ledger. Mirrors the Takeal API's
7
+ * `GET /me/balance[?currency=<code>]` route. Balances are per-currency; with
8
+ * no `currency` the wallet's own currency is returned (see `client.wallet`).
10
9
  */
11
10
  /** Wallet balance for one currency. `amount` is a decimal string. */
12
11
  interface Balance {
@@ -17,11 +16,11 @@ declare class BalanceResource {
17
16
  private readonly http;
18
17
  constructor(http: HttpClient);
19
18
  /**
20
- * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `"USD"`).
21
- * Required the ledger holds a separate balance per currency, so there is
22
- * no "total" without one.
19
+ * Fetch the user's wallet balance. Omit `currency` for the wallet's own
20
+ * currency; pass an ISO 4217 code (e.g. `"USD"`) to read another one
21
+ * the ledger holds a separate balance per currency.
23
22
  */
24
- get(currency: string): Promise<Balance>;
23
+ get(currency?: string): Promise<Balance>;
25
24
  }
26
25
 
27
26
  export { type Balance, BalanceResource };
@@ -1,12 +1,11 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.js';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
2
 
3
3
  /**
4
4
  * Balance resource — `client.balance.*`.
5
5
  *
6
- * The user's wallet balance, tracked in the ledger. Mirrors
7
- * the Takeal API's `GET /me/balance?currency=<code>` route. Balance is per-currency:
8
- * the endpoint requires a `currency` query param and returns the amount held
9
- * in that currency.
6
+ * The user's wallet balance, tracked in the ledger. Mirrors the Takeal API's
7
+ * `GET /me/balance[?currency=<code>]` route. Balances are per-currency; with
8
+ * no `currency` the wallet's own currency is returned (see `client.wallet`).
10
9
  */
11
10
  /** Wallet balance for one currency. `amount` is a decimal string. */
12
11
  interface Balance {
@@ -17,11 +16,11 @@ declare class BalanceResource {
17
16
  private readonly http;
18
17
  constructor(http: HttpClient);
19
18
  /**
20
- * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `"USD"`).
21
- * Required the ledger holds a separate balance per currency, so there is
22
- * no "total" without one.
19
+ * Fetch the user's wallet balance. Omit `currency` for the wallet's own
20
+ * currency; pass an ISO 4217 code (e.g. `"USD"`) to read another one
21
+ * the ledger holds a separate balance per currency.
23
22
  */
24
- get(currency: string): Promise<Balance>;
23
+ get(currency?: string): Promise<Balance>;
25
24
  }
26
25
 
27
26
  export { type Balance, BalanceResource };
@@ -4,11 +4,12 @@ var BalanceResource = class {
4
4
  this.http = http;
5
5
  }
6
6
  /**
7
- * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `"USD"`).
8
- * Required the ledger holds a separate balance per currency, so there is
9
- * no "total" without one.
7
+ * Fetch the user's wallet balance. Omit `currency` for the wallet's own
8
+ * currency; pass an ISO 4217 code (e.g. `"USD"`) to read another one
9
+ * the ledger holds a separate balance per currency.
10
10
  */
11
11
  async get(currency) {
12
+ if (!currency) return this.http.get("/me/balance");
12
13
  const q = new URLSearchParams({ currency }).toString();
13
14
  return this.http.get(`/me/balance?${q}`);
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/balance.ts"],"names":[],"mappings":";AAiBO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,MAAM,IAAI,QAAA,EAAoC;AAC5C,IAAA,MAAM,IAAI,IAAI,eAAA,CAAgB,EAAE,QAAA,EAAU,EAAE,QAAA,EAAS;AACrD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAa,CAAA,YAAA,EAAe,CAAC,CAAA,CAAE,CAAA;AAAA,EAClD;AACF","file":"balance.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Balance resource — `client.balance.*`.\n *\n * The user's wallet balance, tracked in the ledger. Mirrors\n * the Takeal API's `GET /me/balance?currency=<code>` route. Balance is per-currency:\n * the endpoint requires a `currency` query param and returns the amount held\n * in that currency.\n */\n\n/** Wallet balance for one currency. `amount` is a decimal string. */\nexport interface Balance {\n amount: string;\n currency: string;\n}\n\nexport class BalanceResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Fetch the user's wallet balance for `currency` (ISO 4217, e.g. `\"USD\"`).\n * Required — the ledger holds a separate balance per currency, so there is\n * no \"total\" without one.\n */\n async get(currency: string): Promise<Balance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<Balance>(`/me/balance?${q}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/balance.ts"],"names":[],"mappings":";AAgBO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,MAAM,IAAI,QAAA,EAAqC;AAC7C,IAAA,IAAI,CAAC,QAAA,EAAU,OAAO,IAAA,CAAK,IAAA,CAAK,IAAa,aAAa,CAAA;AAC1D,IAAA,MAAM,IAAI,IAAI,eAAA,CAAgB,EAAE,QAAA,EAAU,EAAE,QAAA,EAAS;AACrD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAa,CAAA,YAAA,EAAe,CAAC,CAAA,CAAE,CAAA;AAAA,EAClD;AACF","file":"balance.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Balance resource — `client.balance.*`.\n *\n * The user's wallet balance, tracked in the ledger. Mirrors the Takeal API's\n * `GET /me/balance[?currency=<code>]` route. Balances are per-currency; with\n * no `currency` the wallet's own currency is returned (see `client.wallet`).\n */\n\n/** Wallet balance for one currency. `amount` is a decimal string. */\nexport interface Balance {\n amount: string;\n currency: string;\n}\n\nexport class BalanceResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Fetch the user's wallet balance. Omit `currency` for the wallet's own\n * currency; pass an ISO 4217 code (e.g. `\"USD\"`) to read another one —\n * the ledger holds a separate balance per currency.\n */\n async get(currency?: string): Promise<Balance> {\n if (!currency) return this.http.get<Balance>(\"/me/balance\");\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<Balance>(`/me/balance?${q}`);\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
  * Blog resource — `client.blog.*`.
@@ -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
  * Blog resource — `client.blog.*`.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/branding.ts"],"names":[],"mappings":";;;AA2BO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAc,WAAA,EAAa,EAAE,UAAU,IAAA,EAAM,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACrF;AACF","file":"branding.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Branding resource — `client.branding.*`.\n *\n * Runtime white-label config published by the deployment at `GET /branding`\n * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform\n * name, logo, favicon and the label used for the end-user's balance — without\n * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values\n * win whenever both are present.\n */\n\n/** Public brand config of the deployment. All strings; empty = use the client default. */\nexport interface Branding {\n /** Platform display name (e.g. the white-label brand). */\n platform_name: string;\n /** Name of the merchant-facing portal. */\n merchant_portal_name: string;\n /** Logo image — absolute URL or `data:` URI. Empty → client default. */\n logo_url: string;\n /** Favicon — absolute URL or `data:` URI. Empty → client default. */\n favicon_url: string;\n /** User-facing name of the balance, e.g. `\"Wallet\"` or `\"Acme Wallet\"`.\n * Display-only: the `balance` API shape never changes with it. */\n wallet_label: string;\n}\n\nexport class BrandingResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Fetch the deployment's public brand config. Safe to call before login. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Branding> {\n return this.http.get<Branding>(\"/branding\", { skipAuth: true, signal: opts.signal });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/branding.ts"],"names":[],"mappings":";;;AAiCO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAc,WAAA,EAAa,EAAE,UAAU,IAAA,EAAM,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACrF;AACF","file":"branding.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Branding resource — `client.branding.*`.\n *\n * Runtime white-label config published by the deployment at `GET /branding`\n * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform\n * name, logo, favicon, brand colours and the label used for the end-user's balance — without\n * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values\n * win whenever both are present.\n */\n\n/** Public brand config of the deployment. All strings; empty = use the client default. */\nexport interface Branding {\n /** Platform display name (e.g. the white-label brand). */\n platform_name: string;\n /** Name of the merchant-facing portal. */\n merchant_portal_name: string;\n /** Logo image — absolute URL or `data:` URI. Empty → client default. */\n logo_url: string;\n /** Favicon — absolute URL or `data:` URI. Empty → client default. */\n favicon_url: string;\n /** User-facing name of the balance, e.g. `\"Wallet\"` or `\"Acme Wallet\"`.\n * Display-only: the `balance` API shape never changes with it. */\n wallet_label: string;\n /** Primary brand colour as `#rrggbb`. Empty → client default palette. */\n primary_color: string;\n /** Secondary brand colour as `#rrggbb`. Empty → client default palette. */\n secondary_color: string;\n /** Accent colour as `#rrggbb`. Empty → client default palette. */\n accent_color: string;\n}\n\nexport class BrandingResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Fetch the deployment's public brand config. Safe to call before login. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Branding> {\n return this.http.get<Branding>(\"/branding\", { skipAuth: true, signal: opts.signal });\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.cjs';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.cjs';
2
2
 
3
3
  /**
4
4
  * Branding resource — `client.branding.*`.
5
5
  *
6
6
  * Runtime white-label config published by the deployment at `GET /branding`
7
7
  * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform
8
- * name, logo, favicon and the label used for the end-user's balance — without
8
+ * name, logo, favicon, brand colours and the label used for the end-user's balance — without
9
9
  * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values
10
10
  * win whenever both are present.
11
11
  */
@@ -22,6 +22,12 @@ interface Branding {
22
22
  /** User-facing name of the balance, e.g. `"Wallet"` or `"Acme Wallet"`.
23
23
  * Display-only: the `balance` API shape never changes with it. */
24
24
  wallet_label: string;
25
+ /** Primary brand colour as `#rrggbb`. Empty → client default palette. */
26
+ primary_color: string;
27
+ /** Secondary brand colour as `#rrggbb`. Empty → client default palette. */
28
+ secondary_color: string;
29
+ /** Accent colour as `#rrggbb`. Empty → client default palette. */
30
+ accent_color: string;
25
31
  }
26
32
  declare class BrandingResource {
27
33
  private readonly http;
@@ -1,11 +1,11 @@
1
- import { H as HttpClient } from '../http-BkZZZI8K.js';
1
+ import { H as HttpClient } from '../http-BkCfOCR0.js';
2
2
 
3
3
  /**
4
4
  * Branding resource — `client.branding.*`.
5
5
  *
6
6
  * Runtime white-label config published by the deployment at `GET /branding`
7
7
  * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform
8
- * name, logo, favicon and the label used for the end-user's balance — without
8
+ * name, logo, favicon, brand colours and the label used for the end-user's balance — without
9
9
  * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values
10
10
  * win whenever both are present.
11
11
  */
@@ -22,6 +22,12 @@ interface Branding {
22
22
  /** User-facing name of the balance, e.g. `"Wallet"` or `"Acme Wallet"`.
23
23
  * Display-only: the `balance` API shape never changes with it. */
24
24
  wallet_label: string;
25
+ /** Primary brand colour as `#rrggbb`. Empty → client default palette. */
26
+ primary_color: string;
27
+ /** Secondary brand colour as `#rrggbb`. Empty → client default palette. */
28
+ secondary_color: string;
29
+ /** Accent colour as `#rrggbb`. Empty → client default palette. */
30
+ accent_color: string;
25
31
  }
26
32
  declare class BrandingResource {
27
33
  private readonly http;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/branding.ts"],"names":[],"mappings":";AA2BO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAc,WAAA,EAAa,EAAE,UAAU,IAAA,EAAM,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACrF;AACF","file":"branding.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Branding resource — `client.branding.*`.\n *\n * Runtime white-label config published by the deployment at `GET /branding`\n * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform\n * name, logo, favicon and the label used for the end-user's balance — without\n * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values\n * win whenever both are present.\n */\n\n/** Public brand config of the deployment. All strings; empty = use the client default. */\nexport interface Branding {\n /** Platform display name (e.g. the white-label brand). */\n platform_name: string;\n /** Name of the merchant-facing portal. */\n merchant_portal_name: string;\n /** Logo image — absolute URL or `data:` URI. Empty → client default. */\n logo_url: string;\n /** Favicon — absolute URL or `data:` URI. Empty → client default. */\n favicon_url: string;\n /** User-facing name of the balance, e.g. `\"Wallet\"` or `\"Acme Wallet\"`.\n * Display-only: the `balance` API shape never changes with it. */\n wallet_label: string;\n}\n\nexport class BrandingResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Fetch the deployment's public brand config. Safe to call before login. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Branding> {\n return this.http.get<Branding>(\"/branding\", { skipAuth: true, signal: opts.signal });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/branding.ts"],"names":[],"mappings":";AAiCO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAc,WAAA,EAAa,EAAE,UAAU,IAAA,EAAM,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,EACrF;AACF","file":"branding.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Branding resource — `client.branding.*`.\n *\n * Runtime white-label config published by the deployment at `GET /branding`\n * (public, no auth). Lets a Cusfront re-theme itself on the fly — platform\n * name, logo, favicon, brand colours and the label used for the end-user's balance — without\n * a rebuild. Pairs with the build-time `BrandConfig`: the server-side values\n * win whenever both are present.\n */\n\n/** Public brand config of the deployment. All strings; empty = use the client default. */\nexport interface Branding {\n /** Platform display name (e.g. the white-label brand). */\n platform_name: string;\n /** Name of the merchant-facing portal. */\n merchant_portal_name: string;\n /** Logo image — absolute URL or `data:` URI. Empty → client default. */\n logo_url: string;\n /** Favicon — absolute URL or `data:` URI. Empty → client default. */\n favicon_url: string;\n /** User-facing name of the balance, e.g. `\"Wallet\"` or `\"Acme Wallet\"`.\n * Display-only: the `balance` API shape never changes with it. */\n wallet_label: string;\n /** Primary brand colour as `#rrggbb`. Empty → client default palette. */\n primary_color: string;\n /** Secondary brand colour as `#rrggbb`. Empty → client default palette. */\n secondary_color: string;\n /** Accent colour as `#rrggbb`. Empty → client default palette. */\n accent_color: string;\n}\n\nexport class BrandingResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Fetch the deployment's public brand config. Safe to call before login. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Branding> {\n return this.http.get<Branding>(\"/branding\", { skipAuth: true, signal: opts.signal });\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
  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
  /**