@entros/verify 0.1.0 → 0.1.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 +15 -13
- package/dist/index.d.mts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@entros/verify)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
React component for Entros verification on Solana devnet. It opens the Entros popup and reports a completed wallet-connected verification.
|
|
6
6
|
|
|
7
7
|
Source: [github.com/entros-protocol/entros-verify](https://github.com/entros-protocol/entros-verify) · Hosted by [entros.io](https://entros.io).
|
|
8
8
|
|
|
@@ -26,25 +26,27 @@ import { EntrosVerify } from "@entros/verify";
|
|
|
26
26
|
```ts
|
|
27
27
|
interface EntrosVerifyResult {
|
|
28
28
|
walletPubkey: string; // base58 Solana pubkey
|
|
29
|
-
attestationPda: string; //
|
|
29
|
+
attestationPda: string; // derived SAS account address
|
|
30
30
|
txSig: string; // base58 verification tx signature
|
|
31
31
|
trustScore: number; // current Trust Score (0–10000)
|
|
32
|
-
cluster: "devnet"
|
|
32
|
+
cluster: "devnet";
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
The callback reports a completed Entros verification and its derived attestation address. It does not independently prove physical presence.
|
|
37
|
+
|
|
38
|
+
SAS issuance is best-effort after wallet-connected verification. Check that the returned address contains an attestation account before relying on it.
|
|
37
39
|
|
|
38
40
|
## Full API
|
|
39
41
|
|
|
40
42
|
```tsx
|
|
41
43
|
<EntrosVerify
|
|
42
|
-
integratorKey="
|
|
43
|
-
cluster="devnet"
|
|
44
|
-
minTrustScore={200} // optional
|
|
44
|
+
integratorKey="your-integrator-key" // required
|
|
45
|
+
cluster="devnet" // only supported cluster
|
|
46
|
+
minTrustScore={200} // optional floor on verification history
|
|
45
47
|
popupWidth={480} // CSS px, default 480
|
|
46
48
|
popupHeight={720} // CSS px, default 720
|
|
47
|
-
timeoutMs={
|
|
49
|
+
timeoutMs={9 * 60 * 1000} // 9 min default
|
|
48
50
|
popupBlockedFallback={true} // inline retry UI when popup blocked
|
|
49
51
|
className="..." // applied to trigger button
|
|
50
52
|
style={{ ... }}
|
|
@@ -73,15 +75,15 @@ Specific server-side rejection signals are deliberately not surfaced to the clie
|
|
|
73
75
|
|
|
74
76
|
## v1 limitations
|
|
75
77
|
|
|
76
|
-
- Devnet only. Mainnet support
|
|
77
|
-
- Hardcoded integrator allowlist on the entros.io side. Self-serve integrator onboarding
|
|
78
|
-
- Mobile browsers may open the popup as a new tab rather than a windowed popup. Mobile
|
|
78
|
+
- Devnet only. Mainnet support is planned after the protocol clears its release gates.
|
|
79
|
+
- Hardcoded integrator allowlist on the entros.io side. Self-serve integrator onboarding is planned.
|
|
80
|
+
- Mobile browsers may open the popup as a new tab rather than a windowed popup. Native mobile support via Mobile Wallet Adapter is not yet implemented in this component; see [`entros-mobile`](https://github.com/entros-protocol/entros-mobile) for the native Solana Mobile dApp.
|
|
79
81
|
|
|
80
|
-
##
|
|
82
|
+
## Integration safeguards
|
|
81
83
|
|
|
82
84
|
- Origin gate on every postMessage (`event.origin === "https://entros.io"`)
|
|
83
85
|
- Replay protection via per-popup `request_id`
|
|
84
|
-
-
|
|
86
|
+
- Parent timeout through [`timeoutMs`](#full-api)
|
|
85
87
|
- Popup-blocked fallback with user-gesture retry
|
|
86
88
|
- Idempotent cancel
|
|
87
89
|
- React 19 typed strict-mode
|
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { ReactNode, CSSProperties, ReactElement } from 'react';
|
|
|
7
7
|
* (`wallet_pubkey`); the JS API surfaced to integrators uses camelCase
|
|
8
8
|
* (`walletPubkey`). The popup-manager layer translates between them.
|
|
9
9
|
*/
|
|
10
|
-
type Cluster = "devnet"
|
|
10
|
+
type Cluster = "devnet";
|
|
11
11
|
/** Result delivered to the integrator's onVerified callback. */
|
|
12
12
|
interface EntrosVerifyResult {
|
|
13
13
|
walletPubkey: string;
|
|
@@ -62,10 +62,7 @@ interface EntrosVerifyProps {
|
|
|
62
62
|
popupWidth?: number;
|
|
63
63
|
/** Popup height in CSS pixels. Defaults to 720. */
|
|
64
64
|
popupHeight?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Maximum time the popup is allowed to be open before this component
|
|
67
|
-
* fires onError({reason: "timeout"}). Defaults to 5 minutes.
|
|
68
|
-
*/
|
|
65
|
+
/** See README.md#full-api for timeout behavior and the default. */
|
|
69
66
|
timeoutMs?: number;
|
|
70
67
|
/** Custom button content. Defaults to "Verify with Entros". */
|
|
71
68
|
children?: ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ReactNode, CSSProperties, ReactElement } from 'react';
|
|
|
7
7
|
* (`wallet_pubkey`); the JS API surfaced to integrators uses camelCase
|
|
8
8
|
* (`walletPubkey`). The popup-manager layer translates between them.
|
|
9
9
|
*/
|
|
10
|
-
type Cluster = "devnet"
|
|
10
|
+
type Cluster = "devnet";
|
|
11
11
|
/** Result delivered to the integrator's onVerified callback. */
|
|
12
12
|
interface EntrosVerifyResult {
|
|
13
13
|
walletPubkey: string;
|
|
@@ -62,10 +62,7 @@ interface EntrosVerifyProps {
|
|
|
62
62
|
popupWidth?: number;
|
|
63
63
|
/** Popup height in CSS pixels. Defaults to 720. */
|
|
64
64
|
popupHeight?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Maximum time the popup is allowed to be open before this component
|
|
67
|
-
* fires onError({reason: "timeout"}). Defaults to 5 minutes.
|
|
68
|
-
*/
|
|
65
|
+
/** See README.md#full-api for timeout behavior and the default. */
|
|
69
66
|
timeoutMs?: number;
|
|
70
67
|
/** Custom button content. Defaults to "Verify with Entros". */
|
|
71
68
|
children?: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ var ENTROS_MESSAGE_TYPES = /* @__PURE__ */ new Set([
|
|
|
52
52
|
"entros/error",
|
|
53
53
|
"entros/heartbeat"
|
|
54
54
|
]);
|
|
55
|
-
var CLUSTERS = /* @__PURE__ */ new Set(["devnet"
|
|
55
|
+
var CLUSTERS = /* @__PURE__ */ new Set(["devnet"]);
|
|
56
56
|
function isEntrosMessage(data) {
|
|
57
57
|
if (typeof data !== "object" || data === null) return false;
|
|
58
58
|
const msg = data;
|
|
@@ -81,6 +81,9 @@ function isHeartbeatPayload(payload) {
|
|
|
81
81
|
var VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;
|
|
82
82
|
var ORIGIN_PATTERN = /^https?:\/\/[^/]+$/;
|
|
83
83
|
function buildPopupUrl(opts) {
|
|
84
|
+
if (opts.cluster !== "devnet") {
|
|
85
|
+
throw new Error("Unsupported cluster: @entros/verify currently supports devnet only");
|
|
86
|
+
}
|
|
84
87
|
if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {
|
|
85
88
|
throw new Error(
|
|
86
89
|
`Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got "${opts.integratorKey}")`
|
|
@@ -131,7 +134,7 @@ function generateRequestId() {
|
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
// src/popup-manager.ts
|
|
134
|
-
var DEFAULT_TIMEOUT_MS =
|
|
137
|
+
var DEFAULT_TIMEOUT_MS = 9 * 60 * 1e3;
|
|
135
138
|
var POPUP_CLOSED_POLL_MS = 500;
|
|
136
139
|
var POPUP_CLOSED_GRACE_MS = 1500;
|
|
137
140
|
var POPUP_OWNED_FALLBACK_CLOSE_MS = 3e4;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/EntrosVerify.tsx","../src/messaging.ts","../src/url.ts","../src/popup-manager.ts"],"sourcesContent":["/**\n * `@entros/verify` — public surface.\n *\n * Drop-in React component for Entros verification. See\n * https://entros.io and https://docs.entros.io/integrate/verify.\n */\n\nexport { EntrosVerify } from \"./EntrosVerify\";\nexport type { EntrosVerifyProps } from \"./EntrosVerify\";\nexport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyProgressStatus,\n EntrosVerifyResult,\n} from \"./types\";\n","/**\n * <EntrosVerify> — drop-in trigger for the Entros verification popup.\n *\n * Renders a button. On click, opens a popup window to entros.io. User\n * completes wallet-connected verification inside the popup; the popup\n * posts the result back via postMessage; this component fires the\n * integrator's onVerified callback.\n *\n * See README and `EntrosVerifyProps` for usage.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, ReactElement, ReactNode } from \"react\";\n\nimport { openVerifyPopup, type PopupHandle } from \"./popup-manager\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_ORIGIN = \"https://entros.io\";\nconst DEFAULT_POPUP_WIDTH = 480;\nconst DEFAULT_POPUP_HEIGHT = 720;\n/**\n * After a verification settles (done or error), state returns to idle so\n * the component is ready for re-use without consumer intervention. Long\n * enough to render the brief \"done\" / \"error\" UX without blocking re-clicks.\n */\nconst SETTLE_RESET_MS = 1500;\n\nexport interface EntrosVerifyProps {\n /** Integrator key registered with Entros. Required. */\n integratorKey: string;\n /** Solana cluster. Defaults to \"devnet\". v1 supports devnet only. */\n cluster?: Cluster;\n /**\n * Optional Trust Score floor. The popup runs the verification regardless\n * and reports the result; if `minTrustScore` is set and the resulting\n * score is below it, the popup posts `entros/error` with reason\n * `validation_failed` instead of `entros/verified`.\n */\n minTrustScore?: number;\n /** Called on successful verification. Required. */\n onVerified: (result: EntrosVerifyResult) => void;\n /** Called on any failure or cancellation. Optional. */\n onError?: (error: EntrosVerifyError) => void;\n /** Called on progress heartbeats from the popup. Optional. */\n onProgress?: (progress: EntrosVerifyProgress) => void;\n /** Popup width in CSS pixels. Defaults to 480. */\n popupWidth?: number;\n /** Popup height in CSS pixels. Defaults to 720. */\n popupHeight?: number;\n /**\n * Maximum time the popup is allowed to be open before this component\n * fires onError({reason: \"timeout\"}). Defaults to 5 minutes.\n */\n timeoutMs?: number;\n /** Custom button content. Defaults to \"Verify with Entros\". */\n children?: ReactNode;\n /** className applied to the trigger button. */\n className?: string;\n /** Inline style applied to the trigger button. */\n style?: CSSProperties;\n /**\n * If true, when the popup is blocked the component renders an inline\n * retry button. Clicking it triggers a fresh window.open from a confirmed\n * user gesture, which most browsers allow. Defaults to true.\n */\n popupBlockedFallback?: boolean;\n /**\n * INTERNAL: Override the entros.io base origin. Intended for end-to-end\n * testing against a localhost popup host. Production consumers should\n * not set this.\n */\n baseOrigin?: string;\n}\n\ntype State =\n | { kind: \"idle\" }\n | { kind: \"opening\" }\n | { kind: \"blocked\" }\n | { kind: \"waiting\" }\n | { kind: \"done\" }\n | { kind: \"error\"; reason: EntrosVerifyErrorReason };\n\nexport function EntrosVerify(props: EntrosVerifyProps): ReactElement {\n const [state, setState] = useState<State>({ kind: \"idle\" });\n const handleRef = useRef<PopupHandle | null>(null);\n const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Refs hold the latest callbacks so trigger stays stable across re-renders\n // even when consumers pass inline arrow functions. Avoids unnecessary\n // re-creation of the click handler on every parent render.\n const onVerifiedRef = useRef(props.onVerified);\n const onErrorRef = useRef(props.onError);\n const onProgressRef = useRef(props.onProgress);\n useEffect(() => {\n onVerifiedRef.current = props.onVerified;\n onErrorRef.current = props.onError;\n onProgressRef.current = props.onProgress;\n });\n\n // Tear down any in-flight popup + reset timer on unmount.\n useEffect(() => {\n return () => {\n if (handleRef.current) {\n handleRef.current.cancel();\n handleRef.current = null;\n }\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n };\n }, []);\n\n const scheduleReset = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n }\n resetTimerRef.current = setTimeout(() => {\n resetTimerRef.current = null;\n setState({ kind: \"idle\" });\n }, SETTLE_RESET_MS);\n }, []);\n\n const trigger = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n setState({ kind: \"opening\" });\n\n const handle = openVerifyPopup({\n baseOrigin: props.baseOrigin ?? DEFAULT_BASE_ORIGIN,\n integratorKey: props.integratorKey,\n cluster: props.cluster ?? \"devnet\",\n minTrustScore: props.minTrustScore,\n popupWidth: props.popupWidth ?? DEFAULT_POPUP_WIDTH,\n popupHeight: props.popupHeight ?? DEFAULT_POPUP_HEIGHT,\n timeoutMs: props.timeoutMs,\n onVerified: (result) => {\n handleRef.current = null;\n setState({ kind: \"done\" });\n onVerifiedRef.current(result);\n scheduleReset();\n },\n onError: (error) => {\n handleRef.current = null;\n setState({ kind: \"error\", reason: error.reason });\n onErrorRef.current?.(error);\n scheduleReset();\n },\n onProgress: (progress) => {\n onProgressRef.current?.(progress);\n },\n });\n\n if (handle === null) {\n setState({ kind: \"blocked\" });\n onErrorRef.current?.({ reason: \"popup_blocked\" });\n return;\n }\n\n handleRef.current = handle;\n setState({ kind: \"waiting\" });\n }, [\n props.baseOrigin,\n props.cluster,\n props.integratorKey,\n props.minTrustScore,\n props.popupHeight,\n props.popupWidth,\n props.timeoutMs,\n scheduleReset,\n ]);\n\n const isWaiting = state.kind === \"opening\" || state.kind === \"waiting\";\n const showFallback =\n state.kind === \"blocked\" && (props.popupBlockedFallback ?? true);\n\n return (\n <div className=\"entros-verify-container\" data-state={state.kind}>\n <button\n type=\"button\"\n onClick={trigger}\n disabled={isWaiting}\n className={props.className}\n style={props.style}\n >\n {isWaiting\n ? \"Verifying…\"\n : (props.children ?? \"Verify with Entros\")}\n </button>\n {showFallback && (\n <div role=\"alert\" className=\"entros-verify-blocked\">\n <span>Popup blocked. </span>\n <button type=\"button\" onClick={trigger} className={props.className}>\n Click here to open verification\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * Type guards and validation for postMessage envelopes received from the\n * Entros verify popup. The component is the trust boundary — every message\n * arriving on `window` is hostile until proven otherwise.\n *\n * Validation order in popup-manager.ts:\n * 1. event.origin matches expected popup origin (caller's responsibility)\n * 2. isEntrosMessage(event.data)\n * 3. event.data.request_id matches the parent's expected ID\n * 4. isFreshMessage(event.data)\n * 5. payload-specific guard for the message type\n *\n * Skipping any step is a security regression.\n */\n\nimport type {\n EntrosMessage,\n ErrorPayload,\n HeartbeatPayload,\n VerifiedPayload,\n} from \"./types\";\n\n/**\n * Maximum allowed clock drift between popup and parent. 90 seconds.\n *\n * The popup completes verification in seconds. A tighter window narrows\n * replay surface without affecting legitimate flows. The 5-minute\n * popup-open timeout is enforced separately by popup-manager.\n */\nconst MAX_TIMESTAMP_DRIFT_MS = 90 * 1000;\n\n/** Allowed error reason values on the wire. */\nconst ERROR_REASONS = new Set<string>([\n \"wallet_rejected\",\n \"validation_failed\",\n \"network_error\",\n \"user_canceled\",\n \"origin_invalid\",\n \"popup_blocked\",\n \"timeout\",\n \"unknown\",\n]);\n\nconst HEARTBEAT_STATUSES = new Set<string>([\n \"wallet_connecting\",\n \"capturing\",\n \"proving\",\n \"submitting\",\n \"attesting\",\n]);\n\nconst ENTROS_MESSAGE_TYPES = new Set<string>([\n \"entros/verified\",\n \"entros/error\",\n \"entros/heartbeat\",\n]);\n\nconst CLUSTERS = new Set<string>([\"devnet\", \"mainnet-beta\"]);\n\nexport function isEntrosMessage(data: unknown): data is EntrosMessage {\n if (typeof data !== \"object\" || data === null) return false;\n const msg = data as Record<string, unknown>;\n return (\n msg.source === \"entros\" &&\n msg.version === 1 &&\n typeof msg.type === \"string\" &&\n ENTROS_MESSAGE_TYPES.has(msg.type) &&\n typeof msg.request_id === \"string\" &&\n msg.request_id.length > 0 &&\n typeof msg.timestamp === \"number\" &&\n Number.isFinite(msg.timestamp) &&\n \"payload\" in msg\n );\n}\n\nexport function isFreshMessage(msg: EntrosMessage, now: number = Date.now()): boolean {\n return Math.abs(now - msg.timestamp) < MAX_TIMESTAMP_DRIFT_MS;\n}\n\nexport function isVerifiedPayload(payload: unknown): payload is VerifiedPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return (\n typeof p.wallet_pubkey === \"string\" &&\n p.wallet_pubkey.length > 0 &&\n typeof p.attestation_pda === \"string\" &&\n p.attestation_pda.length > 0 &&\n typeof p.tx_sig === \"string\" &&\n p.tx_sig.length > 0 &&\n typeof p.trust_score === \"number\" &&\n Number.isFinite(p.trust_score) &&\n p.trust_score >= 0 &&\n typeof p.cluster === \"string\" &&\n CLUSTERS.has(p.cluster)\n );\n}\n\nexport function isErrorPayload(payload: unknown): payload is ErrorPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.reason === \"string\" && ERROR_REASONS.has(p.reason);\n}\n\nexport function isHeartbeatPayload(payload: unknown): payload is HeartbeatPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.status === \"string\" && HEARTBEAT_STATUSES.has(p.status);\n}\n","/**\n * URL builders for the Entros verify popup.\n *\n * The component constructs the popup URL deterministically from the\n * integrator's props. The popup host validates every field server-side;\n * these helpers exist to fail loudly on the integrator's side when a\n * misconfiguration would have wasted a popup roundtrip.\n */\n\nimport type { Cluster } from \"./types\";\n\nconst VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;\nconst ORIGIN_PATTERN = /^https?:\\/\\/[^/]+$/;\n\nexport interface BuildPopupUrlOptions {\n /** entros.io base origin. Override for E2E testing only. */\n baseOrigin: string;\n integratorKey: string;\n /** Caller's window origin — popup posts back to this. */\n parentOrigin: string;\n cluster: Cluster;\n requestId: string;\n minTrustScore?: number;\n}\n\nexport function buildPopupUrl(opts: BuildPopupUrlOptions): string {\n if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {\n throw new Error(\n `Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got \"${opts.integratorKey}\")`,\n );\n }\n if (!ORIGIN_PATTERN.test(opts.parentOrigin)) {\n throw new Error(\n `Invalid parentOrigin: must be a fully-qualified origin (got \"${opts.parentOrigin}\")`,\n );\n }\n if (opts.minTrustScore !== undefined) {\n if (\n !Number.isInteger(opts.minTrustScore) ||\n opts.minTrustScore < 0 ||\n opts.minTrustScore > 10000\n ) {\n throw new Error(\n `Invalid minTrustScore: must be an integer in [0, 10000] (got ${String(opts.minTrustScore)})`,\n );\n }\n }\n\n const url = new URL(\"/embed/verify-popup\", opts.baseOrigin);\n url.searchParams.set(\"integrator\", opts.integratorKey);\n url.searchParams.set(\"parent_origin\", opts.parentOrigin);\n url.searchParams.set(\"cluster\", opts.cluster);\n url.searchParams.set(\"request_id\", opts.requestId);\n if (opts.minTrustScore !== undefined) {\n url.searchParams.set(\"min_trust_score\", String(opts.minTrustScore));\n }\n return url.toString();\n}\n\n/**\n * Generates a cryptographically random request ID for replay protection.\n * Uses crypto.randomUUID when available (modern browsers + Node 19+).\n * Falls back to crypto.getRandomValues (broadly supported back to IE11)\n * formatted as a UUIDv4. Math.random is never used.\n */\nexport function generateRequestId(): string {\n if (typeof crypto === \"undefined\") {\n throw new Error(\n \"crypto is unavailable in this environment; @entros/verify requires a secure context\",\n );\n }\n if (typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues is unavailable; @entros/verify requires a secure context\",\n );\n }\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n // RFC 4122 v4 framing: bits 6-7 of byte 8 are 0b10, bits 12-15 of byte 6\n // are 0b0100. The remaining bits are random.\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return (\n hex.slice(0, 4).join(\"\") +\n \"-\" +\n hex.slice(4, 6).join(\"\") +\n \"-\" +\n hex.slice(6, 8).join(\"\") +\n \"-\" +\n hex.slice(8, 10).join(\"\") +\n \"-\" +\n hex.slice(10, 16).join(\"\")\n );\n}\n","/**\n * Popup-window state machine for `<EntrosVerify>`.\n *\n * Owns: window.open, postMessage listener, popup.closed polling, timeout.\n * Boundary with the React layer: open → returns a handle (or null if blocked).\n * Component is responsible for rendering the trigger button and the\n * popup-blocked fallback UI.\n *\n * Security model — every postMessage from the popup is treated as hostile\n * until proven otherwise. Validation order (skipping any step is a\n * regression):\n * 1. event.origin === expectedPopupOrigin\n * 2. event.source === popup (the window we opened, not a sibling tab)\n * 3. envelope shape matches `EntrosMessage` (version, source, type)\n * 4. event.data.request_id === this popup's request_id (replay defense)\n * 5. timestamp within drift window (90s)\n * 6. payload-specific guard for the message type\n */\n\nimport {\n isEntrosMessage,\n isErrorPayload,\n isFreshMessage,\n isHeartbeatPayload,\n isVerifiedPayload,\n} from \"./messaging\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\nimport { buildPopupUrl, generateRequestId } from \"./url\";\n\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes\nconst POPUP_CLOSED_POLL_MS = 500;\n\n/**\n * Grace period after detecting popup.closed before firing user_canceled.\n * Lets the final `entros/verified` message arrive when the popup posts\n * and self-closes within the same event-loop turn.\n */\nconst POPUP_CLOSED_GRACE_MS = 1500;\n\n/**\n * After a popup-emitted outcome (`entros/verified` or `entros/error`),\n * the popup owns its own close — its success / failure surface renders\n * and either self-closes or waits for explicit user action (e.g., the\n * baseline-stale recovery surface). The parent only force-closes after\n * this defensive fallback in case the popup fails to close itself.\n * Generous enough to allow interactive failure surfaces to be read and\n * acted on; short enough that an abandoned popup eventually dies.\n */\nconst POPUP_OWNED_FALLBACK_CLOSE_MS = 30_000;\n\nexport interface OpenPopupOptions {\n baseOrigin: string;\n integratorKey: string;\n cluster: Cluster;\n minTrustScore?: number;\n popupWidth: number;\n popupHeight: number;\n timeoutMs?: number;\n onVerified: (result: EntrosVerifyResult) => void;\n onError: (error: EntrosVerifyError) => void;\n onProgress?: (progress: EntrosVerifyProgress) => void;\n}\n\nexport interface PopupHandle {\n /**\n * Force-cancel the popup. Closes the window if still open, fires\n * onError({reason: \"user_canceled\"}), and tears down listeners.\n * Idempotent.\n */\n cancel: () => void;\n}\n\nexport function openVerifyPopup(opts: OpenPopupOptions): PopupHandle | null {\n if (typeof window === \"undefined\") {\n throw new Error(\"openVerifyPopup must be called in a browser context\");\n }\n\n const requestId = generateRequestId();\n const parentOrigin = window.location.origin;\n const url = buildPopupUrl({\n baseOrigin: opts.baseOrigin,\n integratorKey: opts.integratorKey,\n parentOrigin,\n cluster: opts.cluster,\n requestId,\n minTrustScore: opts.minTrustScore,\n });\n\n const left = Math.max(\n 0,\n Math.floor((window.screen.availWidth - opts.popupWidth) / 2),\n );\n const top = Math.max(\n 0,\n Math.floor((window.screen.availHeight - opts.popupHeight) / 2),\n );\n const features = [\n `width=${opts.popupWidth}`,\n `height=${opts.popupHeight}`,\n `left=${left}`,\n `top=${top}`,\n \"menubar=no\",\n \"toolbar=no\",\n // location=yes lets the user verify entros.io in the URL bar.\n \"location=yes\",\n \"status=no\",\n \"resizable=yes\",\n \"scrollbars=yes\",\n ].join(\",\");\n\n // Unique window name per popup. A fixed name causes collision when an\n // integrator renders multiple <EntrosVerify> on one page — the second\n // window.open would reuse the existing popup.\n const popupName = `entros_verify_${requestId}`;\n const rawPopup = window.open(url, popupName, features);\n if (!rawPopup || rawPopup.closed) {\n return null;\n }\n // Narrow once so closures below see the non-null type.\n const popup: Window = rawPopup;\n\n const expectedPopupOrigin = new URL(opts.baseOrigin).origin;\n\n let settled = false;\n let pollTimerId: ReturnType<typeof setInterval> | null = null;\n let timeoutTimerId: ReturnType<typeof setTimeout> | null = null;\n let popupClosedAtMs: number | null = null;\n\n function clearListenersAndTimers(): void {\n window.removeEventListener(\"message\", onMessage);\n if (pollTimerId !== null) {\n clearInterval(pollTimerId);\n pollTimerId = null;\n }\n if (timeoutTimerId !== null) {\n clearTimeout(timeoutTimerId);\n timeoutTimerId = null;\n }\n }\n\n function forceClosePopup(): void {\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // Defensive only. We opened this window so we own the close permission;\n // this branch is for esoteric extension or browser-quirk edge cases.\n }\n }\n }\n\n function settleVerified(result: EntrosVerifyResult): void {\n if (settled) return;\n settled = true;\n // The popup owns its own close on the verified path so its\n // recognition surface (`Verified.` checkmark) is visible to the user\n // before the window dies. Parent only force-closes as a defensive\n // fallback in case the popup fails to close itself.\n clearListenersAndTimers();\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n opts.onVerified(result);\n }\n\n /**\n * @param forceImmediateClose\n * - false (default) — error came from a popup-emitted `entros/error`\n * message; the popup is still alive and rendering its own\n * `PopupFailure` (auto-close) or interactive recovery surface\n * (e.g., baseline-stale). Parent waits the fallback window before\n * force-closing so the user sees the failure category.\n * - true — error came from the parent (timeout, user cancel, or\n * polling detected the popup already closed). No popup-side\n * surface to preserve; force-close immediately.\n */\n function settleError(\n reason: EntrosVerifyErrorReason,\n forceImmediateClose = false,\n ): void {\n if (settled) return;\n settled = true;\n clearListenersAndTimers();\n if (forceImmediateClose) {\n forceClosePopup();\n } else {\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n }\n opts.onError({ reason });\n }\n\n function onMessage(event: MessageEvent): void {\n if (settled) return;\n\n // Origin gate — first and most important check.\n if (event.origin !== expectedPopupOrigin) return;\n\n // Source gate — defense-in-depth against another same-origin tab on\n // entros.io (e.g., the standalone /verify route open in a sibling tab)\n // posting a forged message. Only the popup we opened is authoritative.\n if (event.source !== popup) return;\n\n if (!isEntrosMessage(event.data)) return;\n\n // Replay protection — request_id must match this popup's ID.\n if (event.data.request_id !== requestId) return;\n\n if (!isFreshMessage(event.data)) return;\n\n switch (event.data.type) {\n case \"entros/verified\": {\n if (isVerifiedPayload(event.data.payload)) {\n settleVerified({\n walletPubkey: event.data.payload.wallet_pubkey,\n attestationPda: event.data.payload.attestation_pda,\n txSig: event.data.payload.tx_sig,\n trustScore: event.data.payload.trust_score,\n cluster: event.data.payload.cluster,\n });\n }\n break;\n }\n case \"entros/error\": {\n if (isErrorPayload(event.data.payload)) {\n settleError(event.data.payload.reason);\n }\n break;\n }\n case \"entros/heartbeat\": {\n if (isHeartbeatPayload(event.data.payload) && opts.onProgress) {\n opts.onProgress({ status: event.data.payload.status });\n }\n break;\n }\n }\n }\n\n function onPoll(): void {\n if (settled) return;\n if (popup.closed) {\n // Start the grace period the first time we observe the close.\n if (popupClosedAtMs === null) {\n popupClosedAtMs = Date.now();\n return;\n }\n if (Date.now() - popupClosedAtMs >= POPUP_CLOSED_GRACE_MS) {\n settleError(\"user_canceled\", true);\n }\n } else {\n popupClosedAtMs = null;\n }\n }\n\n function onTimeout(): void {\n settleError(\"timeout\", true);\n }\n\n window.addEventListener(\"message\", onMessage);\n pollTimerId = setInterval(onPoll, POPUP_CLOSED_POLL_MS);\n timeoutTimerId = setTimeout(onTimeout, opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n\n return {\n cancel: () => settleError(\"user_canceled\", true),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,mBAAyD;;;ACkBzD,IAAM,yBAAyB,KAAK;AAGpC,IAAM,gBAAgB,oBAAI,IAAY;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,qBAAqB,oBAAI,IAAY;AAAA,EACzC;AAAA,EACA;AAAA,EACA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B,OAAO,MAAM;AAAA,QAEZ,sBACG,oBACC,MAAM,YAAY;AAAA;AAAA,IACzB;AAAA,IACC,gBACC,6CAAC,SAAI,MAAK,SAAQ,WAAU,yBAC1B;AAAA,kDAAC,UAAK,6BAAe;AAAA,MACrB,4CAAC,YAAO,MAAK,UAAS,SAAS,SAAS,WAAW,MAAM,WAAW,6CAEpE;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/EntrosVerify.tsx","../src/messaging.ts","../src/url.ts","../src/popup-manager.ts"],"sourcesContent":["/**\n * `@entros/verify` — public surface.\n *\n * Drop-in React component for Entros verification. See\n * https://entros.io and https://docs.entros.io/integrate/verify.\n */\n\nexport { EntrosVerify } from \"./EntrosVerify\";\nexport type { EntrosVerifyProps } from \"./EntrosVerify\";\nexport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyProgressStatus,\n EntrosVerifyResult,\n} from \"./types\";\n","/**\n * <EntrosVerify> — drop-in trigger for the Entros verification popup.\n *\n * Renders a button. On click, opens a popup window to entros.io. User\n * completes wallet-connected verification inside the popup; the popup\n * posts the result back via postMessage; this component fires the\n * integrator's onVerified callback.\n *\n * See README and `EntrosVerifyProps` for usage.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, ReactElement, ReactNode } from \"react\";\n\nimport { openVerifyPopup, type PopupHandle } from \"./popup-manager\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_ORIGIN = \"https://entros.io\";\nconst DEFAULT_POPUP_WIDTH = 480;\nconst DEFAULT_POPUP_HEIGHT = 720;\n/**\n * After a verification settles (done or error), state returns to idle so\n * the component is ready for re-use without consumer intervention. Long\n * enough to render the brief \"done\" / \"error\" UX without blocking re-clicks.\n */\nconst SETTLE_RESET_MS = 1500;\n\nexport interface EntrosVerifyProps {\n /** Integrator key registered with Entros. Required. */\n integratorKey: string;\n /** Solana cluster. Defaults to \"devnet\". v1 supports devnet only. */\n cluster?: Cluster;\n /**\n * Optional Trust Score floor. The popup runs the verification regardless\n * and reports the result; if `minTrustScore` is set and the resulting\n * score is below it, the popup posts `entros/error` with reason\n * `validation_failed` instead of `entros/verified`.\n */\n minTrustScore?: number;\n /** Called on successful verification. Required. */\n onVerified: (result: EntrosVerifyResult) => void;\n /** Called on any failure or cancellation. Optional. */\n onError?: (error: EntrosVerifyError) => void;\n /** Called on progress heartbeats from the popup. Optional. */\n onProgress?: (progress: EntrosVerifyProgress) => void;\n /** Popup width in CSS pixels. Defaults to 480. */\n popupWidth?: number;\n /** Popup height in CSS pixels. Defaults to 720. */\n popupHeight?: number;\n /** See README.md#full-api for timeout behavior and the default. */\n timeoutMs?: number;\n /** Custom button content. Defaults to \"Verify with Entros\". */\n children?: ReactNode;\n /** className applied to the trigger button. */\n className?: string;\n /** Inline style applied to the trigger button. */\n style?: CSSProperties;\n /**\n * If true, when the popup is blocked the component renders an inline\n * retry button. Clicking it triggers a fresh window.open from a confirmed\n * user gesture, which most browsers allow. Defaults to true.\n */\n popupBlockedFallback?: boolean;\n /**\n * INTERNAL: Override the entros.io base origin. Intended for end-to-end\n * testing against a localhost popup host. Production consumers should\n * not set this.\n */\n baseOrigin?: string;\n}\n\ntype State =\n | { kind: \"idle\" }\n | { kind: \"opening\" }\n | { kind: \"blocked\" }\n | { kind: \"waiting\" }\n | { kind: \"done\" }\n | { kind: \"error\"; reason: EntrosVerifyErrorReason };\n\nexport function EntrosVerify(props: EntrosVerifyProps): ReactElement {\n const [state, setState] = useState<State>({ kind: \"idle\" });\n const handleRef = useRef<PopupHandle | null>(null);\n const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Refs hold the latest callbacks so trigger stays stable across re-renders\n // even when consumers pass inline arrow functions. Avoids unnecessary\n // re-creation of the click handler on every parent render.\n const onVerifiedRef = useRef(props.onVerified);\n const onErrorRef = useRef(props.onError);\n const onProgressRef = useRef(props.onProgress);\n useEffect(() => {\n onVerifiedRef.current = props.onVerified;\n onErrorRef.current = props.onError;\n onProgressRef.current = props.onProgress;\n });\n\n // Tear down any in-flight popup + reset timer on unmount.\n useEffect(() => {\n return () => {\n if (handleRef.current) {\n handleRef.current.cancel();\n handleRef.current = null;\n }\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n };\n }, []);\n\n const scheduleReset = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n }\n resetTimerRef.current = setTimeout(() => {\n resetTimerRef.current = null;\n setState({ kind: \"idle\" });\n }, SETTLE_RESET_MS);\n }, []);\n\n const trigger = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n setState({ kind: \"opening\" });\n\n const handle = openVerifyPopup({\n baseOrigin: props.baseOrigin ?? DEFAULT_BASE_ORIGIN,\n integratorKey: props.integratorKey,\n cluster: props.cluster ?? \"devnet\",\n minTrustScore: props.minTrustScore,\n popupWidth: props.popupWidth ?? DEFAULT_POPUP_WIDTH,\n popupHeight: props.popupHeight ?? DEFAULT_POPUP_HEIGHT,\n timeoutMs: props.timeoutMs,\n onVerified: (result) => {\n handleRef.current = null;\n setState({ kind: \"done\" });\n onVerifiedRef.current(result);\n scheduleReset();\n },\n onError: (error) => {\n handleRef.current = null;\n setState({ kind: \"error\", reason: error.reason });\n onErrorRef.current?.(error);\n scheduleReset();\n },\n onProgress: (progress) => {\n onProgressRef.current?.(progress);\n },\n });\n\n if (handle === null) {\n setState({ kind: \"blocked\" });\n onErrorRef.current?.({ reason: \"popup_blocked\" });\n return;\n }\n\n handleRef.current = handle;\n setState({ kind: \"waiting\" });\n }, [\n props.baseOrigin,\n props.cluster,\n props.integratorKey,\n props.minTrustScore,\n props.popupHeight,\n props.popupWidth,\n props.timeoutMs,\n scheduleReset,\n ]);\n\n const isWaiting = state.kind === \"opening\" || state.kind === \"waiting\";\n const showFallback =\n state.kind === \"blocked\" && (props.popupBlockedFallback ?? true);\n\n return (\n <div className=\"entros-verify-container\" data-state={state.kind}>\n <button\n type=\"button\"\n onClick={trigger}\n disabled={isWaiting}\n className={props.className}\n style={props.style}\n >\n {isWaiting\n ? \"Verifying…\"\n : (props.children ?? \"Verify with Entros\")}\n </button>\n {showFallback && (\n <div role=\"alert\" className=\"entros-verify-blocked\">\n <span>Popup blocked. </span>\n <button type=\"button\" onClick={trigger} className={props.className}>\n Click here to open verification\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * Type guards and validation for postMessage envelopes received from the\n * Entros verify popup. The component is the trust boundary — every message\n * arriving on `window` is hostile until proven otherwise.\n *\n * Validation order in popup-manager.ts:\n * 1. event.origin matches expected popup origin (caller's responsibility)\n * 2. isEntrosMessage(event.data)\n * 3. event.data.request_id matches the parent's expected ID\n * 4. isFreshMessage(event.data)\n * 5. payload-specific guard for the message type\n *\n * Skipping any step is a security regression.\n */\n\nimport type {\n EntrosMessage,\n ErrorPayload,\n HeartbeatPayload,\n VerifiedPayload,\n} from \"./types\";\n\n/**\n * Maximum allowed clock drift between popup and parent. 90 seconds.\n *\n * The popup timestamps each message when it posts it. This window checks\n * delivery freshness and does not limit total verification duration.\n */\nconst MAX_TIMESTAMP_DRIFT_MS = 90 * 1000;\n\n/** Allowed error reason values on the wire. */\nconst ERROR_REASONS = new Set<string>([\n \"wallet_rejected\",\n \"validation_failed\",\n \"network_error\",\n \"user_canceled\",\n \"origin_invalid\",\n \"popup_blocked\",\n \"timeout\",\n \"unknown\",\n]);\n\nconst HEARTBEAT_STATUSES = new Set<string>([\n \"wallet_connecting\",\n \"capturing\",\n \"proving\",\n \"submitting\",\n \"attesting\",\n]);\n\nconst ENTROS_MESSAGE_TYPES = new Set<string>([\n \"entros/verified\",\n \"entros/error\",\n \"entros/heartbeat\",\n]);\n\nconst CLUSTERS = new Set<string>([\"devnet\"]);\n\nexport function isEntrosMessage(data: unknown): data is EntrosMessage {\n if (typeof data !== \"object\" || data === null) return false;\n const msg = data as Record<string, unknown>;\n return (\n msg.source === \"entros\" &&\n msg.version === 1 &&\n typeof msg.type === \"string\" &&\n ENTROS_MESSAGE_TYPES.has(msg.type) &&\n typeof msg.request_id === \"string\" &&\n msg.request_id.length > 0 &&\n typeof msg.timestamp === \"number\" &&\n Number.isFinite(msg.timestamp) &&\n \"payload\" in msg\n );\n}\n\nexport function isFreshMessage(msg: EntrosMessage, now: number = Date.now()): boolean {\n return Math.abs(now - msg.timestamp) < MAX_TIMESTAMP_DRIFT_MS;\n}\n\nexport function isVerifiedPayload(payload: unknown): payload is VerifiedPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return (\n typeof p.wallet_pubkey === \"string\" &&\n p.wallet_pubkey.length > 0 &&\n typeof p.attestation_pda === \"string\" &&\n p.attestation_pda.length > 0 &&\n typeof p.tx_sig === \"string\" &&\n p.tx_sig.length > 0 &&\n typeof p.trust_score === \"number\" &&\n Number.isFinite(p.trust_score) &&\n p.trust_score >= 0 &&\n typeof p.cluster === \"string\" &&\n CLUSTERS.has(p.cluster)\n );\n}\n\nexport function isErrorPayload(payload: unknown): payload is ErrorPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.reason === \"string\" && ERROR_REASONS.has(p.reason);\n}\n\nexport function isHeartbeatPayload(payload: unknown): payload is HeartbeatPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.status === \"string\" && HEARTBEAT_STATUSES.has(p.status);\n}\n","/**\n * URL builders for the Entros verify popup.\n *\n * The component constructs the popup URL deterministically from the\n * integrator's props. The popup host validates every field server-side;\n * these helpers exist to fail loudly on the integrator's side when a\n * misconfiguration would have wasted a popup roundtrip.\n */\n\nimport type { Cluster } from \"./types\";\n\nconst VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;\nconst ORIGIN_PATTERN = /^https?:\\/\\/[^/]+$/;\n\nexport interface BuildPopupUrlOptions {\n /** entros.io base origin. Override for E2E testing only. */\n baseOrigin: string;\n integratorKey: string;\n /** Caller's window origin — popup posts back to this. */\n parentOrigin: string;\n cluster: Cluster;\n requestId: string;\n minTrustScore?: number;\n}\n\nexport function buildPopupUrl(opts: BuildPopupUrlOptions): string {\n if (opts.cluster !== \"devnet\") {\n throw new Error(\"Unsupported cluster: @entros/verify currently supports devnet only\");\n }\n if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {\n throw new Error(\n `Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got \"${opts.integratorKey}\")`,\n );\n }\n if (!ORIGIN_PATTERN.test(opts.parentOrigin)) {\n throw new Error(\n `Invalid parentOrigin: must be a fully-qualified origin (got \"${opts.parentOrigin}\")`,\n );\n }\n if (opts.minTrustScore !== undefined) {\n if (\n !Number.isInteger(opts.minTrustScore) ||\n opts.minTrustScore < 0 ||\n opts.minTrustScore > 10000\n ) {\n throw new Error(\n `Invalid minTrustScore: must be an integer in [0, 10000] (got ${String(opts.minTrustScore)})`,\n );\n }\n }\n\n const url = new URL(\"/embed/verify-popup\", opts.baseOrigin);\n url.searchParams.set(\"integrator\", opts.integratorKey);\n url.searchParams.set(\"parent_origin\", opts.parentOrigin);\n url.searchParams.set(\"cluster\", opts.cluster);\n url.searchParams.set(\"request_id\", opts.requestId);\n if (opts.minTrustScore !== undefined) {\n url.searchParams.set(\"min_trust_score\", String(opts.minTrustScore));\n }\n return url.toString();\n}\n\n/**\n * Generates a cryptographically random request ID for replay protection.\n * Uses crypto.randomUUID when available (modern browsers + Node 19+).\n * Falls back to crypto.getRandomValues (broadly supported back to IE11)\n * formatted as a UUIDv4. Math.random is never used.\n */\nexport function generateRequestId(): string {\n if (typeof crypto === \"undefined\") {\n throw new Error(\n \"crypto is unavailable in this environment; @entros/verify requires a secure context\",\n );\n }\n if (typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues is unavailable; @entros/verify requires a secure context\",\n );\n }\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n // RFC 4122 v4 framing: bits 6-7 of byte 8 are 0b10, bits 12-15 of byte 6\n // are 0b0100. The remaining bits are random.\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return (\n hex.slice(0, 4).join(\"\") +\n \"-\" +\n hex.slice(4, 6).join(\"\") +\n \"-\" +\n hex.slice(6, 8).join(\"\") +\n \"-\" +\n hex.slice(8, 10).join(\"\") +\n \"-\" +\n hex.slice(10, 16).join(\"\")\n );\n}\n","/**\n * Popup-window state machine for `<EntrosVerify>`.\n *\n * Owns: window.open, postMessage listener, popup.closed polling, timeout.\n * Boundary with the React layer: open → returns a handle (or null if blocked).\n * Component is responsible for rendering the trigger button and the\n * popup-blocked fallback UI.\n *\n * Security model — every postMessage from the popup is treated as hostile\n * until proven otherwise. Validation order (skipping any step is a\n * regression):\n * 1. event.origin === expectedPopupOrigin\n * 2. event.source === popup (the window we opened, not a sibling tab)\n * 3. envelope shape matches `EntrosMessage` (version, source, type)\n * 4. event.data.request_id === this popup's request_id (replay defense)\n * 5. timestamp within drift window (90s)\n * 6. payload-specific guard for the message type\n */\n\nimport {\n isEntrosMessage,\n isErrorPayload,\n isFreshMessage,\n isHeartbeatPayload,\n isVerifiedPayload,\n} from \"./messaging\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\nimport { buildPopupUrl, generateRequestId } from \"./url\";\n\nconst DEFAULT_TIMEOUT_MS = 9 * 60 * 1000;\nconst POPUP_CLOSED_POLL_MS = 500;\n\n/**\n * Grace period after detecting popup.closed before firing user_canceled.\n * Lets the final `entros/verified` message arrive when the popup posts\n * and self-closes within the same event-loop turn.\n */\nconst POPUP_CLOSED_GRACE_MS = 1500;\n\n/**\n * After a popup-emitted outcome (`entros/verified` or `entros/error`),\n * the popup owns its own close — its success / failure surface renders\n * and either self-closes or waits for explicit user action (e.g., the\n * baseline-stale recovery surface). The parent only force-closes after\n * this defensive fallback in case the popup fails to close itself.\n * Generous enough to allow interactive failure surfaces to be read and\n * acted on; short enough that an abandoned popup eventually dies.\n */\nconst POPUP_OWNED_FALLBACK_CLOSE_MS = 30_000;\n\nexport interface OpenPopupOptions {\n baseOrigin: string;\n integratorKey: string;\n cluster: Cluster;\n minTrustScore?: number;\n popupWidth: number;\n popupHeight: number;\n timeoutMs?: number;\n onVerified: (result: EntrosVerifyResult) => void;\n onError: (error: EntrosVerifyError) => void;\n onProgress?: (progress: EntrosVerifyProgress) => void;\n}\n\nexport interface PopupHandle {\n /**\n * Force-cancel the popup. Closes the window if still open, fires\n * onError({reason: \"user_canceled\"}), and tears down listeners.\n * Idempotent.\n */\n cancel: () => void;\n}\n\nexport function openVerifyPopup(opts: OpenPopupOptions): PopupHandle | null {\n if (typeof window === \"undefined\") {\n throw new Error(\"openVerifyPopup must be called in a browser context\");\n }\n\n const requestId = generateRequestId();\n const parentOrigin = window.location.origin;\n const url = buildPopupUrl({\n baseOrigin: opts.baseOrigin,\n integratorKey: opts.integratorKey,\n parentOrigin,\n cluster: opts.cluster,\n requestId,\n minTrustScore: opts.minTrustScore,\n });\n\n const left = Math.max(\n 0,\n Math.floor((window.screen.availWidth - opts.popupWidth) / 2),\n );\n const top = Math.max(\n 0,\n Math.floor((window.screen.availHeight - opts.popupHeight) / 2),\n );\n const features = [\n `width=${opts.popupWidth}`,\n `height=${opts.popupHeight}`,\n `left=${left}`,\n `top=${top}`,\n \"menubar=no\",\n \"toolbar=no\",\n // location=yes lets the user verify entros.io in the URL bar.\n \"location=yes\",\n \"status=no\",\n \"resizable=yes\",\n \"scrollbars=yes\",\n ].join(\",\");\n\n // Unique window name per popup. A fixed name causes collision when an\n // integrator renders multiple <EntrosVerify> on one page — the second\n // window.open would reuse the existing popup.\n const popupName = `entros_verify_${requestId}`;\n const rawPopup = window.open(url, popupName, features);\n if (!rawPopup || rawPopup.closed) {\n return null;\n }\n // Narrow once so closures below see the non-null type.\n const popup: Window = rawPopup;\n\n const expectedPopupOrigin = new URL(opts.baseOrigin).origin;\n\n let settled = false;\n let pollTimerId: ReturnType<typeof setInterval> | null = null;\n let timeoutTimerId: ReturnType<typeof setTimeout> | null = null;\n let popupClosedAtMs: number | null = null;\n\n function clearListenersAndTimers(): void {\n window.removeEventListener(\"message\", onMessage);\n if (pollTimerId !== null) {\n clearInterval(pollTimerId);\n pollTimerId = null;\n }\n if (timeoutTimerId !== null) {\n clearTimeout(timeoutTimerId);\n timeoutTimerId = null;\n }\n }\n\n function forceClosePopup(): void {\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // Defensive only. We opened this window so we own the close permission;\n // this branch is for esoteric extension or browser-quirk edge cases.\n }\n }\n }\n\n function settleVerified(result: EntrosVerifyResult): void {\n if (settled) return;\n settled = true;\n // The popup owns its own close on the verified path so its\n // recognition surface (`Verified.` checkmark) is visible to the user\n // before the window dies. Parent only force-closes as a defensive\n // fallback in case the popup fails to close itself.\n clearListenersAndTimers();\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n opts.onVerified(result);\n }\n\n /**\n * @param forceImmediateClose\n * - false (default) — error came from a popup-emitted `entros/error`\n * message; the popup is still alive and rendering its own\n * `PopupFailure` (auto-close) or interactive recovery surface\n * (e.g., baseline-stale). Parent waits the fallback window before\n * force-closing so the user sees the failure category.\n * - true — error came from the parent (timeout, user cancel, or\n * polling detected the popup already closed). No popup-side\n * surface to preserve; force-close immediately.\n */\n function settleError(\n reason: EntrosVerifyErrorReason,\n forceImmediateClose = false,\n ): void {\n if (settled) return;\n settled = true;\n clearListenersAndTimers();\n if (forceImmediateClose) {\n forceClosePopup();\n } else {\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n }\n opts.onError({ reason });\n }\n\n function onMessage(event: MessageEvent): void {\n if (settled) return;\n\n // Origin gate — first and most important check.\n if (event.origin !== expectedPopupOrigin) return;\n\n // Source gate — defense-in-depth against another same-origin tab on\n // entros.io (e.g., the standalone /verify route open in a sibling tab)\n // posting a forged message. Only the popup we opened is authoritative.\n if (event.source !== popup) return;\n\n if (!isEntrosMessage(event.data)) return;\n\n // Replay protection — request_id must match this popup's ID.\n if (event.data.request_id !== requestId) return;\n\n if (!isFreshMessage(event.data)) return;\n\n switch (event.data.type) {\n case \"entros/verified\": {\n if (isVerifiedPayload(event.data.payload)) {\n settleVerified({\n walletPubkey: event.data.payload.wallet_pubkey,\n attestationPda: event.data.payload.attestation_pda,\n txSig: event.data.payload.tx_sig,\n trustScore: event.data.payload.trust_score,\n cluster: event.data.payload.cluster,\n });\n }\n break;\n }\n case \"entros/error\": {\n if (isErrorPayload(event.data.payload)) {\n settleError(event.data.payload.reason);\n }\n break;\n }\n case \"entros/heartbeat\": {\n if (isHeartbeatPayload(event.data.payload) && opts.onProgress) {\n opts.onProgress({ status: event.data.payload.status });\n }\n break;\n }\n }\n }\n\n function onPoll(): void {\n if (settled) return;\n if (popup.closed) {\n // Start the grace period the first time we observe the close.\n if (popupClosedAtMs === null) {\n popupClosedAtMs = Date.now();\n return;\n }\n if (Date.now() - popupClosedAtMs >= POPUP_CLOSED_GRACE_MS) {\n settleError(\"user_canceled\", true);\n }\n } else {\n popupClosedAtMs = null;\n }\n }\n\n function onTimeout(): void {\n settleError(\"timeout\", true);\n }\n\n window.addEventListener(\"message\", onMessage);\n pollTimerId = setInterval(onPoll, POPUP_CLOSED_POLL_MS);\n timeoutTimerId = setTimeout(onTimeout, opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);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AA,EAC9B,GAAG;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AAED,QAAM,YAAY,MAAM,SAAS,aAAa,MAAM,SAAS;AAC7D,QAAM,eACJ,MAAM,SAAS,cAAc,MAAM,wBAAwB;AAE7D,SACE,6CAAC,SAAI,WAAU,2BAA0B,cAAY,MAAM,MACzD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,WAAW,MAAM;AAAA,QACjB,OAAO,MAAM;AAAA,QAEZ,sBACG,oBACC,MAAM,YAAY;AAAA;AAAA,IACzB;AAAA,IACC,gBACC,6CAAC,SAAI,MAAK,SAAQ,WAAU,yBAC1B;AAAA,kDAAC,UAAK,6BAAe;AAAA,MACrB,4CAAC,YAAO,MAAK,UAAS,SAAS,SAAS,WAAW,MAAM,WAAW,6CAEpE;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ var ENTROS_MESSAGE_TYPES = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"entros/error",
|
|
28
28
|
"entros/heartbeat"
|
|
29
29
|
]);
|
|
30
|
-
var CLUSTERS = /* @__PURE__ */ new Set(["devnet"
|
|
30
|
+
var CLUSTERS = /* @__PURE__ */ new Set(["devnet"]);
|
|
31
31
|
function isEntrosMessage(data) {
|
|
32
32
|
if (typeof data !== "object" || data === null) return false;
|
|
33
33
|
const msg = data;
|
|
@@ -56,6 +56,9 @@ function isHeartbeatPayload(payload) {
|
|
|
56
56
|
var VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;
|
|
57
57
|
var ORIGIN_PATTERN = /^https?:\/\/[^/]+$/;
|
|
58
58
|
function buildPopupUrl(opts) {
|
|
59
|
+
if (opts.cluster !== "devnet") {
|
|
60
|
+
throw new Error("Unsupported cluster: @entros/verify currently supports devnet only");
|
|
61
|
+
}
|
|
59
62
|
if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {
|
|
60
63
|
throw new Error(
|
|
61
64
|
`Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got "${opts.integratorKey}")`
|
|
@@ -106,7 +109,7 @@ function generateRequestId() {
|
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
// src/popup-manager.ts
|
|
109
|
-
var DEFAULT_TIMEOUT_MS =
|
|
112
|
+
var DEFAULT_TIMEOUT_MS = 9 * 60 * 1e3;
|
|
110
113
|
var POPUP_CLOSED_POLL_MS = 500;
|
|
111
114
|
var POPUP_CLOSED_GRACE_MS = 1500;
|
|
112
115
|
var POPUP_OWNED_FALLBACK_CLOSE_MS = 3e4;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EntrosVerify.tsx","../src/messaging.ts","../src/url.ts","../src/popup-manager.ts"],"sourcesContent":["/**\n * <EntrosVerify> — drop-in trigger for the Entros verification popup.\n *\n * Renders a button. On click, opens a popup window to entros.io. User\n * completes wallet-connected verification inside the popup; the popup\n * posts the result back via postMessage; this component fires the\n * integrator's onVerified callback.\n *\n * See README and `EntrosVerifyProps` for usage.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, ReactElement, ReactNode } from \"react\";\n\nimport { openVerifyPopup, type PopupHandle } from \"./popup-manager\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_ORIGIN = \"https://entros.io\";\nconst DEFAULT_POPUP_WIDTH = 480;\nconst DEFAULT_POPUP_HEIGHT = 720;\n/**\n * After a verification settles (done or error), state returns to idle so\n * the component is ready for re-use without consumer intervention. Long\n * enough to render the brief \"done\" / \"error\" UX without blocking re-clicks.\n */\nconst SETTLE_RESET_MS = 1500;\n\nexport interface EntrosVerifyProps {\n /** Integrator key registered with Entros. Required. */\n integratorKey: string;\n /** Solana cluster. Defaults to \"devnet\". v1 supports devnet only. */\n cluster?: Cluster;\n /**\n * Optional Trust Score floor. The popup runs the verification regardless\n * and reports the result; if `minTrustScore` is set and the resulting\n * score is below it, the popup posts `entros/error` with reason\n * `validation_failed` instead of `entros/verified`.\n */\n minTrustScore?: number;\n /** Called on successful verification. Required. */\n onVerified: (result: EntrosVerifyResult) => void;\n /** Called on any failure or cancellation. Optional. */\n onError?: (error: EntrosVerifyError) => void;\n /** Called on progress heartbeats from the popup. Optional. */\n onProgress?: (progress: EntrosVerifyProgress) => void;\n /** Popup width in CSS pixels. Defaults to 480. */\n popupWidth?: number;\n /** Popup height in CSS pixels. Defaults to 720. */\n popupHeight?: number;\n /**\n * Maximum time the popup is allowed to be open before this component\n * fires onError({reason: \"timeout\"}). Defaults to 5 minutes.\n */\n timeoutMs?: number;\n /** Custom button content. Defaults to \"Verify with Entros\". */\n children?: ReactNode;\n /** className applied to the trigger button. */\n className?: string;\n /** Inline style applied to the trigger button. */\n style?: CSSProperties;\n /**\n * If true, when the popup is blocked the component renders an inline\n * retry button. Clicking it triggers a fresh window.open from a confirmed\n * user gesture, which most browsers allow. Defaults to true.\n */\n popupBlockedFallback?: boolean;\n /**\n * INTERNAL: Override the entros.io base origin. Intended for end-to-end\n * testing against a localhost popup host. Production consumers should\n * not set this.\n */\n baseOrigin?: string;\n}\n\ntype State =\n | { kind: \"idle\" }\n | { kind: \"opening\" }\n | { kind: \"blocked\" }\n | { kind: \"waiting\" }\n | { kind: \"done\" }\n | { kind: \"error\"; reason: EntrosVerifyErrorReason };\n\nexport function EntrosVerify(props: EntrosVerifyProps): ReactElement {\n const [state, setState] = useState<State>({ kind: \"idle\" });\n const handleRef = useRef<PopupHandle | null>(null);\n const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Refs hold the latest callbacks so trigger stays stable across re-renders\n // even when consumers pass inline arrow functions. Avoids unnecessary\n // re-creation of the click handler on every parent render.\n const onVerifiedRef = useRef(props.onVerified);\n const onErrorRef = useRef(props.onError);\n const onProgressRef = useRef(props.onProgress);\n useEffect(() => {\n onVerifiedRef.current = props.onVerified;\n onErrorRef.current = props.onError;\n onProgressRef.current = props.onProgress;\n });\n\n // Tear down any in-flight popup + reset timer on unmount.\n useEffect(() => {\n return () => {\n if (handleRef.current) {\n handleRef.current.cancel();\n handleRef.current = null;\n }\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n };\n }, []);\n\n const scheduleReset = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n }\n resetTimerRef.current = setTimeout(() => {\n resetTimerRef.current = null;\n setState({ kind: \"idle\" });\n }, SETTLE_RESET_MS);\n }, []);\n\n const trigger = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n setState({ kind: \"opening\" });\n\n const handle = openVerifyPopup({\n baseOrigin: props.baseOrigin ?? DEFAULT_BASE_ORIGIN,\n integratorKey: props.integratorKey,\n cluster: props.cluster ?? \"devnet\",\n minTrustScore: props.minTrustScore,\n popupWidth: props.popupWidth ?? DEFAULT_POPUP_WIDTH,\n popupHeight: props.popupHeight ?? DEFAULT_POPUP_HEIGHT,\n timeoutMs: props.timeoutMs,\n onVerified: (result) => {\n handleRef.current = null;\n setState({ kind: \"done\" });\n onVerifiedRef.current(result);\n scheduleReset();\n },\n onError: (error) => {\n handleRef.current = null;\n setState({ kind: \"error\", reason: error.reason });\n onErrorRef.current?.(error);\n scheduleReset();\n },\n onProgress: (progress) => {\n onProgressRef.current?.(progress);\n },\n });\n\n if (handle === null) {\n setState({ kind: \"blocked\" });\n onErrorRef.current?.({ reason: \"popup_blocked\" });\n return;\n }\n\n handleRef.current = handle;\n setState({ kind: \"waiting\" });\n }, [\n props.baseOrigin,\n props.cluster,\n props.integratorKey,\n props.minTrustScore,\n props.popupHeight,\n props.popupWidth,\n props.timeoutMs,\n scheduleReset,\n ]);\n\n const isWaiting = state.kind === \"opening\" || state.kind === \"waiting\";\n const showFallback =\n state.kind === \"blocked\" && (props.popupBlockedFallback ?? true);\n\n return (\n <div className=\"entros-verify-container\" data-state={state.kind}>\n <button\n type=\"button\"\n onClick={trigger}\n disabled={isWaiting}\n className={props.className}\n style={props.style}\n >\n {isWaiting\n ? \"Verifying…\"\n : (props.children ?? \"Verify with Entros\")}\n </button>\n {showFallback && (\n <div role=\"alert\" className=\"entros-verify-blocked\">\n <span>Popup blocked. </span>\n <button type=\"button\" onClick={trigger} className={props.className}>\n Click here to open verification\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * Type guards and validation for postMessage envelopes received from the\n * Entros verify popup. The component is the trust boundary — every message\n * arriving on `window` is hostile until proven otherwise.\n *\n * Validation order in popup-manager.ts:\n * 1. event.origin matches expected popup origin (caller's responsibility)\n * 2. isEntrosMessage(event.data)\n * 3. event.data.request_id matches the parent's expected ID\n * 4. isFreshMessage(event.data)\n * 5. payload-specific guard for the message type\n *\n * Skipping any step is a security regression.\n */\n\nimport type {\n EntrosMessage,\n ErrorPayload,\n HeartbeatPayload,\n VerifiedPayload,\n} from \"./types\";\n\n/**\n * Maximum allowed clock drift between popup and parent. 90 seconds.\n *\n * The popup completes verification in seconds. A tighter window narrows\n * replay surface without affecting legitimate flows. The 5-minute\n * popup-open timeout is enforced separately by popup-manager.\n */\nconst MAX_TIMESTAMP_DRIFT_MS = 90 * 1000;\n\n/** Allowed error reason values on the wire. */\nconst ERROR_REASONS = new Set<string>([\n \"wallet_rejected\",\n \"validation_failed\",\n \"network_error\",\n \"user_canceled\",\n \"origin_invalid\",\n \"popup_blocked\",\n \"timeout\",\n \"unknown\",\n]);\n\nconst HEARTBEAT_STATUSES = new Set<string>([\n \"wallet_connecting\",\n \"capturing\",\n \"proving\",\n \"submitting\",\n \"attesting\",\n]);\n\nconst ENTROS_MESSAGE_TYPES = new Set<string>([\n \"entros/verified\",\n \"entros/error\",\n \"entros/heartbeat\",\n]);\n\nconst CLUSTERS = new Set<string>([\"devnet\", \"mainnet-beta\"]);\n\nexport function isEntrosMessage(data: unknown): data is EntrosMessage {\n if (typeof data !== \"object\" || data === null) return false;\n const msg = data as Record<string, unknown>;\n return (\n msg.source === \"entros\" &&\n msg.version === 1 &&\n typeof msg.type === \"string\" &&\n ENTROS_MESSAGE_TYPES.has(msg.type) &&\n typeof msg.request_id === \"string\" &&\n msg.request_id.length > 0 &&\n typeof msg.timestamp === \"number\" &&\n Number.isFinite(msg.timestamp) &&\n \"payload\" in msg\n );\n}\n\nexport function isFreshMessage(msg: EntrosMessage, now: number = Date.now()): boolean {\n return Math.abs(now - msg.timestamp) < MAX_TIMESTAMP_DRIFT_MS;\n}\n\nexport function isVerifiedPayload(payload: unknown): payload is VerifiedPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return (\n typeof p.wallet_pubkey === \"string\" &&\n p.wallet_pubkey.length > 0 &&\n typeof p.attestation_pda === \"string\" &&\n p.attestation_pda.length > 0 &&\n typeof p.tx_sig === \"string\" &&\n p.tx_sig.length > 0 &&\n typeof p.trust_score === \"number\" &&\n Number.isFinite(p.trust_score) &&\n p.trust_score >= 0 &&\n typeof p.cluster === \"string\" &&\n CLUSTERS.has(p.cluster)\n );\n}\n\nexport function isErrorPayload(payload: unknown): payload is ErrorPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.reason === \"string\" && ERROR_REASONS.has(p.reason);\n}\n\nexport function isHeartbeatPayload(payload: unknown): payload is HeartbeatPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.status === \"string\" && HEARTBEAT_STATUSES.has(p.status);\n}\n","/**\n * URL builders for the Entros verify popup.\n *\n * The component constructs the popup URL deterministically from the\n * integrator's props. The popup host validates every field server-side;\n * these helpers exist to fail loudly on the integrator's side when a\n * misconfiguration would have wasted a popup roundtrip.\n */\n\nimport type { Cluster } from \"./types\";\n\nconst VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;\nconst ORIGIN_PATTERN = /^https?:\\/\\/[^/]+$/;\n\nexport interface BuildPopupUrlOptions {\n /** entros.io base origin. Override for E2E testing only. */\n baseOrigin: string;\n integratorKey: string;\n /** Caller's window origin — popup posts back to this. */\n parentOrigin: string;\n cluster: Cluster;\n requestId: string;\n minTrustScore?: number;\n}\n\nexport function buildPopupUrl(opts: BuildPopupUrlOptions): string {\n if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {\n throw new Error(\n `Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got \"${opts.integratorKey}\")`,\n );\n }\n if (!ORIGIN_PATTERN.test(opts.parentOrigin)) {\n throw new Error(\n `Invalid parentOrigin: must be a fully-qualified origin (got \"${opts.parentOrigin}\")`,\n );\n }\n if (opts.minTrustScore !== undefined) {\n if (\n !Number.isInteger(opts.minTrustScore) ||\n opts.minTrustScore < 0 ||\n opts.minTrustScore > 10000\n ) {\n throw new Error(\n `Invalid minTrustScore: must be an integer in [0, 10000] (got ${String(opts.minTrustScore)})`,\n );\n }\n }\n\n const url = new URL(\"/embed/verify-popup\", opts.baseOrigin);\n url.searchParams.set(\"integrator\", opts.integratorKey);\n url.searchParams.set(\"parent_origin\", opts.parentOrigin);\n url.searchParams.set(\"cluster\", opts.cluster);\n url.searchParams.set(\"request_id\", opts.requestId);\n if (opts.minTrustScore !== undefined) {\n url.searchParams.set(\"min_trust_score\", String(opts.minTrustScore));\n }\n return url.toString();\n}\n\n/**\n * Generates a cryptographically random request ID for replay protection.\n * Uses crypto.randomUUID when available (modern browsers + Node 19+).\n * Falls back to crypto.getRandomValues (broadly supported back to IE11)\n * formatted as a UUIDv4. Math.random is never used.\n */\nexport function generateRequestId(): string {\n if (typeof crypto === \"undefined\") {\n throw new Error(\n \"crypto is unavailable in this environment; @entros/verify requires a secure context\",\n );\n }\n if (typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues is unavailable; @entros/verify requires a secure context\",\n );\n }\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n // RFC 4122 v4 framing: bits 6-7 of byte 8 are 0b10, bits 12-15 of byte 6\n // are 0b0100. The remaining bits are random.\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return (\n hex.slice(0, 4).join(\"\") +\n \"-\" +\n hex.slice(4, 6).join(\"\") +\n \"-\" +\n hex.slice(6, 8).join(\"\") +\n \"-\" +\n hex.slice(8, 10).join(\"\") +\n \"-\" +\n hex.slice(10, 16).join(\"\")\n );\n}\n","/**\n * Popup-window state machine for `<EntrosVerify>`.\n *\n * Owns: window.open, postMessage listener, popup.closed polling, timeout.\n * Boundary with the React layer: open → returns a handle (or null if blocked).\n * Component is responsible for rendering the trigger button and the\n * popup-blocked fallback UI.\n *\n * Security model — every postMessage from the popup is treated as hostile\n * until proven otherwise. Validation order (skipping any step is a\n * regression):\n * 1. event.origin === expectedPopupOrigin\n * 2. event.source === popup (the window we opened, not a sibling tab)\n * 3. envelope shape matches `EntrosMessage` (version, source, type)\n * 4. event.data.request_id === this popup's request_id (replay defense)\n * 5. timestamp within drift window (90s)\n * 6. payload-specific guard for the message type\n */\n\nimport {\n isEntrosMessage,\n isErrorPayload,\n isFreshMessage,\n isHeartbeatPayload,\n isVerifiedPayload,\n} from \"./messaging\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\nimport { buildPopupUrl, generateRequestId } from \"./url\";\n\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes\nconst POPUP_CLOSED_POLL_MS = 500;\n\n/**\n * Grace period after detecting popup.closed before firing user_canceled.\n * Lets the final `entros/verified` message arrive when the popup posts\n * and self-closes within the same event-loop turn.\n */\nconst POPUP_CLOSED_GRACE_MS = 1500;\n\n/**\n * After a popup-emitted outcome (`entros/verified` or `entros/error`),\n * the popup owns its own close — its success / failure surface renders\n * and either self-closes or waits for explicit user action (e.g., the\n * baseline-stale recovery surface). The parent only force-closes after\n * this defensive fallback in case the popup fails to close itself.\n * Generous enough to allow interactive failure surfaces to be read and\n * acted on; short enough that an abandoned popup eventually dies.\n */\nconst POPUP_OWNED_FALLBACK_CLOSE_MS = 30_000;\n\nexport interface OpenPopupOptions {\n baseOrigin: string;\n integratorKey: string;\n cluster: Cluster;\n minTrustScore?: number;\n popupWidth: number;\n popupHeight: number;\n timeoutMs?: number;\n onVerified: (result: EntrosVerifyResult) => void;\n onError: (error: EntrosVerifyError) => void;\n onProgress?: (progress: EntrosVerifyProgress) => void;\n}\n\nexport interface PopupHandle {\n /**\n * Force-cancel the popup. Closes the window if still open, fires\n * onError({reason: \"user_canceled\"}), and tears down listeners.\n * Idempotent.\n */\n cancel: () => void;\n}\n\nexport function openVerifyPopup(opts: OpenPopupOptions): PopupHandle | null {\n if (typeof window === \"undefined\") {\n throw new Error(\"openVerifyPopup must be called in a browser context\");\n }\n\n const requestId = generateRequestId();\n const parentOrigin = window.location.origin;\n const url = buildPopupUrl({\n baseOrigin: opts.baseOrigin,\n integratorKey: opts.integratorKey,\n parentOrigin,\n cluster: opts.cluster,\n requestId,\n minTrustScore: opts.minTrustScore,\n });\n\n const left = Math.max(\n 0,\n Math.floor((window.screen.availWidth - opts.popupWidth) / 2),\n );\n const top = Math.max(\n 0,\n Math.floor((window.screen.availHeight - opts.popupHeight) / 2),\n );\n const features = [\n `width=${opts.popupWidth}`,\n `height=${opts.popupHeight}`,\n `left=${left}`,\n `top=${top}`,\n \"menubar=no\",\n \"toolbar=no\",\n // location=yes lets the user verify entros.io in the URL bar.\n \"location=yes\",\n \"status=no\",\n \"resizable=yes\",\n \"scrollbars=yes\",\n ].join(\",\");\n\n // Unique window name per popup. A fixed name causes collision when an\n // integrator renders multiple <EntrosVerify> on one page — the second\n // window.open would reuse the existing popup.\n const popupName = `entros_verify_${requestId}`;\n const rawPopup = window.open(url, popupName, features);\n if (!rawPopup || rawPopup.closed) {\n return null;\n }\n // Narrow once so closures below see the non-null type.\n const popup: Window = rawPopup;\n\n const expectedPopupOrigin = new URL(opts.baseOrigin).origin;\n\n let settled = false;\n let pollTimerId: ReturnType<typeof setInterval> | null = null;\n let timeoutTimerId: ReturnType<typeof setTimeout> | null = null;\n let popupClosedAtMs: number | null = null;\n\n function clearListenersAndTimers(): void {\n window.removeEventListener(\"message\", onMessage);\n if (pollTimerId !== null) {\n clearInterval(pollTimerId);\n pollTimerId = null;\n }\n if (timeoutTimerId !== null) {\n clearTimeout(timeoutTimerId);\n timeoutTimerId = null;\n }\n }\n\n function forceClosePopup(): void {\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // Defensive only. We opened this window so we own the close permission;\n // this branch is for esoteric extension or browser-quirk edge cases.\n }\n }\n }\n\n function settleVerified(result: EntrosVerifyResult): void {\n if (settled) return;\n settled = true;\n // The popup owns its own close on the verified path so its\n // recognition surface (`Verified.` checkmark) is visible to the user\n // before the window dies. Parent only force-closes as a defensive\n // fallback in case the popup fails to close itself.\n clearListenersAndTimers();\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n opts.onVerified(result);\n }\n\n /**\n * @param forceImmediateClose\n * - false (default) — error came from a popup-emitted `entros/error`\n * message; the popup is still alive and rendering its own\n * `PopupFailure` (auto-close) or interactive recovery surface\n * (e.g., baseline-stale). Parent waits the fallback window before\n * force-closing so the user sees the failure category.\n * - true — error came from the parent (timeout, user cancel, or\n * polling detected the popup already closed). No popup-side\n * surface to preserve; force-close immediately.\n */\n function settleError(\n reason: EntrosVerifyErrorReason,\n forceImmediateClose = false,\n ): void {\n if (settled) return;\n settled = true;\n clearListenersAndTimers();\n if (forceImmediateClose) {\n forceClosePopup();\n } else {\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n }\n opts.onError({ reason });\n }\n\n function onMessage(event: MessageEvent): void {\n if (settled) return;\n\n // Origin gate — first and most important check.\n if (event.origin !== expectedPopupOrigin) return;\n\n // Source gate — defense-in-depth against another same-origin tab on\n // entros.io (e.g., the standalone /verify route open in a sibling tab)\n // posting a forged message. Only the popup we opened is authoritative.\n if (event.source !== popup) return;\n\n if (!isEntrosMessage(event.data)) return;\n\n // Replay protection — request_id must match this popup's ID.\n if (event.data.request_id !== requestId) return;\n\n if (!isFreshMessage(event.data)) return;\n\n switch (event.data.type) {\n case \"entros/verified\": {\n if (isVerifiedPayload(event.data.payload)) {\n settleVerified({\n walletPubkey: event.data.payload.wallet_pubkey,\n attestationPda: event.data.payload.attestation_pda,\n txSig: event.data.payload.tx_sig,\n trustScore: event.data.payload.trust_score,\n cluster: event.data.payload.cluster,\n });\n }\n break;\n }\n case \"entros/error\": {\n if (isErrorPayload(event.data.payload)) {\n settleError(event.data.payload.reason);\n }\n break;\n }\n case \"entros/heartbeat\": {\n if (isHeartbeatPayload(event.data.payload) && opts.onProgress) {\n opts.onProgress({ status: event.data.payload.status });\n }\n break;\n }\n }\n }\n\n function onPoll(): void {\n if (settled) return;\n if (popup.closed) {\n // Start the grace period the first time we observe the close.\n if (popupClosedAtMs === null) {\n popupClosedAtMs = Date.now();\n return;\n }\n if (Date.now() - popupClosedAtMs >= POPUP_CLOSED_GRACE_MS) {\n settleError(\"user_canceled\", true);\n }\n } else {\n popupClosedAtMs = null;\n }\n }\n\n function onTimeout(): void {\n settleError(\"timeout\", true);\n }\n\n window.addEventListener(\"message\", onMessage);\n pollTimerId = setInterval(onPoll, POPUP_CLOSED_POLL_MS);\n timeoutTimerId = setTimeout(onTimeout, opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n\n return {\n cancel: () => settleError(\"user_canceled\", true),\n };\n}\n"],"mappings":";;;AAWA,SAAS,aAAa,WAAW,QAAQ,gBAAgB;;;ACkBzD,IAAM,yBAAyB,KAAK;AAGpC,IAAM,gBAAgB,oBAAI,IAAY;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,qBAAqB,oBAAI,IAAY;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,uBAAuB,oBAAI,IAAY;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,WAAW,oBAAI,IAAY,CAAC,UAAU,cAAc,CAAC;AAEpD,SAAS,gBAAgB,MAAsC;AACpE,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,MAAM;AACZ,SACE,IAAI,WAAW,YACf,IAAI,YAAY,KAChB,OAAO,IAAI,SAAS,YACpB,qBAAqB,IAAI,IAAI,IAAI,KACjC,OAAO,IAAI,eAAe,YAC1B,IAAI,WAAW,SAAS,KACxB,OAAO,IAAI,cAAc,YACzB,OAAO,SAAS,IAAI,SAAS,KAC7B,aAAa;AAEjB;AAEO,SAAS,eAAe,KAAoB,MAAc,KAAK,IAAI,GAAY;AACpF,SAAO,KAAK,IAAI,MAAM,IAAI,SAAS,IAAI;AACzC;AAEO,SAAS,kBAAkB,SAA8C;AAC9E,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,IAAI;AACV,SACE,OAAO,EAAE,kBAAkB,YAC3B,EAAE,cAAc,SAAS,KACzB,OAAO,EAAE,oBAAoB,YAC7B,EAAE,gBAAgB,SAAS,KAC3B,OAAO,EAAE,WAAW,YACpB,EAAE,OAAO,SAAS,KAClB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ACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AAED,QAAM,YAAY,MAAM,SAAS,aAAa,MAAM,SAAS;AAC7D,QAAM,eACJ,MAAM,SAAS,cAAc,MAAM,wBAAwB;AAE7D,SACE,qBAAC,SAAI,WAAU,2BAA0B,cAAY,MAAM,MACzD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,WAAW,MAAM;AAAA,QACjB,OAAO,MAAM;AAAA,QAEZ,sBACG,oBACC,MAAM,YAAY;AAAA;AAAA,IACzB;AAAA,IACC,gBACC,qBAAC,SAAI,MAAK,SAAQ,WAAU,yBAC1B;AAAA,0BAAC,UAAK,6BAAe;AAAA,MACrB,oBAAC,YAAO,MAAK,UAAS,SAAS,SAAS,WAAW,MAAM,WAAW,6CAEpE;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/EntrosVerify.tsx","../src/messaging.ts","../src/url.ts","../src/popup-manager.ts"],"sourcesContent":["/**\n * <EntrosVerify> — drop-in trigger for the Entros verification popup.\n *\n * Renders a button. On click, opens a popup window to entros.io. User\n * completes wallet-connected verification inside the popup; the popup\n * posts the result back via postMessage; this component fires the\n * integrator's onVerified callback.\n *\n * See README and `EntrosVerifyProps` for usage.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, ReactElement, ReactNode } from \"react\";\n\nimport { openVerifyPopup, type PopupHandle } from \"./popup-manager\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_ORIGIN = \"https://entros.io\";\nconst DEFAULT_POPUP_WIDTH = 480;\nconst DEFAULT_POPUP_HEIGHT = 720;\n/**\n * After a verification settles (done or error), state returns to idle so\n * the component is ready for re-use without consumer intervention. Long\n * enough to render the brief \"done\" / \"error\" UX without blocking re-clicks.\n */\nconst SETTLE_RESET_MS = 1500;\n\nexport interface EntrosVerifyProps {\n /** Integrator key registered with Entros. Required. */\n integratorKey: string;\n /** Solana cluster. Defaults to \"devnet\". v1 supports devnet only. */\n cluster?: Cluster;\n /**\n * Optional Trust Score floor. The popup runs the verification regardless\n * and reports the result; if `minTrustScore` is set and the resulting\n * score is below it, the popup posts `entros/error` with reason\n * `validation_failed` instead of `entros/verified`.\n */\n minTrustScore?: number;\n /** Called on successful verification. Required. */\n onVerified: (result: EntrosVerifyResult) => void;\n /** Called on any failure or cancellation. Optional. */\n onError?: (error: EntrosVerifyError) => void;\n /** Called on progress heartbeats from the popup. Optional. */\n onProgress?: (progress: EntrosVerifyProgress) => void;\n /** Popup width in CSS pixels. Defaults to 480. */\n popupWidth?: number;\n /** Popup height in CSS pixels. Defaults to 720. */\n popupHeight?: number;\n /** See README.md#full-api for timeout behavior and the default. */\n timeoutMs?: number;\n /** Custom button content. Defaults to \"Verify with Entros\". */\n children?: ReactNode;\n /** className applied to the trigger button. */\n className?: string;\n /** Inline style applied to the trigger button. */\n style?: CSSProperties;\n /**\n * If true, when the popup is blocked the component renders an inline\n * retry button. Clicking it triggers a fresh window.open from a confirmed\n * user gesture, which most browsers allow. Defaults to true.\n */\n popupBlockedFallback?: boolean;\n /**\n * INTERNAL: Override the entros.io base origin. Intended for end-to-end\n * testing against a localhost popup host. Production consumers should\n * not set this.\n */\n baseOrigin?: string;\n}\n\ntype State =\n | { kind: \"idle\" }\n | { kind: \"opening\" }\n | { kind: \"blocked\" }\n | { kind: \"waiting\" }\n | { kind: \"done\" }\n | { kind: \"error\"; reason: EntrosVerifyErrorReason };\n\nexport function EntrosVerify(props: EntrosVerifyProps): ReactElement {\n const [state, setState] = useState<State>({ kind: \"idle\" });\n const handleRef = useRef<PopupHandle | null>(null);\n const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Refs hold the latest callbacks so trigger stays stable across re-renders\n // even when consumers pass inline arrow functions. Avoids unnecessary\n // re-creation of the click handler on every parent render.\n const onVerifiedRef = useRef(props.onVerified);\n const onErrorRef = useRef(props.onError);\n const onProgressRef = useRef(props.onProgress);\n useEffect(() => {\n onVerifiedRef.current = props.onVerified;\n onErrorRef.current = props.onError;\n onProgressRef.current = props.onProgress;\n });\n\n // Tear down any in-flight popup + reset timer on unmount.\n useEffect(() => {\n return () => {\n if (handleRef.current) {\n handleRef.current.cancel();\n handleRef.current = null;\n }\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n };\n }, []);\n\n const scheduleReset = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n }\n resetTimerRef.current = setTimeout(() => {\n resetTimerRef.current = null;\n setState({ kind: \"idle\" });\n }, SETTLE_RESET_MS);\n }, []);\n\n const trigger = useCallback(() => {\n if (resetTimerRef.current !== null) {\n clearTimeout(resetTimerRef.current);\n resetTimerRef.current = null;\n }\n setState({ kind: \"opening\" });\n\n const handle = openVerifyPopup({\n baseOrigin: props.baseOrigin ?? DEFAULT_BASE_ORIGIN,\n integratorKey: props.integratorKey,\n cluster: props.cluster ?? \"devnet\",\n minTrustScore: props.minTrustScore,\n popupWidth: props.popupWidth ?? DEFAULT_POPUP_WIDTH,\n popupHeight: props.popupHeight ?? DEFAULT_POPUP_HEIGHT,\n timeoutMs: props.timeoutMs,\n onVerified: (result) => {\n handleRef.current = null;\n setState({ kind: \"done\" });\n onVerifiedRef.current(result);\n scheduleReset();\n },\n onError: (error) => {\n handleRef.current = null;\n setState({ kind: \"error\", reason: error.reason });\n onErrorRef.current?.(error);\n scheduleReset();\n },\n onProgress: (progress) => {\n onProgressRef.current?.(progress);\n },\n });\n\n if (handle === null) {\n setState({ kind: \"blocked\" });\n onErrorRef.current?.({ reason: \"popup_blocked\" });\n return;\n }\n\n handleRef.current = handle;\n setState({ kind: \"waiting\" });\n }, [\n props.baseOrigin,\n props.cluster,\n props.integratorKey,\n props.minTrustScore,\n props.popupHeight,\n props.popupWidth,\n props.timeoutMs,\n scheduleReset,\n ]);\n\n const isWaiting = state.kind === \"opening\" || state.kind === \"waiting\";\n const showFallback =\n state.kind === \"blocked\" && (props.popupBlockedFallback ?? true);\n\n return (\n <div className=\"entros-verify-container\" data-state={state.kind}>\n <button\n type=\"button\"\n onClick={trigger}\n disabled={isWaiting}\n className={props.className}\n style={props.style}\n >\n {isWaiting\n ? \"Verifying…\"\n : (props.children ?? \"Verify with Entros\")}\n </button>\n {showFallback && (\n <div role=\"alert\" className=\"entros-verify-blocked\">\n <span>Popup blocked. </span>\n <button type=\"button\" onClick={trigger} className={props.className}>\n Click here to open verification\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * Type guards and validation for postMessage envelopes received from the\n * Entros verify popup. The component is the trust boundary — every message\n * arriving on `window` is hostile until proven otherwise.\n *\n * Validation order in popup-manager.ts:\n * 1. event.origin matches expected popup origin (caller's responsibility)\n * 2. isEntrosMessage(event.data)\n * 3. event.data.request_id matches the parent's expected ID\n * 4. isFreshMessage(event.data)\n * 5. payload-specific guard for the message type\n *\n * Skipping any step is a security regression.\n */\n\nimport type {\n EntrosMessage,\n ErrorPayload,\n HeartbeatPayload,\n VerifiedPayload,\n} from \"./types\";\n\n/**\n * Maximum allowed clock drift between popup and parent. 90 seconds.\n *\n * The popup timestamps each message when it posts it. This window checks\n * delivery freshness and does not limit total verification duration.\n */\nconst MAX_TIMESTAMP_DRIFT_MS = 90 * 1000;\n\n/** Allowed error reason values on the wire. */\nconst ERROR_REASONS = new Set<string>([\n \"wallet_rejected\",\n \"validation_failed\",\n \"network_error\",\n \"user_canceled\",\n \"origin_invalid\",\n \"popup_blocked\",\n \"timeout\",\n \"unknown\",\n]);\n\nconst HEARTBEAT_STATUSES = new Set<string>([\n \"wallet_connecting\",\n \"capturing\",\n \"proving\",\n \"submitting\",\n \"attesting\",\n]);\n\nconst ENTROS_MESSAGE_TYPES = new Set<string>([\n \"entros/verified\",\n \"entros/error\",\n \"entros/heartbeat\",\n]);\n\nconst CLUSTERS = new Set<string>([\"devnet\"]);\n\nexport function isEntrosMessage(data: unknown): data is EntrosMessage {\n if (typeof data !== \"object\" || data === null) return false;\n const msg = data as Record<string, unknown>;\n return (\n msg.source === \"entros\" &&\n msg.version === 1 &&\n typeof msg.type === \"string\" &&\n ENTROS_MESSAGE_TYPES.has(msg.type) &&\n typeof msg.request_id === \"string\" &&\n msg.request_id.length > 0 &&\n typeof msg.timestamp === \"number\" &&\n Number.isFinite(msg.timestamp) &&\n \"payload\" in msg\n );\n}\n\nexport function isFreshMessage(msg: EntrosMessage, now: number = Date.now()): boolean {\n return Math.abs(now - msg.timestamp) < MAX_TIMESTAMP_DRIFT_MS;\n}\n\nexport function isVerifiedPayload(payload: unknown): payload is VerifiedPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return (\n typeof p.wallet_pubkey === \"string\" &&\n p.wallet_pubkey.length > 0 &&\n typeof p.attestation_pda === \"string\" &&\n p.attestation_pda.length > 0 &&\n typeof p.tx_sig === \"string\" &&\n p.tx_sig.length > 0 &&\n typeof p.trust_score === \"number\" &&\n Number.isFinite(p.trust_score) &&\n p.trust_score >= 0 &&\n typeof p.cluster === \"string\" &&\n CLUSTERS.has(p.cluster)\n );\n}\n\nexport function isErrorPayload(payload: unknown): payload is ErrorPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.reason === \"string\" && ERROR_REASONS.has(p.reason);\n}\n\nexport function isHeartbeatPayload(payload: unknown): payload is HeartbeatPayload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return typeof p.status === \"string\" && HEARTBEAT_STATUSES.has(p.status);\n}\n","/**\n * URL builders for the Entros verify popup.\n *\n * The component constructs the popup URL deterministically from the\n * integrator's props. The popup host validates every field server-side;\n * these helpers exist to fail loudly on the integrator's side when a\n * misconfiguration would have wasted a popup roundtrip.\n */\n\nimport type { Cluster } from \"./types\";\n\nconst VALID_INTEGRATOR_KEY = /^[a-z0-9_-]{1,64}$/;\nconst ORIGIN_PATTERN = /^https?:\\/\\/[^/]+$/;\n\nexport interface BuildPopupUrlOptions {\n /** entros.io base origin. Override for E2E testing only. */\n baseOrigin: string;\n integratorKey: string;\n /** Caller's window origin — popup posts back to this. */\n parentOrigin: string;\n cluster: Cluster;\n requestId: string;\n minTrustScore?: number;\n}\n\nexport function buildPopupUrl(opts: BuildPopupUrlOptions): string {\n if (opts.cluster !== \"devnet\") {\n throw new Error(\"Unsupported cluster: @entros/verify currently supports devnet only\");\n }\n if (!VALID_INTEGRATOR_KEY.test(opts.integratorKey)) {\n throw new Error(\n `Invalid integratorKey: must match /^[a-z0-9_-]{1,64}$/ (got \"${opts.integratorKey}\")`,\n );\n }\n if (!ORIGIN_PATTERN.test(opts.parentOrigin)) {\n throw new Error(\n `Invalid parentOrigin: must be a fully-qualified origin (got \"${opts.parentOrigin}\")`,\n );\n }\n if (opts.minTrustScore !== undefined) {\n if (\n !Number.isInteger(opts.minTrustScore) ||\n opts.minTrustScore < 0 ||\n opts.minTrustScore > 10000\n ) {\n throw new Error(\n `Invalid minTrustScore: must be an integer in [0, 10000] (got ${String(opts.minTrustScore)})`,\n );\n }\n }\n\n const url = new URL(\"/embed/verify-popup\", opts.baseOrigin);\n url.searchParams.set(\"integrator\", opts.integratorKey);\n url.searchParams.set(\"parent_origin\", opts.parentOrigin);\n url.searchParams.set(\"cluster\", opts.cluster);\n url.searchParams.set(\"request_id\", opts.requestId);\n if (opts.minTrustScore !== undefined) {\n url.searchParams.set(\"min_trust_score\", String(opts.minTrustScore));\n }\n return url.toString();\n}\n\n/**\n * Generates a cryptographically random request ID for replay protection.\n * Uses crypto.randomUUID when available (modern browsers + Node 19+).\n * Falls back to crypto.getRandomValues (broadly supported back to IE11)\n * formatted as a UUIDv4. Math.random is never used.\n */\nexport function generateRequestId(): string {\n if (typeof crypto === \"undefined\") {\n throw new Error(\n \"crypto is unavailable in this environment; @entros/verify requires a secure context\",\n );\n }\n if (typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n if (typeof crypto.getRandomValues !== \"function\") {\n throw new Error(\n \"crypto.getRandomValues is unavailable; @entros/verify requires a secure context\",\n );\n }\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n // RFC 4122 v4 framing: bits 6-7 of byte 8 are 0b10, bits 12-15 of byte 6\n // are 0b0100. The remaining bits are random.\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return (\n hex.slice(0, 4).join(\"\") +\n \"-\" +\n hex.slice(4, 6).join(\"\") +\n \"-\" +\n hex.slice(6, 8).join(\"\") +\n \"-\" +\n hex.slice(8, 10).join(\"\") +\n \"-\" +\n hex.slice(10, 16).join(\"\")\n );\n}\n","/**\n * Popup-window state machine for `<EntrosVerify>`.\n *\n * Owns: window.open, postMessage listener, popup.closed polling, timeout.\n * Boundary with the React layer: open → returns a handle (or null if blocked).\n * Component is responsible for rendering the trigger button and the\n * popup-blocked fallback UI.\n *\n * Security model — every postMessage from the popup is treated as hostile\n * until proven otherwise. Validation order (skipping any step is a\n * regression):\n * 1. event.origin === expectedPopupOrigin\n * 2. event.source === popup (the window we opened, not a sibling tab)\n * 3. envelope shape matches `EntrosMessage` (version, source, type)\n * 4. event.data.request_id === this popup's request_id (replay defense)\n * 5. timestamp within drift window (90s)\n * 6. payload-specific guard for the message type\n */\n\nimport {\n isEntrosMessage,\n isErrorPayload,\n isFreshMessage,\n isHeartbeatPayload,\n isVerifiedPayload,\n} from \"./messaging\";\nimport type {\n Cluster,\n EntrosVerifyError,\n EntrosVerifyErrorReason,\n EntrosVerifyProgress,\n EntrosVerifyResult,\n} from \"./types\";\nimport { buildPopupUrl, generateRequestId } from \"./url\";\n\nconst DEFAULT_TIMEOUT_MS = 9 * 60 * 1000;\nconst POPUP_CLOSED_POLL_MS = 500;\n\n/**\n * Grace period after detecting popup.closed before firing user_canceled.\n * Lets the final `entros/verified` message arrive when the popup posts\n * and self-closes within the same event-loop turn.\n */\nconst POPUP_CLOSED_GRACE_MS = 1500;\n\n/**\n * After a popup-emitted outcome (`entros/verified` or `entros/error`),\n * the popup owns its own close — its success / failure surface renders\n * and either self-closes or waits for explicit user action (e.g., the\n * baseline-stale recovery surface). The parent only force-closes after\n * this defensive fallback in case the popup fails to close itself.\n * Generous enough to allow interactive failure surfaces to be read and\n * acted on; short enough that an abandoned popup eventually dies.\n */\nconst POPUP_OWNED_FALLBACK_CLOSE_MS = 30_000;\n\nexport interface OpenPopupOptions {\n baseOrigin: string;\n integratorKey: string;\n cluster: Cluster;\n minTrustScore?: number;\n popupWidth: number;\n popupHeight: number;\n timeoutMs?: number;\n onVerified: (result: EntrosVerifyResult) => void;\n onError: (error: EntrosVerifyError) => void;\n onProgress?: (progress: EntrosVerifyProgress) => void;\n}\n\nexport interface PopupHandle {\n /**\n * Force-cancel the popup. Closes the window if still open, fires\n * onError({reason: \"user_canceled\"}), and tears down listeners.\n * Idempotent.\n */\n cancel: () => void;\n}\n\nexport function openVerifyPopup(opts: OpenPopupOptions): PopupHandle | null {\n if (typeof window === \"undefined\") {\n throw new Error(\"openVerifyPopup must be called in a browser context\");\n }\n\n const requestId = generateRequestId();\n const parentOrigin = window.location.origin;\n const url = buildPopupUrl({\n baseOrigin: opts.baseOrigin,\n integratorKey: opts.integratorKey,\n parentOrigin,\n cluster: opts.cluster,\n requestId,\n minTrustScore: opts.minTrustScore,\n });\n\n const left = Math.max(\n 0,\n Math.floor((window.screen.availWidth - opts.popupWidth) / 2),\n );\n const top = Math.max(\n 0,\n Math.floor((window.screen.availHeight - opts.popupHeight) / 2),\n );\n const features = [\n `width=${opts.popupWidth}`,\n `height=${opts.popupHeight}`,\n `left=${left}`,\n `top=${top}`,\n \"menubar=no\",\n \"toolbar=no\",\n // location=yes lets the user verify entros.io in the URL bar.\n \"location=yes\",\n \"status=no\",\n \"resizable=yes\",\n \"scrollbars=yes\",\n ].join(\",\");\n\n // Unique window name per popup. A fixed name causes collision when an\n // integrator renders multiple <EntrosVerify> on one page — the second\n // window.open would reuse the existing popup.\n const popupName = `entros_verify_${requestId}`;\n const rawPopup = window.open(url, popupName, features);\n if (!rawPopup || rawPopup.closed) {\n return null;\n }\n // Narrow once so closures below see the non-null type.\n const popup: Window = rawPopup;\n\n const expectedPopupOrigin = new URL(opts.baseOrigin).origin;\n\n let settled = false;\n let pollTimerId: ReturnType<typeof setInterval> | null = null;\n let timeoutTimerId: ReturnType<typeof setTimeout> | null = null;\n let popupClosedAtMs: number | null = null;\n\n function clearListenersAndTimers(): void {\n window.removeEventListener(\"message\", onMessage);\n if (pollTimerId !== null) {\n clearInterval(pollTimerId);\n pollTimerId = null;\n }\n if (timeoutTimerId !== null) {\n clearTimeout(timeoutTimerId);\n timeoutTimerId = null;\n }\n }\n\n function forceClosePopup(): void {\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // Defensive only. We opened this window so we own the close permission;\n // this branch is for esoteric extension or browser-quirk edge cases.\n }\n }\n }\n\n function settleVerified(result: EntrosVerifyResult): void {\n if (settled) return;\n settled = true;\n // The popup owns its own close on the verified path so its\n // recognition surface (`Verified.` checkmark) is visible to the user\n // before the window dies. Parent only force-closes as a defensive\n // fallback in case the popup fails to close itself.\n clearListenersAndTimers();\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n opts.onVerified(result);\n }\n\n /**\n * @param forceImmediateClose\n * - false (default) — error came from a popup-emitted `entros/error`\n * message; the popup is still alive and rendering its own\n * `PopupFailure` (auto-close) or interactive recovery surface\n * (e.g., baseline-stale). Parent waits the fallback window before\n * force-closing so the user sees the failure category.\n * - true — error came from the parent (timeout, user cancel, or\n * polling detected the popup already closed). No popup-side\n * surface to preserve; force-close immediately.\n */\n function settleError(\n reason: EntrosVerifyErrorReason,\n forceImmediateClose = false,\n ): void {\n if (settled) return;\n settled = true;\n clearListenersAndTimers();\n if (forceImmediateClose) {\n forceClosePopup();\n } else {\n setTimeout(forceClosePopup, POPUP_OWNED_FALLBACK_CLOSE_MS);\n }\n opts.onError({ reason });\n }\n\n function onMessage(event: MessageEvent): void {\n if (settled) return;\n\n // Origin gate — first and most important check.\n if (event.origin !== expectedPopupOrigin) return;\n\n // Source gate — defense-in-depth against another same-origin tab on\n // entros.io (e.g., the standalone /verify route open in a sibling tab)\n // posting a forged message. Only the popup we opened is authoritative.\n if (event.source !== popup) return;\n\n if (!isEntrosMessage(event.data)) return;\n\n // Replay protection — request_id must match this popup's ID.\n if (event.data.request_id !== requestId) return;\n\n if (!isFreshMessage(event.data)) return;\n\n switch (event.data.type) {\n case \"entros/verified\": {\n if (isVerifiedPayload(event.data.payload)) {\n settleVerified({\n walletPubkey: event.data.payload.wallet_pubkey,\n attestationPda: event.data.payload.attestation_pda,\n txSig: event.data.payload.tx_sig,\n trustScore: event.data.payload.trust_score,\n cluster: event.data.payload.cluster,\n });\n }\n break;\n }\n case \"entros/error\": {\n if (isErrorPayload(event.data.payload)) {\n settleError(event.data.payload.reason);\n }\n break;\n }\n case \"entros/heartbeat\": {\n if (isHeartbeatPayload(event.data.payload) && opts.onProgress) {\n opts.onProgress({ status: event.data.payload.status });\n }\n break;\n }\n }\n }\n\n function onPoll(): void {\n if (settled) return;\n if (popup.closed) {\n // Start the grace period the first time we observe the close.\n if (popupClosedAtMs === null) {\n popupClosedAtMs = Date.now();\n return;\n }\n if (Date.now() - popupClosedAtMs >= POPUP_CLOSED_GRACE_MS) {\n settleError(\"user_canceled\", true);\n }\n } else {\n popupClosedAtMs = null;\n }\n }\n\n function onTimeout(): void {\n settleError(\"timeout\", true);\n }\n\n window.addEventListener(\"message\", onMessage);\n pollTimerId = setInterval(onPoll, POPUP_CLOSED_POLL_MS);\n timeoutTimerId = setTimeout(onTimeout, opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n\n return {\n cancel: () => settleError(\"user_canceled\", true),\n };\n}\n"],"mappings":";;;AAWA,SAAS,aAAa,WAAW,QAAQ,gBAAgB;;;ACiBzD,IAAM,yBAAyB,KAAK;AAGpC,IAAM,gBAAgB,oBAAI,IAAY;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,qBAAqB,oBAAI,IAAY;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,uBAAuB,oBAAI,IAAY;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,WAAW,oBAAI,IAAY,CAAC,QAAQ,CAAC;AAEpC,SAAS,gBAAgB,MAAsC;AACpE,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,MAAM;AACZ,SACE,IAAI,WAAW,YACf,IAAI,YAAY,KAChB,OAAO,IAAI,SAAS,YACpB,qBAAqB,IAAI,IAAI,IAAI,KACjC,OAAO,IAAI,eAAe,YAC1B,IAAI,WAAW,SAAS,KACxB,OAAO,IAAI,cAAc,YACzB,OAAO,SAAS,IAAI,SAAS,KAC7B,aAAa;AAEjB;AAEO,SAAS,eAAe,KAAoB,MAAc,KAAK,IAAI,GAAY;AACpF,SAAO,KAAK,IAAI,MAAM,IAAI,SAAS,IAAI;AACzC;AAEO,SAAS,kBAAkB,SAA8C;AAC9E,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,IAAI;AACV,SACE,OAAO,EAAE,kBAAkB,YAC3B,EAAE,cAAc,SAAS,KACzB,OAAO,EAAE,oBAAoB,YAC7B,EAAE,gBAAgB,SAAS,KAC3B,OAAO,EA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AAChD;AAAA,IACF;AAEA,cAAU,UAAU;AACpB,aAAS,EAAE,MAAM,UAAU,CAAC;AAAA,EAC9B,GAAG;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AAED,QAAM,YAAY,MAAM,SAAS,aAAa,MAAM,SAAS;AAC7D,QAAM,eACJ,MAAM,SAAS,cAAc,MAAM,wBAAwB;AAE7D,SACE,qBAAC,SAAI,WAAU,2BAA0B,cAAY,MAAM,MACzD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,WAAW,MAAM;AAAA,QACjB,OAAO,MAAM;AAAA,QAEZ,sBACG,oBACC,MAAM,YAAY;AAAA;AAAA,IACzB;AAAA,IACC,gBACC,qBAAC,SAAI,MAAK,SAAQ,WAAU,yBAC1B;AAAA,0BAAC,UAAK,6BAAe;AAAA,MACrB,oBAAC,YAAO,MAAK,UAAS,SAAS,SAAS,WAAW,MAAM,WAAW,6CAEpE;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entros/verify",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "React popup component for wallet-connected Entros verification on Solana devnet",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://entros.io",
|
|
7
7
|
"repository": {
|