@airxpay/sdk-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AirXPayConsumer = exports.useIsAirXPayReady = exports.useAirXPayConfig = exports.useAirXPaySafe = exports.useAirXPay = exports.AirXPayProvider = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ // Context with professional error handling
39
+ const AirXPayContext = (0, react_1.createContext)(null);
40
+ AirXPayContext.displayName = "AirXPayContext";
41
+ const AirXPayProvider = ({ config, children, enableLogging = __DEV__, }) => {
42
+ // Validate configuration on mount
43
+ (0, react_1.useEffect)(() => {
44
+ const validationErrors = [];
45
+ // Validate baseUrl
46
+ if (!config.baseUrl) {
47
+ validationErrors.push("baseUrl is required");
48
+ }
49
+ else {
50
+ try {
51
+ new URL(config.baseUrl);
52
+ }
53
+ catch {
54
+ validationErrors.push("baseUrl must be a valid URL (e.g., https://api.airxpay.com)");
55
+ }
56
+ }
57
+ // Validate publicKey
58
+ if (!config.publicKey) {
59
+ validationErrors.push("publicKey is required");
60
+ }
61
+ else if (typeof config.publicKey !== "string") {
62
+ validationErrors.push("publicKey must be a string");
63
+ }
64
+ else if (config.publicKey.length < 20) {
65
+ validationErrors.push("publicKey appears to be invalid. Please check your API key.");
66
+ }
67
+ // Throw error if validation fails
68
+ if (validationErrors.length > 0) {
69
+ const errorMessage = [
70
+ "AirXPayProvider Configuration Error:",
71
+ ...validationErrors.map((err) => ` • ${err}`),
72
+ "",
73
+ "Received config:",
74
+ ` • baseUrl: ${config.baseUrl || "missing"}`,
75
+ ` • publicKey: ${config.publicKey ? `${config.publicKey.substring(0, 8)}...` : "missing"}`,
76
+ ].join("\n");
77
+ if (enableLogging) {
78
+ console.error("❌ AirXPay:", errorMessage);
79
+ }
80
+ throw new Error(errorMessage);
81
+ }
82
+ // Log success in development
83
+ if (enableLogging) {
84
+ console.log("%c✅ AirXPay Provider Initialized", "color: #10b981; font-weight: bold;", {
85
+ baseUrl: config.baseUrl,
86
+ publicKey: `${config.publicKey.substring(0, 8)}...`,
87
+ });
88
+ }
89
+ }, [config, enableLogging]);
90
+ return (<AirXPayContext.Provider value={config}>{children}</AirXPayContext.Provider>);
91
+ };
92
+ exports.AirXPayProvider = AirXPayProvider;
93
+ exports.AirXPayProvider.displayName = "AirXPayProvider";
94
+ // Professional hook with clear error messages
95
+ const useAirXPay = () => {
96
+ const context = (0, react_1.useContext)(AirXPayContext);
97
+ if (!context) {
98
+ const errorMessage = [
99
+ "❌ useAirXPay: Hook must be used within an AirXPayProvider",
100
+ "",
101
+ "This error occurs when:",
102
+ " 1. Your component tree is not wrapped in <AirXPayProvider>",
103
+ " 2. You have multiple React roots in your application",
104
+ " 3. The provider is conditionally rendered",
105
+ "",
106
+ "Solution:",
107
+ " • Wrap your root component with AirXPayProvider:",
108
+ "",
109
+ " <AirXPayProvider",
110
+ " config={{",
111
+ ' baseUrl: "https://api.airxpay.com",',
112
+ ' publicKey: "your_public_key_here"',
113
+ " }}",
114
+ " >",
115
+ " <App />",
116
+ " </AirXPayProvider>",
117
+ "",
118
+ " • Verify the provider is not inside a conditional or loop",
119
+ ` • Component location: ${new Error().stack?.split("\n")[2]?.trim() || "unknown"}`,
120
+ ].join("\n");
121
+ // Log with styling in development
122
+ if (__DEV__) {
123
+ console.error("%c❌ AirXPay Context Error", "color: #ef4444; font-size: 14px; font-weight: bold;", "\n" + errorMessage);
124
+ }
125
+ throw new Error(errorMessage);
126
+ }
127
+ return context;
128
+ };
129
+ exports.useAirXPay = useAirXPay;
130
+ // Helper: Check if config exists without throwing
131
+ const useAirXPaySafe = () => {
132
+ try {
133
+ return (0, exports.useAirXPay)();
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ };
139
+ exports.useAirXPaySafe = useAirXPaySafe;
140
+ // Helper: Access specific config value
141
+ const useAirXPayConfig = (key) => {
142
+ const config = (0, exports.useAirXPaySafe)();
143
+ return config?.[key];
144
+ };
145
+ exports.useAirXPayConfig = useAirXPayConfig;
146
+ // Helper: Check if provider is properly configured
147
+ const useIsAirXPayReady = () => {
148
+ const config = (0, exports.useAirXPaySafe)();
149
+ return !!(config?.baseUrl && config?.publicKey);
150
+ };
151
+ exports.useIsAirXPayReady = useIsAirXPayReady;
152
+ // Export context consumer for advanced use cases
153
+ exports.AirXPayConsumer = AirXPayContext.Consumer;
154
+ exports.default = exports.AirXPayProvider;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const SellerOnboarding_1 = __importDefault(require("../components/ui/SellerOnboard/SellerOnboarding"));
8
+ const SellerOnboarding = (props) => {
9
+ return <SellerOnboarding_1.default {...props}/>;
10
+ };
11
+ exports.default = SellerOnboarding;
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SellerOnboarding = exports.AirXPayProvider = exports.AirXPay = void 0;
7
+ var airxpay_1 = require("./sdk/airxpay");
8
+ Object.defineProperty(exports, "AirXPay", { enumerable: true, get: function () { return airxpay_1.AirXPay; } });
9
+ var AirXPayProvider_1 = require("./contexts/AirXPayProvider");
10
+ Object.defineProperty(exports, "AirXPayProvider", { enumerable: true, get: function () { return AirXPayProvider_1.AirXPayProvider; } });
11
+ var SellerOnboarding_1 = require("./hooks/SellerOnboarding");
12
+ Object.defineProperty(exports, "SellerOnboarding", { enumerable: true, get: function () { return __importDefault(SellerOnboarding_1).default; } });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AirXPay = void 0;
4
+ const seller_1 = require("../api/seller");
5
+ class AirXPay {
6
+ constructor(config) {
7
+ if (!config.baseUrl)
8
+ throw new Error("Base URL is required");
9
+ if (!config.publicKey)
10
+ throw new Error("Public key is required");
11
+ this.baseUrl = config.baseUrl;
12
+ this.publicKey = config.publicKey;
13
+ }
14
+ async initialize() {
15
+ return await (0, seller_1.verifyPublicKey)(this.baseUrl, this.publicKey);
16
+ }
17
+ }
18
+ exports.AirXPay = AirXPay;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // types/sellertypes.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ // This file defines the TypeScript types and interfaces related to sellers in the system, including their KYC status, bank details, and onboarding process. These types will be used throughout the application to ensure type safety and consistency when working with seller data.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@airxpay/sdk-ui",
3
+ "version": "1.0.0",
4
+ "description": "AirXPay Initialization UI Components for React & React Native",
5
+ "author": "Tafseel Khan",
6
+ "license": "MIT",
7
+
8
+ "main": "dist/index.js",
9
+
10
+ "files": [
11
+ "dist"
12
+ ],
13
+
14
+ "scripts": {
15
+ "build": "tsc --project tsconfig.json --outDir dist --declaration false",
16
+ "prepare": "npm run build"
17
+ },
18
+
19
+ "peerDependencies": {
20
+ "react": ">=18",
21
+ "react-native": ">=0.72"
22
+ },
23
+
24
+ "dependencies": {
25
+ "axios": "^1.13.5"
26
+ },
27
+
28
+ "devDependencies": {
29
+ "@react-native-community/datetimepicker": "^8.6.0",
30
+ "@types/react": "^19.2.14",
31
+ "expo-image-picker": "^17.0.10",
32
+ "expo-linear-gradient": "^15.0.8",
33
+ "react": "^19.2.4",
34
+ "react-native": "^0.84.0",
35
+ "react-native-country-picker-modal": "^2.0.0",
36
+ "react-native-paper": "^5.15.0",
37
+ "typescript": "^5.9.3"
38
+ },
39
+
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/tafseelkhan/airxpay-initialization-ui.git"
43
+ },
44
+
45
+ "keywords": [
46
+ "airxpay",
47
+ "react-native",
48
+ "seller-onboarding",
49
+ "payments",
50
+ "ui"
51
+ ],
52
+
53
+ "bugs": {
54
+ "url": "https://github.com/tafseelkhan/airxpay-initialization-ui/issues"
55
+ },
56
+
57
+ "homepage": "https://github.com/tafseelkhan/airxpay-initialization-ui#readme"
58
+ }