Repository navigation
feat(vault): hosted entry and bundle for the vault's own engine #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pradeep-kumar1202
wants to merge
13
commits into
feat/vault-detached-card-form
Choose a base branch
from
feat/vault-native-fields
base: feat/vault-detached-card-form
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
92da59c
feat(vault): hosted entry and bundle toolchain for the vault's own en…
Pradeep-kumar1202 8b6de56
chore(vault): hosted bundles built from 8051eea
Pradeep-kumar1202 613983a
fix(vault): the vault's engine writes no settings to the device log, …
Pradeep-kumar1202 3d0971b
feat(vault): the hosted bundle carries the scan-card JavaScript
Pradeep-kumar1202 fd4b35b
chore(vault): hosted bundles built from c1ca1ac
Pradeep-kumar1202 abf7f9d
fix(vault): the form's first change reaches the merchant, and every p…
Pradeep-kumar1202 4f7a768
chore(vault): hosted bundles built from 6700fb7
Pradeep-kumar1202 1e70a0a
fix(vault): the vault's engine applies new settings before a tokenize…
Pradeep-kumar1202 71988d7
chore(vault): hosted bundles built from 6caa824
Pradeep-kumar1202 4d7dee2
fix(vault): hosted engine review fixes: settings on tokenize, unanswe…
Pradeep-kumar1202 14c0771
chore(vault): hosted bundles built from 7d8784d
Pradeep-kumar1202 9f27670
chore(vault): hosted bundles built from 0aaadd2
Pradeep-kumar1202 0e0785c
chore(vault): hosted bundles built from 9f27670
Pradeep-kumar1202 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/@juspay-tech/react-native-hyperswitch-vault/BUNDLE-PROVENANCE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # What the hosted bundles were built from | ||
|
|
||
| Written by `bundle/build.mjs`. Do not edit by hand: rebuild instead. | ||
|
|
||
| | | | | ||
| |---|---| | ||
| | Vault version | 1.0.5 | | ||
| | Vault source | commit `9f27670bd23ad7cd44a7d195d4582fe5ee2aca01` | | ||
| | Hosted JavaScript before bundling | `bundle/build/vault-fields.js`, 360292 bytes, sha1 `4c8bed0e4b7422d73b014a3910605e6872669c77` | | ||
| | react-native | 0.86.0 | | ||
| | react | 19.2.3 | | ||
| | react-native-svg | 15.15.5 | | ||
| | @juspay-tech/react-native-hyperswitch-scancard | 0.3.1 | | ||
| | metro | 0.84.6 | | ||
| | node | v26.12.1 | | ||
| | Mode | production, minified, plain JavaScript (not Hermes bytecode) | | ||
|
|
||
| | Platform | File | Bytes | sha1 | | ||
| |---|---|---|---| | ||
| | android | `android/src/main/assets/hyperswitch-vault-fields.bundle` | 1180275 | `594aab0c38cab2cb486599e8b6c01df12f5181e1` | | ||
| | ios | `ios/Resources/hyperswitch-vault-fields.bundle` | 1174926 | `4b4d89474d2956a4d7e59a6561c2cbe784ff7491` | | ||
|
|
||
| The bundle carries the JavaScript of the react-native, react-native-svg and scan-card versions above. | ||
| It runs in the app's own native React Native, react-native-svg and scan-card (when the app has it), | ||
| so it is used only in apps whose React Native version is in the vault's tested range. |
673 changes: 673 additions & 0 deletions
673
...ch/react-native-hyperswitch-vault/android/src/main/assets/hyperswitch-vault-fields.bundle
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/@juspay-tech/react-native-hyperswitch-vault/bundle/.npmrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # The scan-card package declares react-native-webview as a peer for its web entry; the bundle | ||
| # never imports it. Keep peers out so `npm ci` reproduces the lockfile exactly. | ||
| legacy-peer-deps=true | ||
1 change: 1 addition & 0 deletions
1
packages/@juspay-tech/react-native-hyperswitch-vault/bundle/babel.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = { presets: ['module:@react-native/babel-preset'] }; |
93 changes: 93 additions & 0 deletions
93
packages/@juspay-tech/react-native-hyperswitch-vault/bundle/build.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Builds hyperswitch-vault-fields.bundle for Android and iOS and records what each was built from. | ||
| * | ||
| * yarn build in the vault package (rescript, types, rollup: writes bundle/build/) | ||
| * npm ci && npm run build in this folder (Metro: writes the two bundles and the record) | ||
| * | ||
| * WHY A TOOLCHAIN OF ITS OWN. A bundle carries React Native's own JavaScript, and that JavaScript | ||
| * must fit the native React Native of the app the bundle runs in. So the bundle is built with one | ||
| * pinned React Native (package.json here, exact versions, locked by package-lock.json), whatever | ||
| * version the monorepo's workspaces are on. Changing the pin changes which apps the bundle runs | ||
| * in: the vault's tested-versions range must be re-run when it moves. | ||
| * | ||
| * The bundles are plain JavaScript text, not Hermes bytecode: bytecode is tied to one Hermes | ||
| * version, and the engine that runs this is the app's. | ||
| */ | ||
| import { createHash } from 'node:crypto'; | ||
| import { execFileSync } from 'node:child_process'; | ||
| import { createRequire } from 'node:module'; | ||
| import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'; | ||
| import { dirname, join, relative } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const here = dirname(fileURLToPath(import.meta.url)); | ||
| const vault = join(here, '..'); | ||
| const require = createRequire(import.meta.url); | ||
|
|
||
| const BUNDLE = 'hyperswitch-vault-fields.bundle'; | ||
| const ENTRY = join(here, 'index.vault-fields.js'); | ||
| const INPUT = join(here, 'build', 'vault-fields.js'); | ||
| const OUTPUTS = { | ||
| android: join(vault, 'android', 'src', 'main', 'assets', BUNDLE), | ||
| ios: join(vault, 'ios', 'Resources', BUNDLE), | ||
| }; | ||
|
|
||
| if (!existsSync(INPUT)) { | ||
| console.error(`Missing ${relative(vault, INPUT)}. Run "yarn build" in the vault package first.`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const versionOf = (name) => require(`${name}/package.json`).version; | ||
| const sha1 = (file) => createHash('sha1').update(readFileSync(file)).digest('hex'); | ||
| const git = (...args) => { | ||
| try { | ||
| return execFileSync('git', args, { cwd: vault, encoding: 'utf8' }).trim(); | ||
| } catch { | ||
| return ''; | ||
| } | ||
| }; | ||
|
|
||
| const { loadConfig } = require('metro-config'); | ||
| const Metro = require('metro'); | ||
| const config = await loadConfig({ cwd: here, config: join(here, 'metro.config.js') }); | ||
|
|
||
| const built = []; | ||
| for (const [platform, out] of Object.entries(OUTPUTS)) { | ||
| mkdirSync(dirname(out), { recursive: true }); | ||
| await Metro.runBuild(config, { entry: ENTRY, out, platform, dev: false, minify: true }); | ||
| /* Metro adds ".js" to an output name that has another extension. */ | ||
| if (existsSync(`${out}.js`)) renameSync(`${out}.js`, out); | ||
| built.push({ platform, file: relative(vault, out), bytes: statSync(out).size, sha1: sha1(out) }); | ||
| } | ||
|
|
||
| const commit = git('rev-parse', 'HEAD'); | ||
| const dirty = git('status', '--porcelain', '--', 'src', 'shared-code', 'rollup.config.mjs') !== ''; | ||
| const record = `# What the hosted bundles were built from | ||
|
|
||
| Written by \`bundle/build.mjs\`. Do not edit by hand: rebuild instead. | ||
|
|
||
| | | | | ||
| |---|---| | ||
| | Vault version | ${JSON.parse(readFileSync(join(vault, 'package.json'), 'utf8')).version} | | ||
| | Vault source | commit \`${commit || 'unknown'}\`${dirty ? ' **plus uncommitted changes**' : ''} | | ||
| | Hosted JavaScript before bundling | \`bundle/build/vault-fields.js\`, ${statSync(INPUT).size} bytes, sha1 \`${sha1(INPUT)}\` | | ||
| | react-native | ${versionOf('react-native')} | | ||
| | react | ${versionOf('react')} | | ||
| | react-native-svg | ${versionOf('react-native-svg')} | | ||
| | @juspay-tech/react-native-hyperswitch-scancard | ${versionOf('@juspay-tech/react-native-hyperswitch-scancard')} | | ||
| | metro | ${versionOf('metro')} | | ||
| | node | ${process.version} | | ||
| | Mode | production, minified, plain JavaScript (not Hermes bytecode) | | ||
|
|
||
| | Platform | File | Bytes | sha1 | | ||
| |---|---|---|---| | ||
| ${built.map((one) => `| ${one.platform} | \`${one.file}\` | ${one.bytes} | \`${one.sha1}\` |`).join('\n')} | ||
|
|
||
| The bundle carries the JavaScript of the react-native, react-native-svg and scan-card versions above. | ||
| It runs in the app's own native React Native, react-native-svg and scan-card (when the app has it), | ||
| so it is used only in apps whose React Native version is in the vault's tested range. | ||
| `; | ||
| writeFileSync(join(vault, 'BUNDLE-PROVENANCE.md'), record); | ||
|
|
||
| for (const one of built) console.log(`${one.platform}: ${one.file} ${one.bytes} bytes ${one.sha1}`); | ||
| console.log(dirty ? 'NOTE: built from uncommitted source.' : `built from ${commit}`); |
6 changes: 6 additions & 0 deletions
6
packages/@juspay-tech/react-native-hyperswitch-vault/bundle/index.vault-fields.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /* | ||
| * What Metro bundles. The JavaScript itself is ./build/vault-fields.js, written by the vault's | ||
| * rollup build from src/hosted-entry.mjs. The native host loads the bundle with this file's name | ||
| * as its main module ("index.vault-fields"). | ||
| */ | ||
| import './build/vault-fields.js'; |
5 changes: 5 additions & 0 deletions
5
packages/@juspay-tech/react-native-hyperswitch-vault/bundle/metro.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /* Everything resolves from this folder's own node_modules: the pinned React Native line and nothing | ||
| from the monorepo around it. */ | ||
| const { getDefaultConfig } = require('@react-native/metro-config'); | ||
|
|
||
| module.exports = getDefaultConfig(__dirname); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.