@astrasyncai/verification-gateway 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.
- package/README.md +213 -0
- package/dist/adapters/express.d.mts +3 -0
- package/dist/adapters/express.d.ts +3 -0
- package/dist/adapters/express.js +516 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/express.mjs +486 -0
- package/dist/adapters/express.mjs.map +1 -0
- package/dist/adapters/nextjs.d.mts +3 -0
- package/dist/adapters/nextjs.d.ts +3 -0
- package/dist/adapters/nextjs.js +624 -0
- package/dist/adapters/nextjs.js.map +1 -0
- package/dist/adapters/nextjs.mjs +586 -0
- package/dist/adapters/nextjs.mjs.map +1 -0
- package/dist/adapters/sdk.d.mts +2 -0
- package/dist/adapters/sdk.d.ts +2 -0
- package/dist/adapters/sdk.js +505 -0
- package/dist/adapters/sdk.js.map +1 -0
- package/dist/adapters/sdk.mjs +473 -0
- package/dist/adapters/sdk.mjs.map +1 -0
- package/dist/express-BhD3mWsL.d.ts +64 -0
- package/dist/express-DUDYpvNZ.d.mts +64 -0
- package/dist/index.d.mts +353 -0
- package/dist/index.d.ts +353 -0
- package/dist/index.js +1499 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1446 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nextjs-BtqyLSVQ.d.mts +22 -0
- package/dist/nextjs-C9FPOjSh.d.ts +22 -0
- package/dist/sdk-BkVigGjF.d.ts +190 -0
- package/dist/sdk-xCbZgeZx.d.mts +190 -0
- package/dist/types-CS6v75-d.d.mts +359 -0
- package/dist/types-CS6v75-d.d.ts +359 -0
- package/dist/ui/index.d.mts +140 -0
- package/dist/ui/index.d.ts +140 -0
- package/dist/ui/index.js +826 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/index.mjs +782 -0
- package/dist/ui/index.mjs.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
// src/ui/commerce-shield.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var defaultStyles = {
|
|
5
|
+
overlay: {
|
|
6
|
+
position: "fixed",
|
|
7
|
+
top: 0,
|
|
8
|
+
left: 0,
|
|
9
|
+
right: 0,
|
|
10
|
+
bottom: 0,
|
|
11
|
+
backgroundColor: "rgba(26, 26, 46, 0.95)",
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
zIndex: 9999,
|
|
16
|
+
padding: "20px"
|
|
17
|
+
},
|
|
18
|
+
container: {
|
|
19
|
+
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
|
20
|
+
borderRadius: "16px",
|
|
21
|
+
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)",
|
|
22
|
+
maxWidth: "480px",
|
|
23
|
+
width: "100%",
|
|
24
|
+
padding: "40px",
|
|
25
|
+
textAlign: "center"
|
|
26
|
+
},
|
|
27
|
+
icon: {
|
|
28
|
+
fontSize: "48px",
|
|
29
|
+
marginBottom: "20px"
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
fontSize: "24px",
|
|
33
|
+
fontWeight: 700,
|
|
34
|
+
color: "#1a1a2e",
|
|
35
|
+
marginBottom: "16px"
|
|
36
|
+
},
|
|
37
|
+
message: {
|
|
38
|
+
color: "#4a5568",
|
|
39
|
+
lineHeight: 1.6,
|
|
40
|
+
marginBottom: "24px"
|
|
41
|
+
},
|
|
42
|
+
stepsContainer: {
|
|
43
|
+
textAlign: "left",
|
|
44
|
+
backgroundColor: "#f7fafc",
|
|
45
|
+
borderRadius: "8px",
|
|
46
|
+
padding: "20px",
|
|
47
|
+
marginBottom: "24px"
|
|
48
|
+
},
|
|
49
|
+
stepsTitle: {
|
|
50
|
+
fontSize: "14px",
|
|
51
|
+
fontWeight: 600,
|
|
52
|
+
color: "#2d3748",
|
|
53
|
+
marginBottom: "12px"
|
|
54
|
+
},
|
|
55
|
+
stepsList: {
|
|
56
|
+
paddingLeft: "20px",
|
|
57
|
+
color: "#4a5568",
|
|
58
|
+
margin: 0
|
|
59
|
+
},
|
|
60
|
+
stepItem: {
|
|
61
|
+
marginBottom: "8px"
|
|
62
|
+
},
|
|
63
|
+
buttonsContainer: {
|
|
64
|
+
display: "flex",
|
|
65
|
+
flexDirection: "column",
|
|
66
|
+
gap: "12px"
|
|
67
|
+
},
|
|
68
|
+
buttonBase: {
|
|
69
|
+
display: "inline-block",
|
|
70
|
+
padding: "14px 24px",
|
|
71
|
+
borderRadius: "8px",
|
|
72
|
+
fontWeight: 600,
|
|
73
|
+
textDecoration: "none",
|
|
74
|
+
cursor: "pointer",
|
|
75
|
+
border: "none",
|
|
76
|
+
fontSize: "16px",
|
|
77
|
+
transition: "all 0.2s"
|
|
78
|
+
},
|
|
79
|
+
buttonPrimary: {
|
|
80
|
+
background: "linear-gradient(135deg, #6366f1 0%, #4f46e5 100%)",
|
|
81
|
+
color: "white"
|
|
82
|
+
},
|
|
83
|
+
buttonSecondary: {
|
|
84
|
+
backgroundColor: "#e2e8f0",
|
|
85
|
+
color: "#4a5568"
|
|
86
|
+
},
|
|
87
|
+
footer: {
|
|
88
|
+
marginTop: "24px",
|
|
89
|
+
fontSize: "14px",
|
|
90
|
+
color: "#718096"
|
|
91
|
+
},
|
|
92
|
+
footerLink: {
|
|
93
|
+
color: "#6366f1",
|
|
94
|
+
textDecoration: "none"
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function CommerceShield({
|
|
98
|
+
visible,
|
|
99
|
+
result,
|
|
100
|
+
onRegister,
|
|
101
|
+
onGuestAccess,
|
|
102
|
+
onDismiss,
|
|
103
|
+
title = "AstraSync Agent Verification",
|
|
104
|
+
message,
|
|
105
|
+
allowGuestAccess = true,
|
|
106
|
+
className
|
|
107
|
+
}) {
|
|
108
|
+
if (!visible) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const displayMessage = message || result?.guidance?.message || "This site verifies AI agents before granting access. We noticed you're visiting without AstraSync credentials.";
|
|
112
|
+
const registrationUrl = result?.guidance?.registrationUrl || "https://astrasync.ai/register";
|
|
113
|
+
const docsUrl = result?.guidance?.documentationUrl || "https://astrasync.ai/docs/agent-access";
|
|
114
|
+
const steps = result?.guidance?.steps || [
|
|
115
|
+
"Register at astrasync.ai/register",
|
|
116
|
+
"Create and register your agent",
|
|
117
|
+
"Add your ASTRA-ID to request headers",
|
|
118
|
+
"Refresh this page"
|
|
119
|
+
];
|
|
120
|
+
const handleRegisterClick = () => {
|
|
121
|
+
if (onRegister) {
|
|
122
|
+
onRegister();
|
|
123
|
+
} else {
|
|
124
|
+
window.location.href = registrationUrl;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const handleGuestClick = () => {
|
|
128
|
+
if (onGuestAccess) {
|
|
129
|
+
onGuestAccess();
|
|
130
|
+
} else if (onDismiss) {
|
|
131
|
+
onDismiss();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ jsx(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
style: defaultStyles.overlay,
|
|
138
|
+
className,
|
|
139
|
+
role: "dialog",
|
|
140
|
+
"aria-modal": "true",
|
|
141
|
+
"aria-labelledby": "commerce-shield-title",
|
|
142
|
+
children: /* @__PURE__ */ jsxs("div", { style: defaultStyles.container, children: [
|
|
143
|
+
/* @__PURE__ */ jsx("div", { style: defaultStyles.icon, "aria-hidden": "true", children: "\u{1F6E1}\uFE0F" }),
|
|
144
|
+
/* @__PURE__ */ jsx("h1", { id: "commerce-shield-title", style: defaultStyles.title, children: title }),
|
|
145
|
+
/* @__PURE__ */ jsx("p", { style: defaultStyles.message, children: displayMessage }),
|
|
146
|
+
/* @__PURE__ */ jsxs("div", { style: defaultStyles.stepsContainer, children: [
|
|
147
|
+
/* @__PURE__ */ jsx("h3", { style: defaultStyles.stepsTitle, children: "To get verified access:" }),
|
|
148
|
+
/* @__PURE__ */ jsx("ol", { style: defaultStyles.stepsList, children: steps.map((step, index) => /* @__PURE__ */ jsx("li", { style: defaultStyles.stepItem, children: step }, index)) })
|
|
149
|
+
] }),
|
|
150
|
+
/* @__PURE__ */ jsxs("div", { style: defaultStyles.buttonsContainer, children: [
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
"button",
|
|
153
|
+
{
|
|
154
|
+
onClick: handleRegisterClick,
|
|
155
|
+
style: { ...defaultStyles.buttonBase, ...defaultStyles.buttonPrimary },
|
|
156
|
+
children: "Register Now"
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
allowGuestAccess && /* @__PURE__ */ jsx(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
onClick: handleGuestClick,
|
|
163
|
+
style: { ...defaultStyles.buttonBase, ...defaultStyles.buttonSecondary },
|
|
164
|
+
children: "Continue as Guest (Limited)"
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxs("p", { style: defaultStyles.footer, children: [
|
|
169
|
+
"Learn more:",
|
|
170
|
+
" ",
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
"a",
|
|
173
|
+
{
|
|
174
|
+
href: docsUrl,
|
|
175
|
+
style: defaultStyles.footerLink,
|
|
176
|
+
target: "_blank",
|
|
177
|
+
rel: "noopener noreferrer",
|
|
178
|
+
children: "Agent Access Documentation"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] })
|
|
182
|
+
] })
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function useCommerceShield(verificationResult) {
|
|
187
|
+
const [visible, setVisible] = React.useState(false);
|
|
188
|
+
const [dismissed, setDismissed] = React.useState(false);
|
|
189
|
+
React.useEffect(() => {
|
|
190
|
+
if (verificationResult && !dismissed) {
|
|
191
|
+
const shouldShow = !verificationResult.verified || verificationResult.accessLevel === "none" || verificationResult.accessLevel === "guidance";
|
|
192
|
+
setVisible(shouldShow);
|
|
193
|
+
}
|
|
194
|
+
}, [verificationResult, dismissed]);
|
|
195
|
+
const dismiss = React.useCallback(() => {
|
|
196
|
+
setDismissed(true);
|
|
197
|
+
setVisible(false);
|
|
198
|
+
}, []);
|
|
199
|
+
const reset = React.useCallback(() => {
|
|
200
|
+
setDismissed(false);
|
|
201
|
+
}, []);
|
|
202
|
+
return {
|
|
203
|
+
visible,
|
|
204
|
+
dismiss,
|
|
205
|
+
reset,
|
|
206
|
+
result: verificationResult
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/ui/credential-prompt.tsx
|
|
211
|
+
import { useState, useCallback } from "react";
|
|
212
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
213
|
+
var defaultStyles2 = {
|
|
214
|
+
overlay: {
|
|
215
|
+
position: "fixed",
|
|
216
|
+
top: 0,
|
|
217
|
+
left: 0,
|
|
218
|
+
right: 0,
|
|
219
|
+
bottom: 0,
|
|
220
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
221
|
+
display: "flex",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
justifyContent: "center",
|
|
224
|
+
zIndex: 9999,
|
|
225
|
+
padding: "20px"
|
|
226
|
+
},
|
|
227
|
+
container: {
|
|
228
|
+
backgroundColor: "white",
|
|
229
|
+
borderRadius: "12px",
|
|
230
|
+
boxShadow: "0 20px 40px rgba(0, 0, 0, 0.3)",
|
|
231
|
+
maxWidth: "400px",
|
|
232
|
+
width: "100%",
|
|
233
|
+
padding: "32px"
|
|
234
|
+
},
|
|
235
|
+
title: {
|
|
236
|
+
fontSize: "20px",
|
|
237
|
+
fontWeight: 600,
|
|
238
|
+
color: "#1a1a2e",
|
|
239
|
+
marginBottom: "8px"
|
|
240
|
+
},
|
|
241
|
+
description: {
|
|
242
|
+
fontSize: "14px",
|
|
243
|
+
color: "#64748b",
|
|
244
|
+
marginBottom: "24px",
|
|
245
|
+
lineHeight: 1.5
|
|
246
|
+
},
|
|
247
|
+
form: {
|
|
248
|
+
display: "flex",
|
|
249
|
+
flexDirection: "column",
|
|
250
|
+
gap: "16px"
|
|
251
|
+
},
|
|
252
|
+
inputGroup: {
|
|
253
|
+
display: "flex",
|
|
254
|
+
flexDirection: "column",
|
|
255
|
+
gap: "6px"
|
|
256
|
+
},
|
|
257
|
+
label: {
|
|
258
|
+
fontSize: "14px",
|
|
259
|
+
fontWeight: 500,
|
|
260
|
+
color: "#374151"
|
|
261
|
+
},
|
|
262
|
+
input: {
|
|
263
|
+
padding: "12px",
|
|
264
|
+
borderRadius: "8px",
|
|
265
|
+
border: "1px solid #d1d5db",
|
|
266
|
+
fontSize: "14px",
|
|
267
|
+
outline: "none",
|
|
268
|
+
transition: "border-color 0.2s"
|
|
269
|
+
},
|
|
270
|
+
error: {
|
|
271
|
+
backgroundColor: "#fef2f2",
|
|
272
|
+
color: "#dc2626",
|
|
273
|
+
padding: "12px",
|
|
274
|
+
borderRadius: "8px",
|
|
275
|
+
fontSize: "14px",
|
|
276
|
+
marginBottom: "16px"
|
|
277
|
+
},
|
|
278
|
+
buttonContainer: {
|
|
279
|
+
display: "flex",
|
|
280
|
+
gap: "12px",
|
|
281
|
+
marginTop: "8px"
|
|
282
|
+
},
|
|
283
|
+
button: {
|
|
284
|
+
flex: 1,
|
|
285
|
+
padding: "12px 16px",
|
|
286
|
+
borderRadius: "8px",
|
|
287
|
+
fontWeight: 600,
|
|
288
|
+
fontSize: "14px",
|
|
289
|
+
cursor: "pointer",
|
|
290
|
+
transition: "all 0.2s",
|
|
291
|
+
border: "none"
|
|
292
|
+
},
|
|
293
|
+
buttonPrimary: {
|
|
294
|
+
backgroundColor: "#4f46e5",
|
|
295
|
+
color: "white"
|
|
296
|
+
},
|
|
297
|
+
buttonSecondary: {
|
|
298
|
+
backgroundColor: "#f1f5f9",
|
|
299
|
+
color: "#475569"
|
|
300
|
+
},
|
|
301
|
+
buttonDisabled: {
|
|
302
|
+
opacity: 0.5,
|
|
303
|
+
cursor: "not-allowed"
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
function CredentialPrompt({
|
|
307
|
+
visible,
|
|
308
|
+
onSubmit,
|
|
309
|
+
onDismiss,
|
|
310
|
+
title = "Enter Agent Credentials",
|
|
311
|
+
description = "Provide your AstraSync agent credentials to verify your identity.",
|
|
312
|
+
showApiKey = true,
|
|
313
|
+
showJwt = false,
|
|
314
|
+
loading = false,
|
|
315
|
+
error,
|
|
316
|
+
className
|
|
317
|
+
}) {
|
|
318
|
+
const [astraId, setAstraId] = useState("");
|
|
319
|
+
const [apiKey, setApiKey] = useState("");
|
|
320
|
+
const [jwt, setJwt] = useState("");
|
|
321
|
+
const handleSubmit = useCallback((e) => {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
const credentials = {};
|
|
324
|
+
if (astraId.trim()) {
|
|
325
|
+
credentials.astraId = astraId.trim();
|
|
326
|
+
}
|
|
327
|
+
if (apiKey.trim()) {
|
|
328
|
+
credentials.apiKey = apiKey.trim();
|
|
329
|
+
}
|
|
330
|
+
if (jwt.trim()) {
|
|
331
|
+
credentials.jwt = jwt.trim();
|
|
332
|
+
}
|
|
333
|
+
onSubmit(credentials);
|
|
334
|
+
}, [astraId, apiKey, jwt, onSubmit]);
|
|
335
|
+
const handleKeyDown = useCallback((e) => {
|
|
336
|
+
if (e.key === "Escape" && onDismiss) {
|
|
337
|
+
onDismiss();
|
|
338
|
+
}
|
|
339
|
+
}, [onDismiss]);
|
|
340
|
+
if (!visible) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
const isValid = astraId.trim() || apiKey.trim() || jwt.trim();
|
|
344
|
+
return /* @__PURE__ */ jsx2(
|
|
345
|
+
"div",
|
|
346
|
+
{
|
|
347
|
+
style: defaultStyles2.overlay,
|
|
348
|
+
className,
|
|
349
|
+
role: "dialog",
|
|
350
|
+
"aria-modal": "true",
|
|
351
|
+
"aria-labelledby": "credential-prompt-title",
|
|
352
|
+
onKeyDown: handleKeyDown,
|
|
353
|
+
children: /* @__PURE__ */ jsxs2("div", { style: defaultStyles2.container, children: [
|
|
354
|
+
/* @__PURE__ */ jsx2("h2", { id: "credential-prompt-title", style: defaultStyles2.title, children: title }),
|
|
355
|
+
/* @__PURE__ */ jsx2("p", { style: defaultStyles2.description, children: description }),
|
|
356
|
+
error && /* @__PURE__ */ jsx2("div", { style: defaultStyles2.error, role: "alert", children: error }),
|
|
357
|
+
/* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, style: defaultStyles2.form, children: [
|
|
358
|
+
/* @__PURE__ */ jsxs2("div", { style: defaultStyles2.inputGroup, children: [
|
|
359
|
+
/* @__PURE__ */ jsx2("label", { htmlFor: "astra-id", style: defaultStyles2.label, children: "ASTRA-ID" }),
|
|
360
|
+
/* @__PURE__ */ jsx2(
|
|
361
|
+
"input",
|
|
362
|
+
{
|
|
363
|
+
id: "astra-id",
|
|
364
|
+
type: "text",
|
|
365
|
+
value: astraId,
|
|
366
|
+
onChange: (e) => setAstraId(e.target.value),
|
|
367
|
+
placeholder: "ASTRA-xxx or ASTRAD-xxx",
|
|
368
|
+
style: defaultStyles2.input,
|
|
369
|
+
disabled: loading
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
] }),
|
|
373
|
+
showApiKey && /* @__PURE__ */ jsxs2("div", { style: defaultStyles2.inputGroup, children: [
|
|
374
|
+
/* @__PURE__ */ jsx2("label", { htmlFor: "api-key", style: defaultStyles2.label, children: "API Key (optional)" }),
|
|
375
|
+
/* @__PURE__ */ jsx2(
|
|
376
|
+
"input",
|
|
377
|
+
{
|
|
378
|
+
id: "api-key",
|
|
379
|
+
type: "password",
|
|
380
|
+
value: apiKey,
|
|
381
|
+
onChange: (e) => setApiKey(e.target.value),
|
|
382
|
+
placeholder: "Your API key",
|
|
383
|
+
style: defaultStyles2.input,
|
|
384
|
+
disabled: loading
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
] }),
|
|
388
|
+
showJwt && /* @__PURE__ */ jsxs2("div", { style: defaultStyles2.inputGroup, children: [
|
|
389
|
+
/* @__PURE__ */ jsx2("label", { htmlFor: "jwt", style: defaultStyles2.label, children: "JWT Token (optional)" }),
|
|
390
|
+
/* @__PURE__ */ jsx2(
|
|
391
|
+
"input",
|
|
392
|
+
{
|
|
393
|
+
id: "jwt",
|
|
394
|
+
type: "password",
|
|
395
|
+
value: jwt,
|
|
396
|
+
onChange: (e) => setJwt(e.target.value),
|
|
397
|
+
placeholder: "Your JWT token",
|
|
398
|
+
style: defaultStyles2.input,
|
|
399
|
+
disabled: loading
|
|
400
|
+
}
|
|
401
|
+
)
|
|
402
|
+
] }),
|
|
403
|
+
/* @__PURE__ */ jsxs2("div", { style: defaultStyles2.buttonContainer, children: [
|
|
404
|
+
onDismiss && /* @__PURE__ */ jsx2(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
type: "button",
|
|
408
|
+
onClick: onDismiss,
|
|
409
|
+
style: { ...defaultStyles2.button, ...defaultStyles2.buttonSecondary },
|
|
410
|
+
disabled: loading,
|
|
411
|
+
children: "Cancel"
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ jsx2(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
type: "submit",
|
|
418
|
+
style: {
|
|
419
|
+
...defaultStyles2.button,
|
|
420
|
+
...defaultStyles2.buttonPrimary,
|
|
421
|
+
...!isValid || loading ? defaultStyles2.buttonDisabled : {}
|
|
422
|
+
},
|
|
423
|
+
disabled: !isValid || loading,
|
|
424
|
+
children: loading ? "Verifying..." : "Verify"
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
] })
|
|
428
|
+
] })
|
|
429
|
+
] })
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
function useCredentialPrompt() {
|
|
434
|
+
const [visible, setVisible] = useState(false);
|
|
435
|
+
const [credentials, setCredentials] = useState(null);
|
|
436
|
+
const [loading, setLoading] = useState(false);
|
|
437
|
+
const [error, setError] = useState(null);
|
|
438
|
+
const show = useCallback(() => {
|
|
439
|
+
setVisible(true);
|
|
440
|
+
setError(null);
|
|
441
|
+
}, []);
|
|
442
|
+
const hide = useCallback(() => {
|
|
443
|
+
setVisible(false);
|
|
444
|
+
setError(null);
|
|
445
|
+
setLoading(false);
|
|
446
|
+
}, []);
|
|
447
|
+
const submit = useCallback((creds) => {
|
|
448
|
+
setCredentials(creds);
|
|
449
|
+
setLoading(true);
|
|
450
|
+
setError(null);
|
|
451
|
+
}, []);
|
|
452
|
+
const setSubmitError = useCallback((err) => {
|
|
453
|
+
setError(err);
|
|
454
|
+
setLoading(false);
|
|
455
|
+
}, []);
|
|
456
|
+
const complete = useCallback(() => {
|
|
457
|
+
setVisible(false);
|
|
458
|
+
setLoading(false);
|
|
459
|
+
setError(null);
|
|
460
|
+
}, []);
|
|
461
|
+
return {
|
|
462
|
+
visible,
|
|
463
|
+
credentials,
|
|
464
|
+
loading,
|
|
465
|
+
error,
|
|
466
|
+
show,
|
|
467
|
+
hide,
|
|
468
|
+
submit,
|
|
469
|
+
setError: setSubmitError,
|
|
470
|
+
complete
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/ui/guidance.tsx
|
|
475
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
476
|
+
var styles = {
|
|
477
|
+
card: {
|
|
478
|
+
backgroundColor: "#f8fafc",
|
|
479
|
+
border: "1px solid #e2e8f0",
|
|
480
|
+
borderRadius: "12px",
|
|
481
|
+
padding: "24px",
|
|
482
|
+
maxWidth: "480px"
|
|
483
|
+
},
|
|
484
|
+
cardCompact: {
|
|
485
|
+
backgroundColor: "#fefce8",
|
|
486
|
+
border: "1px solid #fef08a",
|
|
487
|
+
borderRadius: "8px",
|
|
488
|
+
padding: "16px"
|
|
489
|
+
},
|
|
490
|
+
cardTitle: {
|
|
491
|
+
fontSize: "18px",
|
|
492
|
+
fontWeight: 600,
|
|
493
|
+
color: "#1e293b",
|
|
494
|
+
marginBottom: "12px",
|
|
495
|
+
display: "flex",
|
|
496
|
+
alignItems: "center",
|
|
497
|
+
gap: "8px"
|
|
498
|
+
},
|
|
499
|
+
cardMessage: {
|
|
500
|
+
fontSize: "14px",
|
|
501
|
+
color: "#475569",
|
|
502
|
+
lineHeight: 1.6,
|
|
503
|
+
marginBottom: "16px"
|
|
504
|
+
},
|
|
505
|
+
stepsList: {
|
|
506
|
+
listStyle: "none",
|
|
507
|
+
padding: 0,
|
|
508
|
+
margin: 0
|
|
509
|
+
},
|
|
510
|
+
stepItem: {
|
|
511
|
+
display: "flex",
|
|
512
|
+
alignItems: "flex-start",
|
|
513
|
+
gap: "12px",
|
|
514
|
+
marginBottom: "12px",
|
|
515
|
+
fontSize: "14px",
|
|
516
|
+
color: "#334155"
|
|
517
|
+
},
|
|
518
|
+
stepNumber: {
|
|
519
|
+
backgroundColor: "#e0e7ff",
|
|
520
|
+
color: "#4338ca",
|
|
521
|
+
width: "24px",
|
|
522
|
+
height: "24px",
|
|
523
|
+
borderRadius: "50%",
|
|
524
|
+
display: "flex",
|
|
525
|
+
alignItems: "center",
|
|
526
|
+
justifyContent: "center",
|
|
527
|
+
fontSize: "12px",
|
|
528
|
+
fontWeight: 600,
|
|
529
|
+
flexShrink: 0
|
|
530
|
+
},
|
|
531
|
+
links: {
|
|
532
|
+
display: "flex",
|
|
533
|
+
gap: "16px",
|
|
534
|
+
marginTop: "16px",
|
|
535
|
+
paddingTop: "16px",
|
|
536
|
+
borderTop: "1px solid #e2e8f0"
|
|
537
|
+
},
|
|
538
|
+
link: {
|
|
539
|
+
color: "#4f46e5",
|
|
540
|
+
textDecoration: "none",
|
|
541
|
+
fontSize: "14px",
|
|
542
|
+
fontWeight: 500
|
|
543
|
+
},
|
|
544
|
+
badge: {
|
|
545
|
+
display: "inline-flex",
|
|
546
|
+
alignItems: "center",
|
|
547
|
+
gap: "4px",
|
|
548
|
+
padding: "4px 8px",
|
|
549
|
+
borderRadius: "9999px",
|
|
550
|
+
fontWeight: 600,
|
|
551
|
+
fontSize: "12px"
|
|
552
|
+
},
|
|
553
|
+
badgeSm: {
|
|
554
|
+
padding: "2px 6px",
|
|
555
|
+
fontSize: "10px"
|
|
556
|
+
},
|
|
557
|
+
badgeLg: {
|
|
558
|
+
padding: "6px 12px",
|
|
559
|
+
fontSize: "14px"
|
|
560
|
+
},
|
|
561
|
+
badgeBronze: {
|
|
562
|
+
backgroundColor: "#fef3c7",
|
|
563
|
+
color: "#92400e"
|
|
564
|
+
},
|
|
565
|
+
badgeSilver: {
|
|
566
|
+
backgroundColor: "#e5e7eb",
|
|
567
|
+
color: "#374151"
|
|
568
|
+
},
|
|
569
|
+
badgeGold: {
|
|
570
|
+
backgroundColor: "#fef9c3",
|
|
571
|
+
color: "#854d0e"
|
|
572
|
+
},
|
|
573
|
+
badgePlatinum: {
|
|
574
|
+
backgroundColor: "#e0e7ff",
|
|
575
|
+
color: "#3730a3"
|
|
576
|
+
},
|
|
577
|
+
indicator: {
|
|
578
|
+
display: "flex",
|
|
579
|
+
alignItems: "center",
|
|
580
|
+
gap: "8px",
|
|
581
|
+
fontSize: "14px"
|
|
582
|
+
},
|
|
583
|
+
indicatorDot: {
|
|
584
|
+
width: "8px",
|
|
585
|
+
height: "8px",
|
|
586
|
+
borderRadius: "50%"
|
|
587
|
+
},
|
|
588
|
+
indicatorAllowed: {
|
|
589
|
+
backgroundColor: "#22c55e"
|
|
590
|
+
},
|
|
591
|
+
indicatorDenied: {
|
|
592
|
+
backgroundColor: "#ef4444"
|
|
593
|
+
},
|
|
594
|
+
indicatorLimited: {
|
|
595
|
+
backgroundColor: "#f59e0b"
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
function GuidanceCard({
|
|
599
|
+
guidance,
|
|
600
|
+
title = "How to Get Verified",
|
|
601
|
+
compact = false,
|
|
602
|
+
className
|
|
603
|
+
}) {
|
|
604
|
+
const cardStyle = compact ? styles.cardCompact : styles.card;
|
|
605
|
+
return /* @__PURE__ */ jsxs3("div", { style: cardStyle, className, children: [
|
|
606
|
+
/* @__PURE__ */ jsxs3("h3", { style: styles.cardTitle, children: [
|
|
607
|
+
/* @__PURE__ */ jsx3("span", { children: "\u{1F4A1}" }),
|
|
608
|
+
title
|
|
609
|
+
] }),
|
|
610
|
+
/* @__PURE__ */ jsx3("p", { style: styles.cardMessage, children: guidance.message }),
|
|
611
|
+
guidance.steps && guidance.steps.length > 0 && /* @__PURE__ */ jsx3("ol", { style: styles.stepsList, children: guidance.steps.map((step, index) => /* @__PURE__ */ jsxs3("li", { style: styles.stepItem, children: [
|
|
612
|
+
/* @__PURE__ */ jsx3("span", { style: styles.stepNumber, children: index + 1 }),
|
|
613
|
+
/* @__PURE__ */ jsx3("span", { children: step })
|
|
614
|
+
] }, index)) }),
|
|
615
|
+
/* @__PURE__ */ jsxs3("div", { style: styles.links, children: [
|
|
616
|
+
/* @__PURE__ */ jsx3(
|
|
617
|
+
"a",
|
|
618
|
+
{
|
|
619
|
+
href: guidance.registrationUrl,
|
|
620
|
+
style: styles.link,
|
|
621
|
+
target: "_blank",
|
|
622
|
+
rel: "noopener noreferrer",
|
|
623
|
+
children: "Register \u2192"
|
|
624
|
+
}
|
|
625
|
+
),
|
|
626
|
+
/* @__PURE__ */ jsx3(
|
|
627
|
+
"a",
|
|
628
|
+
{
|
|
629
|
+
href: guidance.documentationUrl,
|
|
630
|
+
style: styles.link,
|
|
631
|
+
target: "_blank",
|
|
632
|
+
rel: "noopener noreferrer",
|
|
633
|
+
children: "Documentation \u2192"
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
] })
|
|
637
|
+
] });
|
|
638
|
+
}
|
|
639
|
+
function TrustLevelBadge({
|
|
640
|
+
level,
|
|
641
|
+
score,
|
|
642
|
+
size = "md",
|
|
643
|
+
className
|
|
644
|
+
}) {
|
|
645
|
+
const levelColors = {
|
|
646
|
+
BRONZE: styles.badgeBronze,
|
|
647
|
+
SILVER: styles.badgeSilver,
|
|
648
|
+
GOLD: styles.badgeGold,
|
|
649
|
+
PLATINUM: styles.badgePlatinum
|
|
650
|
+
};
|
|
651
|
+
const sizeStyles = {
|
|
652
|
+
sm: styles.badgeSm,
|
|
653
|
+
md: {},
|
|
654
|
+
lg: styles.badgeLg
|
|
655
|
+
};
|
|
656
|
+
const levelEmojis = {
|
|
657
|
+
BRONZE: "\u{1F949}",
|
|
658
|
+
SILVER: "\u{1F948}",
|
|
659
|
+
GOLD: "\u{1F947}",
|
|
660
|
+
PLATINUM: "\u{1F48E}"
|
|
661
|
+
};
|
|
662
|
+
return /* @__PURE__ */ jsxs3(
|
|
663
|
+
"span",
|
|
664
|
+
{
|
|
665
|
+
style: {
|
|
666
|
+
...styles.badge,
|
|
667
|
+
...levelColors[level],
|
|
668
|
+
...sizeStyles[size]
|
|
669
|
+
},
|
|
670
|
+
className,
|
|
671
|
+
children: [
|
|
672
|
+
/* @__PURE__ */ jsx3("span", { children: levelEmojis[level] }),
|
|
673
|
+
/* @__PURE__ */ jsx3("span", { children: level }),
|
|
674
|
+
score !== void 0 && /* @__PURE__ */ jsxs3("span", { children: [
|
|
675
|
+
"(",
|
|
676
|
+
score,
|
|
677
|
+
")"
|
|
678
|
+
] })
|
|
679
|
+
]
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
function AccessLevelIndicator({
|
|
684
|
+
accessLevel,
|
|
685
|
+
requiredLevel,
|
|
686
|
+
className
|
|
687
|
+
}) {
|
|
688
|
+
const getStatus = () => {
|
|
689
|
+
if (accessLevel === "none" || accessLevel === "guidance") {
|
|
690
|
+
return "denied";
|
|
691
|
+
}
|
|
692
|
+
if (requiredLevel) {
|
|
693
|
+
const levels = ["none", "guidance", "read-only", "standard", "full", "internal"];
|
|
694
|
+
const currentIndex = levels.indexOf(accessLevel);
|
|
695
|
+
const requiredIndex = levels.indexOf(requiredLevel);
|
|
696
|
+
if (currentIndex < requiredIndex) {
|
|
697
|
+
return "limited";
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return "allowed";
|
|
701
|
+
};
|
|
702
|
+
const status = getStatus();
|
|
703
|
+
const statusColors = {
|
|
704
|
+
allowed: styles.indicatorAllowed,
|
|
705
|
+
denied: styles.indicatorDenied,
|
|
706
|
+
limited: styles.indicatorLimited
|
|
707
|
+
};
|
|
708
|
+
const statusLabels = {
|
|
709
|
+
allowed: "Access Granted",
|
|
710
|
+
denied: "Access Denied",
|
|
711
|
+
limited: "Limited Access"
|
|
712
|
+
};
|
|
713
|
+
return /* @__PURE__ */ jsxs3("div", { style: styles.indicator, className, children: [
|
|
714
|
+
/* @__PURE__ */ jsx3("span", { style: { ...styles.indicatorDot, ...statusColors[status] } }),
|
|
715
|
+
/* @__PURE__ */ jsx3("span", { children: statusLabels[status] }),
|
|
716
|
+
/* @__PURE__ */ jsxs3("span", { style: { color: "#94a3b8" }, children: [
|
|
717
|
+
"(",
|
|
718
|
+
accessLevel,
|
|
719
|
+
")"
|
|
720
|
+
] })
|
|
721
|
+
] });
|
|
722
|
+
}
|
|
723
|
+
function DenialReasons({ reasons, className }) {
|
|
724
|
+
if (reasons.length === 0) {
|
|
725
|
+
return /* @__PURE__ */ jsx3(Fragment, {});
|
|
726
|
+
}
|
|
727
|
+
return /* @__PURE__ */ jsxs3(
|
|
728
|
+
"div",
|
|
729
|
+
{
|
|
730
|
+
style: {
|
|
731
|
+
backgroundColor: "#fef2f2",
|
|
732
|
+
border: "1px solid #fecaca",
|
|
733
|
+
borderRadius: "8px",
|
|
734
|
+
padding: "16px"
|
|
735
|
+
},
|
|
736
|
+
className,
|
|
737
|
+
children: [
|
|
738
|
+
/* @__PURE__ */ jsxs3(
|
|
739
|
+
"h4",
|
|
740
|
+
{
|
|
741
|
+
style: {
|
|
742
|
+
fontSize: "14px",
|
|
743
|
+
fontWeight: 600,
|
|
744
|
+
color: "#dc2626",
|
|
745
|
+
marginBottom: "8px",
|
|
746
|
+
display: "flex",
|
|
747
|
+
alignItems: "center",
|
|
748
|
+
gap: "6px"
|
|
749
|
+
},
|
|
750
|
+
children: [
|
|
751
|
+
/* @__PURE__ */ jsx3("span", { children: "\u26A0\uFE0F" }),
|
|
752
|
+
"Access Denied"
|
|
753
|
+
]
|
|
754
|
+
}
|
|
755
|
+
),
|
|
756
|
+
/* @__PURE__ */ jsx3(
|
|
757
|
+
"ul",
|
|
758
|
+
{
|
|
759
|
+
style: {
|
|
760
|
+
margin: 0,
|
|
761
|
+
paddingLeft: "20px",
|
|
762
|
+
color: "#991b1b",
|
|
763
|
+
fontSize: "14px"
|
|
764
|
+
},
|
|
765
|
+
children: reasons.map((reason, index) => /* @__PURE__ */ jsx3("li", { style: { marginBottom: "4px" }, children: reason }, index))
|
|
766
|
+
}
|
|
767
|
+
)
|
|
768
|
+
]
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
export {
|
|
773
|
+
AccessLevelIndicator,
|
|
774
|
+
CommerceShield,
|
|
775
|
+
CredentialPrompt,
|
|
776
|
+
DenialReasons,
|
|
777
|
+
GuidanceCard,
|
|
778
|
+
TrustLevelBadge,
|
|
779
|
+
useCommerceShield,
|
|
780
|
+
useCredentialPrompt
|
|
781
|
+
};
|
|
782
|
+
//# sourceMappingURL=index.mjs.map
|