@worldcoin/idkit 2.3.0 → 2.4.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.
- package/README.md +33 -0
- package/build/chunk-PWFTYFSZ.js +373 -0
- package/build/{config-BRFx4nLT.d.cts → config-SH5TbLYj.d.cts} +13 -1
- package/build/{config-BRFx4nLT.d.ts → config-SH5TbLYj.d.ts} +13 -1
- package/build/index.cjs +275 -53
- package/build/index.d.cts +2 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +130 -45
- package/build/internal.cjs +154 -10
- package/build/internal.d.cts +23 -8
- package/build/internal.d.ts +23 -8
- package/build/internal.js +10 -2
- package/package.json +4 -1
- package/src/index.ts +15 -2
- package/build/chunk-3HCETHXP.js +0 -233
package/build/index.cjs
CHANGED
|
@@ -33,6 +33,10 @@ __export(src_exports, {
|
|
|
33
33
|
IDKitWidget: () => IDKitWidget_default,
|
|
34
34
|
VerificationLevel: () => import_idkit_core7.VerificationLevel,
|
|
35
35
|
VerificationState: () => import_idkit_core7.VerificationState,
|
|
36
|
+
getCurrentLanguage: () => getCurrentLanguage,
|
|
37
|
+
getLocalizationConfig: () => getLocalizationConfig,
|
|
38
|
+
getSupportedLanguages: () => getSupportedLanguages,
|
|
39
|
+
setLocalizationConfig: () => setLocalizationConfig,
|
|
36
40
|
solidityEncode: () => import_hashing.solidityEncode,
|
|
37
41
|
useIDKit: () => useIDKit_default,
|
|
38
42
|
useSession: () => useSession,
|
|
@@ -43,21 +47,157 @@ module.exports = __toCommonJS(src_exports);
|
|
|
43
47
|
// src/hooks/useIDKit.ts
|
|
44
48
|
var import_react = require("react");
|
|
45
49
|
|
|
50
|
+
// src/lang/translations/en.ts
|
|
51
|
+
var en = {
|
|
52
|
+
"All set!": "All set!",
|
|
53
|
+
"Your World ID is now connected": "Your World ID is now connected",
|
|
54
|
+
"Transmitting verification to host app. Please wait...": "Transmitting verification to host app. Please wait...",
|
|
55
|
+
"Something went wrong": "Something went wrong",
|
|
56
|
+
"Verification Declined": "Verification Declined",
|
|
57
|
+
"Request cancelled": "Request cancelled",
|
|
58
|
+
"Connection to your wallet failed. Please try again.": "Connection to your wallet failed. Please try again.",
|
|
59
|
+
"You've cancelled the request in World App.": "You've cancelled the request in World App.",
|
|
60
|
+
"You have already verified the maximum number of times for this action.": "You have already verified the maximum number of times for this action.",
|
|
61
|
+
"It seems you do not have the verification level required by this app.": "It seems you do not have the verification level required by this app.",
|
|
62
|
+
"Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Invalid network. If you are the app owner, visit docs.world.org/test for details.",
|
|
63
|
+
"Your identity is still being registered. Please wait a few minutes and try again.": "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
64
|
+
"We couldn't complete your request. Please try again.": "We couldn't complete your request. Please try again.",
|
|
65
|
+
"Try Again": "Try Again",
|
|
66
|
+
"Open World App": "Open World App",
|
|
67
|
+
"Hide QR Code": "Hide QR Code",
|
|
68
|
+
"Display QR Code": "Display QR Code",
|
|
69
|
+
"QR Code copied": "QR Code copied",
|
|
70
|
+
"Connect your World ID": "Connect your World ID",
|
|
71
|
+
"Use phone camera to scan the QR code": "Use phone camera to scan the QR code",
|
|
72
|
+
"Connecting...": "Connecting...",
|
|
73
|
+
"Please continue in app": "Please continue in app",
|
|
74
|
+
"You will be redirected to the app, please return to this page once you're done": "You will be redirected to the app, please return to this page once you're done",
|
|
75
|
+
"Action cannot be an empty string.": "Action cannot be an empty string.",
|
|
76
|
+
"Invalid IDKitStage :stage.": "Invalid IDKitStage :stage.",
|
|
77
|
+
"Terms & Privacy": "Terms & Privacy"
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/lang/translations/es.ts
|
|
81
|
+
var es = {
|
|
82
|
+
"All set!": "\xA1Todo listo!",
|
|
83
|
+
"Your World ID is now connected": "Tu World ID ahora est\xE1 conectado",
|
|
84
|
+
"Transmitting verification to host app. Please wait...": "Transmitiendo verificaci\xF3n a la aplicaci\xF3n host. Por favor espera...",
|
|
85
|
+
"Something went wrong": "Algo sali\xF3 mal",
|
|
86
|
+
"Verification Declined": "Verificaci\xF3n rechazada",
|
|
87
|
+
"Request cancelled": "Solicitud cancelada",
|
|
88
|
+
"Connection to your wallet failed. Please try again.": "La conexi\xF3n a tu billetera fall\xF3. Por favor intenta de nuevo.",
|
|
89
|
+
"You've cancelled the request in World App.": "Has cancelado la solicitud en World App.",
|
|
90
|
+
"You have already verified the maximum number of times for this action.": "Ya has verificado el n\xFAmero m\xE1ximo de veces para esta acci\xF3n.",
|
|
91
|
+
"It seems you do not have the verification level required by this app.": "Parece que no tienes el nivel de verificaci\xF3n requerido por esta aplicaci\xF3n.",
|
|
92
|
+
"Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Red inv\xE1lida. Si eres el propietario de la aplicaci\xF3n, visita docs.world.org/test para m\xE1s detalles.",
|
|
93
|
+
"Your identity is still being registered. Please wait a few minutes and try again.": "Tu identidad a\xFAn se est\xE1 registrando. Por favor espera unos minutos e intenta de nuevo.",
|
|
94
|
+
"We couldn't complete your request. Please try again.": "No pudimos completar tu solicitud. Por favor intenta de nuevo.",
|
|
95
|
+
"Try Again": "Intentar de nuevo",
|
|
96
|
+
"Open World App": "Abrir World App",
|
|
97
|
+
"Hide QR Code": "Ocultar c\xF3digo QR",
|
|
98
|
+
"Display QR Code": "Mostrar c\xF3digo QR",
|
|
99
|
+
"QR Code copied": "C\xF3digo QR copiado",
|
|
100
|
+
"Connect your World ID": "Conecta tu World ID",
|
|
101
|
+
"Use phone camera to scan the QR code": "Usa la c\xE1mara del tel\xE9fono para escanear el c\xF3digo QR",
|
|
102
|
+
"Connecting...": "Conectando...",
|
|
103
|
+
"Please continue in app": "Por favor contin\xFAa en la aplicaci\xF3n",
|
|
104
|
+
"You will be redirected to the app, please return to this page once you're done": "Ser\xE1s redirigido a la aplicaci\xF3n, por favor regresa a esta p\xE1gina una vez que hayas terminado",
|
|
105
|
+
"Action cannot be an empty string.": "La acci\xF3n no puede ser una cadena vac\xEDa.",
|
|
106
|
+
"Invalid IDKitStage :stage.": "IDKitStage inv\xE1lido :stage.",
|
|
107
|
+
"Terms & Privacy": "T\xE9rminos y privacidad"
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/lang/translations/th.ts
|
|
111
|
+
var th = {
|
|
112
|
+
"All set!": "\u0E40\u0E23\u0E35\u0E22\u0E1A\u0E23\u0E49\u0E2D\u0E22!",
|
|
113
|
+
"Your World ID is now connected": "World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E41\u0E25\u0E49\u0E27",
|
|
114
|
+
"Transmitting verification to host app. Please wait...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E2A\u0E48\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B\u0E42\u0E2E\u0E2A\u0E15\u0E4C \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48...",
|
|
115
|
+
"Something went wrong": "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14",
|
|
116
|
+
"Verification Declined": "\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E16\u0E39\u0E01\u0E1B\u0E0F\u0E34\u0E40\u0E2A\u0E18",
|
|
117
|
+
"Request cancelled": "\u0E04\u0E33\u0E02\u0E2D\u0E16\u0E39\u0E01\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
|
|
118
|
+
"Connection to your wallet failed. Please try again.": "\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E01\u0E31\u0E1A\u0E01\u0E23\u0E30\u0E40\u0E1B\u0E4B\u0E32\u0E40\u0E07\u0E34\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
|
|
119
|
+
"You've cancelled the request in World App.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01\u0E04\u0E33\u0E02\u0E2D\u0E43\u0E19 World App",
|
|
120
|
+
"You have already verified the maximum number of times for this action.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E04\u0E23\u0E1A\u0E08\u0E33\u0E19\u0E27\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E19\u0E35\u0E49\u0E41\u0E25\u0E49\u0E27",
|
|
121
|
+
"It seems you do not have the verification level required by this app.": "\u0E14\u0E39\u0E40\u0E2B\u0E21\u0E37\u0E2D\u0E19\u0E27\u0E48\u0E32\u0E04\u0E38\u0E13\u0E44\u0E21\u0E48\u0E21\u0E35\u0E23\u0E30\u0E14\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E2D\u0E1B\u0E19\u0E35\u0E49\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23",
|
|
122
|
+
"Invalid network. If you are the app owner, visit docs.world.org/test for details.": "\u0E40\u0E04\u0E23\u0E37\u0E2D\u0E02\u0E48\u0E32\u0E22\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 \u0E2B\u0E32\u0E01\u0E04\u0E38\u0E13\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E08\u0E49\u0E32\u0E02\u0E2D\u0E07\u0E41\u0E2D\u0E1B \u0E42\u0E1B\u0E23\u0E14\u0E44\u0E1B\u0E17\u0E35\u0E48 docs.world.org/test \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14",
|
|
123
|
+
"Your identity is still being registered. Please wait a few minutes and try again.": "\u0E15\u0E31\u0E27\u0E15\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E22\u0E31\u0E07\u0E2D\u0E22\u0E39\u0E48\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E01\u0E32\u0E23\u0E25\u0E07\u0E17\u0E30\u0E40\u0E1A\u0E35\u0E22\u0E19 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
|
|
124
|
+
"We couldn't complete your request. Please try again.": "\u0E40\u0E23\u0E32\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E32\u0E21\u0E04\u0E33\u0E02\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
|
|
125
|
+
"Try Again": "\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
|
|
126
|
+
"Open World App": "\u0E40\u0E1B\u0E34\u0E14 World App",
|
|
127
|
+
"Hide QR Code": "\u0E0B\u0E48\u0E2D\u0E19 QR Code",
|
|
128
|
+
"Display QR Code": "\u0E41\u0E2A\u0E14\u0E07 QR Code",
|
|
129
|
+
"QR Code copied": "\u0E04\u0E31\u0E14\u0E25\u0E2D\u0E01 QR Code \u0E41\u0E25\u0E49\u0E27",
|
|
130
|
+
"Connect your World ID": "\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13",
|
|
131
|
+
"Use phone camera to scan the QR code": "\u0E43\u0E0A\u0E49\u0E01\u0E25\u0E49\u0E2D\u0E07\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E2A\u0E41\u0E01\u0E19 QR code",
|
|
132
|
+
"Connecting...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D...",
|
|
133
|
+
"Please continue in app": "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E48\u0E2D\u0E43\u0E19\u0E41\u0E2D\u0E1B",
|
|
134
|
+
"You will be redirected to the app, please return to this page once you're done": "\u0E04\u0E38\u0E13\u0E08\u0E30\u0E16\u0E39\u0E01\u0E19\u0E33\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B \u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E25\u0E31\u0E1A\u0E21\u0E32\u0E17\u0E35\u0E48\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E40\u0E2A\u0E23\u0E47\u0E08\u0E41\u0E25\u0E49\u0E27",
|
|
135
|
+
"Action cannot be an empty string.": "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E27\u0E48\u0E32\u0E07\u0E44\u0E14\u0E49",
|
|
136
|
+
"Invalid IDKitStage :stage.": "IDKitStage \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 :stage.",
|
|
137
|
+
"Terms & Privacy": "\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E41\u0E25\u0E30\u0E04\u0E27\u0E32\u0E21\u0E40\u0E1B\u0E47\u0E19\u0E2A\u0E48\u0E27\u0E19\u0E15\u0E31\u0E27"
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// src/lang/translations/index.ts
|
|
141
|
+
var translations = {
|
|
142
|
+
en,
|
|
143
|
+
es,
|
|
144
|
+
th
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/lang/localization.ts
|
|
148
|
+
var currentConfig = {};
|
|
149
|
+
var setLocalizationConfig = (config) => {
|
|
150
|
+
currentConfig = config;
|
|
151
|
+
};
|
|
152
|
+
var getLocalizationConfig = () => currentConfig;
|
|
153
|
+
var detectBrowserLanguage = () => {
|
|
154
|
+
for (const lang of navigator.languages) {
|
|
155
|
+
const [language] = lang.split("-");
|
|
156
|
+
const normalizedLang = language.toLowerCase();
|
|
157
|
+
if (normalizedLang in translations) {
|
|
158
|
+
return normalizedLang;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return void 0;
|
|
162
|
+
};
|
|
163
|
+
var getCurrentLanguage = () => {
|
|
164
|
+
const config = getLocalizationConfig();
|
|
165
|
+
if (config.language && config.language in translations) {
|
|
166
|
+
return config.language;
|
|
167
|
+
}
|
|
168
|
+
const browserLang = detectBrowserLanguage();
|
|
169
|
+
if (browserLang) {
|
|
170
|
+
return browserLang;
|
|
171
|
+
}
|
|
172
|
+
return "en";
|
|
173
|
+
};
|
|
174
|
+
var getTranslations = () => {
|
|
175
|
+
const currentLang = getCurrentLanguage();
|
|
176
|
+
return translations[currentLang];
|
|
177
|
+
};
|
|
178
|
+
var getSupportedLanguages = () => {
|
|
179
|
+
return Object.keys(translations);
|
|
180
|
+
};
|
|
181
|
+
|
|
46
182
|
// src/lang/index.ts
|
|
47
|
-
var translations = {};
|
|
48
183
|
var getLang = () => {
|
|
49
|
-
|
|
50
|
-
const supportedLang = navigator.languages.find((l) => translations[l] != void 0) ?? "";
|
|
51
|
-
return translations[supportedLang];
|
|
184
|
+
return getTranslations();
|
|
52
185
|
};
|
|
53
186
|
var replaceParams = (str, params) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
187
|
+
if (!params) return str;
|
|
188
|
+
let result = str;
|
|
189
|
+
for (const [key, value] of Object.entries(params)) {
|
|
190
|
+
result = result.replace(`:${key}`, value);
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
57
193
|
};
|
|
58
|
-
function __(str,
|
|
59
|
-
|
|
60
|
-
|
|
194
|
+
function __(str, ...args) {
|
|
195
|
+
const [params] = args;
|
|
196
|
+
if (typeof navigator === "undefined" && typeof window === "undefined") {
|
|
197
|
+
return replaceParams(str, params);
|
|
198
|
+
}
|
|
199
|
+
const translated = getLang()?.[str] ?? str;
|
|
200
|
+
return replaceParams(translated, params);
|
|
61
201
|
}
|
|
62
202
|
|
|
63
203
|
// src/store/idkit.ts
|
|
@@ -211,13 +351,13 @@ var import_react2 = require("react");
|
|
|
211
351
|
var useMedia = () => {
|
|
212
352
|
const getInitialState = () => {
|
|
213
353
|
if (typeof window !== "undefined") {
|
|
214
|
-
return window.matchMedia("(max-width:
|
|
354
|
+
return window.matchMedia("(max-width: 1024px)").matches ? "mobile" : "desktop";
|
|
215
355
|
}
|
|
216
356
|
return "desktop";
|
|
217
357
|
};
|
|
218
358
|
const [media, setMedia] = (0, import_react2.useState)(getInitialState());
|
|
219
359
|
(0, import_react2.useEffect)(() => {
|
|
220
|
-
const mql = window.matchMedia("(max-width:
|
|
360
|
+
const mql = window.matchMedia("(max-width: 1024px)");
|
|
221
361
|
const handleChange = (mql2) => setMedia(mql2.matches ? "mobile" : "desktop");
|
|
222
362
|
handleChange(mql);
|
|
223
363
|
mql.addEventListener("change", handleChange);
|
|
@@ -1513,6 +1653,9 @@ input[type='number']::-webkit-inner-spin-button,
|
|
|
1513
1653
|
.md\\:mt-2 {
|
|
1514
1654
|
margin-top: 8px;
|
|
1515
1655
|
}
|
|
1656
|
+
.md\\:block {
|
|
1657
|
+
display: block;
|
|
1658
|
+
}
|
|
1516
1659
|
.md\\:hidden {
|
|
1517
1660
|
display: none;
|
|
1518
1661
|
}
|
|
@@ -1539,6 +1682,15 @@ input[type='number']::-webkit-inner-spin-button,
|
|
|
1539
1682
|
padding: 16px;
|
|
1540
1683
|
}
|
|
1541
1684
|
}
|
|
1685
|
+
|
|
1686
|
+
@media (min-width: 1280px) {
|
|
1687
|
+
.xl\\:block {
|
|
1688
|
+
display: block;
|
|
1689
|
+
}
|
|
1690
|
+
.xl\\:hidden {
|
|
1691
|
+
display: none;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1542
1694
|
`;
|
|
1543
1695
|
|
|
1544
1696
|
// src/components/Styles.tsx
|
|
@@ -1703,25 +1855,36 @@ var WarningIcon_default = WarningIcon;
|
|
|
1703
1855
|
// src/components/IDKitWidget/States/ErrorState.tsx
|
|
1704
1856
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1705
1857
|
var getParams = ({ retryFlow, errorState }) => ({ retryFlow, errorState });
|
|
1706
|
-
var
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1858
|
+
var getErrorTitle = (code) => {
|
|
1859
|
+
switch (code) {
|
|
1860
|
+
case import_idkit_core2.AppErrorCodes.GenericError:
|
|
1861
|
+
return __("Something went wrong");
|
|
1862
|
+
case import_idkit_core2.AppErrorCodes.FailedByHostApp:
|
|
1863
|
+
return __("Verification Declined");
|
|
1864
|
+
case import_idkit_core2.AppErrorCodes.VerificationRejected:
|
|
1865
|
+
return __("Request cancelled");
|
|
1866
|
+
default:
|
|
1867
|
+
return __("Something went wrong");
|
|
1868
|
+
}
|
|
1710
1869
|
};
|
|
1711
|
-
var
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1870
|
+
var getErrorMessage = (code) => {
|
|
1871
|
+
switch (code) {
|
|
1872
|
+
case import_idkit_core2.AppErrorCodes.ConnectionFailed:
|
|
1873
|
+
return __("Connection to your wallet failed. Please try again.");
|
|
1874
|
+
case import_idkit_core2.AppErrorCodes.VerificationRejected:
|
|
1875
|
+
return __("You've cancelled the request in World App.");
|
|
1876
|
+
case import_idkit_core2.AppErrorCodes.MaxVerificationsReached:
|
|
1877
|
+
return __("You've already verified the maximum number of times for this action.");
|
|
1878
|
+
case import_idkit_core2.AppErrorCodes.CredentialUnavailable:
|
|
1879
|
+
return __("It seems you don't have the verification level required by this app.");
|
|
1880
|
+
case import_idkit_core2.AppErrorCodes.InvalidNetwork:
|
|
1881
|
+
return __("Invalid network. If you are the app owner, visit docs.world.org/test for details.");
|
|
1882
|
+
case import_idkit_core2.AppErrorCodes.InclusionProofPending:
|
|
1883
|
+
return __("Your identity is still being registered. Please wait a few minutes and try again.");
|
|
1884
|
+
case import_idkit_core2.AppErrorCodes.GenericError:
|
|
1885
|
+
default:
|
|
1886
|
+
return __("We couldn't complete your request. Please try again.");
|
|
1887
|
+
}
|
|
1725
1888
|
};
|
|
1726
1889
|
var ErrorState = (props) => {
|
|
1727
1890
|
const { retryFlow, errorState } = idkit_default(getParams);
|
|
@@ -1734,8 +1897,8 @@ var ErrorState = (props) => {
|
|
|
1734
1897
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-8", children: [
|
|
1735
1898
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: clsx_default("flex items-center justify-center", show_modal ? "-mt-5" : ""), children: errorState?.code == import_idkit_core2.AppErrorCodes.VerificationRejected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WarningIcon_default, { className: "w-24" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorIcon_default, { className: "w-24" }) }),
|
|
1736
1899
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1737
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children:
|
|
1738
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children:
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: errorState?.code ? getErrorTitle(errorState.code) : getErrorTitle(import_idkit_core2.AppErrorCodes.GenericError) }),
|
|
1901
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: errorState?.code ? getErrorMessage(errorState.code) : getErrorMessage(import_idkit_core2.AppErrorCodes.GenericError) })
|
|
1739
1902
|
] }),
|
|
1740
1903
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1741
1904
|
"button",
|
|
@@ -2022,15 +2185,22 @@ var QRState = ({ qrData, showQR, setShowQR }) => {
|
|
|
2022
2185
|
setTimeout(() => setCopiedLink(false), 2e3);
|
|
2023
2186
|
}, [qrData]);
|
|
2024
2187
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2025
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
2188
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "md:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2189
|
+
"a",
|
|
2190
|
+
{
|
|
2191
|
+
href: qrData ?? "",
|
|
2192
|
+
className: "flex w-full items-center space-x-2 rounded-2xl border border-transparent p-4 font-medium shadow-sm bg-0d151d text-white dark:bg-white dark:text-0d151d",
|
|
2193
|
+
children: [
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(WorldcoinIcon_default, { className: "size-5" }),
|
|
2195
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "flex-1 text-center", children: __("Open World App") })
|
|
2196
|
+
]
|
|
2197
|
+
}
|
|
2198
|
+
) }),
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: clsx_default("hidden md:block xl:hidden", { "mb-10 space-y-4": !showQR }), children: [
|
|
2026
2200
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2027
|
-
|
|
2201
|
+
"a",
|
|
2028
2202
|
{
|
|
2029
2203
|
href: qrData ?? "",
|
|
2030
|
-
whileTap: { scale: 0.95 },
|
|
2031
|
-
whileHover: { scale: 1.05 },
|
|
2032
|
-
transition: { layout: { duration: 0.15 } },
|
|
2033
|
-
layoutId: media == "desktop" ? void 0 : "worldid-button",
|
|
2034
2204
|
className: clsx_default(
|
|
2035
2205
|
"flex w-full items-center space-x-2 rounded-2xl border border-transparent p-4 font-medium shadow-sm",
|
|
2036
2206
|
"bg-0d151d text-white dark:bg-white dark:text-0d151d",
|
|
@@ -2038,20 +2208,12 @@ var QRState = ({ qrData, showQR, setShowQR }) => {
|
|
|
2038
2208
|
),
|
|
2039
2209
|
children: [
|
|
2040
2210
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(WorldcoinIcon_default, { className: "size-5" }),
|
|
2041
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2042
|
-
import_framer_motion.motion.span,
|
|
2043
|
-
{
|
|
2044
|
-
className: "flex-1 text-center",
|
|
2045
|
-
transition: { layout: { duration: 0.15 } },
|
|
2046
|
-
layoutId: media == "desktop" ? void 0 : "worldid-text",
|
|
2047
|
-
children: __("Open World App")
|
|
2048
|
-
}
|
|
2049
|
-
)
|
|
2211
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "flex-1 text-center", children: __("Open World App") })
|
|
2050
2212
|
]
|
|
2051
2213
|
}
|
|
2052
2214
|
),
|
|
2053
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: clsx_default("mb-3
|
|
2054
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className:
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: clsx_default("mb-3 space-y-4", { hidden: showQR }), children: [
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center space-x-4", children: [
|
|
2055
2217
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("hr", { className: "flex-1" }),
|
|
2056
2218
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-xs font-medium text-9ba3ae", children: "or" }),
|
|
2057
2219
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("hr", { className: "flex-1" })
|
|
@@ -2061,12 +2223,61 @@ var QRState = ({ qrData, showQR, setShowQR }) => {
|
|
|
2061
2223
|
{
|
|
2062
2224
|
className: "w-full rounded-2xl border border-ebecef p-4 text-lg font-medium text-3c424b",
|
|
2063
2225
|
onClick: () => setShowQR((state) => !state),
|
|
2064
|
-
children:
|
|
2226
|
+
children: __("Display QR Code")
|
|
2065
2227
|
}
|
|
2066
2228
|
)
|
|
2067
2229
|
] })
|
|
2068
2230
|
] }),
|
|
2069
|
-
|
|
2231
|
+
showQR && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "hidden md:block xl:hidden", children: [
|
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2233
|
+
import_framer_motion.motion.button,
|
|
2234
|
+
{
|
|
2235
|
+
className: "w-full rounded-2xl border border-ebecef p-4 text-lg font-medium text-3c424b",
|
|
2236
|
+
onClick: () => setShowQR(false),
|
|
2237
|
+
children: __("Hide QR Code")
|
|
2238
|
+
}
|
|
2239
|
+
) }),
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative inline-flex items-center justify-center rounded-2xl border border-f1f5f8 p-3 dark:border-f1f5f8/10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-29343f dark:text-white", children: qrData ? (
|
|
2241
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { onClick: copyLink, className: "cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(QRCode_default, { data: qrData, size: 200 }) })
|
|
2243
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex size-[200px] items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(QRPlaceholderIcon_default, { className: "size-[200px] animate-pulse" }) }) }) }),
|
|
2244
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_framer_motion.AnimatePresence, { children: copiedLink && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2245
|
+
import_framer_motion.motion.div,
|
|
2246
|
+
{
|
|
2247
|
+
className: "text-sm text-9eafc0 text-center",
|
|
2248
|
+
initial: "hidden",
|
|
2249
|
+
animate: "visible",
|
|
2250
|
+
exit: "exit",
|
|
2251
|
+
variants: {
|
|
2252
|
+
hidden: { opacity: 0, height: 0, marginTop: 0 },
|
|
2253
|
+
visible: {
|
|
2254
|
+
opacity: 1,
|
|
2255
|
+
height: "auto",
|
|
2256
|
+
marginTop: 8,
|
|
2257
|
+
transition: {
|
|
2258
|
+
duration: 0.25,
|
|
2259
|
+
opacity: { delay: 0.05, duration: 0.2 },
|
|
2260
|
+
ease: "easeInOut"
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
exit: {
|
|
2264
|
+
opacity: 0,
|
|
2265
|
+
height: 0,
|
|
2266
|
+
marginTop: 0,
|
|
2267
|
+
transition: {
|
|
2268
|
+
duration: 0.4,
|
|
2269
|
+
delay: 0.1,
|
|
2270
|
+
opacity: { duration: 0.25, delay: 0 },
|
|
2271
|
+
ease: "easeInOut"
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
},
|
|
2275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "rounded-lg border border-f1f5f8 px-2 py-1 text-sm", children: __("QR Code copied") })
|
|
2276
|
+
},
|
|
2277
|
+
"copied"
|
|
2278
|
+
) })
|
|
2279
|
+
] }),
|
|
2280
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "hidden xl:block", children: [
|
|
2070
2281
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_framer_motion.AnimatePresence, { children: copiedLink && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2071
2282
|
import_framer_motion.motion.div,
|
|
2072
2283
|
{
|
|
@@ -2245,7 +2456,8 @@ var WorldIDState = (props) => {
|
|
|
2245
2456
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: clsx_default(!show_modal ? "hidden" : ""), children: [
|
|
2246
2457
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "mb-4 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex size-14 items-center justify-center rounded-full border-[1.2px] border-solid border-[#EBECEF]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(WorldcoinIcon_default, { className: "size-8 text-0d151d dark:text-white" }) }) }),
|
|
2247
2458
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-2xl font-semibold text-gray-900 dark:text-white", children: __("Connect your World ID") }),
|
|
2248
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") })
|
|
2459
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") }),
|
|
2460
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media !== "mobile" }), children: __("You will be redirected to the app, please return to this page once you're done") })
|
|
2249
2461
|
] }),
|
|
2250
2462
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative w-full", children: [
|
|
2251
2463
|
verificationState === import_idkit_core4.VerificationState.WaitingForApp && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "absolute inset-0 flex flex-col items-center justify-center space-y-6", children: [
|
|
@@ -2303,10 +2515,16 @@ var IDKitWidget = ({
|
|
|
2303
2515
|
show_modal = true,
|
|
2304
2516
|
container_id,
|
|
2305
2517
|
disable_default_modal_behavior = false,
|
|
2518
|
+
language,
|
|
2306
2519
|
...config
|
|
2307
2520
|
}) => {
|
|
2308
2521
|
const media = useMedia_default();
|
|
2309
2522
|
const { isOpen, onOpenChange, stage, setStage, setOptions, setErrorState } = idkit_default(getParams2, import_shallow3.shallow);
|
|
2523
|
+
(0, import_react9.useEffect)(() => {
|
|
2524
|
+
if (language) {
|
|
2525
|
+
setLocalizationConfig({ language });
|
|
2526
|
+
}
|
|
2527
|
+
}, [language]);
|
|
2310
2528
|
(0, import_react9.useEffect)(() => {
|
|
2311
2529
|
if (config.action === "") {
|
|
2312
2530
|
throw new Error(__("Action cannot be an empty string."));
|
|
@@ -2324,7 +2542,7 @@ var IDKitWidget = ({
|
|
|
2324
2542
|
case "HOST_APP_VERIFICATION" /* HOST_APP_VERIFICATION */:
|
|
2325
2543
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HostAppVerificationState_default, {});
|
|
2326
2544
|
default:
|
|
2327
|
-
throw new Error(__("Invalid IDKitStage :stage.", { stage }));
|
|
2545
|
+
throw new Error(__("Invalid IDKitStage :stage.", { s: String(stage) }));
|
|
2328
2546
|
}
|
|
2329
2547
|
}, [stage, show_modal]);
|
|
2330
2548
|
const widgetContent = /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ShadowHost, { mode: "open", id: "idkit-widget", children: [
|
|
@@ -2469,6 +2687,10 @@ function useSession(config) {
|
|
|
2469
2687
|
IDKitWidget,
|
|
2470
2688
|
VerificationLevel,
|
|
2471
2689
|
VerificationState,
|
|
2690
|
+
getCurrentLanguage,
|
|
2691
|
+
getLocalizationConfig,
|
|
2692
|
+
getSupportedLanguages,
|
|
2693
|
+
setLocalizationConfig,
|
|
2472
2694
|
solidityEncode,
|
|
2473
2695
|
useIDKit,
|
|
2474
2696
|
useSession,
|
package/build/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as Config, W as WidgetProps } from './config-
|
|
1
|
+
import { C as Config, W as WidgetProps } from './config-SH5TbLYj.cjs';
|
|
2
|
+
export { S as SupportedLanguage, a as getCurrentLanguage, g as getLocalizationConfig, b as getSupportedLanguages, s as setLocalizationConfig } from './config-SH5TbLYj.cjs';
|
|
2
3
|
import * as react from 'react';
|
|
3
4
|
export { solidityEncode } from '@worldcoin/idkit-core/hashing';
|
|
4
5
|
export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as Config, W as WidgetProps } from './config-
|
|
1
|
+
import { C as Config, W as WidgetProps } from './config-SH5TbLYj.js';
|
|
2
|
+
export { S as SupportedLanguage, a as getCurrentLanguage, g as getLocalizationConfig, b as getSupportedLanguages, s as setLocalizationConfig } from './config-SH5TbLYj.js';
|
|
2
3
|
import * as react from 'react';
|
|
3
4
|
export { solidityEncode } from '@worldcoin/idkit-core/hashing';
|
|
4
5
|
export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
|