@getenginex/sdk-igaming 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @getenginex/sdk-igaming
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8020869: Align the SDK with the gateway contract in production.
8
+
9
+ **Type changes (may need code changes when upgrading):**
10
+
11
+ - `@getenginex/sdk`: `PixDeposit.expiresAt` is now optional (`string | undefined`); code such as `new Date(pix.expiresAt)` must handle a missing expiry. New optional fields: `PixDeposit.redirectUrl`, `Deposit.expiresAt` and `Deposit.redirectUrl`.
12
+ - `@getenginex/sdk-igaming`: `GameLaunch` gains the required `launchTarget` (new exported type `LaunchTarget`: `'iframe' | 'redirect' | 'new_tab'` or a future value) and the optional `providerCode` and `expiresAt`. Hand-written `GameLaunch` objects (e.g. test fixtures) need a `launchTarget`.
13
+
14
+ **Behavior changes:**
15
+
16
+ - `deposits.createPix` no longer throws `VALIDATION_ERROR` after the charge was created when the payment provider reports no expiry.
17
+ - The session is renewed and the request retried only on a 401 that refuses the access token: a 401 without a code (what the gateway's auth middleware answers for a missing, expired or invalid token), `TOKEN_EXPIRED` or `TOKEN_STALE`. A 401 with any other code, such as `INVALID_CREDENTIALS` for a wrong current password in `changePassword` or `disable2fa`, or an explicit `UNAUTHENTICATED`/`TOKEN_INVALID`, is no longer retried and no longer fires `onAccessTokenRejected`. An error body with a top-level `code` (e.g. `TOKEN_STALE`) now keeps that code.
18
+ - `auth.logout` sends the stored refresh token so the gateway revokes it. With an expired access token the gateway refuses the call before revoking, so logout renews once (without storing the new tokens or calling `onSessionExpired`) and revokes the renewed refresh token. The local session is always cleared; if the renewal or the request fails, the refresh token may stay valid on the server until it expires.
19
+ - `casino.launchGame` returns `launchTarget`, so apps can open each game the way its provider requires. A response without it is treated as `iframe`, as before. The testing mock returns `launch_target`, `provider_code` and `expires_at`.
20
+ - `withdrawals.request` docs and the testing mock match the gateway: while an OTP request is pending (until its `expiresAt`, also after its code was confirmed), the same request is replayed and any other request is refused with `FAILED_PRECONDITION` (422) `another withdrawal request is pending`, instead of replacing it. After a confirmed withdrawal, the next one can only be requested once the previous request expires.
21
+
22
+ ### Patch Changes
23
+
24
+ - 7be12eb: Code comments, TSDoc and runtime error messages are now in English. Error `code` values are unchanged; if your UI shows `error.message` to players, it now shows English text — map `code` to your own copy instead.
25
+ - d330035: READMEs and package metadata in English; docs site now in English, Portuguese and Spanish.
26
+
3
27
  ## 0.5.0
4
28
 
5
29
  ### Minor Changes
package/README.md CHANGED
@@ -1,28 +1,24 @@
1
1
  # @getenginex/sdk-igaming
2
2
 
3
- 📖 [game-engine-io.github.io/enginex-frontend-sdk](https://game-engine-io.github.io/enginex-frontend-sdk/igaming/)
3
+ Casino, bonuses, missions, loyalty, referrals and the FIRST sportsbook for EngineX, built on the `@getenginex/sdk` client.
4
4
 
5
- Cassino, bônus, engajamento e sportsbook FIRST do EngineX, montados sobre o cliente de
6
- [`@getenginex/sdk`](https://www.npmjs.com/package/@getenginex/sdk): `casino` (catálogo, abrir jogo,
7
- sessões, histórico e ranking de ganhadores), `bonus` (campanhas de bônus, opt-in, resgate e promo
8
- codes), `missions` (missões e progresso), `loyalty` (pontos, tier e resgate), `referrals` (código,
9
- histórico e registro de indicação) e `sportsbook` (sessão do FIRST para o iframe).
5
+ [Docs](https://game-engine-io.github.io/enginex-frontend-sdk/igaming/) · [Português](https://game-engine-io.github.io/enginex-frontend-sdk/pt/igaming/) · [Español](https://game-engine-io.github.io/enginex-frontend-sdk/es/igaming/)
10
6
 
11
- ## Instalação
7
+ Namespaces: `casino` (catalog, launch game, sessions, history, winners ranking), `bonus` (campaigns, opt-in, claim, promo
8
+ codes), `missions`, `loyalty` (points, tier, redeem), `referrals` and `sportsbook` (FIRST session for the iframe).
12
9
 
13
- Instale junto com o core — ele é _peer dependency_, então existe uma única cópia do core no app (a
14
- mesma sessão, tenant, hooks e validação para tudo):
10
+ ## Install
11
+
12
+ Install it next to the core. The core is a peer dependency, so the app has a single copy of it (one session, tenant, hooks and validation for everything):
15
13
 
16
14
  ```bash
17
15
  npm i @getenginex/sdk @getenginex/sdk-igaming
18
16
  ```
19
17
 
20
- Core compatível: `>=0.6.0 <1.0.0` (peer). Em tempo de execução, um cliente criado por uma cópia do
21
- core com contrato de transporte incompatível faz `createIgaming` lançar `CONFIGURATION_ERROR`. O `zod`
22
- (4.x) é dependência comum do core e deste pacote: mantenha um único `zod` 4 no projeto para não
23
- duplicá-lo no bundle.
18
+ Peer: `@getenginex/sdk >=0.6.0 <1.0.0`. A client created by a core copy with an incompatible transport contract makes
19
+ `createIgaming` throw `CONFIGURATION_ERROR`. `zod` 4 is shared with the core: keep a single `zod` 4 in the project.
24
20
 
25
- ## Uso
21
+ ## Quick start
26
22
 
27
23
  ```ts
28
24
  import { createEnginexClient } from '@getenginex/sdk'
@@ -32,53 +28,45 @@ export const enginex = createEnginexClient({ locale: 'pt-BR' })
32
28
  export const igaming = createIgaming(enginex)
33
29
 
34
30
  const games = await igaming.casino.listGames({ category: 'slots', perPage: 24 })
35
- const { gameUrl } = await igaming.casino.launchGame({ gameId: games.items[0].id }) // exige login
36
-
37
- const offers = await igaming.bonus.listOffers() // exige login
38
- await igaming.bonus.redeemPromoCode({ code: 'BEMVINDO' }, { idempotencyKey: crypto.randomUUID() })
31
+ const { gameUrl } = await igaming.casino.launchGame({ gameId: games.items[0].id }) // requires login
39
32
 
40
- const missions = await igaming.missions.list() // exige login
41
- const loyalty = await igaming.loyalty.get() // exige login
42
- const referral = await igaming.referrals.get() // exige login
33
+ const offers = await igaming.bonus.listOffers() // requires login
34
+ await igaming.bonus.redeemPromoCode({ code: 'WELCOME' }, { idempotencyKey: crypto.randomUUID() })
43
35
  ```
44
36
 
45
- `gameUrl` carrega o token da sessão de jogo: o SDK a devolve só no retorno (nunca nos hooks) — não a
46
- registre em logs.
37
+ `gameUrl` carries the game session token: the SDK returns it only as a result (never in hooks), so do not log it.
38
+
39
+ `createIgaming` creates no session, tenant or transport of its own and makes no request: every method goes through the app's
40
+ client. Create one per client (one per app in the browser; one per request on the server). A value that is not a client
41
+ created by `createEnginexClient` (for example a copy `{ ...enginex }`) is rejected with `CONFIGURATION_ERROR`.
47
42
 
48
- `createIgaming` não cria sessão, tenant nem transporte próprios e não faz nenhum request: todo método
49
- de iGaming passa pelo cliente do app (renovação de tokens, `X-Original-Host`, `Accept-Language`,
50
- `hooks`, `validation` e `dispose()`). Crie um por cliente: no browser, um por app; no servidor, um
51
- por request, junto com o cliente. Um valor que não é um cliente criado por `createEnginexClient` (ex.:
52
- uma cópia `{ ...enginex }`) é rejeitado com `CONFIGURATION_ERROR`.
43
+ ## Entry points
53
44
 
54
- ## Queries e mutations
45
+ | Subpath | Purpose |
46
+ | --- | --- |
47
+ | `@getenginex/sdk-igaming` | `createIgaming` and the casino, bonus, missions, loyalty, referrals and sportsbook namespaces |
48
+ | `@getenginex/sdk-igaming/testing` | Mock routes for iGaming (`withIgamingRoutes`) on top of the core's `createMockFetch` |
49
+ | `@getenginex/sdk-igaming/first-frame` | Origin-checked `postMessage` events and commands for the FIRST sportsbook iframe |
50
+ | `@getenginex/sdk-igaming/query` | Query and mutation factories for TanStack Query v5 |
55
51
 
56
- `@getenginex/sdk-igaming/query` traz as fábricas de query e mutation dos namespaces, no mesmo formato do
57
- `@getenginex/sdk/query` (compatível com `useQuery`, `useMutation` e `prefetchQuery` do TanStack Query v5,
58
- sem depender dele):
52
+ ### Queries and mutations
59
53
 
60
54
  ```ts
61
- import { createIgaming } from '@getenginex/sdk-igaming'
62
55
  import { createIgamingMutations, createIgamingQueries } from '@getenginex/sdk-igaming/query'
63
56
 
64
- const igaming = createIgaming(enginex)
65
57
  const q = createIgamingQueries(igaming)
66
58
  const m = createIgamingMutations(igaming)
67
59
 
68
60
  q.casino.listGames({ page: 1 }) // { queryKey: ['enginex', 'public', 'casino', 'listGames', { page: 1 }], queryFn }
69
- q.loyalty.get() // { queryKey: ['enginex', 'user', <userId>, 'loyalty', 'get'], queryFn }
70
- m.loyalty.redeem() // { mutationKey, mutationFn, invalidates }: loyalty e o saldo do core (wallet)
61
+ m.loyalty.redeem() // { mutationKey, mutationFn, invalidates }: loyalty and the core wallet
71
62
  ```
72
63
 
73
- Catálogo do cassino e ofertas públicas de bônus usam chave `public`; as demais leituras, a chave do
74
- usuário. `bonus.optIn/claim/redeemPromoCode` e `loyalty.redeem` mandam uma `Idempotency-Key` que só é
75
- reaproveitada depois de falha ambígua (rede, timeout, 5xx, `KEY_IN_USE` ou `VALIDATION_ERROR` depois de 2xx), com a mesma entrada e na mesma mutation, e aceitam `m.loyalty.redeem({ idempotencyKey })`. O entry exige `@getenginex/sdk >=0.6.0` e não
76
- entra no bundle de quem importa só `@getenginex/sdk-igaming`.
77
-
78
- ## Eventos do iframe do FIRST
64
+ The casino catalog and public bonus offers use the `public` key; other reads use the user key. `bonus.optIn/claim/redeemPromoCode`
65
+ and `loyalty.redeem` send an `Idempotency-Key` that is reused only after an ambiguous failure, with the same input and in the
66
+ same mutation ([Idempotency](https://game-engine-io.github.io/enginex-frontend-sdk/concepts/idempotency)). The entry requires `@getenginex/sdk >=0.6.0` and is not
67
+ in the bundle of anyone who imports only the main entry.
79
68
 
80
- `@getenginex/sdk-igaming/first-frame` (opcional, fora do bundle principal) recebe os eventos
81
- `postMessage` do iframe do sportsbook com checagem de origem e janela, e envia comandos:
69
+ ### FIRST iframe events
82
70
 
83
71
  ```ts
84
72
  import { connectFirstFrame } from '@getenginex/sdk-igaming/first-frame'
@@ -87,14 +75,14 @@ const frame = connectFirstFrame(iframe, {
87
75
  onBetPlaced: () => void enginex.wallet.getBalance().then(showBalance),
88
76
  onLoginRequired: () => openLoginModal(),
89
77
  })
90
- frame.dispose() // ao desmontar
78
+ frame.dispose() // on unmount
91
79
  ```
92
80
 
93
- Detalhes na [documentação](https://game-engine-io.github.io/enginex-frontend-sdk/igaming/sportsbook).
81
+ Details in [Sportsbook (FIRST)](https://game-engine-io.github.io/enginex-frontend-sdk/igaming/sportsbook).
94
82
 
95
- ## Testes
83
+ ## Testing
96
84
 
97
- `@getenginex/sdk-igaming/testing` soma as rotas mock de iGaming ao `createMockFetch` do core:
85
+ `withIgamingRoutes` adds the iGaming mock routes to the core's `createMockFetch`:
98
86
 
99
87
  ```ts
100
88
  import { createEnginexClient } from '@getenginex/sdk'
@@ -103,21 +91,21 @@ import { createIgaming } from '@getenginex/sdk-igaming'
103
91
  import { withIgamingRoutes } from '@getenginex/sdk-igaming/testing'
104
92
 
105
93
  const enginex = createEnginexClient({
106
- baseUrl: 'https://gateway.test', // em Node: baseUrl absoluto + tenantHost (no browser, opcionais)
94
+ baseUrl: 'https://gateway.test', // in Node: absolute baseUrl + tenantHost (optional in the browser)
107
95
  tenantHost: 'casino.test',
108
96
  fetch: createMockFetch(withIgamingRoutes({ withdrawalOtp: true })),
109
97
  })
110
98
  const igaming = createIgaming(enginex)
111
99
  ```
112
100
 
113
- As rotas do core continuam valendo e as de `options.routes` vencem as de iGaming. Para montar o
114
- objeto de rotas à mão, use `createIgamingRoutes()`.
101
+ Core routes still apply and `options.routes` win over the iGaming ones. To build the routes object by hand, use
102
+ `createIgamingRoutes()`. See [Testing and mocks](https://game-engine-io.github.io/enginex-frontend-sdk/guide/testing).
115
103
 
116
- ## Runtimes suportados
104
+ ## Versions
117
105
 
118
- Os mesmos do core: browsers com `fetch` e `AbortController`, Node 20+, Edge runtimes e Bun. ESM e
119
- CommonJS; os tipos não dependem de `lib: DOM`.
106
+ While the major version is `0`, minor versions may contain breaking changes and patch versions do not. Pin a tilde range
107
+ (for example `~0.x.0`, with the minor you use) to take only fixes, and read the [upgrade guide](https://game-engine-io.github.io/enginex-frontend-sdk/guide/upgrading) and the [changelog](https://game-engine-io.github.io/enginex-frontend-sdk/changelog) before upgrading.
120
108
 
121
- ## Licença
109
+ ## License
122
110
 
123
- [Apache License 2.0](LICENSE).
111
+ [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
@@ -18,7 +18,7 @@ var FirstFrameConfigurationError = class extends Error {
18
18
  return { name: this.name, code: this.code, message: this.message, status: this.status };
19
19
  }
20
20
  };
21
- var NO_ORIGIN = "O src do iframe do FIRST n\xE3o tem uma origem http(s) v\xE1lida: defina iframe.src com a launchUrl antes de usar o frame.";
21
+ var NO_ORIGIN = "The FIRST iframe src has no valid http(s) origin: set iframe.src to the launchUrl before using the frame.";
22
22
  function originOf(src) {
23
23
  try {
24
24
  const url = new URL(src);
@@ -99,7 +99,7 @@ function connectFirstFrame(iframe, handlers, options = {}) {
99
99
  const win = options.window ?? globalThis;
100
100
  if (typeof win.addEventListener !== "function" || typeof win.removeEventListener !== "function") {
101
101
  throw new FirstFrameConfigurationError(
102
- "connectFirstFrame precisa de uma janela com addEventListener: fora do browser, passe options.window."
102
+ "connectFirstFrame needs a window with addEventListener: outside the browser, pass options.window."
103
103
  );
104
104
  }
105
105
  let disposed = false;
@@ -114,12 +114,12 @@ function connectFirstFrame(iframe, handlers, options = {}) {
114
114
  win.addEventListener("message", listener);
115
115
  return {
116
116
  send(eventType, eventData) {
117
- if (disposed) throw new FirstFrameConfigurationError("O frame do FIRST j\xE1 foi encerrado (dispose).");
117
+ if (disposed) throw new FirstFrameConfigurationError("The FIRST frame has already been closed (dispose).");
118
118
  const origin = originOf(iframe.src);
119
119
  if (origin === null) throw new FirstFrameConfigurationError(NO_ORIGIN);
120
120
  const target = iframe.contentWindow;
121
121
  if (target === null) {
122
- throw new FirstFrameConfigurationError("O iframe do FIRST ainda n\xE3o tem contentWindow (n\xE3o est\xE1 no documento).");
122
+ throw new FirstFrameConfigurationError("The FIRST iframe has no contentWindow yet (it is not in the document).");
123
123
  }
124
124
  target.postMessage(JSON.stringify({ eventType, eventData }), origin);
125
125
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/first-frame/index.ts"],"names":[],"mappings":";;;AA0HA,IAAM,KAAA,mBAAQ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,QAAA,MAAM,IAAI,6BAA6B,iFAAwE,CAAA;AAAA,MACjH;AACA,MAAA,MAAA,CAAO,WAAA,CAAY,KAAK,SAAA,CAAU,EAAE,WAAW,SAAA,EAAW,GAAG,MAAM,CAAA;AAAA,IACrE,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,IAAI,QAAA,EAAU;AACd,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,GAAA,CAAI,mBAAA,GAAsB,WAAW,QAAQ,CAAA;AAAA,IAC/C;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Ponte tipada e com checagem de origem para os eventos `postMessage` do iframe do sportsbook FIRST.\n *\n * Este entry não importa o core em runtime nem exige `lib.dom` nos tipos do consumidor. É o único\n * entry do pacote que toca o DOM, e só através dos objetos que o app passa (o iframe e a janela).\n * @module @getenginex/sdk-igaming/first-frame\n */\n\n/**\n * Mensagem `postMessage` como o helper a lê: só os campos que ele usa (um `MessageEvent` do DOM é\n * atribuível).\n * @category Sportsbook\n */\nexport interface FirstFrameMessageEvent {\n /** Conteúdo enviado pelo iframe: string JSON ou objeto. */\n readonly data: unknown\n /** Origem de quem enviou. */\n readonly origin: string\n /** Janela de quem enviou. */\n readonly source: unknown\n}\n\n/**\n * Janela da página, no mínimo que o helper usa: um `Window` do DOM é atribuível. É a janela do app\n * (a que recebe as mensagens do iframe), não a do iframe.\n * @category Sportsbook\n */\nexport interface FirstFrameWindow {\n /** Registra o listener de `message`. */\n addEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void\n /** Remove o listener de `message`. */\n removeEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void\n}\n\n/**\n * O iframe do FIRST, no mínimo que o helper usa: um `HTMLIFrameElement` é atribuível. A origem\n * esperada e o destino das mensagens saem de `src` (relido a cada mensagem).\n * @category Sportsbook\n */\nexport interface FirstFrameTarget {\n /** URL carregada no iframe (a `launchUrl` da sessão). Dela vem a origem confiável. */\n readonly src: string\n /** Janela do iframe; `null` enquanto ele não está no documento. */\n readonly contentWindow: {\n /** Envia uma mensagem para o iframe. */\n postMessage(message: string, targetOrigin: string): void\n } | null\n}\n\n/**\n * Argumento de `onRedirect`: os campos de `eventData` (se for um objeto) mais o `link` do topo da\n * mensagem. O SDK só garante que `link`, quando presente, é texto (um `link` de outro tipo é\n * descartado); o conteúdo não é validado e `link` pode faltar.\n * @category Sportsbook\n */\nexport interface FirstFrameRedirect {\n /** Destino pedido pelo FIRST; opcional e não confiável (valide antes de abrir). */\n link?: string\n /** Demais campos de `eventData`, como o FIRST os enviou. */\n [key: string]: unknown\n}\n\n/**\n * Handlers dos eventos do iframe. Todos opcionais; um handler que lança (ou rejeita) é ignorado e\n * não impede os demais.\n * @category Sportsbook\n */\nexport interface FirstFrameHandlers {\n /** `APP_READY`: o sportsbook carregou e aceita `send`. */\n onReady?(): void\n /** `BET_WAS_PLACED`: uma aposta foi feita (bom momento para reler o saldo). */\n onBetPlaced?(data: unknown): void\n /** `INSUFFICIENT_FUNDS`: saldo insuficiente para a aposta. */\n onInsufficientFunds?(data: unknown): void\n /** `depositClick`: o jogador pediu para depositar. */\n onDepositClick?(data: unknown): void\n /** `PLACE_BET_CLICKED_NOT_LOGGED_IN` ou `OPEN_LOGIN_POPUP`: o jogador precisa entrar. */\n onLoginRequired?(data: unknown): void\n /** `on-page-height-change` / `ON_PAGE_HEIGHT_CHANGE`: nova altura (px, positiva) do conteúdo. */\n onHeightChange?(height: number): void\n /**\n * `BUTTON_REDIRECT`: o FIRST pede para abrir um link. `data.link` vem no topo da mensagem (ou em\n * `eventData`) e **pode faltar ou não ser uma URL válida**. **Valide antes de abrir**: aceite só\n * http(s), sem credenciais.\n */\n onRedirect?(data: FirstFrameRedirect): void\n /** `SCROLL_TO_TOP`: o FIRST pede para rolar a página ao topo. */\n onScrollToTop?(): void\n /** Todo evento aceito, inclusive os que também têm handler dedicado. */\n onEvent?(eventType: string, eventData: unknown): void\n}\n\n/**\n * Conexão com o iframe do FIRST.\n * @category Sportsbook\n */\nexport interface FirstFrame {\n /**\n * Envia um evento ao iframe: `postMessage(JSON.stringify({ eventType, eventData }), origem)`, com a\n * origem do `src` (nunca `'*'`). Espere `onReady` antes de enviar: o FIRST só ouve depois de\n * carregar. Eventos que o FIRST entende: `sportId`, `leagueId`, `eventId` (`{ value: id }`),\n * `liveBetting`, `home` (`{ value: true }`), `betting-history`, `open-bets`, `expand-bet-slip`\n * (`{ value: boolean }`), `bscode` (`{ value: código }`) e `shareBetslip` (`{ url }`).\n * @example\n * frame.send('sportId', { value: '66' })\n * @throws {EnginexError} `CONFIGURATION_ERROR` se o `src` não tem origem http(s) válida, se o\n * iframe não tem `contentWindow` ou depois de `dispose()`.\n */\n send(eventType: string, eventData?: unknown): void\n /** Remove o listener. Idempotente; depois disso nada é entregue e `send` lança. */\n dispose(): void\n}\n\n/**\n * Opções de {@link connectFirstFrame}.\n * @category Sportsbook\n */\nexport interface ConnectFirstFrameOptions {\n /** Janela onde ouvir `message`. Padrão: `globalThis` (a janela da página que contém o iframe). */\n window?: FirstFrameWindow\n}\n\nconst BRAND = Symbol.for('getenginex.error')\n\n// Erro compatível com o `EnginexError` do core sem importá-lo: o core não pode entrar neste entry\n// (importar `@getenginex/sdk`, mesmo só para o erro, deixaria um `import` em runtime). O core\n// reconhece erros por `instanceof Error` + a marca global `Symbol.for('getenginex.error')`, então\n// `isEnginexError(e, 'CONFIGURATION_ERROR')` responde `true` para este erro.\nclass FirstFrameConfigurationError extends Error {\n override readonly name = 'EnginexError'\n readonly code = 'CONFIGURATION_ERROR'\n readonly status = 0\n readonly details = undefined\n constructor(message: string) {\n super(message)\n Object.defineProperty(this, BRAND, { value: true })\n }\n\n override toString(): string {\n return `EnginexError [${this.code}]: ${this.message}`\n }\n\n toJSON() {\n return { name: this.name, code: this.code, message: this.message, status: this.status }\n }\n}\n\nconst NO_ORIGIN =\n 'O src do iframe do FIRST não tem uma origem http(s) válida: defina iframe.src com a launchUrl antes de usar o frame.'\n\n/** Origem http(s) de `src`, ou `null`. Nunca lança nem inclui o `src` (tem token) em mensagens. */\nfunction originOf(src: string): string | null {\n try {\n const url = new URL(src)\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.origin : null\n } catch {\n return null\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction parse(data: unknown): Record<string, unknown> | undefined {\n let value = data\n if (typeof value === 'string') {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isRecord(value) ? value : undefined\n}\n\nfunction call(fn: (() => unknown) | undefined): void {\n if (!fn) return\n try {\n const result = fn()\n // `Promise.resolve` adota também thenables e promises de outro realm (não `instanceof Promise`).\n Promise.resolve(result).catch(() => {})\n } catch {\n // um handler com defeito não derruba o listener nem os outros handlers\n }\n}\n\nfunction positiveNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined\n}\n\nfunction dispatch(message: Record<string, unknown>, handlers: FirstFrameHandlers): void {\n const rawType = message.eventType || message.type\n if (typeof rawType !== 'string' || rawType === '') return\n const eventType = rawType\n const eventData = message.eventData\n const on = <A extends unknown[]>(handler: ((...args: A) => void) | undefined, ...args: A) =>\n call(handler && (() => handler.apply(handlers, args)))\n\n switch (eventType) {\n case 'APP_READY':\n on(handlers.onReady)\n break\n case 'BET_WAS_PLACED':\n on(handlers.onBetPlaced, eventData)\n break\n case 'INSUFFICIENT_FUNDS':\n on(handlers.onInsufficientFunds, eventData)\n break\n case 'depositClick':\n on(handlers.onDepositClick, eventData)\n break\n case 'PLACE_BET_CLICKED_NOT_LOGGED_IN':\n case 'OPEN_LOGIN_POPUP':\n on(handlers.onLoginRequired, eventData)\n break\n case 'on-page-height-change':\n case 'ON_PAGE_HEIGHT_CHANGE': {\n const height =\n positiveNumber(isRecord(eventData) ? eventData.height : undefined) ?? positiveNumber(message.height)\n if (height !== undefined) on(handlers.onHeightChange, height)\n break\n }\n case 'BUTTON_REDIRECT': {\n // `link` só chega ao handler se for texto (o do topo da mensagem tem precedência): o tipo\n // público promete `link?: string`, e um número ou objeto vindo do iframe quebraria quem valida a URL.\n const data: FirstFrameRedirect = { ...(isRecord(eventData) ? eventData : {}) }\n if (typeof message.link === 'string') data.link = message.link\n else if (typeof data.link !== 'string') delete data.link\n on(handlers.onRedirect, data)\n break\n }\n case 'SCROLL_TO_TOP':\n on(handlers.onScrollToTop)\n break\n default:\n break\n }\n on(handlers.onEvent, eventType, eventData)\n}\n\n/**\n * Conecta ao iframe do sportsbook FIRST: recebe os eventos do FIRST em handlers tipados e envia\n * comandos com `send`. Só entrega mensagens cuja `origin` é a origem do `src` do iframe **e** cuja\n * `source` é o `contentWindow` do iframe; JSON inválido ou sem `eventType` é ignorado sem lançar.\n * O payload chega como o FIRST o enviou (`unknown`): valide antes de usar.\n * @example\n * import { connectFirstFrame } from '@getenginex/sdk-igaming/first-frame'\n *\n * const frame = connectFirstFrame(iframe, {\n * onBetPlaced: () => void enginex.wallet.getBalance().then(showBalance),\n * onLoginRequired: () => openLogin(),\n * })\n * // ao desmontar o iframe:\n * frame.dispose()\n * @throws {EnginexError} `CONFIGURATION_ERROR` se a janela (`options.window` ou `globalThis`) não\n * tem `addEventListener`/`removeEventListener`.\n * @category Sportsbook\n */\nexport function connectFirstFrame(\n iframe: FirstFrameTarget,\n handlers: FirstFrameHandlers,\n options: ConnectFirstFrameOptions = {},\n): FirstFrame {\n const win = options.window ?? (globalThis as unknown as Partial<FirstFrameWindow>)\n if (typeof win.addEventListener !== 'function' || typeof win.removeEventListener !== 'function') {\n throw new FirstFrameConfigurationError(\n 'connectFirstFrame precisa de uma janela com addEventListener: fora do browser, passe options.window.',\n )\n }\n let disposed = false\n\n const listener = (event: FirstFrameMessageEvent): void => {\n if (disposed) return\n const target = iframe.contentWindow\n const origin = originOf(iframe.src)\n if (target === null || origin === null || event.source !== target || event.origin !== origin) return\n const message = parse(event.data)\n if (message) dispatch(message, handlers)\n }\n win.addEventListener('message', listener)\n\n return {\n send(eventType, eventData) {\n if (disposed) throw new FirstFrameConfigurationError('O frame do FIRST já foi encerrado (dispose).')\n const origin = originOf(iframe.src)\n if (origin === null) throw new FirstFrameConfigurationError(NO_ORIGIN)\n const target = iframe.contentWindow\n if (target === null) {\n throw new FirstFrameConfigurationError('O iframe do FIRST ainda não tem contentWindow (não está no documento).')\n }\n target.postMessage(JSON.stringify({ eventType, eventData }), origin)\n },\n dispose() {\n if (disposed) return\n disposed = true\n win.removeEventListener?.('message', listener)\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/first-frame/index.ts"],"names":[],"mappings":";;;AA0HA,IAAM,KAAA,mBAAQ,MAAA,CAAO,GAAA,CAAI,kBAAkB,CAAA;AAM3C,IAAM,4BAAA,GAAN,cAA2C,KAAA,CAAM;AAAA,EAC7B,IAAA,GAAO,cAAA;AAAA,EAChB,IAAA,GAAO,qBAAA;AAAA,EACP,MAAA,GAAS,CAAA;AAAA,EACT,OAAA,GAAU,MAAA;AAAA,EACnB,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,MAAA,CAAO,eAAe,IAAA,EAAM,KAAA,EAAO,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,EACpD;AAAA,EAES,QAAA,GAAmB;AAC1B,IAAA,OAAO,CAAA,cAAA,EAAiB,IAAA,CAAK,IAAI,CAAA,GAAA,EAAM,KAAK,OAAO,CAAA,CAAA;AAAA,EACrD;AAAA,EAEA,MAAA,GAAS;AACP,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,CAAK,OAAA,EAAS,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAO;AAAA,EACxF;AACF,CAAA;AAEA,IAAM,SAAA,GACJ,2GAAA;AAGF,SAAS,SAAS,GAAA,EAA4B;AAC5C,EAAA,IAAI;AACF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AA,EACzC,CAAA;AACA,EAAA,GAAA,CAAI,gBAAA,CAAiB,WAAW,QAAQ,CAAA;AAExC,EAAA,OAAO;AAAA,IACL,IAAA,CAAK,WAAW,SAAA,EAAW;AACzB,MAAA,IAAI,QAAA,EAAU,MAAM,IAAI,4BAAA,CAA6B,oDAAoD,CAAA;AACzG,MAAA,MAAM,MAAA,GAAS,QAAA,CAAS,MAAA,CAAO,GAAG,CAAA;AAClC,MAAA,IAAI,MAAA,KAAW,IAAA,EAAM,MAAM,IAAI,6BAA6B,SAAS,CAAA;AACrE,MAAA,MAAM,SAAS,MAAA,CAAO,aAAA;AACtB,MAAA,IAAI,WAAW,IAAA,EAAM;AACnB,QAAA,MAAM,IAAI,6BAA6B,wEAAwE,CAAA;AAAA,MACjH;AACA,MAAA,MAAA,CAAO,WAAA,CAAY,KAAK,SAAA,CAAU,EAAE,WAAW,SAAA,EAAW,GAAG,MAAM,CAAA;AAAA,IACrE,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,IAAI,QAAA,EAAU;AACd,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,GAAA,CAAI,mBAAA,GAAsB,WAAW,QAAQ,CAAA;AAAA,IAC/C;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Typed bridge with origin checking for the `postMessage` events of the FIRST sportsbook iframe.\n *\n * This entry does not import the core at runtime nor require `lib.dom` in the consumer's types. It is the only\n * entry of the package that touches the DOM, and only through the objects the app passes (the iframe and the window).\n * @module @getenginex/sdk-igaming/first-frame\n */\n\n/**\n * `postMessage` message as the helper reads it: only the fields it uses (a DOM `MessageEvent` is\n * assignable).\n * @category Sportsbook\n */\nexport interface FirstFrameMessageEvent {\n /** Content sent by the iframe: a JSON string or an object. */\n readonly data: unknown\n /** Sender's origin. */\n readonly origin: string\n /** Sender's window. */\n readonly source: unknown\n}\n\n/**\n * Page window, with the minimum the helper uses: a DOM `Window` is assignable. It is the app's window\n * (the one that receives the iframe's messages), not the iframe's.\n * @category Sportsbook\n */\nexport interface FirstFrameWindow {\n /** Registers the `message` listener. */\n addEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void\n /** Removes the `message` listener. */\n removeEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void\n}\n\n/**\n * The FIRST iframe, with the minimum the helper uses: an `HTMLIFrameElement` is assignable. The expected\n * origin and the destination of the messages come from `src` (re-read on every message).\n * @category Sportsbook\n */\nexport interface FirstFrameTarget {\n /** URL loaded in the iframe (the session's `launchUrl`). The trusted origin comes from it. */\n readonly src: string\n /** The iframe's window; `null` while it is not in the document. */\n readonly contentWindow: {\n /** Sends a message to the iframe. */\n postMessage(message: string, targetOrigin: string): void\n } | null\n}\n\n/**\n * Argument of `onRedirect`: the fields of `eventData` (if it is an object) plus the top-level `link` of the\n * message. The SDK only guarantees that `link`, when present, is text (a `link` of another type is\n * dropped); the content is not validated and `link` may be missing.\n * @category Sportsbook\n */\nexport interface FirstFrameRedirect {\n /** Destination requested by FIRST; optional and untrusted (validate before opening). */\n link?: string\n /** Other `eventData` fields, as FIRST sent them. */\n [key: string]: unknown\n}\n\n/**\n * Handlers for the iframe events. All optional; a handler that throws (or rejects) is ignored and\n * does not prevent the others.\n * @category Sportsbook\n */\nexport interface FirstFrameHandlers {\n /** `APP_READY`: the sportsbook has loaded and accepts `send`. */\n onReady?(): void\n /** `BET_WAS_PLACED`: a bet was placed (a good moment to re-read the balance). */\n onBetPlaced?(data: unknown): void\n /** `INSUFFICIENT_FUNDS`: insufficient balance for the bet. */\n onInsufficientFunds?(data: unknown): void\n /** `depositClick`: the player asked to deposit. */\n onDepositClick?(data: unknown): void\n /** `PLACE_BET_CLICKED_NOT_LOGGED_IN` or `OPEN_LOGIN_POPUP`: the player needs to log in. */\n onLoginRequired?(data: unknown): void\n /** `on-page-height-change` / `ON_PAGE_HEIGHT_CHANGE`: new content height (px, positive). */\n onHeightChange?(height: number): void\n /**\n * `BUTTON_REDIRECT`: FIRST asks to open a link. `data.link` comes at the top of the message (or in\n * `eventData`) and **may be missing or not a valid URL**. **Validate before opening**: accept only\n * http(s), without credentials.\n */\n onRedirect?(data: FirstFrameRedirect): void\n /** `SCROLL_TO_TOP`: FIRST asks to scroll the page to the top. */\n onScrollToTop?(): void\n /** Every accepted event, including those that also have a dedicated handler. */\n onEvent?(eventType: string, eventData: unknown): void\n}\n\n/**\n * Connection to the FIRST iframe.\n * @category Sportsbook\n */\nexport interface FirstFrame {\n /**\n * Sends an event to the iframe: `postMessage(JSON.stringify({ eventType, eventData }), origin)`, with the\n * origin of the `src` (never `'*'`). Wait for `onReady` before sending: FIRST only listens after\n * loading. Events FIRST understands: `sportId`, `leagueId`, `eventId` (`{ value: id }`),\n * `liveBetting`, `home` (`{ value: true }`), `betting-history`, `open-bets`, `expand-bet-slip`\n * (`{ value: boolean }`), `bscode` (`{ value: code }`) and `shareBetslip` (`{ url }`).\n * @example\n * frame.send('sportId', { value: '66' })\n * @throws {EnginexError} `CONFIGURATION_ERROR` if the `src` has no valid http(s) origin, if the\n * iframe has no `contentWindow` or after `dispose()`.\n */\n send(eventType: string, eventData?: unknown): void\n /** Removes the listener. Idempotent; after that nothing is delivered and `send` throws. */\n dispose(): void\n}\n\n/**\n * Options of {@link connectFirstFrame}.\n * @category Sportsbook\n */\nexport interface ConnectFirstFrameOptions {\n /** Window to listen for `message` on. Default: `globalThis` (the window of the page that contains the iframe). */\n window?: FirstFrameWindow\n}\n\nconst BRAND = Symbol.for('getenginex.error')\n\n// Error compatible with the core's `EnginexError` without importing it: the core cannot enter this entry\n// (importing `@getenginex/sdk`, even only for the error, would leave a runtime `import`). The core\n// recognizes errors by `instanceof Error` + the global mark `Symbol.for('getenginex.error')`, so\n// `isEnginexError(e, 'CONFIGURATION_ERROR')` answers `true` for this error.\nclass FirstFrameConfigurationError extends Error {\n override readonly name = 'EnginexError'\n readonly code = 'CONFIGURATION_ERROR'\n readonly status = 0\n readonly details = undefined\n constructor(message: string) {\n super(message)\n Object.defineProperty(this, BRAND, { value: true })\n }\n\n override toString(): string {\n return `EnginexError [${this.code}]: ${this.message}`\n }\n\n toJSON() {\n return { name: this.name, code: this.code, message: this.message, status: this.status }\n }\n}\n\nconst NO_ORIGIN =\n 'The FIRST iframe src has no valid http(s) origin: set iframe.src to the launchUrl before using the frame.'\n\n/** http(s) origin of `src`, or `null`. It never throws nor includes the `src` (it has a token) in messages. */\nfunction originOf(src: string): string | null {\n try {\n const url = new URL(src)\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.origin : null\n } catch {\n return null\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction parse(data: unknown): Record<string, unknown> | undefined {\n let value = data\n if (typeof value === 'string') {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isRecord(value) ? value : undefined\n}\n\nfunction call(fn: (() => unknown) | undefined): void {\n if (!fn) return\n try {\n const result = fn()\n // `Promise.resolve` also adopts thenables and promises from another realm (not `instanceof Promise`).\n Promise.resolve(result).catch(() => {})\n } catch {\n // a faulty handler does not take down the listener nor the other handlers\n }\n}\n\nfunction positiveNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined\n}\n\nfunction dispatch(message: Record<string, unknown>, handlers: FirstFrameHandlers): void {\n const rawType = message.eventType || message.type\n if (typeof rawType !== 'string' || rawType === '') return\n const eventType = rawType\n const eventData = message.eventData\n const on = <A extends unknown[]>(handler: ((...args: A) => void) | undefined, ...args: A) =>\n call(handler && (() => handler.apply(handlers, args)))\n\n switch (eventType) {\n case 'APP_READY':\n on(handlers.onReady)\n break\n case 'BET_WAS_PLACED':\n on(handlers.onBetPlaced, eventData)\n break\n case 'INSUFFICIENT_FUNDS':\n on(handlers.onInsufficientFunds, eventData)\n break\n case 'depositClick':\n on(handlers.onDepositClick, eventData)\n break\n case 'PLACE_BET_CLICKED_NOT_LOGGED_IN':\n case 'OPEN_LOGIN_POPUP':\n on(handlers.onLoginRequired, eventData)\n break\n case 'on-page-height-change':\n case 'ON_PAGE_HEIGHT_CHANGE': {\n const height =\n positiveNumber(isRecord(eventData) ? eventData.height : undefined) ?? positiveNumber(message.height)\n if (height !== undefined) on(handlers.onHeightChange, height)\n break\n }\n case 'BUTTON_REDIRECT': {\n // `link` only reaches the handler if it is text (the top-level one in the message takes precedence): the public\n // type promises `link?: string`, and a number or object coming from the iframe would break whoever validates the URL.\n const data: FirstFrameRedirect = { ...(isRecord(eventData) ? eventData : {}) }\n if (typeof message.link === 'string') data.link = message.link\n else if (typeof data.link !== 'string') delete data.link\n on(handlers.onRedirect, data)\n break\n }\n case 'SCROLL_TO_TOP':\n on(handlers.onScrollToTop)\n break\n default:\n break\n }\n on(handlers.onEvent, eventType, eventData)\n}\n\n/**\n * Connects to the FIRST sportsbook iframe: receives FIRST's events in typed handlers and sends\n * commands with `send`. It only delivers messages whose `origin` is the `src` origin of the iframe **and** whose\n * `source` is the iframe's `contentWindow`; invalid JSON or JSON without `eventType` is ignored without throwing.\n * The payload arrives as FIRST sent it (`unknown`): validate before using it.\n * @example\n * import { connectFirstFrame } from '@getenginex/sdk-igaming/first-frame'\n *\n * const frame = connectFirstFrame(iframe, {\n * onBetPlaced: () => void enginex.wallet.getBalance().then(showBalance),\n * onLoginRequired: () => openLogin(),\n * })\n * // when unmounting the iframe:\n * frame.dispose()\n * @throws {EnginexError} `CONFIGURATION_ERROR` if the window (`options.window` or `globalThis`) has no\n * `addEventListener`/`removeEventListener`.\n * @category Sportsbook\n */\nexport function connectFirstFrame(\n iframe: FirstFrameTarget,\n handlers: FirstFrameHandlers,\n options: ConnectFirstFrameOptions = {},\n): FirstFrame {\n const win = options.window ?? (globalThis as unknown as Partial<FirstFrameWindow>)\n if (typeof win.addEventListener !== 'function' || typeof win.removeEventListener !== 'function') {\n throw new FirstFrameConfigurationError(\n 'connectFirstFrame needs a window with addEventListener: outside the browser, pass options.window.',\n )\n }\n let disposed = false\n\n const listener = (event: FirstFrameMessageEvent): void => {\n if (disposed) return\n const target = iframe.contentWindow\n const origin = originOf(iframe.src)\n if (target === null || origin === null || event.source !== target || event.origin !== origin) return\n const message = parse(event.data)\n if (message) dispatch(message, handlers)\n }\n win.addEventListener('message', listener)\n\n return {\n send(eventType, eventData) {\n if (disposed) throw new FirstFrameConfigurationError('The FIRST frame has already been closed (dispose).')\n const origin = originOf(iframe.src)\n if (origin === null) throw new FirstFrameConfigurationError(NO_ORIGIN)\n const target = iframe.contentWindow\n if (target === null) {\n throw new FirstFrameConfigurationError('The FIRST iframe has no contentWindow yet (it is not in the document).')\n }\n target.postMessage(JSON.stringify({ eventType, eventData }), origin)\n },\n dispose() {\n if (disposed) return\n disposed = true\n win.removeEventListener?.('message', listener)\n },\n }\n}\n"]}
@@ -1,122 +1,122 @@
1
1
  /**
2
- * Ponte tipada e com checagem de origem para os eventos `postMessage` do iframe do sportsbook FIRST.
2
+ * Typed bridge with origin checking for the `postMessage` events of the FIRST sportsbook iframe.
3
3
  *
4
- * Este entry não importa o core em runtime nem exige `lib.dom` nos tipos do consumidor. É o único
5
- * entry do pacote que toca o DOM, e só através dos objetos que o app passa (o iframe e a janela).
4
+ * This entry does not import the core at runtime nor require `lib.dom` in the consumer's types. It is the only
5
+ * entry of the package that touches the DOM, and only through the objects the app passes (the iframe and the window).
6
6
  * @module @getenginex/sdk-igaming/first-frame
7
7
  */
8
8
  /**
9
- * Mensagem `postMessage` como o helper a lê: só os campos que ele usa (um `MessageEvent` do DOM é
10
- * atribuível).
9
+ * `postMessage` message as the helper reads it: only the fields it uses (a DOM `MessageEvent` is
10
+ * assignable).
11
11
  * @category Sportsbook
12
12
  */
13
13
  interface FirstFrameMessageEvent {
14
- /** Conteúdo enviado pelo iframe: string JSON ou objeto. */
14
+ /** Content sent by the iframe: a JSON string or an object. */
15
15
  readonly data: unknown;
16
- /** Origem de quem enviou. */
16
+ /** Sender's origin. */
17
17
  readonly origin: string;
18
- /** Janela de quem enviou. */
18
+ /** Sender's window. */
19
19
  readonly source: unknown;
20
20
  }
21
21
  /**
22
- * Janela da página, no mínimo que o helper usa: um `Window` do DOM é atribuível. É a janela do app
23
- * (a que recebe as mensagens do iframe), não a do iframe.
22
+ * Page window, with the minimum the helper uses: a DOM `Window` is assignable. It is the app's window
23
+ * (the one that receives the iframe's messages), not the iframe's.
24
24
  * @category Sportsbook
25
25
  */
26
26
  interface FirstFrameWindow {
27
- /** Registra o listener de `message`. */
27
+ /** Registers the `message` listener. */
28
28
  addEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void;
29
- /** Remove o listener de `message`. */
29
+ /** Removes the `message` listener. */
30
30
  removeEventListener(type: 'message', listener: (event: FirstFrameMessageEvent) => void): void;
31
31
  }
32
32
  /**
33
- * O iframe do FIRST, no mínimo que o helper usa: um `HTMLIFrameElement` é atribuível. A origem
34
- * esperada e o destino das mensagens saem de `src` (relido a cada mensagem).
33
+ * The FIRST iframe, with the minimum the helper uses: an `HTMLIFrameElement` is assignable. The expected
34
+ * origin and the destination of the messages come from `src` (re-read on every message).
35
35
  * @category Sportsbook
36
36
  */
37
37
  interface FirstFrameTarget {
38
- /** URL carregada no iframe (a `launchUrl` da sessão). Dela vem a origem confiável. */
38
+ /** URL loaded in the iframe (the session's `launchUrl`). The trusted origin comes from it. */
39
39
  readonly src: string;
40
- /** Janela do iframe; `null` enquanto ele não está no documento. */
40
+ /** The iframe's window; `null` while it is not in the document. */
41
41
  readonly contentWindow: {
42
- /** Envia uma mensagem para o iframe. */
42
+ /** Sends a message to the iframe. */
43
43
  postMessage(message: string, targetOrigin: string): void;
44
44
  } | null;
45
45
  }
46
46
  /**
47
- * Argumento de `onRedirect`: os campos de `eventData` (se for um objeto) mais o `link` do topo da
48
- * mensagem. O SDK só garante que `link`, quando presente, é texto (um `link` de outro tipo é
49
- * descartado); o conteúdo não é validado e `link` pode faltar.
47
+ * Argument of `onRedirect`: the fields of `eventData` (if it is an object) plus the top-level `link` of the
48
+ * message. The SDK only guarantees that `link`, when present, is text (a `link` of another type is
49
+ * dropped); the content is not validated and `link` may be missing.
50
50
  * @category Sportsbook
51
51
  */
52
52
  interface FirstFrameRedirect {
53
- /** Destino pedido pelo FIRST; opcional e não confiável (valide antes de abrir). */
53
+ /** Destination requested by FIRST; optional and untrusted (validate before opening). */
54
54
  link?: string;
55
- /** Demais campos de `eventData`, como o FIRST os enviou. */
55
+ /** Other `eventData` fields, as FIRST sent them. */
56
56
  [key: string]: unknown;
57
57
  }
58
58
  /**
59
- * Handlers dos eventos do iframe. Todos opcionais; um handler que lança (ou rejeita) é ignorado e
60
- * não impede os demais.
59
+ * Handlers for the iframe events. All optional; a handler that throws (or rejects) is ignored and
60
+ * does not prevent the others.
61
61
  * @category Sportsbook
62
62
  */
63
63
  interface FirstFrameHandlers {
64
- /** `APP_READY`: o sportsbook carregou e aceita `send`. */
64
+ /** `APP_READY`: the sportsbook has loaded and accepts `send`. */
65
65
  onReady?(): void;
66
- /** `BET_WAS_PLACED`: uma aposta foi feita (bom momento para reler o saldo). */
66
+ /** `BET_WAS_PLACED`: a bet was placed (a good moment to re-read the balance). */
67
67
  onBetPlaced?(data: unknown): void;
68
- /** `INSUFFICIENT_FUNDS`: saldo insuficiente para a aposta. */
68
+ /** `INSUFFICIENT_FUNDS`: insufficient balance for the bet. */
69
69
  onInsufficientFunds?(data: unknown): void;
70
- /** `depositClick`: o jogador pediu para depositar. */
70
+ /** `depositClick`: the player asked to deposit. */
71
71
  onDepositClick?(data: unknown): void;
72
- /** `PLACE_BET_CLICKED_NOT_LOGGED_IN` ou `OPEN_LOGIN_POPUP`: o jogador precisa entrar. */
72
+ /** `PLACE_BET_CLICKED_NOT_LOGGED_IN` or `OPEN_LOGIN_POPUP`: the player needs to log in. */
73
73
  onLoginRequired?(data: unknown): void;
74
- /** `on-page-height-change` / `ON_PAGE_HEIGHT_CHANGE`: nova altura (px, positiva) do conteúdo. */
74
+ /** `on-page-height-change` / `ON_PAGE_HEIGHT_CHANGE`: new content height (px, positive). */
75
75
  onHeightChange?(height: number): void;
76
76
  /**
77
- * `BUTTON_REDIRECT`: o FIRST pede para abrir um link. `data.link` vem no topo da mensagem (ou em
78
- * `eventData`) e **pode faltar ou não ser uma URL válida**. **Valide antes de abrir**: aceite só
79
- * http(s), sem credenciais.
77
+ * `BUTTON_REDIRECT`: FIRST asks to open a link. `data.link` comes at the top of the message (or in
78
+ * `eventData`) and **may be missing or not a valid URL**. **Validate before opening**: accept only
79
+ * http(s), without credentials.
80
80
  */
81
81
  onRedirect?(data: FirstFrameRedirect): void;
82
- /** `SCROLL_TO_TOP`: o FIRST pede para rolar a página ao topo. */
82
+ /** `SCROLL_TO_TOP`: FIRST asks to scroll the page to the top. */
83
83
  onScrollToTop?(): void;
84
- /** Todo evento aceito, inclusive os que também têm handler dedicado. */
84
+ /** Every accepted event, including those that also have a dedicated handler. */
85
85
  onEvent?(eventType: string, eventData: unknown): void;
86
86
  }
87
87
  /**
88
- * Conexão com o iframe do FIRST.
88
+ * Connection to the FIRST iframe.
89
89
  * @category Sportsbook
90
90
  */
91
91
  interface FirstFrame {
92
92
  /**
93
- * Envia um evento ao iframe: `postMessage(JSON.stringify({ eventType, eventData }), origem)`, com a
94
- * origem do `src` (nunca `'*'`). Espere `onReady` antes de enviar: o FIRST só ouve depois de
95
- * carregar. Eventos que o FIRST entende: `sportId`, `leagueId`, `eventId` (`{ value: id }`),
93
+ * Sends an event to the iframe: `postMessage(JSON.stringify({ eventType, eventData }), origin)`, with the
94
+ * origin of the `src` (never `'*'`). Wait for `onReady` before sending: FIRST only listens after
95
+ * loading. Events FIRST understands: `sportId`, `leagueId`, `eventId` (`{ value: id }`),
96
96
  * `liveBetting`, `home` (`{ value: true }`), `betting-history`, `open-bets`, `expand-bet-slip`
97
- * (`{ value: boolean }`), `bscode` (`{ value: código }`) e `shareBetslip` (`{ url }`).
97
+ * (`{ value: boolean }`), `bscode` (`{ value: code }`) and `shareBetslip` (`{ url }`).
98
98
  * @example
99
99
  * frame.send('sportId', { value: '66' })
100
- * @throws {EnginexError} `CONFIGURATION_ERROR` se o `src` não tem origem http(s) válida, se o
101
- * iframe não tem `contentWindow` ou depois de `dispose()`.
100
+ * @throws {EnginexError} `CONFIGURATION_ERROR` if the `src` has no valid http(s) origin, if the
101
+ * iframe has no `contentWindow` or after `dispose()`.
102
102
  */
103
103
  send(eventType: string, eventData?: unknown): void;
104
- /** Remove o listener. Idempotente; depois disso nada é entregue e `send` lança. */
104
+ /** Removes the listener. Idempotent; after that nothing is delivered and `send` throws. */
105
105
  dispose(): void;
106
106
  }
107
107
  /**
108
- * Opções de {@link connectFirstFrame}.
108
+ * Options of {@link connectFirstFrame}.
109
109
  * @category Sportsbook
110
110
  */
111
111
  interface ConnectFirstFrameOptions {
112
- /** Janela onde ouvir `message`. Padrão: `globalThis` (a janela da página que contém o iframe). */
112
+ /** Window to listen for `message` on. Default: `globalThis` (the window of the page that contains the iframe). */
113
113
  window?: FirstFrameWindow;
114
114
  }
115
115
  /**
116
- * Conecta ao iframe do sportsbook FIRST: recebe os eventos do FIRST em handlers tipados e envia
117
- * comandos com `send`. Só entrega mensagens cuja `origin` é a origem do `src` do iframe **e** cuja
118
- * `source` é o `contentWindow` do iframe; JSON inválido ou sem `eventType` é ignorado sem lançar.
119
- * O payload chega como o FIRST o enviou (`unknown`): valide antes de usar.
116
+ * Connects to the FIRST sportsbook iframe: receives FIRST's events in typed handlers and sends
117
+ * commands with `send`. It only delivers messages whose `origin` is the `src` origin of the iframe **and** whose
118
+ * `source` is the iframe's `contentWindow`; invalid JSON or JSON without `eventType` is ignored without throwing.
119
+ * The payload arrives as FIRST sent it (`unknown`): validate before using it.
120
120
  * @example
121
121
  * import { connectFirstFrame } from '@getenginex/sdk-igaming/first-frame'
122
122
  *
@@ -124,10 +124,10 @@ interface ConnectFirstFrameOptions {
124
124
  * onBetPlaced: () => void enginex.wallet.getBalance().then(showBalance),
125
125
  * onLoginRequired: () => openLogin(),
126
126
  * })
127
- * // ao desmontar o iframe:
127
+ * // when unmounting the iframe:
128
128
  * frame.dispose()
129
- * @throws {EnginexError} `CONFIGURATION_ERROR` se a janela (`options.window` ou `globalThis`) não
130
- * tem `addEventListener`/`removeEventListener`.
129
+ * @throws {EnginexError} `CONFIGURATION_ERROR` if the window (`options.window` or `globalThis`) has no
130
+ * `addEventListener`/`removeEventListener`.
131
131
  * @category Sportsbook
132
132
  */
133
133
  declare function connectFirstFrame(iframe: FirstFrameTarget, handlers: FirstFrameHandlers, options?: ConnectFirstFrameOptions): FirstFrame;