pa-sdk-react-native 0.0.0-stage → 3.0.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -2
  3. package/lib/api.d.ts +88 -0
  4. package/lib/api.js +163 -0
  5. package/lib/confirm.d.ts +65 -0
  6. package/lib/confirm.js +358 -0
  7. package/lib/errors.d.ts +38 -0
  8. package/lib/errors.generated.d.ts +13 -0
  9. package/lib/errors.generated.js +63 -0
  10. package/lib/errors.js +80 -0
  11. package/lib/index.d.ts +43 -0
  12. package/lib/index.js +94 -0
  13. package/lib/init.d.ts +47 -0
  14. package/lib/init.js +96 -0
  15. package/lib/locales.d.ts +36 -0
  16. package/lib/locales.generated.d.ts +22 -0
  17. package/lib/locales.generated.js +134 -0
  18. package/lib/locales.js +100 -0
  19. package/lib/poll.d.ts +61 -0
  20. package/lib/poll.js +172 -0
  21. package/lib/threeDs.d.ts +59 -0
  22. package/lib/threeDs.js +64 -0
  23. package/lib/threeDsHost.d.ts +17 -0
  24. package/lib/threeDsHost.js +159 -0
  25. package/lib/tokenize.d.ts +22 -0
  26. package/lib/tokenize.js +50 -0
  27. package/lib/types.d.ts +127 -0
  28. package/lib/types.js +16 -0
  29. package/lib/validator.d.ts +71 -0
  30. package/lib/validator.js +190 -0
  31. package/locales/en-US.json +30 -0
  32. package/locales/ms-MY.json +30 -0
  33. package/locales/zh-CN.json +30 -0
  34. package/locales/zh-TW.json +30 -0
  35. package/native/android/build.gradle +49 -0
  36. package/native/android/src/main/AndroidManifest.xml +42 -0
  37. package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsActivity.kt +243 -0
  38. package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsModule.kt +110 -0
  39. package/native/android/src/main/java/com/pasdk/reactnative/PaSdkReactNativePackage.kt +27 -0
  40. package/native/ios/PaSdk3ds.swift +311 -0
  41. package/native/ios/PaSdk3dsModule.m +47 -0
  42. package/pa-sdk-react-native.podspec +23 -0
  43. package/package.json +47 -4
  44. package/scripts/generate-errors.js +86 -0
  45. package/scripts/generate-locales.js +95 -0
