@globiguard/react 1.0.0 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,128 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and
27
+ configuration files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object
31
+ code, generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work.
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original
45
+ version of the Work and any modifications or additions to that Work or
46
+ Derivative Works thereof, that is intentionally submitted to Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or Legal
48
+ Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
51
+ of whom a Contribution has been received by Licensor and subsequently
52
+ incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License.
55
+
56
+ Subject to the terms and conditions of this License, each Contributor hereby
57
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
58
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
59
+ publicly display, publicly perform, sublicense, and distribute the Work and
60
+ such Derivative Works in Source or Object form.
61
+
62
+ 3. Grant of Patent License.
63
+
64
+ Subject to the terms and conditions of this License, each Contributor hereby
65
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
66
+ irrevocable patent license to make, have made, use, offer to sell, sell,
67
+ import, and otherwise transfer the Work.
68
+
69
+ 4. Redistribution.
70
+
71
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
72
+ in any medium, with or without modifications, and in Source or Object form,
73
+ provided that You meet the following conditions:
74
+
75
+ (a) You must give any other recipients of the Work or Derivative Works a copy
76
+ of this License; and
77
+
78
+ (b) You must cause any modified files to carry prominent notices stating that
79
+ You changed the files; and
80
+
81
+ (c) You must retain, in the Source form of any Derivative Works that You
82
+ distribute, all copyright, patent, trademark, and attribution notices from the
83
+ Source form of the Work, excluding those notices that do not pertain to any
84
+ part of the Derivative Works; and
85
+
86
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
87
+ any Derivative Works that You distribute must include a readable copy of the
88
+ attribution notices contained within such NOTICE file, excluding those notices
89
+ that do not pertain to any part of the Derivative Works, in at least one of the
90
+ following places: within a NOTICE text file distributed as part of the
91
+ Derivative Works; within the Source form or documentation, if provided along
92
+ with the Derivative Works; or within a display generated by the Derivative
93
+ Works, if and wherever such third-party notices normally appear.
94
+
95
+ 5. Submission of Contributions.
96
+
97
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
98
+ for inclusion in the Work by You to the Licensor shall be under the terms and
99
+ conditions of this License, without any additional terms or conditions.
100
+
101
+ 6. Trademarks.
102
+
103
+ This License does not grant permission to use the trade names, trademarks,
104
+ service marks, or product names of the Licensor, except as required for
105
+ reasonable and customary use in describing the origin of the Work.
106
+
107
+ 7. Disclaimer of Warranty.
108
+
109
+ Unless required by applicable law or agreed to in writing, Licensor provides
110
+ the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
111
+ either express or implied, including, without limitation, any warranties or
112
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
113
+ PARTICULAR PURPOSE.
114
+
115
+ 8. Limitation of Liability.
116
+
117
+ In no event and under no legal theory, whether in tort (including negligence),
118
+ contract, or otherwise, unless required by applicable law, shall any
119
+ Contributor be liable to You for damages, including any direct, indirect,
120
+ special, incidental, or consequential damages of any character arising as a
121
+ result of this License or out of the use or inability to use the Work.
122
+
123
+ 9. Accepting Warranty or Additional Liability.
124
+
125
+ While redistributing the Work or Derivative Works thereof, You may choose to
126
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
127
+ other liability obligations and/or rights consistent with this License.
128
+
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @globiguard/react
2
+
3
+ Browser-safe React bindings for GlobiGuard governance state.
4
+
5
+ ## Boundary
6
+
7
+ React never owns approval, resume, bypass, webhook-signing, or secret-key
8
+ authority. Components display decisions, approval status, evidence summaries, and
9
+ incident replay metadata returned by the browser-safe SDK or by caller-owned
10
+ server endpoints.
11
+
12
+ ## Components
13
+
14
+ - `PolicyDecisionBadge`
15
+ - `ApprovalStatusCard`
16
+ - `EvidencePackageSummary`
17
+ - `IncidentReplayTimeline`
18
+ - `GovernedActionBoundary`
19
+ - `QueuedActionNotice`
20
+ - `GovernedActionSubmitButton`
21
+
22
+ `GovernedActionBoundary` fails closed on missing decisions, loading failures,
23
+ stale state, unresolved queue state, and blocked decisions. It renders protected
24
+ children only for `ALLOW`.
25
+
26
+ ## Hooks
27
+
28
+ - `useActionDecision`
29
+ - `useApprovalStatus`
30
+ - `useEvidenceRefs`
31
+ - `useEvidencePackage`
32
+ - `useIncidentReplay`
33
+ - `useTrustWebhookVerificationResult`
34
+
35
+ Webhook verification results should be produced by server code using
36
+ `@globiguard/sdk/server`; React can display the result but must not verify
37
+ signing secrets itself.
38
+
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=actions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/actions.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { renderToStaticMarkup } from "react-dom/server";
4
+ import { EvidencePackageSummary, GovernedActionBoundary, IncidentReplayTimeline } from "../actions.js";
5
+ describe("@globiguard/react governance components", () => {
6
+ it("fails closed instead of rendering protected children when decision state is missing", () => {
7
+ const html = renderToStaticMarkup(_jsx(GovernedActionBoundary, { decision: null, children: _jsx("button", { children: "Send customer email" }) }));
8
+ expect(html).toContain("data-globiguard-fail-closed");
9
+ expect(html).not.toContain("Send customer email");
10
+ });
11
+ it("renders protected children only for an ALLOW decision", () => {
12
+ const html = renderToStaticMarkup(_jsx(GovernedActionBoundary, { decision: {
13
+ contractVersion: "2026-04-action-beta",
14
+ authorizationId: "authz_123",
15
+ decision: "ALLOW",
16
+ approvalState: "NOT_REQUIRED",
17
+ evidenceRefs: []
18
+ }, children: _jsx("button", { children: "Send customer email" }) }));
19
+ expect(html).toContain("Send customer email");
20
+ expect(html).not.toContain("data-globiguard-fail-closed");
21
+ });
22
+ it("shows queued state without rendering protected children", () => {
23
+ const html = renderToStaticMarkup(_jsx(GovernedActionBoundary, { decision: {
24
+ contractVersion: "2026-04-action-beta",
25
+ authorizationId: "authz_123",
26
+ decision: "QUEUE",
27
+ approvalState: "PENDING",
28
+ queueEntryId: "queue_123",
29
+ evidenceRefs: [],
30
+ reason: "Human review required"
31
+ }, children: _jsx("button", { children: "Send customer email" }) }));
32
+ expect(html).toContain("data-globiguard-queued-action");
33
+ expect(html).toContain("queue_123");
34
+ expect(html).not.toContain("Send customer email");
35
+ });
36
+ it("renders metadata-safe evidence package summaries", () => {
37
+ const html = renderToStaticMarkup(_jsx(EvidencePackageSummary, { summary: {
38
+ boundary: {
39
+ authorityLevel: "browser_read",
40
+ browserSafe: true,
41
+ serverSecretRequired: false,
42
+ rawPayloadAllowed: false
43
+ },
44
+ schemaVersion: "2026-05-evidence-summary-beta",
45
+ evidencePackageId: "evpkg_123",
46
+ status: "ready",
47
+ scope: {},
48
+ decisionCounts: { QUEUE: 1 },
49
+ redaction: {
50
+ mode: "metadata_only",
51
+ rawPayloadIncluded: false
52
+ },
53
+ sourceRefs: [{ kind: "audit_event", id: "audit_123" }],
54
+ disclaimers: []
55
+ } }));
56
+ expect(html).toContain("data-globiguard-evidence-package=\"evpkg_123\"");
57
+ expect(html).toContain("raw payload included");
58
+ expect(html).toContain("false");
59
+ });
60
+ it("renders incident replay gaps honestly", () => {
61
+ const html = renderToStaticMarkup(_jsx(IncidentReplayTimeline, { replay: {
62
+ boundary: {
63
+ authorityLevel: "browser_read",
64
+ browserSafe: true,
65
+ serverSecretRequired: false,
66
+ rawPayloadAllowed: false
67
+ },
68
+ schemaVersion: "2026-05-incident-replay-beta",
69
+ incidentReplayId: "replay_123",
70
+ generatedAt: "2026-05-17T20:00:00.000Z",
71
+ lookup: { workflowRunId: "run_123" },
72
+ complete: false,
73
+ correlationIds: [],
74
+ timeline: [],
75
+ gaps: [
76
+ {
77
+ id: "gap_123",
78
+ status: "missing",
79
+ expectedKind: "action_resumed",
80
+ reason: "No resume event observed."
81
+ }
82
+ ],
83
+ disclaimers: []
84
+ } }));
85
+ expect(html).toContain("Replay incomplete");
86
+ expect(html).toContain("No resume event observed.");
87
+ });
88
+ });
89
+ //# sourceMappingURL=actions.test.js.map
@@ -0,0 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QAC/C,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,IAAI,GAAG,oBAAoB,CAC/B,KAAC,sBAAsB,IACrB,MAAM,EAAE;gBACN,QAAQ,EAAE;oBACR,cAAc,EAAE,cAAc;oBAC9B,WAAW,EAAE,IAAI;oBACjB,oBAAoB,EAAE,KAAK;oBAC3B,iBAAiB,EAAE,KAAK;iBACzB;gBACD,aAAa,EAAE,8BAA8B;gBAC7C,gBAAgB,EAAE,YAAY;gBAC9B,WAAW,EAAE,0BAA0B;gBACvC,MAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;gBACpC,QAAQ,EAAE,KAAK;gBACf,cAAc,EAAE,EAAE;gBAClB,QAAQ,EAAE,EAAE;gBACZ,IAAI,EAAE;oBACJ;wBACE,EAAE,EAAE,SAAS;wBACb,MAAM,EAAE,SAAS;wBACjB,YAAY,EAAE,gBAAgB;wBAC9B,MAAM,EAAE,2BAA2B;qBACpC;iBACF;gBACD,WAAW,EAAE,EAAE;aAChB,GACD,CACH,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { type ReactNode } from "react";
2
+ import type { GlobiguardActionAuthorizationRequest, GlobiguardActionAuthorizationResponse, GlobiguardApproval, GlobiguardApprovalState, GlobiguardDecision, GlobiguardEvidencePackageSummary as GlobiguardEvidencePackageSummaryContract, GlobiguardEvidenceListRequest, GlobiguardEvidenceRef, GlobiguardIncidentReplay, GlobiguardIncidentReplayLookupRequest, GlobiguardTrustWebhookVerificationResult } from "@globiguard/contracts";
3
+ export interface GlobiguardAsyncState<TValue> {
4
+ data: TValue | null;
5
+ error: Error | null;
6
+ loading: boolean;
7
+ refresh(): Promise<TValue | null>;
8
+ }
9
+ export interface GlobiguardHookOptions {
10
+ enabled?: boolean;
11
+ }
12
+ export declare function useApprovalStatus(approvalId: string | null | undefined, options?: GlobiguardHookOptions): GlobiguardAsyncState<GlobiguardApproval>;
13
+ export declare function useEvidenceRefs(request?: GlobiguardEvidenceListRequest, options?: GlobiguardHookOptions): GlobiguardAsyncState<GlobiguardEvidenceRef[]>;
14
+ export declare function useActionDecision(authorizationId: string | null | undefined, options?: GlobiguardHookOptions): GlobiguardAsyncState<GlobiguardActionAuthorizationResponse>;
15
+ export declare function useEvidencePackage(evidencePackageId: string | null | undefined, options?: GlobiguardHookOptions): GlobiguardAsyncState<GlobiguardEvidencePackageSummaryContract>;
16
+ export declare function useIncidentReplay(request: GlobiguardIncidentReplayLookupRequest | null | undefined, options?: GlobiguardHookOptions): GlobiguardAsyncState<GlobiguardIncidentReplay>;
17
+ export declare function useTrustWebhookVerificationResult(result: GlobiguardTrustWebhookVerificationResult | null | undefined): {
18
+ result: GlobiguardTrustWebhookVerificationResult | null;
19
+ verified: boolean;
20
+ failed: boolean;
21
+ duplicateDelivery: boolean;
22
+ message: string;
23
+ };
24
+ export type GlobiguardGovernedActionSubmitter = (request: GlobiguardActionAuthorizationRequest) => Promise<GlobiguardActionAuthorizationResponse>;
25
+ export interface GlobiguardGovernedActionSubmissionState {
26
+ decision: GlobiguardActionAuthorizationResponse | null;
27
+ error: Error | null;
28
+ loading: boolean;
29
+ submit(request: GlobiguardActionAuthorizationRequest): Promise<GlobiguardActionAuthorizationResponse | null>;
30
+ }
31
+ export declare function useGovernedActionSubmission(submitAction: GlobiguardGovernedActionSubmitter): GlobiguardGovernedActionSubmissionState;
32
+ export interface PolicyDecisionBadgeProps {
33
+ decision: GlobiguardDecision;
34
+ labels?: Partial<Record<GlobiguardDecision, ReactNode>>;
35
+ }
36
+ export declare function PolicyDecisionBadge({ decision, labels }: PolicyDecisionBadgeProps): import("react/jsx-runtime").JSX.Element;
37
+ export interface ApprovalStatusBadgeProps {
38
+ state: GlobiguardApprovalState;
39
+ labels?: Partial<Record<GlobiguardApprovalState, ReactNode>>;
40
+ }
41
+ export declare function ApprovalStatusBadge({ state, labels }: ApprovalStatusBadgeProps): import("react/jsx-runtime").JSX.Element;
42
+ export interface ApprovalStatusCardProps {
43
+ approval: GlobiguardApproval | null;
44
+ error?: Error | null;
45
+ loading?: boolean;
46
+ fallback?: ReactNode;
47
+ }
48
+ export declare function ApprovalStatusCard({ approval, error, loading, fallback }: ApprovalStatusCardProps): import("react/jsx-runtime").JSX.Element;
49
+ export interface ApprovalStatusProps {
50
+ approvalId: string;
51
+ fallback?: ReactNode;
52
+ }
53
+ export declare function ApprovalStatus({ approvalId, fallback }: ApprovalStatusProps): import("react/jsx-runtime").JSX.Element | null;
54
+ export declare function getEvidenceHref(evidenceRef: GlobiguardEvidenceRef): string;
55
+ export interface EvidenceLinksProps {
56
+ evidenceRefs: GlobiguardEvidenceRef[];
57
+ renderLabel?: (evidenceRef: GlobiguardEvidenceRef) => ReactNode;
58
+ }
59
+ export declare function EvidenceLinks({ evidenceRefs, renderLabel }: EvidenceLinksProps): import("react/jsx-runtime").JSX.Element | null;
60
+ export interface EvidencePackageSummaryProps {
61
+ summary: GlobiguardEvidencePackageSummaryContract | null;
62
+ error?: Error | null;
63
+ loading?: boolean;
64
+ }
65
+ export declare function EvidencePackageSummary({ summary, error, loading }: EvidencePackageSummaryProps): import("react/jsx-runtime").JSX.Element;
66
+ export interface IncidentReplayTimelineProps {
67
+ replay: GlobiguardIncidentReplay | null;
68
+ error?: Error | null;
69
+ loading?: boolean;
70
+ }
71
+ export declare function IncidentReplayTimeline({ replay, error, loading }: IncidentReplayTimelineProps): import("react/jsx-runtime").JSX.Element;
72
+ export interface QueuedActionNoticeProps {
73
+ queueEntryId?: string | null;
74
+ reason?: ReactNode;
75
+ }
76
+ export declare function QueuedActionNotice({ queueEntryId, reason }: QueuedActionNoticeProps): import("react/jsx-runtime").JSX.Element;
77
+ export interface GovernedActionBoundaryProps {
78
+ decision: GlobiguardActionAuthorizationResponse | null | undefined;
79
+ loading?: boolean;
80
+ error?: Error | null;
81
+ stale?: boolean;
82
+ children: ReactNode;
83
+ blockedFallback?: ReactNode;
84
+ queuedFallback?: ReactNode;
85
+ modifiedFallback?: ReactNode;
86
+ degradedFallback?: ReactNode;
87
+ }
88
+ export declare function GovernedActionBoundary({ decision, loading, error, stale, children, blockedFallback, queuedFallback, modifiedFallback, degradedFallback }: GovernedActionBoundaryProps): import("react/jsx-runtime").JSX.Element;
89
+ export interface GovernedActionSubmitButtonProps {
90
+ request: GlobiguardActionAuthorizationRequest;
91
+ submitAction: GlobiguardGovernedActionSubmitter;
92
+ children?: ReactNode;
93
+ disabled?: boolean;
94
+ onDecision?: (decision: GlobiguardActionAuthorizationResponse) => void;
95
+ }
96
+ export declare function GovernedActionSubmitButton({ request, submitAction, children, disabled, onDecision }: GovernedActionSubmitButtonProps): import("react/jsx-runtime").JSX.Element;
97
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,oCAAoC,EACpC,qCAAqC,EACrC,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,gCAAgC,IAAI,wCAAwC,EAC5E,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,qCAAqC,EACrC,wCAAwC,EACzC,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,oBAAoB,CAAC,MAAM;IAC1C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,I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ACR,OAAe,EACf,KAAY,EACZ,KAAa,EACb,QAAQ,EACR,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,gBAAyG,EAC1G,EAAE,2BAA2B,2CAuC7B;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,oCAAoC,CAAC;IAC9C,YAAY,EAAE,iCAAiC,CAAC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,qCAAqC,KAAK,IAAI,CAAC;CACxE;AAED,wBAAgB,0BAA0B,CAAC,EACzC,OAAO,EACP,YAAY,EACZ,QAAkC,EAClC,QAAgB,EAChB,UAAU,EACX,EAAE,+BAA+B,2CAkBjC"}
@@ -0,0 +1,341 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { useGlobiguardClient } from "./provider.js";
4
+ export function useApprovalStatus(approvalId, options = {}) {
5
+ const client = useGlobiguardClient();
6
+ const enabled = options.enabled ?? true;
7
+ const [approval, setApproval] = useState(null);
8
+ const [error, setError] = useState(null);
9
+ const [loading, setLoading] = useState(false);
10
+ const refresh = useCallback(async () => {
11
+ if (!enabled || !approvalId) {
12
+ setApproval(null);
13
+ return null;
14
+ }
15
+ setLoading(true);
16
+ setError(null);
17
+ try {
18
+ const nextApproval = await client.actions.getApproval(approvalId);
19
+ setApproval(nextApproval);
20
+ return nextApproval;
21
+ }
22
+ catch (caught) {
23
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
24
+ setError(nextError);
25
+ return null;
26
+ }
27
+ finally {
28
+ setLoading(false);
29
+ }
30
+ }, [approvalId, client, enabled]);
31
+ useEffect(() => {
32
+ void refresh();
33
+ }, [refresh]);
34
+ return {
35
+ data: approval,
36
+ error,
37
+ loading,
38
+ refresh
39
+ };
40
+ }
41
+ export function useEvidenceRefs(request, options = {}) {
42
+ const client = useGlobiguardClient();
43
+ const enabled = options.enabled ?? true;
44
+ const [evidenceRefs, setEvidenceRefs] = useState(null);
45
+ const [error, setError] = useState(null);
46
+ const [loading, setLoading] = useState(false);
47
+ const stableRequest = useMemo(() => request, [request?.approvalId, request?.authorizationId, request?.workflowRunId]);
48
+ const refresh = useCallback(async () => {
49
+ if (!enabled) {
50
+ setEvidenceRefs(null);
51
+ return null;
52
+ }
53
+ setLoading(true);
54
+ setError(null);
55
+ try {
56
+ const nextEvidenceRefs = await client.actions.listEvidence(stableRequest);
57
+ setEvidenceRefs(nextEvidenceRefs);
58
+ return nextEvidenceRefs;
59
+ }
60
+ catch (caught) {
61
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
62
+ setError(nextError);
63
+ return null;
64
+ }
65
+ finally {
66
+ setLoading(false);
67
+ }
68
+ }, [client, enabled, stableRequest]);
69
+ useEffect(() => {
70
+ void refresh();
71
+ }, [refresh]);
72
+ return {
73
+ data: evidenceRefs,
74
+ error,
75
+ loading,
76
+ refresh
77
+ };
78
+ }
79
+ export function useActionDecision(authorizationId, options = {}) {
80
+ const client = useGlobiguardClient();
81
+ const enabled = options.enabled ?? true;
82
+ const [decision, setDecision] = useState(null);
83
+ const [error, setError] = useState(null);
84
+ const [loading, setLoading] = useState(false);
85
+ const refresh = useCallback(async () => {
86
+ if (!enabled || !authorizationId) {
87
+ setDecision(null);
88
+ return null;
89
+ }
90
+ setLoading(true);
91
+ setError(null);
92
+ try {
93
+ const nextDecision = await client.actions.getAuthorization(authorizationId);
94
+ setDecision(nextDecision);
95
+ return nextDecision;
96
+ }
97
+ catch (caught) {
98
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
99
+ setError(nextError);
100
+ return null;
101
+ }
102
+ finally {
103
+ setLoading(false);
104
+ }
105
+ }, [authorizationId, client, enabled]);
106
+ useEffect(() => {
107
+ void refresh();
108
+ }, [refresh]);
109
+ return {
110
+ data: decision,
111
+ error,
112
+ loading,
113
+ refresh
114
+ };
115
+ }
116
+ export function useEvidencePackage(evidencePackageId, options = {}) {
117
+ const client = useGlobiguardClient();
118
+ const enabled = options.enabled ?? true;
119
+ const [summary, setSummary] = useState(null);
120
+ const [error, setError] = useState(null);
121
+ const [loading, setLoading] = useState(false);
122
+ const refresh = useCallback(async () => {
123
+ if (!enabled || !evidencePackageId) {
124
+ setSummary(null);
125
+ return null;
126
+ }
127
+ setLoading(true);
128
+ setError(null);
129
+ try {
130
+ const nextSummary = await client.audit.getEvidencePackageSummary(evidencePackageId);
131
+ setSummary(nextSummary);
132
+ return nextSummary;
133
+ }
134
+ catch (caught) {
135
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
136
+ setError(nextError);
137
+ return null;
138
+ }
139
+ finally {
140
+ setLoading(false);
141
+ }
142
+ }, [client, enabled, evidencePackageId]);
143
+ useEffect(() => {
144
+ void refresh();
145
+ }, [refresh]);
146
+ return {
147
+ data: summary,
148
+ error,
149
+ loading,
150
+ refresh
151
+ };
152
+ }
153
+ export function useIncidentReplay(request, options = {}) {
154
+ const client = useGlobiguardClient();
155
+ const enabled = options.enabled ?? true;
156
+ const [replay, setReplay] = useState(null);
157
+ const [error, setError] = useState(null);
158
+ const [loading, setLoading] = useState(false);
159
+ const stableRequest = useMemo(() => request, [
160
+ request?.auditEventId,
161
+ request?.authorizationId,
162
+ request?.correlationId,
163
+ request?.queueEntryId,
164
+ request?.workflowRunId
165
+ ]);
166
+ const refresh = useCallback(async () => {
167
+ if (!enabled || !stableRequest) {
168
+ setReplay(null);
169
+ return null;
170
+ }
171
+ setLoading(true);
172
+ setError(null);
173
+ try {
174
+ const nextReplay = await client.audit.getIncidentReplay(stableRequest);
175
+ setReplay(nextReplay);
176
+ return nextReplay;
177
+ }
178
+ catch (caught) {
179
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
180
+ setError(nextError);
181
+ return null;
182
+ }
183
+ finally {
184
+ setLoading(false);
185
+ }
186
+ }, [client, enabled, stableRequest]);
187
+ useEffect(() => {
188
+ void refresh();
189
+ }, [refresh]);
190
+ return {
191
+ data: replay,
192
+ error,
193
+ loading,
194
+ refresh
195
+ };
196
+ }
197
+ export function useTrustWebhookVerificationResult(result) {
198
+ return useMemo(() => ({
199
+ result: result ?? null,
200
+ verified: result?.ok === true,
201
+ failed: result?.ok === false,
202
+ duplicateDelivery: result?.ok === true ? result.duplicateDelivery : false,
203
+ message: result?.ok === false
204
+ ? result.error.message
205
+ : result?.ok === true
206
+ ? "Verified GlobiGuard webhook delivery."
207
+ : "No webhook verification result yet."
208
+ }), [result]);
209
+ }
210
+ export function useGovernedActionSubmission(submitAction) {
211
+ const [decision, setDecision] = useState(null);
212
+ const [error, setError] = useState(null);
213
+ const [loading, setLoading] = useState(false);
214
+ const submit = useCallback(async (request) => {
215
+ setLoading(true);
216
+ setError(null);
217
+ try {
218
+ const nextDecision = await submitAction(request);
219
+ setDecision(nextDecision);
220
+ return nextDecision;
221
+ }
222
+ catch (caught) {
223
+ const nextError = caught instanceof Error ? caught : new Error(String(caught));
224
+ setError(nextError);
225
+ return null;
226
+ }
227
+ finally {
228
+ setLoading(false);
229
+ }
230
+ }, [submitAction]);
231
+ return {
232
+ decision,
233
+ error,
234
+ loading,
235
+ submit
236
+ };
237
+ }
238
+ export function PolicyDecisionBadge({ decision, labels }) {
239
+ return (_jsx("span", { "data-globiguard-decision": decision, children: labels?.[decision] ?? decision }));
240
+ }
241
+ export function ApprovalStatusBadge({ state, labels }) {
242
+ return (_jsx("span", { "data-globiguard-approval-state": state, children: labels?.[state] ?? state }));
243
+ }
244
+ export function ApprovalStatusCard({ approval, error = null, loading = false, fallback = "Approval status unavailable." }) {
245
+ if (error) {
246
+ return _jsx("section", { role: "alert", children: error.message });
247
+ }
248
+ if (loading && !approval) {
249
+ return _jsx("section", { "aria-busy": "true", children: "Loading approval status..." });
250
+ }
251
+ if (!approval) {
252
+ return _jsx("section", { "data-globiguard-degraded": true, children: fallback });
253
+ }
254
+ return (_jsxs("section", { "data-globiguard-approval-card": true, children: [_jsx(ApprovalStatusBadge, { state: approval.state }), _jsx("p", { children: approval.state === "PENDING"
255
+ ? "The action is waiting for human review."
256
+ : `Review state: ${approval.state}.` }), approval.reviewedBy ? _jsxs("p", { children: ["Reviewed by ", approval.reviewedBy] }) : null] }));
257
+ }
258
+ export function ApprovalStatus({ approvalId, fallback = "Loading approval..." }) {
259
+ const approval = useApprovalStatus(approvalId);
260
+ if (approval.loading && !approval.data) {
261
+ return _jsx(_Fragment, { children: fallback });
262
+ }
263
+ if (approval.error) {
264
+ return _jsx("span", { role: "alert", children: approval.error.message });
265
+ }
266
+ if (!approval.data) {
267
+ return null;
268
+ }
269
+ return _jsx(ApprovalStatusBadge, { state: approval.data.state });
270
+ }
271
+ export function getEvidenceHref(evidenceRef) {
272
+ try {
273
+ const parsedUri = new URL(evidenceRef.uri);
274
+ if (["evidence:", "https:", "http:", "urn:"].includes(parsedUri.protocol)) {
275
+ return evidenceRef.uri;
276
+ }
277
+ }
278
+ catch {
279
+ return "#";
280
+ }
281
+ return "#";
282
+ }
283
+ export function EvidenceLinks({ evidenceRefs, renderLabel }) {
284
+ if (evidenceRefs.length === 0) {
285
+ return null;
286
+ }
287
+ return (_jsx("ul", { "data-globiguard-evidence-links": true, children: evidenceRefs.map((evidenceRef) => (_jsx("li", { children: _jsx("a", { href: getEvidenceHref(evidenceRef), rel: "noreferrer", children: renderLabel?.(evidenceRef) ?? evidenceRef.label ?? evidenceRef.uri }) }, evidenceRef.id))) }));
288
+ }
289
+ export function EvidencePackageSummary({ summary, error = null, loading = false }) {
290
+ if (error) {
291
+ return _jsxs("section", { role: "alert", children: ["Evidence unavailable: ", error.message] });
292
+ }
293
+ if (loading && !summary) {
294
+ return _jsx("section", { "aria-busy": "true", children: "Loading evidence package..." });
295
+ }
296
+ if (!summary) {
297
+ return (_jsx("section", { "data-globiguard-evidence-unavailable": true, children: "Evidence package metadata is not available yet." }));
298
+ }
299
+ return (_jsxs("section", { "data-globiguard-evidence-package": summary.evidencePackageId, children: [_jsxs("strong", { children: ["Evidence package ", summary.status] }), _jsxs("p", { children: [summary.redaction.mode, " redaction; raw payload included:", " ", String(summary.redaction.rawPayloadIncluded)] }), summary.integrity ? (_jsxs("p", { children: [summary.integrity.checksumAlgorithm, ": ", summary.integrity.checksum] })) : null, _jsxs("p", { children: [summary.sourceRefs.length, " source reference(s)"] }), summary.artifact?.uri ? (_jsx("a", { href: summary.artifact.uri, rel: "noreferrer", children: "Download metadata-safe artifact" })) : null] }));
300
+ }
301
+ export function IncidentReplayTimeline({ replay, error = null, loading = false }) {
302
+ if (error) {
303
+ return _jsxs("section", { role: "alert", children: ["Incident replay unavailable: ", error.message] });
304
+ }
305
+ if (loading && !replay) {
306
+ return _jsx("section", { "aria-busy": "true", children: "Loading incident replay..." });
307
+ }
308
+ if (!replay) {
309
+ return (_jsx("section", { "data-globiguard-replay-unavailable": true, children: "Incident replay is not available yet." }));
310
+ }
311
+ return (_jsxs("section", { "data-globiguard-incident-replay": replay.incidentReplayId, children: [_jsx("strong", { children: replay.complete ? "Replay complete" : "Replay incomplete" }), _jsx("ol", { children: replay.timeline.map((entry) => (_jsxs("li", { "data-globiguard-replay-status": entry.status, children: [_jsx("span", { children: entry.occurredAt }), " - ", _jsx("strong", { children: entry.title }), entry.summary ? _jsx("p", { children: entry.summary }) : null] }, entry.id))) }), replay.gaps.length > 0 ? (_jsx("ul", { "data-globiguard-replay-gaps": true, children: replay.gaps.map((gap) => (_jsxs("li", { children: [gap.expectedKind, ": ", gap.reason] }, gap.id))) })) : null] }));
312
+ }
313
+ export function QueuedActionNotice({ queueEntryId, reason = "GlobiGuard queued this action for review. Do not perform the downstream business action yet." }) {
314
+ return (_jsxs("section", { "data-globiguard-queued-action": true, children: [_jsx("strong", { children: "Queued for review" }), _jsx("p", { children: reason }), queueEntryId ? _jsxs("p", { children: ["Queue entry: ", queueEntryId] }) : null] }));
315
+ }
316
+ export function GovernedActionBoundary({ decision, loading = false, error = null, stale = false, children, blockedFallback, queuedFallback, modifiedFallback, degradedFallback = "GlobiGuard cannot verify this action right now, so the protected action is disabled." }) {
317
+ if (error || stale || loading || !decision) {
318
+ return (_jsx("section", { "data-globiguard-fail-closed": true, role: error ? "alert" : undefined, children: error ? error.message : degradedFallback }));
319
+ }
320
+ if (decision.decision === "ALLOW") {
321
+ return _jsx(_Fragment, { children: children });
322
+ }
323
+ if (decision.decision === "MODIFY") {
324
+ return (_jsx("section", { "data-globiguard-modified-action": true, children: modifiedFallback ?? "GlobiGuard requires modified action terms before continuation." }));
325
+ }
326
+ if (decision.decision === "QUEUE") {
327
+ return (_jsx(_Fragment, { children: queuedFallback ?? (_jsx(QueuedActionNotice, { queueEntryId: decision.queueEntryId, reason: decision.reason })) }));
328
+ }
329
+ return (_jsx("section", { "data-globiguard-blocked-action": true, children: blockedFallback ?? decision.reason ?? "GlobiGuard blocked this action." }));
330
+ }
331
+ export function GovernedActionSubmitButton({ request, submitAction, children = "Check with GlobiGuard", disabled = false, onDecision }) {
332
+ const submission = useGovernedActionSubmission(submitAction);
333
+ return (_jsx("button", { type: "button", disabled: disabled || submission.loading, onClick: () => {
334
+ void submission.submit(request).then((decision) => {
335
+ if (decision) {
336
+ onDecision?.(decision);
337
+ }
338
+ });
339
+ }, children: submission.loading ? "Checking..." : children }));
340
+ }
341
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EAET,MAAM,OAAO,CAAC;AAgBf,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAapD,MAAM,UAAU,iBAAiB,CAC/B,UAAqC,EACrC,UAAiC,EAAE;IAEnC,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;IACxC,MAAM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GAChE,CACX,CAAC;AACJ,CAAC;AAUD,MAAM,UAAU,0BAA0B,CAAC,EACzC,OAAO,EACP,YAAY,EACZ,QAAQ,GAAG,uBAAuB,EAClC,QAAQ,GAAG,KAAK,EAChB,UAAU,EACsB;IAChC,MAAM,UAAU,GAAG,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAE7D,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,IAAI,UAAU,CAAC,OAAO,EACxC,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAChD,IAAI,QAAQ,EAAE,CAAC;oBACb,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,YAEA,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,GACvC,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./provider.js";
2
+ export * from "./actions.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./provider.js";
2
+ export * from "./actions.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type PropsWithChildren, type ReactNode } from "react";
2
+ import type { GlobiguardBrowserClient, GlobiguardRealtimeClient } from "@globiguard/sdk";
3
+ export interface GlobiguardProviderProps extends PropsWithChildren {
4
+ client: GlobiguardBrowserClient;
5
+ fallback?: ReactNode;
6
+ }
7
+ export declare function GlobiguardProvider({ client, children, fallback }: GlobiguardProviderProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
8
+ export declare function useGlobiguardClient(): GlobiguardBrowserClient;
9
+ export declare function useGlobiguardRealtimeClient(): GlobiguardRealtimeClient;
10
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,MAAM,EAAE,uBAAuB,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAe,EAChB,EAAE,uBAAuB,+TAUzB;AAED,wBAAgB,mBAAmB,IAAI,uBAAuB,CAU7D;AAED,wBAAgB,2BAA2B,IAAI,wBAAwB,CAUtE"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const GlobiguardContext = createContext(null);
4
+ export function GlobiguardProvider({ client, children, fallback = null }) {
5
+ if (!client) {
6
+ return fallback;
7
+ }
8
+ return (_jsx(GlobiguardContext.Provider, { value: client, children: children }));
9
+ }
10
+ export function useGlobiguardClient() {
11
+ const client = useContext(GlobiguardContext);
12
+ if (!client) {
13
+ throw new Error("useGlobiguardClient must be used inside a GlobiguardProvider.");
14
+ }
15
+ return client;
16
+ }
17
+ export function useGlobiguardRealtimeClient() {
18
+ const client = useGlobiguardClient();
19
+ if (!client.realtime) {
20
+ throw new Error("useGlobiguardRealtimeClient requires createBrowserClient({ realtime: ... }) configuration.");
21
+ }
22
+ return client.realtime;
23
+ }
24
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EAGX,MAAM,OAAO,CAAC;AAOf,MAAM,iBAAiB,GAAG,aAAa,CAAiC,IAAI,CAAC,CAAC;AAO9E,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAQ,GAAG,IAAI,EACS;IACxB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YACtC,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,MAAM,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IAErC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,4FAA4F,CAC7F,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,49 @@
1
- {
2
- "name": "@globiguard/react",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "keywords": [],
9
- "author": "",
10
- "license": "ISC",
11
- "description": ""
12
- }
1
+ {
2
+ "name": "@globiguard/react",
3
+ "version": "1.0.1",
4
+ "description": "React bindings for GlobiGuard's browser-safe distribution layer.",
5
+ "author": "GuideGDM",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/globiguard/globiguard-open.git",
22
+ "directory": "packages/react"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@globiguard/contracts": "1.0.1",
29
+ "@globiguard/sdk": "1.0.1"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^18.3.0 || ^19.0.0",
33
+ "react-dom": "^18.3.0 || ^19.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^19.1.2",
37
+ "@types/react-dom": "^19.1.2",
38
+ "react": "^19.1.0",
39
+ "react-dom": "^19.1.0",
40
+ "vitest": "^2.1.8"
41
+ },
42
+ "scripts": {
43
+ "build:deps": "pnpm --dir ../contracts build && pnpm --dir ../sdk build",
44
+ "build": "pnpm run build:deps && tsc -p tsconfig.json",
45
+ "typecheck": "pnpm run build:deps && tsc -p tsconfig.json --noEmit",
46
+ "pretest": "pnpm run build:deps",
47
+ "test": "vitest run --passWithNoTests"
48
+ }
49
+ }