zopassport 0.1.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.
- package/LICENSE +22 -0
- package/README.md +407 -0
- package/app/.env.example +15 -0
- package/app/README.md +28 -0
- package/app/package.json +24 -0
- package/app/reanimated-mock.js +102 -0
- package/app/reanimated-mock.jsx +97 -0
- package/app/src/App.tsx +331 -0
- package/app/src/components/FounderBadge.tsx +26 -0
- package/app/src/components/OTPInput.tsx +149 -0
- package/app/src/components/PhoneInput.tsx +109 -0
- package/app/src/components/ZoAuth.tsx +320 -0
- package/app/src/components/ZoAvatar.tsx +87 -0
- package/app/src/components/ZoLanding.tsx +231 -0
- package/app/src/components/ZoOnboarding.tsx +524 -0
- package/app/src/components/ZoPassportCard.tsx +183 -0
- package/app/src/components/ZoProgressRing.tsx +57 -0
- package/app/src/components/index.ts +16 -0
- package/app/src/components/wallet/MovingShine.tsx +43 -0
- package/app/src/components/wallet/TransactionItem.tsx +84 -0
- package/app/src/components/wallet/TransactionList.tsx +65 -0
- package/app/src/components/wallet/WalletCard.tsx +152 -0
- package/app/src/components/wallet/WalletScreen.tsx +190 -0
- package/app/src/components/wallet/ZoToken.tsx +69 -0
- package/app/src/components/wallet/index.ts +8 -0
- package/app/src/components/wallet/styles/index.ts +4 -0
- package/app/src/components/wallet/styles/walletStyles.ts +210 -0
- package/app/src/sdk/ZoPassportSDK.ts +277 -0
- package/app/src/sdk/lib/api/auth.ts +223 -0
- package/app/src/sdk/lib/api/avatar.ts +155 -0
- package/app/src/sdk/lib/api/client.ts +135 -0
- package/app/src/sdk/lib/api/index.ts +8 -0
- package/app/src/sdk/lib/api/profile.ts +80 -0
- package/app/src/sdk/lib/api/wallet.ts +59 -0
- package/app/src/sdk/lib/types/auth.ts +78 -0
- package/app/src/sdk/lib/types/avatar.ts +22 -0
- package/app/src/sdk/lib/types/index.ts +8 -0
- package/app/src/sdk/lib/types/profile.ts +18 -0
- package/app/src/sdk/lib/types/wallet.ts +103 -0
- package/app/src/sdk/lib/types.ts +205 -0
- package/app/src/sdk/lib/utils/index.ts +6 -0
- package/app/src/sdk/lib/utils/phone.ts +71 -0
- package/app/src/sdk/lib/utils/storage.ts +116 -0
- package/app/src/sdk/lib/utils/wallet.ts +73 -0
- package/app/src/sdk/types.ts +205 -0
- package/app/src/styles.css +154 -0
- package/app/svg-mock.js +125 -0
- package/app/svg-mock.jsx +120 -0
- package/app/vite.config.ts +70 -0
- package/assets/ASSETS_MANIFEST.md +124 -0
- package/assets/bae.png +0 -0
- package/assets/bro.png +0 -0
- package/assets/cultural-stickers/Business.png +0 -0
- package/assets/cultural-stickers/Default (2).jpg +0 -0
- package/assets/cultural-stickers/Design.png +0 -0
- package/assets/cultural-stickers/FollowYourHeart.png +0 -0
- package/assets/cultural-stickers/Food.png +0 -0
- package/assets/cultural-stickers/Game.png +0 -0
- package/assets/cultural-stickers/Health&Fitness.png +0 -0
- package/assets/cultural-stickers/Home&Lifestyle.png +0 -0
- package/assets/cultural-stickers/Law.png +0 -0
- package/assets/cultural-stickers/Literature&Stories.png +0 -0
- package/assets/cultural-stickers/Music&Entertainment.png +0 -0
- package/assets/cultural-stickers/Nature&Wildlife.png +0 -0
- package/assets/cultural-stickers/Photography.png +0 -0
- package/assets/cultural-stickers/Science&Technology.png +0 -0
- package/assets/cultural-stickers/Spiritual.png +0 -0
- package/assets/cultural-stickers/Sport.png +0 -0
- package/assets/cultural-stickers/Stories&Journal.png +0 -0
- package/assets/cultural-stickers/Television&Cinema.png +0 -0
- package/assets/cultural-stickers/Travel&Adventure.png +0 -0
- package/assets/cultural-stickers/z.jpg (1).jpg +0 -0
- package/assets/figma-assets/landing-zo-logo.png +0 -0
- package/assets/images/rank1.jpeg +0 -0
- package/assets/index.ts +76 -0
- package/assets/lotties/loader.json +1216 -0
- package/assets/lotties/spinner.json +1 -0
- package/assets/videos/loading-screen-background.mp4 +0 -0
- package/assets/videos/opening-disks.mp4 +0 -0
- package/assets/wallet/constants.ts +38 -0
- package/assets/zo-coin.gif +0 -0
- package/assets/zo-fallback.png +0 -0
- package/dist/assets/index.d.mts +136 -0
- package/dist/assets/index.d.ts +136 -0
- package/dist/assets/index.js +133 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/assets/index.mjs +100 -0
- package/dist/assets/index.mjs.map +1 -0
- package/dist/index.d.mts +789 -0
- package/dist/index.d.ts +789 -0
- package/dist/index.js +1118 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1060 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react-native.d.mts +537 -0
- package/dist/react-native.d.ts +537 -0
- package/dist/react-native.js +1617 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react-native.mjs +1588 -0
- package/dist/react-native.mjs.map +1 -0
- package/dist/react.d.mts +824 -0
- package/dist/react.d.ts +824 -0
- package/dist/react.js +3856 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +3801 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +112 -0
- package/scripts/init.js +196 -0
- package/scripts/postinstall.js +174 -0
- package/scripts/verify-build.js +121 -0
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zopassport",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zo Passport SDK - Phone to Avatar to Passport. Complete authentication and onboarding flow for Zo World.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/react.d.ts",
|
|
16
|
+
"import": "./dist/react.mjs",
|
|
17
|
+
"require": "./dist/react.js"
|
|
18
|
+
},
|
|
19
|
+
"./react-native": {
|
|
20
|
+
"types": "./dist/react-native.d.ts",
|
|
21
|
+
"import": "./dist/react-native.mjs",
|
|
22
|
+
"require": "./dist/react-native.js"
|
|
23
|
+
},
|
|
24
|
+
"./assets": {
|
|
25
|
+
"types": "./dist/assets/index.d.ts",
|
|
26
|
+
"import": "./dist/assets/index.mjs",
|
|
27
|
+
"require": "./dist/assets/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"assets",
|
|
33
|
+
"app/src",
|
|
34
|
+
"app/public",
|
|
35
|
+
"app/package.json",
|
|
36
|
+
"app/README.md",
|
|
37
|
+
"app/vite.config.ts",
|
|
38
|
+
"app/tsconfig.json",
|
|
39
|
+
"app/.env.example",
|
|
40
|
+
"app/reanimated-mock.js",
|
|
41
|
+
"app/reanimated-mock.jsx",
|
|
42
|
+
"app/svg-mock.js",
|
|
43
|
+
"app/svg-mock.jsx",
|
|
44
|
+
"scripts",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/zo-world/zopassport.git"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://zo.xyz",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/zo-world/zopassport/issues"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"dev": "tsup --watch",
|
|
59
|
+
"type-check": "tsc --noEmit",
|
|
60
|
+
"clean": "rm -rf dist"
|
|
61
|
+
},
|
|
62
|
+
"bin": {
|
|
63
|
+
"create-zopassport": "./scripts/init.js"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"axios": "^1.6.0",
|
|
67
|
+
"moment": "^2.30.1"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"react": ">=17.0.0",
|
|
71
|
+
"react-dom": ">=17.0.0",
|
|
72
|
+
"react-native": ">=0.70.0",
|
|
73
|
+
"react-native-reanimated": ">=3.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"react": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"react-dom": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"react-native": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"react-native-reanimated": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@types/react": "^18.3.27",
|
|
91
|
+
"@types/react-dom": "^18.3.7",
|
|
92
|
+
"react": "^18.2.0",
|
|
93
|
+
"react-dom": "^18.2.0",
|
|
94
|
+
"react-native": "^0.74.0",
|
|
95
|
+
"react-native-reanimated": "^4.2.0",
|
|
96
|
+
"react-native-svg": "^15.15.1",
|
|
97
|
+
"tsup": "^8.0.0",
|
|
98
|
+
"typescript": "^5.0.0"
|
|
99
|
+
},
|
|
100
|
+
"keywords": [
|
|
101
|
+
"zo",
|
|
102
|
+
"zo-world",
|
|
103
|
+
"passport",
|
|
104
|
+
"authentication",
|
|
105
|
+
"avatar",
|
|
106
|
+
"phone-auth",
|
|
107
|
+
"otp",
|
|
108
|
+
"sdk"
|
|
109
|
+
],
|
|
110
|
+
"author": "Zo World Team",
|
|
111
|
+
"license": "MIT"
|
|
112
|
+
}
|
package/scripts/init.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zo Passport Initializer
|
|
5
|
+
* Sets up a new Zo Passport app
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
const GREEN = '\x1b[32m';
|
|
13
|
+
const BLUE = '\x1b[34m';
|
|
14
|
+
const YELLOW = '\x1b[33m';
|
|
15
|
+
const RED = '\x1b[31m';
|
|
16
|
+
const RESET = '\x1b[0m';
|
|
17
|
+
const BOLD = '\x1b[1m';
|
|
18
|
+
|
|
19
|
+
function log(message, color = RESET) {
|
|
20
|
+
console.log(`${color}${message}${RESET}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function copyRecursive(src, dest) {
|
|
24
|
+
const stats = fs.statSync(src);
|
|
25
|
+
|
|
26
|
+
if (stats.isDirectory()) {
|
|
27
|
+
if (!fs.existsSync(dest)) {
|
|
28
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
const entries = fs.readdirSync(src);
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (entry === 'node_modules' || entry === 'dist') continue;
|
|
33
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
fs.copyFileSync(src, dest);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function init() {
|
|
41
|
+
log('\n╔════════════════════════════════════════════════════════════╗', BLUE);
|
|
42
|
+
log('║ 🌍 ZO PASSPORT - Project Initialization 🌍 ║', BLUE);
|
|
43
|
+
log('╚════════════════════════════════════════════════════════════╝\n', BLUE);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const cwd = process.cwd();
|
|
47
|
+
|
|
48
|
+
// Check if directory is empty (except for package.json, node_modules)
|
|
49
|
+
const files = fs.readdirSync(cwd).filter(f =>
|
|
50
|
+
!f.startsWith('.') && f !== 'node_modules' && f !== 'package.json' && f !== 'package-lock.json'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (files.length > 0) {
|
|
54
|
+
log('⚠️ Warning: Current directory is not empty', YELLOW);
|
|
55
|
+
log('Files will be copied without overwriting existing files\n', YELLOW);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Find zopassport in node_modules
|
|
59
|
+
const sdkPath = path.join(cwd, 'node_modules', 'zopassport');
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(sdkPath)) {
|
|
62
|
+
log('❌ Error: zopassport not found in node_modules', RED);
|
|
63
|
+
log('\nPlease run: npm install zopassport\n', YELLOW);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const appTemplateDir = path.join(sdkPath, 'app');
|
|
68
|
+
const assetsDir = path.join(sdkPath, 'assets');
|
|
69
|
+
|
|
70
|
+
if (!fs.existsSync(appTemplateDir)) {
|
|
71
|
+
log('❌ Error: App template not found in zopassport', RED);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
log('📋 Copying app files...', BLUE);
|
|
76
|
+
|
|
77
|
+
// Copy app structure
|
|
78
|
+
const appFiles = [
|
|
79
|
+
'src',
|
|
80
|
+
'public',
|
|
81
|
+
'index.html',
|
|
82
|
+
'vite.config.ts',
|
|
83
|
+
'tsconfig.json',
|
|
84
|
+
'.env.example'
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
for (const file of appFiles) {
|
|
88
|
+
const srcPath = path.join(appTemplateDir, file);
|
|
89
|
+
const destPath = path.join(cwd, file);
|
|
90
|
+
|
|
91
|
+
if (fs.existsSync(srcPath)) {
|
|
92
|
+
if (!fs.existsSync(destPath)) {
|
|
93
|
+
log(` ✓ ${file}`, GREEN);
|
|
94
|
+
copyRecursive(srcPath, destPath);
|
|
95
|
+
} else {
|
|
96
|
+
log(` ⊗ ${file} (already exists, skipping)`, YELLOW);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Copy assets to public
|
|
102
|
+
if (fs.existsSync(assetsDir)) {
|
|
103
|
+
const assetsTarget = path.join(cwd, 'public', 'assets');
|
|
104
|
+
if (!fs.existsSync(assetsTarget)) {
|
|
105
|
+
log(' ✓ public/assets/', GREEN);
|
|
106
|
+
copyRecursive(assetsDir, assetsTarget);
|
|
107
|
+
} else {
|
|
108
|
+
log(' ⊗ public/assets/ (already exists, skipping)', YELLOW);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Update or create package.json
|
|
113
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
114
|
+
let packageJson = {};
|
|
115
|
+
|
|
116
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
117
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
118
|
+
log(' ✓ Updating package.json', GREEN);
|
|
119
|
+
} else {
|
|
120
|
+
log(' ✓ Creating package.json', GREEN);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Merge with required fields
|
|
124
|
+
const sdkVersion = JSON.parse(
|
|
125
|
+
fs.readFileSync(path.join(sdkPath, 'package.json'), 'utf-8')
|
|
126
|
+
).version;
|
|
127
|
+
|
|
128
|
+
packageJson = {
|
|
129
|
+
...packageJson,
|
|
130
|
+
name: packageJson.name || 'my-zopassport-app',
|
|
131
|
+
version: packageJson.version || '1.0.0',
|
|
132
|
+
description: packageJson.description || 'Zo Passport - One line reputation to rule the world',
|
|
133
|
+
type: 'module',
|
|
134
|
+
scripts: {
|
|
135
|
+
...packageJson.scripts,
|
|
136
|
+
dev: 'vite',
|
|
137
|
+
build: 'tsc -b && vite build',
|
|
138
|
+
preview: 'vite preview'
|
|
139
|
+
},
|
|
140
|
+
dependencies: {
|
|
141
|
+
...packageJson.dependencies,
|
|
142
|
+
'zopassport': `^${sdkVersion}`,
|
|
143
|
+
'react': '^18.3.1',
|
|
144
|
+
'react-dom': '^18.3.1',
|
|
145
|
+
'react-native-web': '^0.19.12',
|
|
146
|
+
'axios': '^1.6.0',
|
|
147
|
+
'moment': '^2.30.1'
|
|
148
|
+
},
|
|
149
|
+
devDependencies: {
|
|
150
|
+
...packageJson.devDependencies,
|
|
151
|
+
'@types/react': '^18.3.27',
|
|
152
|
+
'@types/react-dom': '^18.3.7',
|
|
153
|
+
'@vitejs/plugin-react': '^4.3.4',
|
|
154
|
+
'typescript': '^5.6.3',
|
|
155
|
+
'vite': '^6.0.3'
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
fs.writeFileSync(
|
|
160
|
+
packageJsonPath,
|
|
161
|
+
JSON.stringify(packageJson, null, 2)
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
log('\n✨ Project initialized successfully!\n', GREEN);
|
|
165
|
+
|
|
166
|
+
// Next steps
|
|
167
|
+
log('╔════════════════════════════════════════════════════════════╗', GREEN);
|
|
168
|
+
log('║ 🎉 READY TO GO! 🎉 ║', GREEN);
|
|
169
|
+
log('╠════════════════════════════════════════════════════════════╣', GREEN);
|
|
170
|
+
log('║ Next steps: ║', GREEN);
|
|
171
|
+
log('║ ║', GREEN);
|
|
172
|
+
log('║ 1. Copy the environment template: ║', GREEN);
|
|
173
|
+
log('║ ' + BOLD + 'cp .env.example .env' + RESET + GREEN + ' ║', GREEN);
|
|
174
|
+
log('║ ║', GREEN);
|
|
175
|
+
log('║ 2. Edit .env with your Zo client key: ║', GREEN);
|
|
176
|
+
log('║ ' + BOLD + 'VITE_ZO_CLIENT_KEY=your-key-here' + RESET + GREEN + ' ║', GREEN);
|
|
177
|
+
log('║ Get your key: https://zo.xyz/developers ║', GREEN);
|
|
178
|
+
log('║ ║', GREEN);
|
|
179
|
+
log('║ 3. Install dependencies: ║', GREEN);
|
|
180
|
+
log('║ ' + BOLD + 'npm install' + RESET + GREEN + ' ║', GREEN);
|
|
181
|
+
log('║ ║', GREEN);
|
|
182
|
+
log('║ 4. Start the dev server: ║', GREEN);
|
|
183
|
+
log('║ ' + BOLD + 'npm run dev' + RESET + GREEN + ' ║', GREEN);
|
|
184
|
+
log('║ ║', GREEN);
|
|
185
|
+
log('║ 🌍 One line reputation to rule the world ║', GREEN);
|
|
186
|
+
log('╚════════════════════════════════════════════════════════════╝\n', GREEN);
|
|
187
|
+
|
|
188
|
+
} catch (error) {
|
|
189
|
+
log('\n❌ Initialization failed:', RED);
|
|
190
|
+
console.error(error);
|
|
191
|
+
log('\nReport issues: https://github.com/zo-world/zopassport/issues\n', YELLOW);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
init().catch(console.error);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Post-install script for zopassport
|
|
5
|
+
* Sets up the demo app with all dependencies and assets
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
const GREEN = '\x1b[32m';
|
|
13
|
+
const BLUE = '\x1b[34m';
|
|
14
|
+
const YELLOW = '\x1b[33m';
|
|
15
|
+
const RESET = '\x1b[0m';
|
|
16
|
+
const BOLD = '\x1b[1m';
|
|
17
|
+
|
|
18
|
+
function log(message, color = RESET) {
|
|
19
|
+
console.log(`${color}${message}${RESET}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function copyRecursive(src, dest) {
|
|
23
|
+
const stats = fs.statSync(src);
|
|
24
|
+
|
|
25
|
+
if (stats.isDirectory()) {
|
|
26
|
+
if (!fs.existsSync(dest)) {
|
|
27
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
const entries = fs.readdirSync(src);
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
fs.copyFileSync(src, dest);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function setup() {
|
|
39
|
+
log('\n╔════════════════════════════════════════════════════════════╗', BLUE);
|
|
40
|
+
log('║ 🌍 ZO PASSPORT - Installation Setup 🌍 ║', BLUE);
|
|
41
|
+
log('╚════════════════════════════════════════════════════════════╝\n', BLUE);
|
|
42
|
+
|
|
43
|
+
// Check if we're in a fresh install (not in the SDK repo itself)
|
|
44
|
+
const cwd = process.cwd();
|
|
45
|
+
const isDevMode = fs.existsSync(path.join(cwd, 'tsup.config.ts'));
|
|
46
|
+
|
|
47
|
+
if (isDevMode) {
|
|
48
|
+
log('📦 Development mode detected - skipping setup\n', YELLOW);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
// Find the package installation directory
|
|
54
|
+
const packageDir = path.join(__dirname, '..');
|
|
55
|
+
const appTemplateDir = path.join(packageDir, 'app');
|
|
56
|
+
const assetsDir = path.join(packageDir, 'assets');
|
|
57
|
+
|
|
58
|
+
// Target directory for the demo app
|
|
59
|
+
const targetDir = cwd;
|
|
60
|
+
|
|
61
|
+
log('📋 Copying demo application files...', BLUE);
|
|
62
|
+
|
|
63
|
+
// Copy app files
|
|
64
|
+
if (fs.existsSync(appTemplateDir)) {
|
|
65
|
+
const appFiles = [
|
|
66
|
+
'src',
|
|
67
|
+
'public',
|
|
68
|
+
'index.html',
|
|
69
|
+
'vite.config.ts',
|
|
70
|
+
'tsconfig.json',
|
|
71
|
+
'.env.example'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
for (const file of appFiles) {
|
|
75
|
+
const srcPath = path.join(appTemplateDir, file);
|
|
76
|
+
const destPath = path.join(targetDir, file);
|
|
77
|
+
|
|
78
|
+
if (fs.existsSync(srcPath)) {
|
|
79
|
+
if (!fs.existsSync(destPath)) {
|
|
80
|
+
log(` ✓ ${file}`, GREEN);
|
|
81
|
+
copyRecursive(srcPath, destPath);
|
|
82
|
+
} else {
|
|
83
|
+
log(` ⊗ ${file} (already exists, skipping)`, YELLOW);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Copy assets
|
|
89
|
+
if (fs.existsSync(assetsDir)) {
|
|
90
|
+
const assetsTarget = path.join(targetDir, 'public', 'assets');
|
|
91
|
+
if (!fs.existsSync(assetsTarget)) {
|
|
92
|
+
log(' ✓ assets/', GREEN);
|
|
93
|
+
copyRecursive(assetsDir, assetsTarget);
|
|
94
|
+
} else {
|
|
95
|
+
log(' ⊗ assets/ (already exists, skipping)', YELLOW);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Create package.json if it doesn't exist
|
|
100
|
+
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
101
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
102
|
+
const demoPackageJson = {
|
|
103
|
+
name: 'my-zopassport-app',
|
|
104
|
+
version: '1.0.0',
|
|
105
|
+
description: 'Zo Passport - One line reputation to rule the world',
|
|
106
|
+
type: 'module',
|
|
107
|
+
scripts: {
|
|
108
|
+
dev: 'vite',
|
|
109
|
+
build: 'tsc -b && vite build',
|
|
110
|
+
preview: 'vite preview'
|
|
111
|
+
},
|
|
112
|
+
dependencies: {
|
|
113
|
+
'zopassport-sdk': require(path.join(packageDir, 'package.json')).version,
|
|
114
|
+
'react': '^18.3.1',
|
|
115
|
+
'react-dom': '^18.3.1',
|
|
116
|
+
'react-native-web': '^0.19.12',
|
|
117
|
+
'axios': '^1.6.0',
|
|
118
|
+
'moment': '^2.30.1'
|
|
119
|
+
},
|
|
120
|
+
devDependencies: {
|
|
121
|
+
'@types/react': '^18.3.27',
|
|
122
|
+
'@types/react-dom': '^18.3.7',
|
|
123
|
+
'@vitejs/plugin-react': '^4.3.4',
|
|
124
|
+
'typescript': '^5.6.3',
|
|
125
|
+
'vite': '^6.0.3'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
fs.writeFileSync(
|
|
130
|
+
packageJsonPath,
|
|
131
|
+
JSON.stringify(demoPackageJson, null, 2)
|
|
132
|
+
);
|
|
133
|
+
log(' ✓ package.json', GREEN);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
log('\n✨ Demo app files copied successfully!\n', GREEN);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Installation instructions
|
|
140
|
+
log('╔════════════════════════════════════════════════════════════╗', GREEN);
|
|
141
|
+
log('║ 🎉 SETUP COMPLETE! 🎉 ║', GREEN);
|
|
142
|
+
log('╠════════════════════════════════════════════════════════════╣', GREEN);
|
|
143
|
+
log('║ Next steps: ║', GREEN);
|
|
144
|
+
log('║ ║', GREEN);
|
|
145
|
+
log('║ 1. Copy the example environment file: ║', GREEN);
|
|
146
|
+
log('║ ' + BOLD + 'cp .env.example .env' + RESET + GREEN + ' ║', GREEN);
|
|
147
|
+
log('║ ║', GREEN);
|
|
148
|
+
log('║ 2. Edit .env and add your Zo client key: ║', GREEN);
|
|
149
|
+
log('║ ' + BOLD + 'VITE_ZO_CLIENT_KEY=your-key-here' + RESET + GREEN + ' ║', GREEN);
|
|
150
|
+
log('║ Get your key at: https://zo.xyz/developers ║', GREEN);
|
|
151
|
+
log('║ ║', GREEN);
|
|
152
|
+
log('║ 3. Install dependencies: ║', GREEN);
|
|
153
|
+
log('║ ' + BOLD + 'npm install' + RESET + GREEN + ' ║', GREEN);
|
|
154
|
+
log('║ ║', GREEN);
|
|
155
|
+
log('║ 4. Start the development server: ║', GREEN);
|
|
156
|
+
log('║ ' + BOLD + 'npm run dev' + RESET + GREEN + ' ║', GREEN);
|
|
157
|
+
log('║ ║', GREEN);
|
|
158
|
+
log('║ 🌍 One line reputation to rule the world ║', GREEN);
|
|
159
|
+
log('╚════════════════════════════════════════════════════════════╝\n', GREEN);
|
|
160
|
+
|
|
161
|
+
} catch (error) {
|
|
162
|
+
log('\n❌ Setup failed:', 'red');
|
|
163
|
+
console.error(error);
|
|
164
|
+
log('\nPlease report this issue at: https://github.com/zo-world/zopassport/issues\n', YELLOW);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Only run if called directly (not required as module)
|
|
170
|
+
if (require.main === module) {
|
|
171
|
+
setup().catch(console.error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = { setup };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const Module = require('module');
|
|
2
|
+
const originalRequire = Module.prototype.require;
|
|
3
|
+
|
|
4
|
+
// Mock React Native and other UI dependencies
|
|
5
|
+
const mockComponent = () => 'MockComponent';
|
|
6
|
+
const mockRN = {
|
|
7
|
+
View: mockComponent,
|
|
8
|
+
Text: mockComponent,
|
|
9
|
+
Image: mockComponent,
|
|
10
|
+
ScrollView: mockComponent,
|
|
11
|
+
Pressable: mockComponent,
|
|
12
|
+
ActivityIndicator: mockComponent,
|
|
13
|
+
StyleSheet: { create: (obj) => obj },
|
|
14
|
+
Platform: { OS: 'ios' },
|
|
15
|
+
SafeAreaView: mockComponent,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mockReanimated = {
|
|
19
|
+
default: {
|
|
20
|
+
View: mockComponent,
|
|
21
|
+
createAnimatedComponent: (c) => c,
|
|
22
|
+
},
|
|
23
|
+
FadeIn: {},
|
|
24
|
+
FadeOut: {},
|
|
25
|
+
FadeInUp: {},
|
|
26
|
+
FadeOutUp: {},
|
|
27
|
+
FadeInDown: {},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const mockSvg = {
|
|
31
|
+
Svg: mockComponent,
|
|
32
|
+
Path: mockComponent,
|
|
33
|
+
Circle: mockComponent,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Patch require to return mocks
|
|
37
|
+
Module.prototype.require = function (path) {
|
|
38
|
+
if (path === 'react-native') return mockRN;
|
|
39
|
+
if (path === 'react-native-reanimated') return mockReanimated;
|
|
40
|
+
if (path === 'react-native-svg') return mockSvg;
|
|
41
|
+
if (path === 'moment') return () => ({ format: () => 'date' });
|
|
42
|
+
return originalRequire.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const { ZoPassportSDK, ZoWallet } = require('../dist/index.js');
|
|
46
|
+
|
|
47
|
+
console.log('--- Verifying Core SDK Exports ---');
|
|
48
|
+
|
|
49
|
+
if (typeof ZoPassportSDK !== 'function') {
|
|
50
|
+
console.error('FAIL: ZoPassportSDK is not exported as a constructor');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
} else {
|
|
53
|
+
console.log('PASS: ZoPassportSDK is exported');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof ZoWallet !== 'function') {
|
|
57
|
+
console.error('FAIL: ZoWallet is not exported');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
} else {
|
|
60
|
+
console.log('PASS: ZoWallet is exported');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const sdk = new ZoPassportSDK({ clientKey: 'test-key' });
|
|
65
|
+
console.log('PASS: ZoPassportSDK instantiated');
|
|
66
|
+
|
|
67
|
+
if (sdk.wallet && typeof sdk.wallet.getBalance === 'function') {
|
|
68
|
+
console.log('PASS: sdk.wallet.getBalance is available');
|
|
69
|
+
} else {
|
|
70
|
+
console.error('FAIL: sdk.wallet is missing or malformed');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error('FAIL: Error instantiating SDK:', e);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('\n--- Verifying React Exports ---');
|
|
79
|
+
|
|
80
|
+
// Now require React exports with mocks in place
|
|
81
|
+
const ReactExports = require('../dist/react.js');
|
|
82
|
+
|
|
83
|
+
const expectedComponents = [
|
|
84
|
+
'WalletScreen',
|
|
85
|
+
'WalletCard',
|
|
86
|
+
'TransactionList',
|
|
87
|
+
'TransactionItem',
|
|
88
|
+
'ZoToken'
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
let missingComponents = [];
|
|
92
|
+
expectedComponents.forEach(comp => {
|
|
93
|
+
if (ReactExports[comp]) {
|
|
94
|
+
console.log(`PASS: ${comp} is exported`);
|
|
95
|
+
} else {
|
|
96
|
+
console.error(`FAIL: ${comp} is missing`);
|
|
97
|
+
missingComponents.push(comp);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const expectedHooks = [
|
|
102
|
+
'useWallet',
|
|
103
|
+
'useWalletBalance',
|
|
104
|
+
'useTransactions'
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
expectedHooks.forEach(hook => {
|
|
108
|
+
if (ReactExports[hook]) {
|
|
109
|
+
console.log(`PASS: ${hook} is exported`);
|
|
110
|
+
} else {
|
|
111
|
+
console.error(`FAIL: ${hook} is missing`);
|
|
112
|
+
missingComponents.push(hook);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (missingComponents.length > 0) {
|
|
117
|
+
console.error('Some React exports are missing!');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log('\nSUCCESS: All verification checks passed!');
|