@lumiapassport/ui-kit 1.16.9 → 1.17.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/README.md +87 -7
- package/dist/iframe/index.html +1 -1
- package/dist/iframe/main.js +6 -15
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +16187 -14339
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +852 -162
- package/dist/index.d.ts +852 -162
- package/dist/index.js +16068 -14238
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -22,9 +22,11 @@ yarn add @lumiapassport/ui-kit
|
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The UI Kit requires `@tanstack/react-query` for query management & `i18next` + `react-i18next` for multilanguages support.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### 1. QueryClient Setup (Required)
|
|
28
|
+
|
|
29
|
+
First, create a query client:
|
|
28
30
|
|
|
29
31
|
```tsx
|
|
30
32
|
// queryClient.ts
|
|
@@ -35,19 +37,84 @@ export const queryClient = new QueryClient({
|
|
|
35
37
|
})
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
### 2.
|
|
40
|
+
### 2. I18n config (Required) & typing (Optional)
|
|
41
|
+
|
|
42
|
+
i18next lib should be inited above both passport & your app, so your app language can be switched by Passport's lang selector.
|
|
43
|
+
Create the following folder structure for your app's translations:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
src/
|
|
47
|
+
└── i18n/
|
|
48
|
+
├── locales/
|
|
49
|
+
│ └── en.json
|
|
50
|
+
└── index.ts
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Where:
|
|
54
|
+
|
|
55
|
+
- `locales/*.json` files contain i18next translation maps
|
|
56
|
+
- `index.ts` exports translation resources as const
|
|
57
|
+
|
|
58
|
+
`IMPORTANT` YOUR_APP_TRANSLATION_RESOURSES should be structured with namespaces as shown, where "app" is example namespace
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import en from './locales/en.json'
|
|
62
|
+
|
|
63
|
+
export const YOUR_APP_TRANSLATION_RESOURSES = {
|
|
64
|
+
en: { app: en } // language: { namespace: jsonLocale }
|
|
65
|
+
// ...
|
|
66
|
+
} as const
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`NOTE` If you don't need to translate your app then leave YOUR_APP_TRANSLATION_RESOURSES empty. Also there is no need in locales folder
|
|
70
|
+
|
|
71
|
+
Decalre types at `src/i18next.d.ts` so t-method provides intellisence typings for yor translations, your default locale can be used for typing
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import en from './i18n/locales/en.json'
|
|
75
|
+
|
|
76
|
+
declare module 'i18next' {
|
|
77
|
+
interface CustomTypeOptions {
|
|
78
|
+
defaultNS: 'app' //
|
|
79
|
+
resources: {
|
|
80
|
+
app: typeof en
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Wrap your app with providers & init i18n
|
|
39
87
|
|
|
40
88
|
```tsx
|
|
41
89
|
import {
|
|
90
|
+
combineI18NResources,
|
|
91
|
+
LOCAL_STORAGE_I18N_KEY,
|
|
42
92
|
//
|
|
43
93
|
LumiaPassportProvider,
|
|
44
94
|
LumiaPassportSessionProvider,
|
|
45
95
|
LumiaRainbowKitProvider
|
|
46
96
|
} from '@lumiapassport/ui-kit'
|
|
97
|
+
//
|
|
98
|
+
import i18n from 'i18next'
|
|
99
|
+
import { initReactI18next, useTranslation } from 'react-i18next'
|
|
47
100
|
|
|
101
|
+
// import { YOUR_APP_TRANSLATION_RESOURSES } from './i18n'
|
|
48
102
|
import { queryClient } from './queryClient'
|
|
49
103
|
|
|
104
|
+
const i18nResourcesWithPassport = combineI18NResources(/** YOUR_APP_TRANSLATION_RESOURSES */)
|
|
105
|
+
const savedLanguage = localStorage.getItem(LOCAL_STORAGE_I18N_KEY) // passport saves language setup on change
|
|
106
|
+
|
|
107
|
+
i18n.use(initReactI18next).init({
|
|
108
|
+
resources: i18nResourcesWithPassport,
|
|
109
|
+
lng: savedLanguage || 'en',
|
|
110
|
+
fallbackLng: 'en', // default
|
|
111
|
+
defaultNS: 'app', // your app i18n-namespace, example: app
|
|
112
|
+
debug: false
|
|
113
|
+
})
|
|
114
|
+
|
|
50
115
|
function Root() {
|
|
116
|
+
const { t } = useTranslation(/** optionaly our app i18next namespace, example namespace: app */)
|
|
117
|
+
|
|
51
118
|
return (
|
|
52
119
|
<QueryClientProvider client={queryClient}>
|
|
53
120
|
<LumiaPassportProvider
|
|
@@ -55,6 +122,8 @@ function Root() {
|
|
|
55
122
|
>
|
|
56
123
|
<LumiaRainbowKitProvider>
|
|
57
124
|
<LumiaPassportSessionProvider>
|
|
125
|
+
{/* Note! provided translation resourses will be available under provided namespace, example namespace: app */}
|
|
126
|
+
{/* <span>{t('app:title')}</span> */}
|
|
58
127
|
<YourApp />
|
|
59
128
|
</LumiaPassportSessionProvider>
|
|
60
129
|
</LumiaRainbowKitProvider>
|
|
@@ -64,7 +133,7 @@ function Root() {
|
|
|
64
133
|
}
|
|
65
134
|
```
|
|
66
135
|
|
|
67
|
-
###
|
|
136
|
+
### 4. Add the Connect Button
|
|
68
137
|
|
|
69
138
|
```tsx
|
|
70
139
|
import { ConnectWalletButton } from '@lumiapassport/ui-kit'
|
|
@@ -79,7 +148,7 @@ function YourApp() {
|
|
|
79
148
|
}
|
|
80
149
|
```
|
|
81
150
|
|
|
82
|
-
###
|
|
151
|
+
### 5. (Optional)
|
|
83
152
|
|
|
84
153
|
Custom unconnected button can be provided via ConnectButton prop.
|
|
85
154
|
Prop consumes standart HTMLButton component and will provide required onClick to it
|
|
@@ -116,7 +185,7 @@ That's it! The `ConnectWalletButton` provides a complete authentication UI with
|
|
|
116
185
|
network: {
|
|
117
186
|
name: 'Lumia Beam',
|
|
118
187
|
symbol: 'LUMIA',
|
|
119
|
-
chainId: 2030232745,
|
|
188
|
+
chainId: 2030232745, // Default chain for your dApp
|
|
120
189
|
rpcUrl: 'https://beam-rpc.lumia.org',
|
|
121
190
|
explorerUrl: 'https://beam-explorer.lumia.org',
|
|
122
191
|
testnet: true,
|
|
@@ -125,6 +194,16 @@ That's it! The `ConnectWalletButton` provides a complete authentication UI with
|
|
|
125
194
|
>
|
|
126
195
|
```
|
|
127
196
|
|
|
197
|
+
**Network Chain Priority:**
|
|
198
|
+
|
|
199
|
+
The SDK uses the following priority for determining the active chain:
|
|
200
|
+
|
|
201
|
+
1. **User's explicit selection** - If user manually switched chains in the UI, their choice is preserved (stored in localStorage)
|
|
202
|
+
2. **dApp config `network.chainId`** - Your configured default chain for first-time users
|
|
203
|
+
3. **SDK default** - Lumia Testnet (fallback if no config provided)
|
|
204
|
+
|
|
205
|
+
This ensures returning users keep their preferred chain while new users start on your configured network.
|
|
206
|
+
|
|
128
207
|
### Advanced Configuration
|
|
129
208
|
|
|
130
209
|
```tsx
|
|
@@ -196,10 +275,11 @@ That's it! The `ConnectWalletButton` provides a complete authentication UI with
|
|
|
196
275
|
},
|
|
197
276
|
|
|
198
277
|
// Network configuration
|
|
278
|
+
// chainId sets default chain for new users (see "Network Chain Priority" above)
|
|
199
279
|
network: {
|
|
200
280
|
name: 'Lumia Beam',
|
|
201
281
|
symbol: 'LUMIA',
|
|
202
|
-
chainId: 2030232745,
|
|
282
|
+
chainId: 2030232745, // Your dApp's default chain
|
|
203
283
|
rpcUrl: 'https\:\/\/beam-rpc.lumia.org',
|
|
204
284
|
explorerUrl: 'https\:\/\/beam-explorer.lumia.org',
|
|
205
285
|
testnet: true,
|
package/dist/iframe/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<meta http-equiv="X-Content-Type-Options" content="nosniff" />
|
|
16
16
|
<meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
|
|
17
17
|
|
|
18
|
-
<title>Lumia Passport Secure Wallet - iframe version 1.
|
|
18
|
+
<title>Lumia Passport Secure Wallet - iframe version 1.17.0</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -1327,7 +1327,7 @@ function buildAuthorizationTemplateData(project, origin, metadata, userProfile)
|
|
|
1327
1327
|
const displayLogo = metadata?.logo || project.logoUrl || "";
|
|
1328
1328
|
const displayDescription = metadata?.description || "";
|
|
1329
1329
|
const userAvatar = userProfile?.avatar || "";
|
|
1330
|
-
const userName = userProfile?.displayName || "
|
|
1330
|
+
const userName = userProfile?.displayName || "Mbark Wallet";
|
|
1331
1331
|
return {
|
|
1332
1332
|
// Display
|
|
1333
1333
|
displayName,
|
|
@@ -1363,7 +1363,7 @@ function buildSignTxTemplateData(project, origin, typedData, metadata, userProfi
|
|
|
1363
1363
|
const metadataName = metadata?.name || project.name;
|
|
1364
1364
|
const metadataLogo = metadata?.logo || project.logoUrl || "";
|
|
1365
1365
|
const userAvatar = userProfile?.avatar || "";
|
|
1366
|
-
const userName = userProfile?.displayName || "
|
|
1366
|
+
const userName = userProfile?.displayName || "Mbark Wallet";
|
|
1367
1367
|
const formatFieldValue = (value) => {
|
|
1368
1368
|
if (Array.isArray(value)) {
|
|
1369
1369
|
return `[${value.map((v) => formatFieldValue(v)).join(", ")}]`;
|
|
@@ -1478,7 +1478,7 @@ function buildConfirmTxTemplateData(project, origin, transaction, risk, metadata
|
|
|
1478
1478
|
const displayName = metadata?.name || project.name;
|
|
1479
1479
|
const displayLogo = metadata?.logo || project.logoUrl || "";
|
|
1480
1480
|
const userAvatar = userProfile?.avatar || "";
|
|
1481
|
-
const userName = userProfile?.displayName || "
|
|
1481
|
+
const userName = userProfile?.displayName || "Mbark Wallet";
|
|
1482
1482
|
const domainStatusClass = isVerifiedOrigin ? "verified" : "unverified";
|
|
1483
1483
|
const domainStatusText = isVerifiedOrigin ? "\u2705" : "\u26A0\uFE0F";
|
|
1484
1484
|
const fromAddressFull = transaction.userOpDetails?.sender || "";
|
|
@@ -2043,7 +2043,7 @@ var GoogleDriveProvider = class {
|
|
|
2043
2043
|
return this.performUpload(metadata, content);
|
|
2044
2044
|
}
|
|
2045
2045
|
async uploadToAppFolder(fileName, content) {
|
|
2046
|
-
const folderName = "
|
|
2046
|
+
const folderName = "Mbark Wallet Backups";
|
|
2047
2047
|
const folderId = await this.findOrCreateFolder(folderName);
|
|
2048
2048
|
const metadata = {
|
|
2049
2049
|
name: fileName,
|
|
@@ -3236,16 +3236,7 @@ var RampnowOnrampAPI = class {
|
|
|
3236
3236
|
};
|
|
3237
3237
|
|
|
3238
3238
|
// src/lib/errors.ts
|
|
3239
|
-
|
|
3240
|
-
constructor(message, code) {
|
|
3241
|
-
super(message);
|
|
3242
|
-
this.code = code;
|
|
3243
|
-
this.name = "LumiaPassportError";
|
|
3244
|
-
if (Error.captureStackTrace) {
|
|
3245
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
};
|
|
3239
|
+
import { LumiaPassportError } from "@lumiapassport/core";
|
|
3249
3240
|
var _UserRejectedError = class _UserRejectedError extends LumiaPassportError {
|
|
3250
3241
|
constructor(message = "User rejected transaction") {
|
|
3251
3242
|
super(message, _UserRejectedError.CODE);
|
|
@@ -4411,7 +4402,7 @@ var SigningManager = class extends TokenRefreshApiClient {
|
|
|
4411
4402
|
};
|
|
4412
4403
|
|
|
4413
4404
|
// src/iframe/main.ts
|
|
4414
|
-
var IFRAME_VERSION = "1.
|
|
4405
|
+
var IFRAME_VERSION = "1.17.0";
|
|
4415
4406
|
var IframeWallet = class {
|
|
4416
4407
|
constructor() {
|
|
4417
4408
|
console.log("=".repeat(60));
|