@@ -0,0 +1,47 @@
1
+ // PaSdk3dsModule.m — classic NativeModules bridge for the Swift 3DS module.
2
+ //
3
+ // Uses RCT_EXTERN_METHOD against PaSdk3dsSwift (see PaSdk3ds.swift), so the
4
+ // module works with the legacy bridge AND on the New Architecture through
5
+ // React Native's interop layer (RN 0.79+, no TurboModule codegen needed).
6
+ //
7
+ // The Swift header name derives from the pod name in pa-sdk-react-native.podspec
8
+ // (module "pa_sdk_react_native").
9
+
10
+ #import <Foundation/Foundation.h>
11
+ #import <React/RCTBridgeModule.h>
12
+ #import <React/RCTLog.h>
13
+
14
+ #if __has_include("pa_sdk_react_native-Swift.h")
15
+ #import "pa_sdk_react_native-Swift.h"
16
+ #elif __has_include("PaSdkReactNative-Swift.h")
17
+ #import "PaSdkReactNative-Swift.h"
18
+ #else
19
+ #import <pa_sdk_react_native/pa_sdk_react_native-Swift.h>
20
+ #endif
21
+
22
+ @interface RCT_EXTERN_REMAP_MODULE(PaSdk3ds, PaSdk3dsSwift, NSObject)
23
+
24
+ /**
25
+ * Present the full-screen 3DS challenge.
26
+ * params: {
27
+ * url: NSString — Cardinal StepUp URL or issuer ACS URL
28
+ * fields: NSDictionary — form fields, e.g. {JWT: "..."} or {creq: "..."}
29
+ * strings: NSDictionary — {title, cancel, close, processing, redirecting}
30
+ * returnUrlScheme: NSString — e.g. "yourapp://" (optional)
31
+ * returnUrlUniversalHost: NSString — e.g. "https://links.yourapp.com" (optional)
32
+ * }
33
+ * resolves: { cancelled: BOOL, returnUrlConsumed: BOOL }
34
+ */
35
+ RCT_EXTERN_METHOD(present:(NSDictionary *)params
36
+ resolver:(RCTPromiseResolveBlock)resolve
37
+ rejecter:(RCTPromiseRejectBlock)reject)
38
+
39
+ /** Dismiss the challenge after the JS poller observed a terminal state. */
40
+ RCT_EXTERN_METHOD(close:(RCTPromiseResolveBlock)resolve)
41
+
42
+ + (BOOL)requiresMainQueueSetup
43
+ {
44
+ return NO;
45
+ }
46
+
47
+ @end
@@ -0,0 +1,23 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'pa-sdk-react-native'
7
+ s.version = package['version']
8
+ s.summary = 'Payment Asia card payment SDK for React Native (headless card APIs + SDK-presented 3DS).'
9
+ s.description = package['description']
10
+ s.homepage = 'https://www.paymentasia.com'
11
+ s.license = { type: 'MIT', file: 'LICENSE' }
12
+ s.author = { 'Payment Asia' => 'dev@paymentasia.com' }
13
+ s.platforms = { ios: '13.0' }
14
+ s.swift_version = '5.0'
15
+ s.source = { git: 'https://github.com/paymentasia/pa-sdk-react-native.git', tag: "v#{s.version}" }
16
+
17
+ s.source_files = 'native/ios/**/*.{swift,h,m}'
18
+ s.public_header_files = 'native/ios/**/*.h'
19
+
20
+ # Classic NativeModules bridge (works under the New Architecture interop
21
+ # layer). React-Core provides RCTBridgeModule / RCTPromise*Block.
22
+ s.dependency 'React-Core'
23
+ end
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "pa-sdk-react-native",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.1",
4
+ "description": "Payment Asia card payment SDK for React Native — headless card validation, tokenization, payment confirmation with built-in 3D Secure, card saving and multi-market merchant accounts.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "locales",
10
+ "native",
11
+ "scripts",
12
+ "pa-sdk-react-native.podspec",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "typecheck": "tsc --noEmit",
18
+ "generate": "node scripts/generate-errors.js && node scripts/generate-locales.js",
19
+ "generate:errors": "node scripts/generate-errors.js",
20
+ "generate:locales": "node scripts/generate-locales.js"
21
+ },
22
+ "keywords": [
23
+ "payment",
24
+ "payment-asia",
25
+ "react-native",
26
+ "card",
27
+ "3ds",
28
+ "3d-secure",
29
+ "tokenization"
30
+ ],
31
+ "license": "MIT",
32
+ "peerDependencies": {
33
+ "react-native": ">=0.79"
34
+ },
35
+ "dependencies": {
36
+ "react-native-webview": "^13.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^19.0.0",
40
+ "react": "^19.0.0",
41
+ "react-native": "0.79.0",
42
+ "typescript": "^5.5.0"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://git.prizm.digital/nelson.lin/security_component_rn.git"
47
+ },
48
+ "homepage": "https://git.prizm.digital/nelson.lin/security_component_rn#readme"
49
+ }
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generates src/errors.generated.ts from the shared PA SDK error code table
4
+ * (errors.json, the single source of truth also used by the web SDK and the
5
+ * server API).
6
+ *
7
+ * Usage:
8
+ * node scripts/generate-errors.js [path/to/errors.json]
9
+ *
10
+ * Default input path points at the sibling system-v3 checkout:
11
+ * ../system-v3/public_html/pasdk/v3/errors.json
12
+ */
13
+ 'use strict';
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ const defaultInput = path.resolve(
19
+ __dirname,
20
+ '..',
21
+ '..',
22
+ 'system-v3',
23
+ 'public_html',
24
+ 'pasdk',
25
+ 'v3',
26
+ 'errors.json'
27
+ );
28
+ const inputPath = process.argv[2] || defaultInput;
29
+ const outputPath = path.resolve(__dirname, '..', 'src', 'errors.generated.ts');
30
+
31
+ const raw = fs.readFileSync(inputPath, 'utf8');
32
+ const table = JSON.parse(raw);
33
+
34
+ if (!table.codes || typeof table.codes !== 'object') {
35
+ console.error('generate-errors: %s has no "codes" object', inputPath);
36
+ process.exit(1);
37
+ }
38
+
39
+ // Flatten the grouped table ({ payment: {...}, field: {...}, load: {...} })
40
+ // into a single code -> English developer message map.
41
+ const flat = {};
42
+ for (const group of Object.keys(table.codes)) {
43
+ const groupCodes = table.codes[group];
44
+ if (groupCodes && typeof groupCodes === 'object') {
45
+ for (const code of Object.keys(groupCodes)) {
46
+ if (Object.prototype.hasOwnProperty.call(flat, code)) {
47
+ console.error('generate-errors: duplicate code "%s" — keeping first', code);
48
+ continue;
49
+ }
50
+ flat[code] = String(groupCodes[code]);
51
+ }
52
+ }
53
+ }
54
+
55
+ const header = [
56
+ '/* eslint-disable */',
57
+ '/**',
58
+ ' * GENERATED FILE — do not edit by hand.',
59
+ ' * Generated by scripts/generate-errors.js from: ' + path.basename(inputPath),
60
+ ' * Table version: ' + (table.version != null ? table.version : 'unknown') +
61
+ ', generated_at: ' + (table.generated_at || 'unknown') + '.',
62
+ ' *',
63
+ ' * One code table shared by the server API, webhooks, the web SDK and this',
64
+ ' * React Native SDK. Values are English developer',
65
+ ' * messages; localized user messages live in the locale bundles.',
66
+ ' */',
67
+ '',
68
+ 'export const ERROR_TABLE_VERSION: number = ' + JSON.stringify(table.version == null ? 1 : table.version) + ';',
69
+ '',
70
+ 'export const ERROR_DEVELOPER_MESSAGES: { readonly [code: string]: string } = {',
71
+ ];
72
+
73
+ for (const code of Object.keys(flat).sort()) {
74
+ header.push(' ' + JSON.stringify(code) + ': ' + JSON.stringify(flat[code]) + ',');
75
+ }
76
+
77
+ header.push('};', '');
78
+
79
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
80
+ fs.writeFileSync(outputPath, header.join('\n'), 'utf8');
81
+ console.log(
82
+ 'generate-errors: wrote %s (%d codes, table v%s)',
83
+ path.relative(process.cwd(), outputPath),
84
+ Object.keys(flat).length,
85
+ table.version == null ? '?' : table.version
86
+ );
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generates src/locales.generated.ts from the canonical locale bundles in
4
+ * locales/*.json (en-US, zh-TW, zh-CN, ms-MY).
5
+ *
6
+ * The JSON files in locales/ are the source of truth; this script mirrors
7
+ * them into src/ so the TypeScript build stays self-contained under rootDir.
8
+ *
9
+ * Usage: node scripts/generate-locales.js
10
+ */
11
+ 'use strict';
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ const localesDir = path.resolve(__dirname, '..', 'locales');
17
+ const outputPath = path.resolve(__dirname, '..', 'src', 'locales.generated.ts');
18
+
19
+ const files = fs
20
+ .readdirSync(localesDir)
21
+ .filter((f) => f.endsWith('.json'))
22
+ .sort();
23
+
24
+ if (files.length === 0) {
25
+ console.error('generate-locales: no JSON files found in %s', localesDir);
26
+ process.exit(1);
27
+ }
28
+
29
+ const bundles = [];
30
+ for (const file of files) {
31
+ const raw = fs.readFileSync(path.join(localesDir, file), 'utf8');
32
+ bundles.push(' ' + JSON.stringify(file.replace(/\.json$/, '')) + ': ' + JSON.stringify(JSON.parse(raw), null, 2).replace(/\n/g, '\n ') + ',');
33
+ }
34
+
35
+ const out = [
36
+ '/* eslint-disable */',
37
+ '/**',
38
+ ' * GENERATED FILE — do not edit by hand.',
39
+ ' * Generated by scripts/generate-locales.js from locales/*.json.',
40
+ ' *',
41
+ ' * Locale coverage: en-US (complete), zh-TW (complete,',
42
+ ' * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — complete,',
43
+ ' * falls back to en-US at runtime until translations are supplied).',
44
+ ' */',
45
+ '',
46
+ 'export interface LocaleMeta {',
47
+ ' name: string;',
48
+ ' canonical: string;',
49
+ ' fallback: string | null;',
50
+ ' complete: boolean;',
51
+ '}',
52
+ '',
53
+ 'export type LocaleKey =',
54
+ " | 'threeds.title'",
55
+ " | 'threeds.cancel'",
56
+ " | 'threeds.close'",
57
+ " | 'threeds.processing'",
58
+ " | 'threeds.redirecting'",
59
+ " | 'payment.processing'",
60
+ " | 'result.cancelled'",
61
+ " | 'error.generic'",
62
+ " | 'error.rate_limited'",
63
+ " | 'error.processing_timeout'",
64
+ " | 'error.sdk_load_failed'",
65
+ " | 'error.invalid_publishable_key'",
66
+ " | 'error.invalid_client_token'",
67
+ " | 'error.origin_not_allowed'",
68
+ " | 'error.font_load_failed'",
69
+ " | 'field.incomplete_number'",
70
+ " | 'field.invalid_number'",
71
+ " | 'field.incomplete_expiry'",
72
+ " | 'field.invalid_expiry'",
73
+ " | 'field.incomplete_cvc'",
74
+ " | 'field.invalid_cvc'",
75
+ " | 'field.unsupported_brand';",
76
+ '',
77
+ 'export interface LocaleBundle {',
78
+ ' _meta: LocaleMeta;',
79
+ ' [key: string]: string | LocaleMeta;',
80
+ '}',
81
+ '',
82
+ 'export const LOCALE_BUNDLES: { readonly [locale: string]: LocaleBundle } = {',
83
+ ...bundles,
84
+ '};',
85
+ '',
86
+ ];
87
+
88
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
89
+ fs.writeFileSync(outputPath, out.join('\n'), 'utf8');
90
+ console.log(
91
+ 'generate-locales: wrote %s (%d locales: %s)',
92
+ path.relative(process.cwd(), outputPath),
93
+ files.length,
94
+ files.map((f) => f.replace(/\.json$/, '')).join(', ')
95
+ );