@bemony/card-embed-react 0.2.0-next.0 → 0.2.0-next.2

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/README.md CHANGED
@@ -50,6 +50,26 @@ encaminhados ao SDK Web sem reinicializar o iframe.
50
50
  Os callbacks públicos incluem `onReady`, `onStateChange`, `onError`, `onSessionExpiring`,
51
51
  `onSessionExpired` e `onDestroyed`.
52
52
 
53
+ ## Bandeiras aceitas
54
+
55
+ O componente não recebe uma prop de bandeiras. A allowlist vem da CheckoutSession, é aplicada pelo
56
+ Card Frame e é a mesma do SDK Web. Uma projeção legada ausente ou inválida usa o fallback
57
+ `VISA` + `MASTERCARD`, sem habilitar outras redes. O callback `onStateChange` informa `brand?` e
58
+ `errors.number === 'CARD_BRAND_NOT_SUPPORTED'` quando o comprador digita uma bandeira fora da
59
+ configuração. Nesse caso `valid` é `false` e `ref.current.tokenize()` rejeita com o erro público
60
+ `CARD_BRAND_NOT_SUPPORTED` sem iniciar tokenização.
61
+
62
+ ```tsx
63
+ onStateChange={(state) => {
64
+ setCanContinue(state.valid && state.errors.number !== 'CARD_BRAND_NOT_SUPPORTED');
65
+ }}
66
+ ```
67
+
68
+ O adaptador não reclassifica erros. `onError` e a rejeição de `tokenize()` mantêm o mesmo
69
+ `CardEmbedError` entregue pelo SDK Web, inclusive `code`, `message`, `type`, `field`, `details`,
70
+ `retryable`, `requestId` e `httpStatus`. Cabe ao produto consumidor mapear esse contrato para a
71
+ mensagem apresentada ao comprador.
72
+
53
73
  O adapter usa um `AbortController` privado para cancelar montagens ainda pendentes no cleanup.
54
74
  Isso é necessário no Strict Mode do React, que executa um ciclo extra de efeito em
55
75
  desenvolvimento, e impede timeouts de uma instância que já foi descartada.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,uBAAuB,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;AAE1F,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,qBAAqB,EACrB,QAAQ,GAAG,qBAAqB,GAAG,QAAQ,CAC5C,GAAG;IACF,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAaF,eAAO,MAAM,eAAe;yBAdL,MAAM;yDA8G5B,CAAC;AAmBF,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,uBAAuB,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;AAE1F,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,qBAAqB,EACrB,QAAQ,GAAG,qBAAqB,GAAG,QAAQ,CAC5C,GAAG;IACF,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAaF,eAAO,MAAM,eAAe;yBAdL,MAAM;yDA8G5B,CAAC;AAUF,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { BemonyCardEmbed as WebCardEmbed } from '@bemony/card-embed';
2
+ import { BemonyCardEmbed as WebCardEmbed, normalizeCardEmbedError } from '@bemony/card-embed';
3
3
  import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
4
4
  export const BemonyCardEmbed = forwardRef(function BemonyCardEmbed({ sessionClientSecret, environment, layout, onDestroyed, onError, onFrameError, onReady, onSessionExpired, onSessionExpiring, onStateChange }, ref) {
5
5
  const targetRef = useRef(null);
@@ -80,12 +80,5 @@ function notReadyError() {
80
80
  return { code: 'INVALID_STATE', message: 'Card Embed is not ready.' };
81
81
  }
82
82
  function toPublicError(error) {
83
- if (typeof error === 'object' &&
84
- error !== null &&
85
- 'code' in error &&
86
- 'message' in error &&
87
- typeof error.code === 'string' &&
88
- typeof error.message === 'string')
89
- return { code: 'NETWORK_ERROR', message: error.message };
90
- return { code: 'NETWORK_ERROR', message: 'Card Embed could not be initialized.' };
83
+ return normalizeCardEmbedError(error);
91
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemony/card-embed-react",
3
- "version": "0.2.0-next.0",
3
+ "version": "0.2.0-next.2",
4
4
  "description": "Official React adapter for the secure Bemony Card Embed SDK.",
5
5
  "keywords": [
6
6
  "bemony",
@@ -35,7 +35,7 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@bemony/card-embed": "^0.2.0-next.0"
38
+ "@bemony/card-embed": "^0.2.0-next.2"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=19.0.0 <20.0.0",