@autra-io/react-native-card 0.1.0 → 0.1.1
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 +1 -1
- package/LICENSE +216 -21
- package/NOTICE +4 -0
- package/README.md +50 -42
- package/README.pt-BR.md +3 -3
- package/SECURITY.md +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -43,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
43
43
|
|
|
44
44
|
### Changed
|
|
45
45
|
|
|
46
|
-
- Package prepared for public release:
|
|
46
|
+
- Package prepared for public release: Apache-2.0 license, `publishConfig.access:
|
|
47
47
|
public`; publishing remains manual and gated (see `docs/platform.md`).
|
|
48
48
|
|
|
49
49
|
### Notes
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,216 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
Copyright 2026 Autra
|
|
205
|
+
|
|
206
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
207
|
+
you may not use this file except in compliance with the License.
|
|
208
|
+
You may obtain a copy of the License at
|
|
209
|
+
|
|
210
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
211
|
+
|
|
212
|
+
Unless required by applicable law or agreed to in writing, software
|
|
213
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
214
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
215
|
+
See the License for the specific language governing permissions and
|
|
216
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
React Native SDK for secure card tokenization via Autra's hosted card page.
|
|
4
4
|
**Card data never touches your app or your servers.**
|
|
5
5
|
|
|
6
|
-
[](./LICENSE)
|
|
8
|
-
<!-- Enable after the first npm publish:
|
|
6
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
9
7
|
[](https://www.npmjs.com/package/@autra-io/react-native-card)
|
|
10
|
-
-->
|
|
11
8
|
|
|
12
|
-
> 🇧🇷
|
|
13
|
-
>
|
|
9
|
+
> 🇧🇷 Uma versão em português deste guia (`README.pt-BR.md`) acompanha o
|
|
10
|
+
> pacote npm. Guias completos em português no portal do desenvolvedor
|
|
11
|
+
> <!-- PLACEHOLDER: developer portal URL -->
|
|
14
12
|
|
|
15
13
|
## Table of contents
|
|
16
14
|
|
|
@@ -24,7 +22,6 @@ React Native SDK for secure card tokenization via Autra's hosted card page.
|
|
|
24
22
|
- [Testing your integration](#testing-your-integration)
|
|
25
23
|
- [Troubleshooting](#troubleshooting)
|
|
26
24
|
- [Documentation](#documentation)
|
|
27
|
-
- [Contributing](#contributing)
|
|
28
25
|
- [Support](#support)
|
|
29
26
|
- [License](#license)
|
|
30
27
|
|
|
@@ -86,25 +83,41 @@ npm install @autra-io/react-native-card
|
|
|
86
83
|
|
|
87
84
|
## How it works
|
|
88
85
|
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
```text
|
|
87
|
+
Your app (SDK) Your backend Autra API Hosted card page
|
|
88
|
+
│ │ │ │
|
|
89
|
+
│ 1. request session │ │ │
|
|
90
|
+
│────────────────────▶│ 2. POST /v1/ │ │
|
|
91
|
+
│ │ acquiring/ │ │
|
|
92
|
+
│ │ card-sessions ─────▶│ │
|
|
93
|
+
│ hostedCardUrl │◀── hostedCardUrl ───│ │
|
|
94
|
+
│◀────────────────────│ (short-lived, │ │
|
|
95
|
+
│ │ single-use) │ │
|
|
96
|
+
│ 3. <AutraCardForm hostedCardUrl /> renders the page in a WebView│
|
|
97
|
+
│─────────────────────────────────────────────────────────────── ▶│
|
|
98
|
+
│ │ │ 4. cardholder types│
|
|
99
|
+
│ │ │ PAN/CVV here — │
|
|
100
|
+
│ │ │ never in the app│
|
|
101
|
+
│ │ │◀──── tokenize ──────│
|
|
102
|
+
│ │ │── token references ▶│
|
|
103
|
+
│◀──────────── 5. message: tokenized ───────────────────────────── │
|
|
104
|
+
│ 6. slugStoredCard │ │ │
|
|
105
|
+
│────────────────────▶│ (store server-side for future charges) │
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
1. Your app asks **your backend** for a card session.
|
|
109
|
+
2. Your backend calls the Autra API (`POST /v1/acquiring/card-sessions`,
|
|
110
|
+
service credentials — server-side only) and receives a short-lived,
|
|
111
|
+
single-use `hostedCardUrl`.
|
|
112
|
+
3. Your app renders `<AutraCardForm hostedCardUrl={...} />`, which loads the
|
|
113
|
+
Autra-hosted page in a hardened WebView.
|
|
114
|
+
4. The cardholder types PAN/CVV **on the hosted page**, which tokenizes
|
|
115
|
+
directly against Autra over HTTPS.
|
|
116
|
+
5. The SDK receives the result and calls `onSuccess` with opaque token
|
|
117
|
+
references.
|
|
118
|
+
6. Your app sends `slugStoredCard` to your backend, which stores it for
|
|
119
|
+
future charges.
|
|
120
|
+
|
|
108
121
|
Card data flows only between the cardholder and Autra's hosted page — it never
|
|
109
122
|
transits your app or backend. Your systems only ever see two opaque values:
|
|
110
123
|
the short-lived `hostedCardUrl` going in, and the `slugStoredCard` /
|
|
@@ -248,8 +261,11 @@ Version marker string, useful for support tickets and smoke tests.
|
|
|
248
261
|
- The WebView is hardened by default: HTTPS-only, navigation allow-list,
|
|
249
262
|
no mixed content, incognito, no disk cache, no file access.
|
|
250
263
|
|
|
251
|
-
Found a vulnerability?
|
|
252
|
-
public
|
|
264
|
+
Found a vulnerability? Report it privately to `security@autra.io`
|
|
265
|
+
<!-- PLACEHOLDER: confirm the public security contact email --> — never
|
|
266
|
+
|
|
267
|
+
through regular support channels. Full policy in the `SECURITY.md` file
|
|
268
|
+
shipped with this package.
|
|
253
269
|
|
|
254
270
|
## Testing your integration
|
|
255
271
|
|
|
@@ -257,10 +273,8 @@ public issue.
|
|
|
257
273
|
values only — never real card data.
|
|
258
274
|
<!-- PLACEHOLDER: sandbox test card numbers, if provided by the team -->
|
|
259
275
|
- For unit tests, inject your session-creation function and mock the WebView
|
|
260
|
-
bridge
|
|
261
|
-
|
|
262
|
-
for a complete reference harness driving `ready`, `tokenized` and `error`
|
|
263
|
-
flows with a mocked backend.
|
|
276
|
+
bridge: emit `autra.card.ready`, `autra.card.tokenized` and
|
|
277
|
+
`autra.card.error` messages against your handlers with mocked payloads.
|
|
264
278
|
|
|
265
279
|
## Troubleshooting
|
|
266
280
|
|
|
@@ -277,22 +291,16 @@ public issue.
|
|
|
277
291
|
|
|
278
292
|
## Documentation
|
|
279
293
|
|
|
280
|
-
- Integration guides: developer portal
|
|
294
|
+
- Integration guides (EN + PT-BR): developer portal
|
|
281
295
|
<!-- PLACEHOLDER: developer portal URL (EN + PT-BR) -->
|
|
282
|
-
- [Backend flow overview](./docs/integration/backend-flow.md)
|
|
283
|
-
- [SDK scope and limitations](./docs/integration/limitations.md)
|
|
284
|
-
|
|
285
|
-
## Contributing
|
|
286
|
-
|
|
287
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md). Never include real card data or
|
|
288
|
-
secrets in issues, PRs or examples.
|
|
289
296
|
|
|
290
297
|
## Support
|
|
291
298
|
|
|
292
|
-
-
|
|
293
|
-
|
|
294
|
-
|
|
299
|
+
- Integration support and bug reports: <!-- PLACEHOLDER: support channel/email -->
|
|
300
|
+
- Security vulnerabilities: `security@autra.io`
|
|
301
|
+
<!-- PLACEHOLDER: confirm the public security contact email --> — never
|
|
302
|
+
through regular support channels (see `SECURITY.md` in this package).
|
|
295
303
|
|
|
296
304
|
## License
|
|
297
305
|
|
|
298
|
-
|
|
306
|
+
Apache-2.0 — see the `LICENSE` file shipped with this package.
|
package/README.pt-BR.md
CHANGED
|
@@ -10,7 +10,7 @@ SDK React Native para tokenização segura de cartões via página hospedada da
|
|
|
10
10
|
Autra. **Os dados do cartão nunca passam pelo seu app nem pelos seus
|
|
11
11
|
servidores.**
|
|
12
12
|
|
|
13
|
-
> 🌎
|
|
13
|
+
> 🌎 `README.md` (in English) (documentação completa) ·
|
|
14
14
|
> Guias completos no portal do desenvolvedor
|
|
15
15
|
> <!-- PLACEHOLDER: URL do portal do desenvolvedor -->
|
|
16
16
|
|
|
@@ -126,8 +126,8 @@ export function AdicionarCartaoScreen() {
|
|
|
126
126
|
## Documentação completa
|
|
127
127
|
|
|
128
128
|
Referência completa da API, segurança & PCI, testes e troubleshooting:
|
|
129
|
-
|
|
129
|
+
o `README.md` (em inglês) que acompanha este pacote.
|
|
130
130
|
|
|
131
131
|
## Licença
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Apache-2.0 — veja o arquivo `LICENSE` que acompanha este pacote.
|
package/SECURITY.md
CHANGED
|
@@ -6,11 +6,11 @@ contributors (human and AI).
|
|
|
6
6
|
|
|
7
7
|
## Reporting a vulnerability
|
|
8
8
|
|
|
9
|
-
- **Do not**
|
|
10
|
-
- Report privately
|
|
11
|
-
[GitHub private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability)
|
|
12
|
-
on this repository, or by email to `security@autra.io`
|
|
9
|
+
- **Do not** report security vulnerabilities through regular support channels.
|
|
10
|
+
- Report privately by email to `security@autra.io`
|
|
13
11
|
<!-- PLACEHOLDER: confirm the public security contact email with the team -->.
|
|
12
|
+
(This repository is private, so GitHub vulnerability reporting is only
|
|
13
|
+
available to internal contributors.)
|
|
14
14
|
- Include: affected version/commit, impact, and reproduction steps using
|
|
15
15
|
**non-sensitive, mock data only**.
|
|
16
16
|
|
package/dist/index.cjs
CHANGED
|
@@ -333,7 +333,7 @@ function isHostedDocumentUrl(eventUrl, documentUrl) {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
// src/index.ts
|
|
336
|
-
var AUTRA_REACT_NATIVE_CARD_SDK_VERSION = "0.1.
|
|
336
|
+
var AUTRA_REACT_NATIVE_CARD_SDK_VERSION = "0.1.1";
|
|
337
337
|
|
|
338
338
|
exports.AUTRA_REACT_NATIVE_CARD_SDK_VERSION = AUTRA_REACT_NATIVE_CARD_SDK_VERSION;
|
|
339
339
|
exports.AutraCardForm = AutraCardForm;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/messages.ts","../src/AutraCardForm.ts","../src/index.ts"],"names":["React","WebView"],"mappings":";;;;;;;;;;;;AAeA,IAAM,UAAA,uBAAiB,GAAA,CAAwB;AAAA,EAC7C,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,yBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,mBAAA,GAAsC;AAAA,EAC1C,IAAA,EAAM,yBA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AAA,EACT;AAEA,EAAA,OAAO,cAAA,CAAe,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAC3C;AAEA,SAAS,mBAAA,CAAoB,UAA8B,WAAA,EAA8B;AACvF,EAAA,IAAI,aAAa,MAAA,EAAW;AAG1B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,QAAA;AAEJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,IAAI,QAAQ,CAAA;AACzB,IAAA,QAAA,GAAW,IAAI,IAAI,WAAW,CAAA;AAAA,EAChC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,CAAS,MAAA,IAAU,MAAA,CAAO,aAAa,QAAA,CAAS,QAAA;AAC3E;;;AC5SO,IAAM,mCAAA,GAAsC","file":"index.cjs","sourcesContent":["import type { AutraCardError, AutraCardErrorCode, AutraCardTokenizedResult } from './index';\n\nexport type AutraCardWebViewNativeMessage = {\n data: string;\n url?: string;\n};\n\nexport type AutraCardHostedMessage =\n | { type: 'tokenized'; result: AutraCardTokenizedResult }\n | { type: 'error'; error: AutraCardError }\n | { type: 'ready'; requestId?: string };\n\nexport type ParseAutraCardWebViewMessageResult =\n { ok: true; message: AutraCardHostedMessage } | { ok: false; error: AutraCardError };\n\nconst errorCodes = new Set<AutraCardErrorCode>([\n 'configuration_error',\n 'token_expired',\n 'message_origin_rejected',\n 'message_invalid',\n 'validation_error',\n 'tokenization_failed',\n]);\n\nconst originRejectedError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Rejected hosted card message origin.',\n retryable: false,\n};\n\nconst invalidMessageError: AutraCardError = {\n code: 'message_invalid',\n message: 'Invalid hosted card message.',\n retryable: false,\n};\n\nexport function deriveAllowedOrigins(cardBaseUrl: string): string[] {\n return [new URL(cardBaseUrl).origin];\n}\n\n/**\n * Normalizes a caller-supplied origin list into canonical HTTPS origins.\n *\n * Guards against silent lockouts: `['https://cards.example/']` (trailing\n * slash) never equals a browser-reported origin and would reject every\n * hosted message. Entries that are not valid HTTPS URLs are dropped —\n * postMessage trust must never be extended to plaintext origins.\n */\nexport function normalizeAllowedOrigins(origins: readonly string[]): string[] {\n const normalized: string[] = [];\n\n for (const candidate of origins) {\n let url: URL;\n\n try {\n url = new URL(candidate);\n } catch {\n continue;\n }\n\n if (url.protocol !== 'https:') {\n continue;\n }\n\n if (!normalized.includes(url.origin)) {\n normalized.push(url.origin);\n }\n }\n\n return normalized;\n}\n\nexport function parseAutraCardWebViewMessage(\n event: AutraCardWebViewNativeMessage,\n allowedOrigins: readonly string[],\n): ParseAutraCardWebViewMessageResult {\n const eventOrigin = toOrigin(event.url);\n\n if (eventOrigin === undefined || !allowedOrigins.includes(eventOrigin)) {\n return { ok: false, error: originRejectedError };\n }\n\n const rawMessage = parseJson(event.data);\n\n if (!isRecord(rawMessage)) {\n return { ok: false, error: invalidMessageError };\n }\n\n if (rawMessage.type === 'autra.card.tokenized' && isRecord(rawMessage.payload)) {\n const result = toTokenizedResult(rawMessage.payload);\n\n if (result !== undefined) {\n return { ok: true, message: { type: 'tokenized', result } };\n }\n }\n\n if (rawMessage.type === 'autra.card.error' && isRecord(rawMessage.error)) {\n const error = toAutraCardError(rawMessage.error);\n\n if (error !== undefined) {\n return { ok: true, message: { type: 'error', error } };\n }\n }\n\n if (rawMessage.type === 'autra.card.ready') {\n return {\n ok: true,\n message: {\n type: 'ready',\n requestId: optionalString(rawMessage.requestId),\n },\n };\n }\n\n return { ok: false, error: invalidMessageError };\n}\n\nfunction toOrigin(url: string | undefined): string | undefined {\n if (url === undefined) {\n return undefined;\n }\n\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJson(data: string): unknown {\n try {\n return JSON.parse(data) as unknown;\n } catch {\n return undefined;\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 optionalString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction toTokenizedResult(payload: Record<string, unknown>): AutraCardTokenizedResult | undefined {\n const storedCard = isRecord(payload.storedCard) ? payload.storedCard : undefined;\n const tokenizedCard = isRecord(payload.tokenizedCard) ? payload.tokenizedCard : undefined;\n\n const slugStoredCard =\n optionalString(payload.slugStoredCard) ?? optionalString(storedCard?.slugStoredCard);\n const slugToken = optionalString(payload.slugToken) ?? optionalString(tokenizedCard?.slugToken);\n const tokenExpirationDate =\n optionalString(payload.tokenExpirationDate) ??\n optionalString(tokenizedCard?.tokenExpirationDate);\n\n if (slugStoredCard === undefined && slugToken === undefined) {\n return undefined;\n }\n\n return {\n slugStoredCard,\n slugToken,\n tokenExpirationDate,\n brand: optionalString(payload.brand),\n last4: optionalString(payload.last4),\n expirationMonth: optionalString(payload.expirationMonth),\n expirationYear: optionalString(payload.expirationYear),\n requestId: optionalString(payload.requestId),\n };\n}\n\nfunction toAutraCardError(error: Record<string, unknown>): AutraCardError | undefined {\n if (typeof error.code !== 'string' || !isAutraCardErrorCode(error.code)) {\n return undefined;\n }\n\n if (typeof error.message !== 'string') {\n return undefined;\n }\n\n return {\n code: error.code,\n message: error.message,\n requestId: optionalString(error.requestId),\n retryable: typeof error.retryable === 'boolean' ? error.retryable : undefined,\n };\n}\n\nfunction isAutraCardErrorCode(code: string): code is AutraCardErrorCode {\n return errorCodes.has(code as AutraCardErrorCode);\n}\n","import React from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\nimport type { AutraCardError, AutraCardTokenizedResult } from './index';\nimport {\n deriveAllowedOrigins,\n normalizeAllowedOrigins,\n parseAutraCardWebViewMessage,\n type AutraCardWebViewNativeMessage,\n} from './messages';\n\nexport type AutraCardFormProps = {\n hostedCardUrl: string;\n onSuccess: (result: AutraCardTokenizedResult) => void;\n onError: (error: AutraCardError) => void;\n allowedOrigins?: readonly string[];\n onReady?: (requestId?: string) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\ntype WebViewMessageEvent = {\n nativeEvent: AutraCardWebViewNativeMessage;\n};\n\ntype WebViewHttpErrorEvent = {\n nativeEvent: {\n statusCode: number;\n url?: string;\n };\n};\n\ntype WebViewNavigationRequest = {\n url: string;\n};\n\ntype AutraCardWebViewProps = {\n source: {\n uri: string;\n };\n originWhitelist: string[];\n onMessage: (event: WebViewMessageEvent) => void;\n onError: () => void;\n onHttpError: (event: WebViewHttpErrorEvent) => void;\n onShouldStartLoadWithRequest: (request: WebViewNavigationRequest) => boolean;\n mixedContentMode: 'never';\n allowFileAccess: boolean;\n allowsBackForwardNavigationGestures: boolean;\n incognito: boolean;\n cacheEnabled: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\nconst hostedPageLoadError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page failed to load.',\n retryable: true,\n};\n\nconst hostedPageHttpError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page returned an HTTP error.',\n retryable: true,\n};\n\nconst hostedSessionUnauthorizedError: AutraCardError = {\n code: 'token_expired',\n message: 'Hosted card session expired or is not authorized.',\n retryable: false,\n};\n\nconst invalidHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Invalid hosted card URL.',\n retryable: false,\n};\n\nconst insecureHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Hosted card URL must use HTTPS.',\n retryable: false,\n};\n\nconst invalidAllowedOriginsError: AutraCardError = {\n code: 'configuration_error',\n message: 'allowedOrigins must contain at least one valid HTTPS origin.',\n retryable: false,\n};\n\nconst blockedNavigationError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Blocked hosted card navigation.',\n retryable: false,\n};\n\nexport function buildAutraCardTokenizeUrl(hostedCardUrl: string): string {\n return hostedCardUrl;\n}\n\ntype HostedCardConfiguration =\n | { ok: true; tokenizeUrl: string; allowedOrigins: readonly string[] }\n | { ok: false; error: AutraCardError };\n\nexport function AutraCardForm(props: AutraCardFormProps): React.ReactElement | null {\n // Key the memo by origin CONTENT so an inline `allowedOrigins={[...]}`\n // (new array identity every render) neither recomputes nor re-emits.\n const allowedOriginsKey = props.allowedOrigins?.join(' ');\n const configuration = React.useMemo<HostedCardConfiguration>(\n () => resolveHostedCardConfiguration(props.hostedCardUrl, props.allowedOrigins),\n // deps intentionally keyed by content (allowedOriginsKey), not array identity\n [props.hostedCardUrl, allowedOriginsKey],\n );\n\n // Terminal guard: once the hosted page reports a successful tokenization,\n // every later event (duplicate `tokenized`, stray errors, sub-frame noise)\n // is ignored so the consumer can never double-charge or double-navigate.\n const terminalRef = React.useRef(false);\n\n const onErrorRef = React.useRef(props.onError);\n React.useEffect(() => {\n onErrorRef.current = props.onError;\n });\n\n // Configuration errors are emitted from an effect: calling props.onError\n // during render would trigger a parent setState mid-render (React error\n // \"Cannot update a component while rendering a different component\") and\n // would re-fire on every re-render.\n React.useEffect(() => {\n if (!configuration.ok) {\n onErrorRef.current(configuration.error);\n }\n }, [configuration]);\n\n if (!configuration.ok) {\n return null;\n }\n\n const { tokenizeUrl, allowedOrigins } = configuration;\n\n const handleMessage = (event: WebViewMessageEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n const result = parseAutraCardWebViewMessage(event.nativeEvent, allowedOrigins);\n\n if (!result.ok) {\n props.onError(result.error);\n return;\n }\n\n if (result.message.type === 'tokenized') {\n terminalRef.current = true;\n props.onSuccess(result.message.result);\n return;\n }\n\n if (result.message.type === 'error') {\n props.onError(result.message.error);\n return;\n }\n\n props.onReady?.(result.message.requestId);\n };\n\n const handleHttpError = (event: WebViewHttpErrorEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n // On Android onHttpError also fires for sub-resources (favicon, assets,\n // page-initiated fetches). Only a failure of the hosted DOCUMENT itself\n // is fatal to the flow — the page reports its own API errors through the\n // postMessage channel.\n if (!isHostedDocumentUrl(event.nativeEvent.url, tokenizeUrl)) {\n return;\n }\n\n if (event.nativeEvent.statusCode === 401 || event.nativeEvent.statusCode === 403) {\n props.onError(hostedSessionUnauthorizedError);\n return;\n }\n\n props.onError(hostedPageHttpError);\n };\n\n const handleShouldStartLoadWithRequest = (request: WebViewNavigationRequest): boolean => {\n if (isAllowedHostedNavigation(request.url, allowedOrigins)) {\n return true;\n }\n\n if (!terminalRef.current) {\n props.onError(blockedNavigationError);\n }\n return false;\n };\n\n const WebViewComponent = WebView as unknown as React.ComponentType<AutraCardWebViewProps>;\n\n return React.createElement(WebViewComponent, {\n source: {\n uri: tokenizeUrl,\n },\n // Security: react-native-webview hands URLs that fail originWhitelist to\n // the OS (Linking.openURL) BEFORE onShouldStartLoadWithRequest runs — a\n // compromised hosted page could silently bounce the user to an external\n // browser (phishing surface). The payment-WebView hardening pattern is a\n // wildcard whitelist plus a full allowlist in\n // onShouldStartLoadWithRequest: returning false there blocks the\n // navigation WITHOUT opening it externally.\n originWhitelist: ['*'],\n onMessage: handleMessage,\n onError: () => {\n if (!terminalRef.current) {\n props.onError(hostedPageLoadError);\n }\n },\n onHttpError: handleHttpError,\n onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,\n mixedContentMode: 'never',\n allowFileAccess: false,\n allowsBackForwardNavigationGestures: false,\n // PCI hygiene: never persist the hosted card page (or anything typed in\n // it) to disk caches.\n incognito: true,\n cacheEnabled: false,\n style: props.style,\n testID: props.testID,\n });\n}\n\nfunction resolveHostedCardConfiguration(\n hostedCardUrl: string,\n allowedOriginsInput: readonly string[] | undefined,\n): HostedCardConfiguration {\n const parsedHostedCardUrl = parseHostedCardUrl(hostedCardUrl);\n\n if (!parsedHostedCardUrl.ok) {\n return parsedHostedCardUrl;\n }\n\n // Normalization guards against silent lockouts: an entry with a trailing\n // slash/path (`https://cards.example/`) would never equal a browser origin\n // and would reject every hosted message. Non-HTTPS entries are dropped.\n const allowedOrigins = normalizeAllowedOrigins(\n allowedOriginsInput ?? deriveAllowedOrigins(hostedCardUrl),\n );\n\n if (allowedOrigins.length === 0) {\n return { ok: false, error: invalidAllowedOriginsError };\n }\n\n return {\n ok: true,\n tokenizeUrl: buildAutraCardTokenizeUrl(hostedCardUrl),\n allowedOrigins,\n };\n}\n\nfunction parseHostedCardUrl(\n hostedCardUrl: string,\n): { ok: true; url: URL } | { ok: false; error: AutraCardError } {\n let url: URL;\n\n try {\n url = new URL(hostedCardUrl);\n } catch {\n return { ok: false, error: invalidHostedUrlError };\n }\n\n if (url.protocol !== 'https:') {\n return { ok: false, error: insecureHostedUrlError };\n }\n\n return { ok: true, url };\n}\n\nfunction isAllowedHostedNavigation(\n navigationUrl: string,\n allowedOrigins: readonly string[],\n): boolean {\n let url: URL;\n\n try {\n url = new URL(navigationUrl);\n } catch {\n return false;\n }\n\n if (url.protocol !== 'https:') {\n return false;\n }\n\n return allowedOrigins.includes(url.origin);\n}\n\nfunction isHostedDocumentUrl(eventUrl: string | undefined, documentUrl: string): boolean {\n if (eventUrl === undefined) {\n // Older react-native-webview versions omit the URL — stay conservative\n // and treat the failure as fatal rather than silently swallowing it.\n return true;\n }\n\n let failed: URL;\n let document: URL;\n\n try {\n failed = new URL(eventUrl);\n document = new URL(documentUrl);\n } catch {\n return true;\n }\n\n return failed.origin === document.origin && failed.pathname === document.pathname;\n}\n","/**\n * @autra-io/react-native-card — hosted card tokenization SDK exports.\n *\n * Phase: v0 hosted-WebView tokenization. The SDK owns only the React Native\n * component shell and message bridge; the hosted card page owns PAN/CVV entry.\n *\n * Security (payment-adjacent SDK):\n * - Never embed or log PAN, CVV, expiry or cardholder data.\n * - Never place OAuth clientSecret or a strong accessToken in the app.\n * - The mobile context must only ever load a short-lived hostedCardUrl.\n */\n\nexport { AutraCardForm } from './AutraCardForm';\nexport type { AutraCardFormProps } from './AutraCardForm';\n\n/** Semantic version marker for the v0 implementation phase. */\nexport const AUTRA_REACT_NATIVE_CARD_SDK_VERSION = '0.1.0';\n\n/**\n * Result returned by a successful card tokenization.\n * `slugStoredCard` is the opaque reference the backend uses to charge later.\n * Never populate this with raw PAN/CVV; only tokenized/masked references.\n */\nexport type AutraCardTokenizedResult = {\n slugStoredCard?: string;\n slugToken?: string;\n tokenExpirationDate?: string;\n brand?: string;\n last4?: string;\n expirationMonth?: string;\n expirationYear?: string;\n requestId?: string;\n};\n\n/** Normalized v0 error code taxonomy surfaced by the SDK. */\nexport type AutraCardErrorCode =\n | 'configuration_error'\n | 'token_expired'\n | 'message_origin_rejected'\n | 'message_invalid'\n | 'validation_error'\n | 'tokenization_failed';\n\nexport type AutraCardError = {\n code: AutraCardErrorCode;\n message: string;\n requestId?: string;\n retryable?: boolean;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/messages.ts","../src/AutraCardForm.ts","../src/index.ts"],"names":["React","WebView"],"mappings":";;;;;;;;;;;;AAeA,IAAM,UAAA,uBAAiB,GAAA,CAAwB;AAAA,EAC7C,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,yBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,mBAAA,GAAsC;AAAA,EAC1C,IAAA,EAAM,yBAAA;AAAA,EACN,OAAA,EAAS,sCAAA;AAAA,EACT,SAAA,EAAW;AACb,CAAA;AAEA,IAAM,mBAAA,GAAsC;AAAA,EAC1C,IAAA,EAAM,iBAAA;AAAA,EACN,OAAA,EAAS,8BAAA;AAAA,EACT,SAAA,EAAW;AACb,CAAA;AAEO,SAAS,qBAAqB,WAAA,EAA+B;AAClE,EAAA,OAAO,CAAC,IAAI,GAAA,CAAI,WAAW,EAAE,MAAM,CAAA;AACrC;AAUO,SAAS,wBAAwB,OAAA,EAAsC;AAC5E,EAAA,MAAM,aAAuB,EAAC;AAE9B,EAAA,KAAA,MAAW,aAAa,OAAA,EAAS;AAC/B,IAAA,IAAI,GAAA;AAEJ,IAAA,IAAI;AACF,MAAA,GAAA,GAAM,IAAI,IAAI,SAAS,CAAA;AAAA,IACzB,CAAA,CAAA,MAA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A;AAC3E;;;ACxSO,IAAM,mCAAA,GAAsC","file":"index.cjs","sourcesContent":["import type { AutraCardError, AutraCardErrorCode, AutraCardTokenizedResult } from './index';\n\nexport type AutraCardWebViewNativeMessage = {\n data: string;\n url?: string;\n};\n\nexport type AutraCardHostedMessage =\n | { type: 'tokenized'; result: AutraCardTokenizedResult }\n | { type: 'error'; error: AutraCardError }\n | { type: 'ready'; requestId?: string };\n\nexport type ParseAutraCardWebViewMessageResult =\n { ok: true; message: AutraCardHostedMessage } | { ok: false; error: AutraCardError };\n\nconst errorCodes = new Set<AutraCardErrorCode>([\n 'configuration_error',\n 'token_expired',\n 'message_origin_rejected',\n 'message_invalid',\n 'validation_error',\n 'tokenization_failed',\n]);\n\nconst originRejectedError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Rejected hosted card message origin.',\n retryable: false,\n};\n\nconst invalidMessageError: AutraCardError = {\n code: 'message_invalid',\n message: 'Invalid hosted card message.',\n retryable: false,\n};\n\nexport function deriveAllowedOrigins(cardBaseUrl: string): string[] {\n return [new URL(cardBaseUrl).origin];\n}\n\n/**\n * Normalizes a caller-supplied origin list into canonical HTTPS origins.\n *\n * Guards against silent lockouts: `['https://cards.example/']` (trailing\n * slash) never equals a browser-reported origin and would reject every\n * hosted message. Entries that are not valid HTTPS URLs are dropped —\n * postMessage trust must never be extended to plaintext origins.\n */\nexport function normalizeAllowedOrigins(origins: readonly string[]): string[] {\n const normalized: string[] = [];\n\n for (const candidate of origins) {\n let url: URL;\n\n try {\n url = new URL(candidate);\n } catch {\n continue;\n }\n\n if (url.protocol !== 'https:') {\n continue;\n }\n\n if (!normalized.includes(url.origin)) {\n normalized.push(url.origin);\n }\n }\n\n return normalized;\n}\n\nexport function parseAutraCardWebViewMessage(\n event: AutraCardWebViewNativeMessage,\n allowedOrigins: readonly string[],\n): ParseAutraCardWebViewMessageResult {\n const eventOrigin = toOrigin(event.url);\n\n if (eventOrigin === undefined || !allowedOrigins.includes(eventOrigin)) {\n return { ok: false, error: originRejectedError };\n }\n\n const rawMessage = parseJson(event.data);\n\n if (!isRecord(rawMessage)) {\n return { ok: false, error: invalidMessageError };\n }\n\n if (rawMessage.type === 'autra.card.tokenized' && isRecord(rawMessage.payload)) {\n const result = toTokenizedResult(rawMessage.payload);\n\n if (result !== undefined) {\n return { ok: true, message: { type: 'tokenized', result } };\n }\n }\n\n if (rawMessage.type === 'autra.card.error' && isRecord(rawMessage.error)) {\n const error = toAutraCardError(rawMessage.error);\n\n if (error !== undefined) {\n return { ok: true, message: { type: 'error', error } };\n }\n }\n\n if (rawMessage.type === 'autra.card.ready') {\n return {\n ok: true,\n message: {\n type: 'ready',\n requestId: optionalString(rawMessage.requestId),\n },\n };\n }\n\n return { ok: false, error: invalidMessageError };\n}\n\nfunction toOrigin(url: string | undefined): string | undefined {\n if (url === undefined) {\n return undefined;\n }\n\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJson(data: string): unknown {\n try {\n return JSON.parse(data) as unknown;\n } catch {\n return undefined;\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 optionalString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction toTokenizedResult(payload: Record<string, unknown>): AutraCardTokenizedResult | undefined {\n const storedCard = isRecord(payload.storedCard) ? payload.storedCard : undefined;\n const tokenizedCard = isRecord(payload.tokenizedCard) ? payload.tokenizedCard : undefined;\n\n const slugStoredCard =\n optionalString(payload.slugStoredCard) ?? optionalString(storedCard?.slugStoredCard);\n const slugToken = optionalString(payload.slugToken) ?? optionalString(tokenizedCard?.slugToken);\n const tokenExpirationDate =\n optionalString(payload.tokenExpirationDate) ??\n optionalString(tokenizedCard?.tokenExpirationDate);\n\n if (slugStoredCard === undefined && slugToken === undefined) {\n return undefined;\n }\n\n return {\n slugStoredCard,\n slugToken,\n tokenExpirationDate,\n brand: optionalString(payload.brand),\n last4: optionalString(payload.last4),\n expirationMonth: optionalString(payload.expirationMonth),\n expirationYear: optionalString(payload.expirationYear),\n requestId: optionalString(payload.requestId),\n };\n}\n\nfunction toAutraCardError(error: Record<string, unknown>): AutraCardError | undefined {\n if (typeof error.code !== 'string' || !isAutraCardErrorCode(error.code)) {\n return undefined;\n }\n\n if (typeof error.message !== 'string') {\n return undefined;\n }\n\n return {\n code: error.code,\n message: error.message,\n requestId: optionalString(error.requestId),\n retryable: typeof error.retryable === 'boolean' ? error.retryable : undefined,\n };\n}\n\nfunction isAutraCardErrorCode(code: string): code is AutraCardErrorCode {\n return errorCodes.has(code as AutraCardErrorCode);\n}\n","import React from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\nimport type { AutraCardError, AutraCardTokenizedResult } from './index';\nimport {\n deriveAllowedOrigins,\n normalizeAllowedOrigins,\n parseAutraCardWebViewMessage,\n type AutraCardWebViewNativeMessage,\n} from './messages';\n\nexport type AutraCardFormProps = {\n hostedCardUrl: string;\n onSuccess: (result: AutraCardTokenizedResult) => void;\n onError: (error: AutraCardError) => void;\n allowedOrigins?: readonly string[];\n onReady?: (requestId?: string) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\ntype WebViewMessageEvent = {\n nativeEvent: AutraCardWebViewNativeMessage;\n};\n\ntype WebViewHttpErrorEvent = {\n nativeEvent: {\n statusCode: number;\n url?: string;\n };\n};\n\ntype WebViewNavigationRequest = {\n url: string;\n};\n\ntype AutraCardWebViewProps = {\n source: {\n uri: string;\n };\n originWhitelist: string[];\n onMessage: (event: WebViewMessageEvent) => void;\n onError: () => void;\n onHttpError: (event: WebViewHttpErrorEvent) => void;\n onShouldStartLoadWithRequest: (request: WebViewNavigationRequest) => boolean;\n mixedContentMode: 'never';\n allowFileAccess: boolean;\n allowsBackForwardNavigationGestures: boolean;\n incognito: boolean;\n cacheEnabled: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\nconst hostedPageLoadError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page failed to load.',\n retryable: true,\n};\n\nconst hostedPageHttpError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page returned an HTTP error.',\n retryable: true,\n};\n\nconst hostedSessionUnauthorizedError: AutraCardError = {\n code: 'token_expired',\n message: 'Hosted card session expired or is not authorized.',\n retryable: false,\n};\n\nconst invalidHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Invalid hosted card URL.',\n retryable: false,\n};\n\nconst insecureHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Hosted card URL must use HTTPS.',\n retryable: false,\n};\n\nconst invalidAllowedOriginsError: AutraCardError = {\n code: 'configuration_error',\n message: 'allowedOrigins must contain at least one valid HTTPS origin.',\n retryable: false,\n};\n\nconst blockedNavigationError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Blocked hosted card navigation.',\n retryable: false,\n};\n\nexport function buildAutraCardTokenizeUrl(hostedCardUrl: string): string {\n return hostedCardUrl;\n}\n\ntype HostedCardConfiguration =\n | { ok: true; tokenizeUrl: string; allowedOrigins: readonly string[] }\n | { ok: false; error: AutraCardError };\n\nexport function AutraCardForm(props: AutraCardFormProps): React.ReactElement | null {\n // Key the memo by origin CONTENT so an inline `allowedOrigins={[...]}`\n // (new array identity every render) neither recomputes nor re-emits.\n const allowedOriginsKey = props.allowedOrigins?.join(' ');\n const configuration = React.useMemo<HostedCardConfiguration>(\n () => resolveHostedCardConfiguration(props.hostedCardUrl, props.allowedOrigins),\n // deps intentionally keyed by content (allowedOriginsKey), not array identity\n [props.hostedCardUrl, allowedOriginsKey],\n );\n\n // Terminal guard: once the hosted page reports a successful tokenization,\n // every later event (duplicate `tokenized`, stray errors, sub-frame noise)\n // is ignored so the consumer can never double-charge or double-navigate.\n const terminalRef = React.useRef(false);\n\n const onErrorRef = React.useRef(props.onError);\n React.useEffect(() => {\n onErrorRef.current = props.onError;\n });\n\n // Configuration errors are emitted from an effect: calling props.onError\n // during render would trigger a parent setState mid-render (React error\n // \"Cannot update a component while rendering a different component\") and\n // would re-fire on every re-render.\n React.useEffect(() => {\n if (!configuration.ok) {\n onErrorRef.current(configuration.error);\n }\n }, [configuration]);\n\n if (!configuration.ok) {\n return null;\n }\n\n const { tokenizeUrl, allowedOrigins } = configuration;\n\n const handleMessage = (event: WebViewMessageEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n const result = parseAutraCardWebViewMessage(event.nativeEvent, allowedOrigins);\n\n if (!result.ok) {\n props.onError(result.error);\n return;\n }\n\n if (result.message.type === 'tokenized') {\n terminalRef.current = true;\n props.onSuccess(result.message.result);\n return;\n }\n\n if (result.message.type === 'error') {\n props.onError(result.message.error);\n return;\n }\n\n props.onReady?.(result.message.requestId);\n };\n\n const handleHttpError = (event: WebViewHttpErrorEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n // On Android onHttpError also fires for sub-resources (favicon, assets,\n // page-initiated fetches). Only a failure of the hosted DOCUMENT itself\n // is fatal to the flow — the page reports its own API errors through the\n // postMessage channel.\n if (!isHostedDocumentUrl(event.nativeEvent.url, tokenizeUrl)) {\n return;\n }\n\n if (event.nativeEvent.statusCode === 401 || event.nativeEvent.statusCode === 403) {\n props.onError(hostedSessionUnauthorizedError);\n return;\n }\n\n props.onError(hostedPageHttpError);\n };\n\n const handleShouldStartLoadWithRequest = (request: WebViewNavigationRequest): boolean => {\n if (isAllowedHostedNavigation(request.url, allowedOrigins)) {\n return true;\n }\n\n if (!terminalRef.current) {\n props.onError(blockedNavigationError);\n }\n return false;\n };\n\n const WebViewComponent = WebView as unknown as React.ComponentType<AutraCardWebViewProps>;\n\n return React.createElement(WebViewComponent, {\n source: {\n uri: tokenizeUrl,\n },\n // Security: react-native-webview hands URLs that fail originWhitelist to\n // the OS (Linking.openURL) BEFORE onShouldStartLoadWithRequest runs — a\n // compromised hosted page could silently bounce the user to an external\n // browser (phishing surface). The payment-WebView hardening pattern is a\n // wildcard whitelist plus a full allowlist in\n // onShouldStartLoadWithRequest: returning false there blocks the\n // navigation WITHOUT opening it externally.\n originWhitelist: ['*'],\n onMessage: handleMessage,\n onError: () => {\n if (!terminalRef.current) {\n props.onError(hostedPageLoadError);\n }\n },\n onHttpError: handleHttpError,\n onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,\n mixedContentMode: 'never',\n allowFileAccess: false,\n allowsBackForwardNavigationGestures: false,\n // PCI hygiene: never persist the hosted card page (or anything typed in\n // it) to disk caches.\n incognito: true,\n cacheEnabled: false,\n style: props.style,\n testID: props.testID,\n });\n}\n\nfunction resolveHostedCardConfiguration(\n hostedCardUrl: string,\n allowedOriginsInput: readonly string[] | undefined,\n): HostedCardConfiguration {\n const parsedHostedCardUrl = parseHostedCardUrl(hostedCardUrl);\n\n if (!parsedHostedCardUrl.ok) {\n return parsedHostedCardUrl;\n }\n\n // Normalization guards against silent lockouts: an entry with a trailing\n // slash/path (`https://cards.example/`) would never equal a browser origin\n // and would reject every hosted message. Non-HTTPS entries are dropped.\n const allowedOrigins = normalizeAllowedOrigins(\n allowedOriginsInput ?? deriveAllowedOrigins(hostedCardUrl),\n );\n\n if (allowedOrigins.length === 0) {\n return { ok: false, error: invalidAllowedOriginsError };\n }\n\n return {\n ok: true,\n tokenizeUrl: buildAutraCardTokenizeUrl(hostedCardUrl),\n allowedOrigins,\n };\n}\n\nfunction parseHostedCardUrl(\n hostedCardUrl: string,\n): { ok: true; url: URL } | { ok: false; error: AutraCardError } {\n let url: URL;\n\n try {\n url = new URL(hostedCardUrl);\n } catch {\n return { ok: false, error: invalidHostedUrlError };\n }\n\n if (url.protocol !== 'https:') {\n return { ok: false, error: insecureHostedUrlError };\n }\n\n return { ok: true, url };\n}\n\nfunction isAllowedHostedNavigation(\n navigationUrl: string,\n allowedOrigins: readonly string[],\n): boolean {\n let url: URL;\n\n try {\n url = new URL(navigationUrl);\n } catch {\n return false;\n }\n\n if (url.protocol !== 'https:') {\n return false;\n }\n\n return allowedOrigins.includes(url.origin);\n}\n\nfunction isHostedDocumentUrl(eventUrl: string | undefined, documentUrl: string): boolean {\n if (eventUrl === undefined) {\n // Older react-native-webview versions omit the URL — stay conservative\n // and treat the failure as fatal rather than silently swallowing it.\n return true;\n }\n\n let failed: URL;\n let document: URL;\n\n try {\n failed = new URL(eventUrl);\n document = new URL(documentUrl);\n } catch {\n return true;\n }\n\n return failed.origin === document.origin && failed.pathname === document.pathname;\n}\n","/**\n * @autra-io/react-native-card — hosted card tokenization SDK exports.\n *\n * Phase: v0 hosted-WebView tokenization. The SDK owns only the React Native\n * component shell and message bridge; the hosted card page owns PAN/CVV entry.\n *\n * Security (payment-adjacent SDK):\n * - Never embed or log PAN, CVV, expiry or cardholder data.\n * - Never place OAuth clientSecret or a strong accessToken in the app.\n * - The mobile context must only ever load a short-lived hostedCardUrl.\n */\n\nexport { AutraCardForm } from './AutraCardForm';\nexport type { AutraCardFormProps } from './AutraCardForm';\n\n// Injected at build time from package.json (see tsup.config.ts /\n// vitest.config.ts) so the constant always matches the published version.\ndeclare const __AUTRA_SDK_VERSION__: string;\n\n/** The published package version of this SDK build. */\nexport const AUTRA_REACT_NATIVE_CARD_SDK_VERSION = __AUTRA_SDK_VERSION__;\n\n/**\n * Result returned by a successful card tokenization.\n * `slugStoredCard` is the opaque reference the backend uses to charge later.\n * Never populate this with raw PAN/CVV; only tokenized/masked references.\n */\nexport type AutraCardTokenizedResult = {\n slugStoredCard?: string;\n slugToken?: string;\n tokenExpirationDate?: string;\n brand?: string;\n last4?: string;\n expirationMonth?: string;\n expirationYear?: string;\n requestId?: string;\n};\n\n/** Normalized v0 error code taxonomy surfaced by the SDK. */\nexport type AutraCardErrorCode =\n | 'configuration_error'\n | 'token_expired'\n | 'message_origin_rejected'\n | 'message_invalid'\n | 'validation_error'\n | 'tokenization_failed';\n\nexport type AutraCardError = {\n code: AutraCardErrorCode;\n message: string;\n requestId?: string;\n retryable?: boolean;\n};\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -24,8 +24,8 @@ declare function AutraCardForm(props: AutraCardFormProps): React.ReactElement |
|
|
|
24
24
|
* - The mobile context must only ever load a short-lived hostedCardUrl.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
declare const AUTRA_REACT_NATIVE_CARD_SDK_VERSION
|
|
27
|
+
/** The published package version of this SDK build. */
|
|
28
|
+
declare const AUTRA_REACT_NATIVE_CARD_SDK_VERSION: string;
|
|
29
29
|
/**
|
|
30
30
|
* Result returned by a successful card tokenization.
|
|
31
31
|
* `slugStoredCard` is the opaque reference the backend uses to charge later.
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ declare function AutraCardForm(props: AutraCardFormProps): React.ReactElement |
|
|
|
24
24
|
* - The mobile context must only ever load a short-lived hostedCardUrl.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
declare const AUTRA_REACT_NATIVE_CARD_SDK_VERSION
|
|
27
|
+
/** The published package version of this SDK build. */
|
|
28
|
+
declare const AUTRA_REACT_NATIVE_CARD_SDK_VERSION: string;
|
|
29
29
|
/**
|
|
30
30
|
* Result returned by a successful card tokenization.
|
|
31
31
|
* `slugStoredCard` is the opaque reference the backend uses to charge later.
|
package/dist/index.js
CHANGED
|
@@ -327,7 +327,7 @@ function isHostedDocumentUrl(eventUrl, documentUrl) {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
// src/index.ts
|
|
330
|
-
var AUTRA_REACT_NATIVE_CARD_SDK_VERSION = "0.1.
|
|
330
|
+
var AUTRA_REACT_NATIVE_CARD_SDK_VERSION = "0.1.1";
|
|
331
331
|
|
|
332
332
|
export { AUTRA_REACT_NATIVE_CARD_SDK_VERSION, AutraCardForm };
|
|
333
333
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/messages.ts","../src/AutraCardForm.ts","../src/index.ts"],"names":[],"mappings":";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,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,IAAI,IAAI,aAAa,CAAA;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,GAAA,CAAI,aAAa,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,cAAA,CAAe,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAC3C;AAEA,SAAS,mBAAA,CAAoB,UAA8B,WAAA,EAA8B;AACvF,EAAA,IAAI,aAAa,MAAA,EAAW;AAG1B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,QAAA;AAEJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,IAAI,QAAQ,CAAA;AACzB,IAAA,QAAA,GAAW,IAAI,IAAI,WAAW,CAAA;AAAA,EAChC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,CAAS,MAAA,IAAU,MAAA,CAAO,aAAa,QAAA,CAAS,QAAA;AAC3E;;;AC5SO,IAAM,mCAAA,GAAsC","file":"index.js","sourcesContent":["import type { AutraCardError, AutraCardErrorCode, AutraCardTokenizedResult } from './index';\n\nexport type AutraCardWebViewNativeMessage = {\n data: string;\n url?: string;\n};\n\nexport type AutraCardHostedMessage =\n | { type: 'tokenized'; result: AutraCardTokenizedResult }\n | { type: 'error'; error: AutraCardError }\n | { type: 'ready'; requestId?: string };\n\nexport type ParseAutraCardWebViewMessageResult =\n { ok: true; message: AutraCardHostedMessage } | { ok: false; error: AutraCardError };\n\nconst errorCodes = new Set<AutraCardErrorCode>([\n 'configuration_error',\n 'token_expired',\n 'message_origin_rejected',\n 'message_invalid',\n 'validation_error',\n 'tokenization_failed',\n]);\n\nconst originRejectedError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Rejected hosted card message origin.',\n retryable: false,\n};\n\nconst invalidMessageError: AutraCardError = {\n code: 'message_invalid',\n message: 'Invalid hosted card message.',\n retryable: false,\n};\n\nexport function deriveAllowedOrigins(cardBaseUrl: string): string[] {\n return [new URL(cardBaseUrl).origin];\n}\n\n/**\n * Normalizes a caller-supplied origin list into canonical HTTPS origins.\n *\n * Guards against silent lockouts: `['https://cards.example/']` (trailing\n * slash) never equals a browser-reported origin and would reject every\n * hosted message. Entries that are not valid HTTPS URLs are dropped —\n * postMessage trust must never be extended to plaintext origins.\n */\nexport function normalizeAllowedOrigins(origins: readonly string[]): string[] {\n const normalized: string[] = [];\n\n for (const candidate of origins) {\n let url: URL;\n\n try {\n url = new URL(candidate);\n } catch {\n continue;\n }\n\n if (url.protocol !== 'https:') {\n continue;\n }\n\n if (!normalized.includes(url.origin)) {\n normalized.push(url.origin);\n }\n }\n\n return normalized;\n}\n\nexport function parseAutraCardWebViewMessage(\n event: AutraCardWebViewNativeMessage,\n allowedOrigins: readonly string[],\n): ParseAutraCardWebViewMessageResult {\n const eventOrigin = toOrigin(event.url);\n\n if (eventOrigin === undefined || !allowedOrigins.includes(eventOrigin)) {\n return { ok: false, error: originRejectedError };\n }\n\n const rawMessage = parseJson(event.data);\n\n if (!isRecord(rawMessage)) {\n return { ok: false, error: invalidMessageError };\n }\n\n if (rawMessage.type === 'autra.card.tokenized' && isRecord(rawMessage.payload)) {\n const result = toTokenizedResult(rawMessage.payload);\n\n if (result !== undefined) {\n return { ok: true, message: { type: 'tokenized', result } };\n }\n }\n\n if (rawMessage.type === 'autra.card.error' && isRecord(rawMessage.error)) {\n const error = toAutraCardError(rawMessage.error);\n\n if (error !== undefined) {\n return { ok: true, message: { type: 'error', error } };\n }\n }\n\n if (rawMessage.type === 'autra.card.ready') {\n return {\n ok: true,\n message: {\n type: 'ready',\n requestId: optionalString(rawMessage.requestId),\n },\n };\n }\n\n return { ok: false, error: invalidMessageError };\n}\n\nfunction toOrigin(url: string | undefined): string | undefined {\n if (url === undefined) {\n return undefined;\n }\n\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJson(data: string): unknown {\n try {\n return JSON.parse(data) as unknown;\n } catch {\n return undefined;\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 optionalString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction toTokenizedResult(payload: Record<string, unknown>): AutraCardTokenizedResult | undefined {\n const storedCard = isRecord(payload.storedCard) ? payload.storedCard : undefined;\n const tokenizedCard = isRecord(payload.tokenizedCard) ? payload.tokenizedCard : undefined;\n\n const slugStoredCard =\n optionalString(payload.slugStoredCard) ?? optionalString(storedCard?.slugStoredCard);\n const slugToken = optionalString(payload.slugToken) ?? optionalString(tokenizedCard?.slugToken);\n const tokenExpirationDate =\n optionalString(payload.tokenExpirationDate) ??\n optionalString(tokenizedCard?.tokenExpirationDate);\n\n if (slugStoredCard === undefined && slugToken === undefined) {\n return undefined;\n }\n\n return {\n slugStoredCard,\n slugToken,\n tokenExpirationDate,\n brand: optionalString(payload.brand),\n last4: optionalString(payload.last4),\n expirationMonth: optionalString(payload.expirationMonth),\n expirationYear: optionalString(payload.expirationYear),\n requestId: optionalString(payload.requestId),\n };\n}\n\nfunction toAutraCardError(error: Record<string, unknown>): AutraCardError | undefined {\n if (typeof error.code !== 'string' || !isAutraCardErrorCode(error.code)) {\n return undefined;\n }\n\n if (typeof error.message !== 'string') {\n return undefined;\n }\n\n return {\n code: error.code,\n message: error.message,\n requestId: optionalString(error.requestId),\n retryable: typeof error.retryable === 'boolean' ? error.retryable : undefined,\n };\n}\n\nfunction isAutraCardErrorCode(code: string): code is AutraCardErrorCode {\n return errorCodes.has(code as AutraCardErrorCode);\n}\n","import React from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\nimport type { AutraCardError, AutraCardTokenizedResult } from './index';\nimport {\n deriveAllowedOrigins,\n normalizeAllowedOrigins,\n parseAutraCardWebViewMessage,\n type AutraCardWebViewNativeMessage,\n} from './messages';\n\nexport type AutraCardFormProps = {\n hostedCardUrl: string;\n onSuccess: (result: AutraCardTokenizedResult) => void;\n onError: (error: AutraCardError) => void;\n allowedOrigins?: readonly string[];\n onReady?: (requestId?: string) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\ntype WebViewMessageEvent = {\n nativeEvent: AutraCardWebViewNativeMessage;\n};\n\ntype WebViewHttpErrorEvent = {\n nativeEvent: {\n statusCode: number;\n url?: string;\n };\n};\n\ntype WebViewNavigationRequest = {\n url: string;\n};\n\ntype AutraCardWebViewProps = {\n source: {\n uri: string;\n };\n originWhitelist: string[];\n onMessage: (event: WebViewMessageEvent) => void;\n onError: () => void;\n onHttpError: (event: WebViewHttpErrorEvent) => void;\n onShouldStartLoadWithRequest: (request: WebViewNavigationRequest) => boolean;\n mixedContentMode: 'never';\n allowFileAccess: boolean;\n allowsBackForwardNavigationGestures: boolean;\n incognito: boolean;\n cacheEnabled: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\nconst hostedPageLoadError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page failed to load.',\n retryable: true,\n};\n\nconst hostedPageHttpError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page returned an HTTP error.',\n retryable: true,\n};\n\nconst hostedSessionUnauthorizedError: AutraCardError = {\n code: 'token_expired',\n message: 'Hosted card session expired or is not authorized.',\n retryable: false,\n};\n\nconst invalidHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Invalid hosted card URL.',\n retryable: false,\n};\n\nconst insecureHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Hosted card URL must use HTTPS.',\n retryable: false,\n};\n\nconst invalidAllowedOriginsError: AutraCardError = {\n code: 'configuration_error',\n message: 'allowedOrigins must contain at least one valid HTTPS origin.',\n retryable: false,\n};\n\nconst blockedNavigationError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Blocked hosted card navigation.',\n retryable: false,\n};\n\nexport function buildAutraCardTokenizeUrl(hostedCardUrl: string): string {\n return hostedCardUrl;\n}\n\ntype HostedCardConfiguration =\n | { ok: true; tokenizeUrl: string; allowedOrigins: readonly string[] }\n | { ok: false; error: AutraCardError };\n\nexport function AutraCardForm(props: AutraCardFormProps): React.ReactElement | null {\n // Key the memo by origin CONTENT so an inline `allowedOrigins={[...]}`\n // (new array identity every render) neither recomputes nor re-emits.\n const allowedOriginsKey = props.allowedOrigins?.join(' ');\n const configuration = React.useMemo<HostedCardConfiguration>(\n () => resolveHostedCardConfiguration(props.hostedCardUrl, props.allowedOrigins),\n // deps intentionally keyed by content (allowedOriginsKey), not array identity\n [props.hostedCardUrl, allowedOriginsKey],\n );\n\n // Terminal guard: once the hosted page reports a successful tokenization,\n // every later event (duplicate `tokenized`, stray errors, sub-frame noise)\n // is ignored so the consumer can never double-charge or double-navigate.\n const terminalRef = React.useRef(false);\n\n const onErrorRef = React.useRef(props.onError);\n React.useEffect(() => {\n onErrorRef.current = props.onError;\n });\n\n // Configuration errors are emitted from an effect: calling props.onError\n // during render would trigger a parent setState mid-render (React error\n // \"Cannot update a component while rendering a different component\") and\n // would re-fire on every re-render.\n React.useEffect(() => {\n if (!configuration.ok) {\n onErrorRef.current(configuration.error);\n }\n }, [configuration]);\n\n if (!configuration.ok) {\n return null;\n }\n\n const { tokenizeUrl, allowedOrigins } = configuration;\n\n const handleMessage = (event: WebViewMessageEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n const result = parseAutraCardWebViewMessage(event.nativeEvent, allowedOrigins);\n\n if (!result.ok) {\n props.onError(result.error);\n return;\n }\n\n if (result.message.type === 'tokenized') {\n terminalRef.current = true;\n props.onSuccess(result.message.result);\n return;\n }\n\n if (result.message.type === 'error') {\n props.onError(result.message.error);\n return;\n }\n\n props.onReady?.(result.message.requestId);\n };\n\n const handleHttpError = (event: WebViewHttpErrorEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n // On Android onHttpError also fires for sub-resources (favicon, assets,\n // page-initiated fetches). Only a failure of the hosted DOCUMENT itself\n // is fatal to the flow — the page reports its own API errors through the\n // postMessage channel.\n if (!isHostedDocumentUrl(event.nativeEvent.url, tokenizeUrl)) {\n return;\n }\n\n if (event.nativeEvent.statusCode === 401 || event.nativeEvent.statusCode === 403) {\n props.onError(hostedSessionUnauthorizedError);\n return;\n }\n\n props.onError(hostedPageHttpError);\n };\n\n const handleShouldStartLoadWithRequest = (request: WebViewNavigationRequest): boolean => {\n if (isAllowedHostedNavigation(request.url, allowedOrigins)) {\n return true;\n }\n\n if (!terminalRef.current) {\n props.onError(blockedNavigationError);\n }\n return false;\n };\n\n const WebViewComponent = WebView as unknown as React.ComponentType<AutraCardWebViewProps>;\n\n return React.createElement(WebViewComponent, {\n source: {\n uri: tokenizeUrl,\n },\n // Security: react-native-webview hands URLs that fail originWhitelist to\n // the OS (Linking.openURL) BEFORE onShouldStartLoadWithRequest runs — a\n // compromised hosted page could silently bounce the user to an external\n // browser (phishing surface). The payment-WebView hardening pattern is a\n // wildcard whitelist plus a full allowlist in\n // onShouldStartLoadWithRequest: returning false there blocks the\n // navigation WITHOUT opening it externally.\n originWhitelist: ['*'],\n onMessage: handleMessage,\n onError: () => {\n if (!terminalRef.current) {\n props.onError(hostedPageLoadError);\n }\n },\n onHttpError: handleHttpError,\n onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,\n mixedContentMode: 'never',\n allowFileAccess: false,\n allowsBackForwardNavigationGestures: false,\n // PCI hygiene: never persist the hosted card page (or anything typed in\n // it) to disk caches.\n incognito: true,\n cacheEnabled: false,\n style: props.style,\n testID: props.testID,\n });\n}\n\nfunction resolveHostedCardConfiguration(\n hostedCardUrl: string,\n allowedOriginsInput: readonly string[] | undefined,\n): HostedCardConfiguration {\n const parsedHostedCardUrl = parseHostedCardUrl(hostedCardUrl);\n\n if (!parsedHostedCardUrl.ok) {\n return parsedHostedCardUrl;\n }\n\n // Normalization guards against silent lockouts: an entry with a trailing\n // slash/path (`https://cards.example/`) would never equal a browser origin\n // and would reject every hosted message. Non-HTTPS entries are dropped.\n const allowedOrigins = normalizeAllowedOrigins(\n allowedOriginsInput ?? deriveAllowedOrigins(hostedCardUrl),\n );\n\n if (allowedOrigins.length === 0) {\n return { ok: false, error: invalidAllowedOriginsError };\n }\n\n return {\n ok: true,\n tokenizeUrl: buildAutraCardTokenizeUrl(hostedCardUrl),\n allowedOrigins,\n };\n}\n\nfunction parseHostedCardUrl(\n hostedCardUrl: string,\n): { ok: true; url: URL } | { ok: false; error: AutraCardError } {\n let url: URL;\n\n try {\n url = new URL(hostedCardUrl);\n } catch {\n return { ok: false, error: invalidHostedUrlError };\n }\n\n if (url.protocol !== 'https:') {\n return { ok: false, error: insecureHostedUrlError };\n }\n\n return { ok: true, url };\n}\n\nfunction isAllowedHostedNavigation(\n navigationUrl: string,\n allowedOrigins: readonly string[],\n): boolean {\n let url: URL;\n\n try {\n url = new URL(navigationUrl);\n } catch {\n return false;\n }\n\n if (url.protocol !== 'https:') {\n return false;\n }\n\n return allowedOrigins.includes(url.origin);\n}\n\nfunction isHostedDocumentUrl(eventUrl: string | undefined, documentUrl: string): boolean {\n if (eventUrl === undefined) {\n // Older react-native-webview versions omit the URL — stay conservative\n // and treat the failure as fatal rather than silently swallowing it.\n return true;\n }\n\n let failed: URL;\n let document: URL;\n\n try {\n failed = new URL(eventUrl);\n document = new URL(documentUrl);\n } catch {\n return true;\n }\n\n return failed.origin === document.origin && failed.pathname === document.pathname;\n}\n","/**\n * @autra-io/react-native-card — hosted card tokenization SDK exports.\n *\n * Phase: v0 hosted-WebView tokenization. The SDK owns only the React Native\n * component shell and message bridge; the hosted card page owns PAN/CVV entry.\n *\n * Security (payment-adjacent SDK):\n * - Never embed or log PAN, CVV, expiry or cardholder data.\n * - Never place OAuth clientSecret or a strong accessToken in the app.\n * - The mobile context must only ever load a short-lived hostedCardUrl.\n */\n\nexport { AutraCardForm } from './AutraCardForm';\nexport type { AutraCardFormProps } from './AutraCardForm';\n\n/** Semantic version marker for the v0 implementation phase. */\nexport const AUTRA_REACT_NATIVE_CARD_SDK_VERSION = '0.1.0';\n\n/**\n * Result returned by a successful card tokenization.\n * `slugStoredCard` is the opaque reference the backend uses to charge later.\n * Never populate this with raw PAN/CVV; only tokenized/masked references.\n */\nexport type AutraCardTokenizedResult = {\n slugStoredCard?: string;\n slugToken?: string;\n tokenExpirationDate?: string;\n brand?: string;\n last4?: string;\n expirationMonth?: string;\n expirationYear?: string;\n requestId?: string;\n};\n\n/** Normalized v0 error code taxonomy surfaced by the SDK. */\nexport type AutraCardErrorCode =\n | 'configuration_error'\n | 'token_expired'\n | 'message_origin_rejected'\n | 'message_invalid'\n | 'validation_error'\n | 'tokenization_failed';\n\nexport type AutraCardError = {\n code: AutraCardErrorCode;\n message: string;\n requestId?: string;\n retryable?: boolean;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/messages.ts","../src/AutraCardForm.ts","../src/index.ts"],"names":[],"mappings":";;;;;;AAeA,IAAM,UAAA,uBAAiB,GAAA,CAAwB;AAAA,EAC7C,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,yBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,mBAAA,GAAsC;AAAA,EAC1C,IAAA,EAAM,yBAAA;AAAA,EACN,OAAA,EAAS,sCAAA;AAAA,EACT,SAAA,EAAW;AACb,CAAA;AAEA,IAAM,mBAAA,GAAsC;AAAA,EAC1C,IAAA,EAAM,iBAAA;AAAA,EACN,OAAA,EAAS,8BAAA;AAAA,EACT,SAAA,EAAW;AACb,CAAA;AAEO,SAAS,qBAAqB,WAAA,EAA+B;AAClE,EAAA,OAAO,CAAC,IAAI,GAAA,CAAI,WAAW,EAAE,MAAM,CAAA;AACrC;AAUO,SAAS,wBAAwB,OAAA,EAAsC;AAC5E,EA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AW,CAAA;AAAA,EAChC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,CAAS,MAAA,IAAU,MAAA,CAAO,aAAa,QAAA,CAAS,QAAA;AAC3E;;;ACxSO,IAAM,mCAAA,GAAsC","file":"index.js","sourcesContent":["import type { AutraCardError, AutraCardErrorCode, AutraCardTokenizedResult } from './index';\n\nexport type AutraCardWebViewNativeMessage = {\n data: string;\n url?: string;\n};\n\nexport type AutraCardHostedMessage =\n | { type: 'tokenized'; result: AutraCardTokenizedResult }\n | { type: 'error'; error: AutraCardError }\n | { type: 'ready'; requestId?: string };\n\nexport type ParseAutraCardWebViewMessageResult =\n { ok: true; message: AutraCardHostedMessage } | { ok: false; error: AutraCardError };\n\nconst errorCodes = new Set<AutraCardErrorCode>([\n 'configuration_error',\n 'token_expired',\n 'message_origin_rejected',\n 'message_invalid',\n 'validation_error',\n 'tokenization_failed',\n]);\n\nconst originRejectedError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Rejected hosted card message origin.',\n retryable: false,\n};\n\nconst invalidMessageError: AutraCardError = {\n code: 'message_invalid',\n message: 'Invalid hosted card message.',\n retryable: false,\n};\n\nexport function deriveAllowedOrigins(cardBaseUrl: string): string[] {\n return [new URL(cardBaseUrl).origin];\n}\n\n/**\n * Normalizes a caller-supplied origin list into canonical HTTPS origins.\n *\n * Guards against silent lockouts: `['https://cards.example/']` (trailing\n * slash) never equals a browser-reported origin and would reject every\n * hosted message. Entries that are not valid HTTPS URLs are dropped —\n * postMessage trust must never be extended to plaintext origins.\n */\nexport function normalizeAllowedOrigins(origins: readonly string[]): string[] {\n const normalized: string[] = [];\n\n for (const candidate of origins) {\n let url: URL;\n\n try {\n url = new URL(candidate);\n } catch {\n continue;\n }\n\n if (url.protocol !== 'https:') {\n continue;\n }\n\n if (!normalized.includes(url.origin)) {\n normalized.push(url.origin);\n }\n }\n\n return normalized;\n}\n\nexport function parseAutraCardWebViewMessage(\n event: AutraCardWebViewNativeMessage,\n allowedOrigins: readonly string[],\n): ParseAutraCardWebViewMessageResult {\n const eventOrigin = toOrigin(event.url);\n\n if (eventOrigin === undefined || !allowedOrigins.includes(eventOrigin)) {\n return { ok: false, error: originRejectedError };\n }\n\n const rawMessage = parseJson(event.data);\n\n if (!isRecord(rawMessage)) {\n return { ok: false, error: invalidMessageError };\n }\n\n if (rawMessage.type === 'autra.card.tokenized' && isRecord(rawMessage.payload)) {\n const result = toTokenizedResult(rawMessage.payload);\n\n if (result !== undefined) {\n return { ok: true, message: { type: 'tokenized', result } };\n }\n }\n\n if (rawMessage.type === 'autra.card.error' && isRecord(rawMessage.error)) {\n const error = toAutraCardError(rawMessage.error);\n\n if (error !== undefined) {\n return { ok: true, message: { type: 'error', error } };\n }\n }\n\n if (rawMessage.type === 'autra.card.ready') {\n return {\n ok: true,\n message: {\n type: 'ready',\n requestId: optionalString(rawMessage.requestId),\n },\n };\n }\n\n return { ok: false, error: invalidMessageError };\n}\n\nfunction toOrigin(url: string | undefined): string | undefined {\n if (url === undefined) {\n return undefined;\n }\n\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJson(data: string): unknown {\n try {\n return JSON.parse(data) as unknown;\n } catch {\n return undefined;\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 optionalString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction toTokenizedResult(payload: Record<string, unknown>): AutraCardTokenizedResult | undefined {\n const storedCard = isRecord(payload.storedCard) ? payload.storedCard : undefined;\n const tokenizedCard = isRecord(payload.tokenizedCard) ? payload.tokenizedCard : undefined;\n\n const slugStoredCard =\n optionalString(payload.slugStoredCard) ?? optionalString(storedCard?.slugStoredCard);\n const slugToken = optionalString(payload.slugToken) ?? optionalString(tokenizedCard?.slugToken);\n const tokenExpirationDate =\n optionalString(payload.tokenExpirationDate) ??\n optionalString(tokenizedCard?.tokenExpirationDate);\n\n if (slugStoredCard === undefined && slugToken === undefined) {\n return undefined;\n }\n\n return {\n slugStoredCard,\n slugToken,\n tokenExpirationDate,\n brand: optionalString(payload.brand),\n last4: optionalString(payload.last4),\n expirationMonth: optionalString(payload.expirationMonth),\n expirationYear: optionalString(payload.expirationYear),\n requestId: optionalString(payload.requestId),\n };\n}\n\nfunction toAutraCardError(error: Record<string, unknown>): AutraCardError | undefined {\n if (typeof error.code !== 'string' || !isAutraCardErrorCode(error.code)) {\n return undefined;\n }\n\n if (typeof error.message !== 'string') {\n return undefined;\n }\n\n return {\n code: error.code,\n message: error.message,\n requestId: optionalString(error.requestId),\n retryable: typeof error.retryable === 'boolean' ? error.retryable : undefined,\n };\n}\n\nfunction isAutraCardErrorCode(code: string): code is AutraCardErrorCode {\n return errorCodes.has(code as AutraCardErrorCode);\n}\n","import React from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\nimport type { AutraCardError, AutraCardTokenizedResult } from './index';\nimport {\n deriveAllowedOrigins,\n normalizeAllowedOrigins,\n parseAutraCardWebViewMessage,\n type AutraCardWebViewNativeMessage,\n} from './messages';\n\nexport type AutraCardFormProps = {\n hostedCardUrl: string;\n onSuccess: (result: AutraCardTokenizedResult) => void;\n onError: (error: AutraCardError) => void;\n allowedOrigins?: readonly string[];\n onReady?: (requestId?: string) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\ntype WebViewMessageEvent = {\n nativeEvent: AutraCardWebViewNativeMessage;\n};\n\ntype WebViewHttpErrorEvent = {\n nativeEvent: {\n statusCode: number;\n url?: string;\n };\n};\n\ntype WebViewNavigationRequest = {\n url: string;\n};\n\ntype AutraCardWebViewProps = {\n source: {\n uri: string;\n };\n originWhitelist: string[];\n onMessage: (event: WebViewMessageEvent) => void;\n onError: () => void;\n onHttpError: (event: WebViewHttpErrorEvent) => void;\n onShouldStartLoadWithRequest: (request: WebViewNavigationRequest) => boolean;\n mixedContentMode: 'never';\n allowFileAccess: boolean;\n allowsBackForwardNavigationGestures: boolean;\n incognito: boolean;\n cacheEnabled: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n};\n\nconst hostedPageLoadError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page failed to load.',\n retryable: true,\n};\n\nconst hostedPageHttpError: AutraCardError = {\n code: 'tokenization_failed',\n message: 'Hosted card page returned an HTTP error.',\n retryable: true,\n};\n\nconst hostedSessionUnauthorizedError: AutraCardError = {\n code: 'token_expired',\n message: 'Hosted card session expired or is not authorized.',\n retryable: false,\n};\n\nconst invalidHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Invalid hosted card URL.',\n retryable: false,\n};\n\nconst insecureHostedUrlError: AutraCardError = {\n code: 'configuration_error',\n message: 'Hosted card URL must use HTTPS.',\n retryable: false,\n};\n\nconst invalidAllowedOriginsError: AutraCardError = {\n code: 'configuration_error',\n message: 'allowedOrigins must contain at least one valid HTTPS origin.',\n retryable: false,\n};\n\nconst blockedNavigationError: AutraCardError = {\n code: 'message_origin_rejected',\n message: 'Blocked hosted card navigation.',\n retryable: false,\n};\n\nexport function buildAutraCardTokenizeUrl(hostedCardUrl: string): string {\n return hostedCardUrl;\n}\n\ntype HostedCardConfiguration =\n | { ok: true; tokenizeUrl: string; allowedOrigins: readonly string[] }\n | { ok: false; error: AutraCardError };\n\nexport function AutraCardForm(props: AutraCardFormProps): React.ReactElement | null {\n // Key the memo by origin CONTENT so an inline `allowedOrigins={[...]}`\n // (new array identity every render) neither recomputes nor re-emits.\n const allowedOriginsKey = props.allowedOrigins?.join(' ');\n const configuration = React.useMemo<HostedCardConfiguration>(\n () => resolveHostedCardConfiguration(props.hostedCardUrl, props.allowedOrigins),\n // deps intentionally keyed by content (allowedOriginsKey), not array identity\n [props.hostedCardUrl, allowedOriginsKey],\n );\n\n // Terminal guard: once the hosted page reports a successful tokenization,\n // every later event (duplicate `tokenized`, stray errors, sub-frame noise)\n // is ignored so the consumer can never double-charge or double-navigate.\n const terminalRef = React.useRef(false);\n\n const onErrorRef = React.useRef(props.onError);\n React.useEffect(() => {\n onErrorRef.current = props.onError;\n });\n\n // Configuration errors are emitted from an effect: calling props.onError\n // during render would trigger a parent setState mid-render (React error\n // \"Cannot update a component while rendering a different component\") and\n // would re-fire on every re-render.\n React.useEffect(() => {\n if (!configuration.ok) {\n onErrorRef.current(configuration.error);\n }\n }, [configuration]);\n\n if (!configuration.ok) {\n return null;\n }\n\n const { tokenizeUrl, allowedOrigins } = configuration;\n\n const handleMessage = (event: WebViewMessageEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n const result = parseAutraCardWebViewMessage(event.nativeEvent, allowedOrigins);\n\n if (!result.ok) {\n props.onError(result.error);\n return;\n }\n\n if (result.message.type === 'tokenized') {\n terminalRef.current = true;\n props.onSuccess(result.message.result);\n return;\n }\n\n if (result.message.type === 'error') {\n props.onError(result.message.error);\n return;\n }\n\n props.onReady?.(result.message.requestId);\n };\n\n const handleHttpError = (event: WebViewHttpErrorEvent): void => {\n if (terminalRef.current) {\n return;\n }\n\n // On Android onHttpError also fires for sub-resources (favicon, assets,\n // page-initiated fetches). Only a failure of the hosted DOCUMENT itself\n // is fatal to the flow — the page reports its own API errors through the\n // postMessage channel.\n if (!isHostedDocumentUrl(event.nativeEvent.url, tokenizeUrl)) {\n return;\n }\n\n if (event.nativeEvent.statusCode === 401 || event.nativeEvent.statusCode === 403) {\n props.onError(hostedSessionUnauthorizedError);\n return;\n }\n\n props.onError(hostedPageHttpError);\n };\n\n const handleShouldStartLoadWithRequest = (request: WebViewNavigationRequest): boolean => {\n if (isAllowedHostedNavigation(request.url, allowedOrigins)) {\n return true;\n }\n\n if (!terminalRef.current) {\n props.onError(blockedNavigationError);\n }\n return false;\n };\n\n const WebViewComponent = WebView as unknown as React.ComponentType<AutraCardWebViewProps>;\n\n return React.createElement(WebViewComponent, {\n source: {\n uri: tokenizeUrl,\n },\n // Security: react-native-webview hands URLs that fail originWhitelist to\n // the OS (Linking.openURL) BEFORE onShouldStartLoadWithRequest runs — a\n // compromised hosted page could silently bounce the user to an external\n // browser (phishing surface). The payment-WebView hardening pattern is a\n // wildcard whitelist plus a full allowlist in\n // onShouldStartLoadWithRequest: returning false there blocks the\n // navigation WITHOUT opening it externally.\n originWhitelist: ['*'],\n onMessage: handleMessage,\n onError: () => {\n if (!terminalRef.current) {\n props.onError(hostedPageLoadError);\n }\n },\n onHttpError: handleHttpError,\n onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,\n mixedContentMode: 'never',\n allowFileAccess: false,\n allowsBackForwardNavigationGestures: false,\n // PCI hygiene: never persist the hosted card page (or anything typed in\n // it) to disk caches.\n incognito: true,\n cacheEnabled: false,\n style: props.style,\n testID: props.testID,\n });\n}\n\nfunction resolveHostedCardConfiguration(\n hostedCardUrl: string,\n allowedOriginsInput: readonly string[] | undefined,\n): HostedCardConfiguration {\n const parsedHostedCardUrl = parseHostedCardUrl(hostedCardUrl);\n\n if (!parsedHostedCardUrl.ok) {\n return parsedHostedCardUrl;\n }\n\n // Normalization guards against silent lockouts: an entry with a trailing\n // slash/path (`https://cards.example/`) would never equal a browser origin\n // and would reject every hosted message. Non-HTTPS entries are dropped.\n const allowedOrigins = normalizeAllowedOrigins(\n allowedOriginsInput ?? deriveAllowedOrigins(hostedCardUrl),\n );\n\n if (allowedOrigins.length === 0) {\n return { ok: false, error: invalidAllowedOriginsError };\n }\n\n return {\n ok: true,\n tokenizeUrl: buildAutraCardTokenizeUrl(hostedCardUrl),\n allowedOrigins,\n };\n}\n\nfunction parseHostedCardUrl(\n hostedCardUrl: string,\n): { ok: true; url: URL } | { ok: false; error: AutraCardError } {\n let url: URL;\n\n try {\n url = new URL(hostedCardUrl);\n } catch {\n return { ok: false, error: invalidHostedUrlError };\n }\n\n if (url.protocol !== 'https:') {\n return { ok: false, error: insecureHostedUrlError };\n }\n\n return { ok: true, url };\n}\n\nfunction isAllowedHostedNavigation(\n navigationUrl: string,\n allowedOrigins: readonly string[],\n): boolean {\n let url: URL;\n\n try {\n url = new URL(navigationUrl);\n } catch {\n return false;\n }\n\n if (url.protocol !== 'https:') {\n return false;\n }\n\n return allowedOrigins.includes(url.origin);\n}\n\nfunction isHostedDocumentUrl(eventUrl: string | undefined, documentUrl: string): boolean {\n if (eventUrl === undefined) {\n // Older react-native-webview versions omit the URL — stay conservative\n // and treat the failure as fatal rather than silently swallowing it.\n return true;\n }\n\n let failed: URL;\n let document: URL;\n\n try {\n failed = new URL(eventUrl);\n document = new URL(documentUrl);\n } catch {\n return true;\n }\n\n return failed.origin === document.origin && failed.pathname === document.pathname;\n}\n","/**\n * @autra-io/react-native-card — hosted card tokenization SDK exports.\n *\n * Phase: v0 hosted-WebView tokenization. The SDK owns only the React Native\n * component shell and message bridge; the hosted card page owns PAN/CVV entry.\n *\n * Security (payment-adjacent SDK):\n * - Never embed or log PAN, CVV, expiry or cardholder data.\n * - Never place OAuth clientSecret or a strong accessToken in the app.\n * - The mobile context must only ever load a short-lived hostedCardUrl.\n */\n\nexport { AutraCardForm } from './AutraCardForm';\nexport type { AutraCardFormProps } from './AutraCardForm';\n\n// Injected at build time from package.json (see tsup.config.ts /\n// vitest.config.ts) so the constant always matches the published version.\ndeclare const __AUTRA_SDK_VERSION__: string;\n\n/** The published package version of this SDK build. */\nexport const AUTRA_REACT_NATIVE_CARD_SDK_VERSION = __AUTRA_SDK_VERSION__;\n\n/**\n * Result returned by a successful card tokenization.\n * `slugStoredCard` is the opaque reference the backend uses to charge later.\n * Never populate this with raw PAN/CVV; only tokenized/masked references.\n */\nexport type AutraCardTokenizedResult = {\n slugStoredCard?: string;\n slugToken?: string;\n tokenExpirationDate?: string;\n brand?: string;\n last4?: string;\n expirationMonth?: string;\n expirationYear?: string;\n requestId?: string;\n};\n\n/** Normalized v0 error code taxonomy surfaced by the SDK. */\nexport type AutraCardErrorCode =\n | 'configuration_error'\n | 'token_expired'\n | 'message_origin_rejected'\n | 'message_invalid'\n | 'validation_error'\n | 'tokenization_failed';\n\nexport type AutraCardError = {\n code: AutraCardErrorCode;\n message: string;\n requestId?: string;\n retryable?: boolean;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autra-io/react-native-card",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Native SDK for secure card tokenization via Autra's hosted card page.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/autratech/autra-card-sdk-react-native.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/autratech/autra-card-sdk-react-native/issues"
|
|
14
|
-
},
|
|
11
|
+
"homepage": "https://autra.io",
|
|
15
12
|
"keywords": [
|
|
16
13
|
"react-native",
|
|
17
14
|
"card",
|
|
@@ -42,7 +39,8 @@
|
|
|
42
39
|
"README.pt-BR.md",
|
|
43
40
|
"SECURITY.md",
|
|
44
41
|
"CHANGELOG.md",
|
|
45
|
-
"LICENSE"
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"NOTICE"
|
|
46
44
|
],
|
|
47
45
|
"engines": {
|
|
48
46
|
"node": ">=20"
|
|
@@ -82,6 +80,7 @@
|
|
|
82
80
|
"eslint-config-prettier": "^9.1.0",
|
|
83
81
|
"prettier": "^3.3.3",
|
|
84
82
|
"react-test-renderer": "^19.2.7",
|
|
83
|
+
"semantic-release": "25.0.5",
|
|
85
84
|
"tsup": "^8.3.5",
|
|
86
85
|
"typescript": "^5.6.3",
|
|
87
86
|
"typescript-eslint": "^8.16.0",
|