@githat/nextjs 0.2.6 → 0.2.8
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 +5 -6
- package/dist/index.d.mts +66 -5
- package/dist/index.d.ts +66 -5
- package/dist/index.js +94 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -3
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +41 -1
- package/dist/server.d.ts +41 -1
- package/dist/server.js +18 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +17 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ GitHat is your backend. This SDK connects your app to `api.githat.io` with pre-b
|
|
|
25
25
|
- **Server-Side Auth** — Verify tokens, wrap API routes, and inject auth headers
|
|
26
26
|
- **Customer Data API** — Store and query app data in GitHat's managed DynamoDB
|
|
27
27
|
- **Multi-Tenant** — Organizations, team invitations, and role-based access — managed by GitHat's backend
|
|
28
|
-
- **
|
|
28
|
+
- **Agent Verification** — Verify AI agents on-chain
|
|
29
29
|
- **Dark Theme Included** — Import `@githat/nextjs/styles` for a polished dark UI out of the box
|
|
30
30
|
- **TypeScript First** — Full type definitions for every component, hook, and utility
|
|
31
31
|
- **Dual Output** — Ships ESM + CJS so it works everywhere
|
|
@@ -194,7 +194,7 @@ That's it. You now have a fully authenticated app with sign-in, sign-up, route p
|
|
|
194
194
|
| Component | Description | Props |
|
|
195
195
|
|------------------|--------------------------------------------|--------------------------------------------------|
|
|
196
196
|
| `ProtectedRoute` | Redirects unauthenticated users to sign-in | `children`, `fallback?` |
|
|
197
|
-
| `VerifiedBadge` | Displays
|
|
197
|
+
| `VerifiedBadge` | Displays agent verification status | `type: 'agent'`, `identifier`, `label?` |
|
|
198
198
|
|
|
199
199
|
### Example: Password Reset Flow
|
|
200
200
|
|
|
@@ -274,8 +274,8 @@ import { VerifiedBadge } from '@githat/nextjs';
|
|
|
274
274
|
export default function AgentCard() {
|
|
275
275
|
return (
|
|
276
276
|
<div>
|
|
277
|
-
<h3>My
|
|
278
|
-
<VerifiedBadge type="
|
|
277
|
+
<h3>My Agent</h3>
|
|
278
|
+
<VerifiedBadge type="agent" identifier="0xABC...123" label="Verified" />
|
|
279
279
|
</div>
|
|
280
280
|
);
|
|
281
281
|
}
|
|
@@ -346,8 +346,7 @@ const {
|
|
|
346
346
|
fetch, // <T>(path: string, init?: RequestInit) => Promise<T>
|
|
347
347
|
getUserOrgs, // () => Promise<{ orgs: GitHatOrg[] }>
|
|
348
348
|
|
|
349
|
-
//
|
|
350
|
-
verifyMCP, // (domain: string) => Promise<{ verified: boolean }>
|
|
349
|
+
// Agent Verification
|
|
351
350
|
verifyAgent, // (wallet: string) => Promise<{ verified: boolean }>
|
|
352
351
|
|
|
353
352
|
// Organization Metadata
|
package/dist/index.d.mts
CHANGED
|
@@ -87,9 +87,6 @@ declare function useGitHat(): {
|
|
|
87
87
|
getUserOrgs: () => Promise<{
|
|
88
88
|
orgs: GitHatOrg[];
|
|
89
89
|
}>;
|
|
90
|
-
verifyMCP: (domain: string) => Promise<{
|
|
91
|
-
verified: boolean;
|
|
92
|
-
}>;
|
|
93
90
|
verifyAgent: (wallet: string) => Promise<{
|
|
94
91
|
verified: boolean;
|
|
95
92
|
}>;
|
|
@@ -232,6 +229,52 @@ declare function useData(): {
|
|
|
232
229
|
batch: (collection: string, operations: BatchOperation[]) => Promise<BatchResult>;
|
|
233
230
|
};
|
|
234
231
|
|
|
232
|
+
interface SendEmailOptions {
|
|
233
|
+
/** Recipient email address(es). Single string or array of up to 50 addresses. */
|
|
234
|
+
to: string | string[];
|
|
235
|
+
/** Email subject line (max 998 characters). */
|
|
236
|
+
subject: string;
|
|
237
|
+
/** HTML body (optional if text is provided). */
|
|
238
|
+
html?: string;
|
|
239
|
+
/** Plain text body (optional if html is provided). */
|
|
240
|
+
text?: string;
|
|
241
|
+
/** Reply-to email address. Recipients can reply directly to this address. */
|
|
242
|
+
replyTo?: string;
|
|
243
|
+
}
|
|
244
|
+
interface SendEmailResult {
|
|
245
|
+
/** SES message ID for tracking. */
|
|
246
|
+
messageId: string;
|
|
247
|
+
/** Recipient addresses the email was sent to. */
|
|
248
|
+
to: string[];
|
|
249
|
+
/** Subject line as sent. */
|
|
250
|
+
subject: string;
|
|
251
|
+
/** Whether the email was sent successfully. */
|
|
252
|
+
sent: boolean;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Hook for sending transactional emails via GitHat's Email API.
|
|
256
|
+
* Emails are sent from noreply@githat.io. Use replyTo for customer replies.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```tsx
|
|
260
|
+
* const { send } = useEmail();
|
|
261
|
+
*
|
|
262
|
+
* await send({
|
|
263
|
+
* to: 'user@example.com',
|
|
264
|
+
* subject: 'Your order is confirmed',
|
|
265
|
+
* html: '<h1>Order Confirmed</h1><p>Thank you!</p>',
|
|
266
|
+
* replyTo: 'support@myapp.com'
|
|
267
|
+
* });
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare function useEmail(): {
|
|
271
|
+
/**
|
|
272
|
+
* Send a transactional email.
|
|
273
|
+
* @param options - Email options (to, subject, html/text, replyTo)
|
|
274
|
+
*/
|
|
275
|
+
send: (options: SendEmailOptions) => Promise<SendEmailResult>;
|
|
276
|
+
};
|
|
277
|
+
|
|
235
278
|
interface SignInFormProps {
|
|
236
279
|
onSuccess?: () => void;
|
|
237
280
|
signUpUrl?: string;
|
|
@@ -267,7 +310,7 @@ declare function UserButton(): react_jsx_runtime.JSX.Element | null;
|
|
|
267
310
|
declare function OrgSwitcher(): react_jsx_runtime.JSX.Element | null;
|
|
268
311
|
|
|
269
312
|
interface VerifiedBadgeProps {
|
|
270
|
-
type: '
|
|
313
|
+
type: 'agent';
|
|
271
314
|
identifier: string;
|
|
272
315
|
label?: string;
|
|
273
316
|
}
|
|
@@ -439,5 +482,23 @@ interface WithAuthOptions {
|
|
|
439
482
|
*/
|
|
440
483
|
onUnauthorized?: () => Response;
|
|
441
484
|
}
|
|
485
|
+
interface ServerSendEmailOptions {
|
|
486
|
+
/** Recipient email address(es). */
|
|
487
|
+
to: string | string[];
|
|
488
|
+
/** Email subject line. */
|
|
489
|
+
subject: string;
|
|
490
|
+
/** HTML body. */
|
|
491
|
+
html?: string;
|
|
492
|
+
/** Plain text body. */
|
|
493
|
+
text?: string;
|
|
494
|
+
/** Reply-to email address. */
|
|
495
|
+
replyTo?: string;
|
|
496
|
+
}
|
|
497
|
+
interface ServerSendEmailResult {
|
|
498
|
+
messageId: string;
|
|
499
|
+
to: string[];
|
|
500
|
+
subject: string;
|
|
501
|
+
sent: boolean;
|
|
502
|
+
}
|
|
442
503
|
|
|
443
|
-
export { type AuthActions, type AuthPayload, type AuthState, type AuthenticatedHandler, type BatchOperation, type BatchResult, ChangePasswordForm, CognitoButton, CognitoCallback, type DataItem, type DeleteResult, type EmailVerificationResult, ForgotPasswordForm, type GitHatConfig, type GitHatContextValue, type GitHatOrg, GitHatProvider, type GitHatUser, GitHubButton, GitHubCallback, type OrgMetadata, OrgSwitcher, type PasswordResetResult, ProtectedRoute, type PutResult, type QueryOptions, type QueryResult, ResetPasswordForm, SignInButton, SignInForm, SignUpButton, type SignUpData, SignUpForm, type SignUpResult, UserButton, VerifiedBadge, VerifyEmailStatus, type VerifyOptions, type WithAuthOptions, useAuth, useData, useGitHat };
|
|
504
|
+
export { type AuthActions, type AuthPayload, type AuthState, type AuthenticatedHandler, type BatchOperation, type BatchResult, ChangePasswordForm, CognitoButton, CognitoCallback, type DataItem, type DeleteResult, type EmailVerificationResult, ForgotPasswordForm, type GitHatConfig, type GitHatContextValue, type GitHatOrg, GitHatProvider, type GitHatUser, GitHubButton, GitHubCallback, type OrgMetadata, OrgSwitcher, type PasswordResetResult, ProtectedRoute, type PutResult, type QueryOptions, type QueryResult, ResetPasswordForm, type SendEmailOptions, type SendEmailResult, type ServerSendEmailOptions, type ServerSendEmailResult, SignInButton, SignInForm, SignUpButton, type SignUpData, SignUpForm, type SignUpResult, UserButton, VerifiedBadge, VerifyEmailStatus, type VerifyOptions, type WithAuthOptions, useAuth, useData, useEmail, useGitHat };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,9 +87,6 @@ declare function useGitHat(): {
|
|
|
87
87
|
getUserOrgs: () => Promise<{
|
|
88
88
|
orgs: GitHatOrg[];
|
|
89
89
|
}>;
|
|
90
|
-
verifyMCP: (domain: string) => Promise<{
|
|
91
|
-
verified: boolean;
|
|
92
|
-
}>;
|
|
93
90
|
verifyAgent: (wallet: string) => Promise<{
|
|
94
91
|
verified: boolean;
|
|
95
92
|
}>;
|
|
@@ -232,6 +229,52 @@ declare function useData(): {
|
|
|
232
229
|
batch: (collection: string, operations: BatchOperation[]) => Promise<BatchResult>;
|
|
233
230
|
};
|
|
234
231
|
|
|
232
|
+
interface SendEmailOptions {
|
|
233
|
+
/** Recipient email address(es). Single string or array of up to 50 addresses. */
|
|
234
|
+
to: string | string[];
|
|
235
|
+
/** Email subject line (max 998 characters). */
|
|
236
|
+
subject: string;
|
|
237
|
+
/** HTML body (optional if text is provided). */
|
|
238
|
+
html?: string;
|
|
239
|
+
/** Plain text body (optional if html is provided). */
|
|
240
|
+
text?: string;
|
|
241
|
+
/** Reply-to email address. Recipients can reply directly to this address. */
|
|
242
|
+
replyTo?: string;
|
|
243
|
+
}
|
|
244
|
+
interface SendEmailResult {
|
|
245
|
+
/** SES message ID for tracking. */
|
|
246
|
+
messageId: string;
|
|
247
|
+
/** Recipient addresses the email was sent to. */
|
|
248
|
+
to: string[];
|
|
249
|
+
/** Subject line as sent. */
|
|
250
|
+
subject: string;
|
|
251
|
+
/** Whether the email was sent successfully. */
|
|
252
|
+
sent: boolean;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Hook for sending transactional emails via GitHat's Email API.
|
|
256
|
+
* Emails are sent from noreply@githat.io. Use replyTo for customer replies.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```tsx
|
|
260
|
+
* const { send } = useEmail();
|
|
261
|
+
*
|
|
262
|
+
* await send({
|
|
263
|
+
* to: 'user@example.com',
|
|
264
|
+
* subject: 'Your order is confirmed',
|
|
265
|
+
* html: '<h1>Order Confirmed</h1><p>Thank you!</p>',
|
|
266
|
+
* replyTo: 'support@myapp.com'
|
|
267
|
+
* });
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare function useEmail(): {
|
|
271
|
+
/**
|
|
272
|
+
* Send a transactional email.
|
|
273
|
+
* @param options - Email options (to, subject, html/text, replyTo)
|
|
274
|
+
*/
|
|
275
|
+
send: (options: SendEmailOptions) => Promise<SendEmailResult>;
|
|
276
|
+
};
|
|
277
|
+
|
|
235
278
|
interface SignInFormProps {
|
|
236
279
|
onSuccess?: () => void;
|
|
237
280
|
signUpUrl?: string;
|
|
@@ -267,7 +310,7 @@ declare function UserButton(): react_jsx_runtime.JSX.Element | null;
|
|
|
267
310
|
declare function OrgSwitcher(): react_jsx_runtime.JSX.Element | null;
|
|
268
311
|
|
|
269
312
|
interface VerifiedBadgeProps {
|
|
270
|
-
type: '
|
|
313
|
+
type: 'agent';
|
|
271
314
|
identifier: string;
|
|
272
315
|
label?: string;
|
|
273
316
|
}
|
|
@@ -439,5 +482,23 @@ interface WithAuthOptions {
|
|
|
439
482
|
*/
|
|
440
483
|
onUnauthorized?: () => Response;
|
|
441
484
|
}
|
|
485
|
+
interface ServerSendEmailOptions {
|
|
486
|
+
/** Recipient email address(es). */
|
|
487
|
+
to: string | string[];
|
|
488
|
+
/** Email subject line. */
|
|
489
|
+
subject: string;
|
|
490
|
+
/** HTML body. */
|
|
491
|
+
html?: string;
|
|
492
|
+
/** Plain text body. */
|
|
493
|
+
text?: string;
|
|
494
|
+
/** Reply-to email address. */
|
|
495
|
+
replyTo?: string;
|
|
496
|
+
}
|
|
497
|
+
interface ServerSendEmailResult {
|
|
498
|
+
messageId: string;
|
|
499
|
+
to: string[];
|
|
500
|
+
subject: string;
|
|
501
|
+
sent: boolean;
|
|
502
|
+
}
|
|
442
503
|
|
|
443
|
-
export { type AuthActions, type AuthPayload, type AuthState, type AuthenticatedHandler, type BatchOperation, type BatchResult, ChangePasswordForm, CognitoButton, CognitoCallback, type DataItem, type DeleteResult, type EmailVerificationResult, ForgotPasswordForm, type GitHatConfig, type GitHatContextValue, type GitHatOrg, GitHatProvider, type GitHatUser, GitHubButton, GitHubCallback, type OrgMetadata, OrgSwitcher, type PasswordResetResult, ProtectedRoute, type PutResult, type QueryOptions, type QueryResult, ResetPasswordForm, SignInButton, SignInForm, SignUpButton, type SignUpData, SignUpForm, type SignUpResult, UserButton, VerifiedBadge, VerifyEmailStatus, type VerifyOptions, type WithAuthOptions, useAuth, useData, useGitHat };
|
|
504
|
+
export { type AuthActions, type AuthPayload, type AuthState, type AuthenticatedHandler, type BatchOperation, type BatchResult, ChangePasswordForm, CognitoButton, CognitoCallback, type DataItem, type DeleteResult, type EmailVerificationResult, ForgotPasswordForm, type GitHatConfig, type GitHatContextValue, type GitHatOrg, GitHatProvider, type GitHatUser, GitHubButton, GitHubCallback, type OrgMetadata, OrgSwitcher, type PasswordResetResult, ProtectedRoute, type PutResult, type QueryOptions, type QueryResult, ResetPasswordForm, type SendEmailOptions, type SendEmailResult, type ServerSendEmailOptions, type ServerSendEmailResult, SignInButton, SignInForm, SignUpButton, type SignUpData, SignUpForm, type SignUpResult, UserButton, VerifiedBadge, VerifyEmailStatus, type VerifyOptions, type WithAuthOptions, useAuth, useData, useEmail, useGitHat };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
VerifyEmailStatus: () => VerifyEmailStatus,
|
|
41
41
|
useAuth: () => useAuth,
|
|
42
42
|
useData: () => useData,
|
|
43
|
+
useEmail: () => useEmail,
|
|
43
44
|
useGitHat: () => useGitHat
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -546,7 +547,6 @@ function useGitHat() {
|
|
|
546
547
|
return {
|
|
547
548
|
fetch: client.fetchApi,
|
|
548
549
|
getUserOrgs: () => client.fetchApi("/user/orgs"),
|
|
549
|
-
verifyMCP: (domain) => client.fetchApi(`/verify/mcp/${domain}`),
|
|
550
550
|
verifyAgent: (wallet) => client.fetchApi(`/verify/agent/${wallet}`),
|
|
551
551
|
getOrgMetadata,
|
|
552
552
|
updateOrgMetadata,
|
|
@@ -643,15 +643,40 @@ function useData() {
|
|
|
643
643
|
}), [client]);
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
-
// src/
|
|
646
|
+
// src/email.ts
|
|
647
647
|
var import_react4 = require("react");
|
|
648
|
+
function useEmail() {
|
|
649
|
+
const ctx = useAuth();
|
|
650
|
+
const client = (0, import_react4.useMemo)(
|
|
651
|
+
() => createClient(ctx.config.apiUrl, ctx.config.publishableKey),
|
|
652
|
+
[ctx.config.apiUrl, ctx.config.publishableKey]
|
|
653
|
+
);
|
|
654
|
+
return (0, import_react4.useMemo)(() => ({
|
|
655
|
+
/**
|
|
656
|
+
* Send a transactional email.
|
|
657
|
+
* @param options - Email options (to, subject, html/text, replyTo)
|
|
658
|
+
*/
|
|
659
|
+
send: async (options) => {
|
|
660
|
+
if (!options.to) throw new Error('Recipient "to" is required');
|
|
661
|
+
if (!options.subject) throw new Error("Subject is required");
|
|
662
|
+
if (!options.html && !options.text) throw new Error('At least one of "html" or "text" is required');
|
|
663
|
+
return client.fetchApi("/email/send", {
|
|
664
|
+
method: "POST",
|
|
665
|
+
body: JSON.stringify(options)
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
}), [client]);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// src/components/SignInForm.tsx
|
|
672
|
+
var import_react5 = require("react");
|
|
648
673
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
649
674
|
function SignInForm({ onSuccess, signUpUrl, forgotPasswordUrl }) {
|
|
650
675
|
const { signIn, config } = useAuth();
|
|
651
|
-
const [email, setEmail] = (0,
|
|
652
|
-
const [password, setPassword] = (0,
|
|
653
|
-
const [error, setError] = (0,
|
|
654
|
-
const [loading, setLoading] = (0,
|
|
676
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
677
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
678
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
679
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
655
680
|
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
656
681
|
const handleSubmit = async (e) => {
|
|
657
682
|
e.preventDefault();
|
|
@@ -737,15 +762,15 @@ function SignInForm({ onSuccess, signUpUrl, forgotPasswordUrl }) {
|
|
|
737
762
|
}
|
|
738
763
|
|
|
739
764
|
// src/components/SignUpForm.tsx
|
|
740
|
-
var
|
|
765
|
+
var import_react6 = require("react");
|
|
741
766
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
742
767
|
function SignUpForm({ onSuccess, signInUrl }) {
|
|
743
768
|
const { signUp, config } = useAuth();
|
|
744
|
-
const [name, setName] = (0,
|
|
745
|
-
const [email, setEmail] = (0,
|
|
746
|
-
const [password, setPassword] = (0,
|
|
747
|
-
const [error, setError] = (0,
|
|
748
|
-
const [loading, setLoading] = (0,
|
|
769
|
+
const [name, setName] = (0, import_react6.useState)("");
|
|
770
|
+
const [email, setEmail] = (0, import_react6.useState)("");
|
|
771
|
+
const [password, setPassword] = (0, import_react6.useState)("");
|
|
772
|
+
const [error, setError] = (0, import_react6.useState)("");
|
|
773
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
749
774
|
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
750
775
|
const passwordValid = password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /\d/.test(password);
|
|
751
776
|
const handleSubmit = async (e) => {
|
|
@@ -851,31 +876,31 @@ function SignUpForm({ onSuccess, signInUrl }) {
|
|
|
851
876
|
}
|
|
852
877
|
|
|
853
878
|
// src/components/SignInButton.tsx
|
|
854
|
-
var
|
|
879
|
+
var import_react7 = require("react");
|
|
855
880
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
856
881
|
function SignInButton({ className, children, href }) {
|
|
857
|
-
const ctx = (0,
|
|
882
|
+
const ctx = (0, import_react7.useContext)(GitHatContext);
|
|
858
883
|
const url = href || ctx?.config.signInUrl || "/sign-in";
|
|
859
884
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: url, className: className || "githat-button githat-button-primary", "aria-label": "Sign in", children: children || "Sign in" });
|
|
860
885
|
}
|
|
861
886
|
|
|
862
887
|
// src/components/SignUpButton.tsx
|
|
863
|
-
var
|
|
888
|
+
var import_react8 = require("react");
|
|
864
889
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
865
890
|
function SignUpButton({ className, children, href }) {
|
|
866
|
-
const ctx = (0,
|
|
891
|
+
const ctx = (0, import_react8.useContext)(GitHatContext);
|
|
867
892
|
const url = href || ctx?.config.signUpUrl || "/sign-up";
|
|
868
893
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: url, className: className || "githat-button githat-button-outline", "aria-label": "Sign up", children: children || "Sign up" });
|
|
869
894
|
}
|
|
870
895
|
|
|
871
896
|
// src/components/UserButton.tsx
|
|
872
|
-
var
|
|
897
|
+
var import_react9 = require("react");
|
|
873
898
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
874
899
|
function UserButton() {
|
|
875
900
|
const { user, org, isSignedIn, signOut } = useAuth();
|
|
876
|
-
const [open, setOpen] = (0,
|
|
877
|
-
const ref = (0,
|
|
878
|
-
(0,
|
|
901
|
+
const [open, setOpen] = (0, import_react9.useState)(false);
|
|
902
|
+
const ref = (0, import_react9.useRef)(null);
|
|
903
|
+
(0, import_react9.useEffect)(() => {
|
|
879
904
|
const handleClickOutside = (e) => {
|
|
880
905
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
881
906
|
};
|
|
@@ -902,23 +927,23 @@ function UserButton() {
|
|
|
902
927
|
}
|
|
903
928
|
|
|
904
929
|
// src/components/OrgSwitcher.tsx
|
|
905
|
-
var
|
|
930
|
+
var import_react10 = require("react");
|
|
906
931
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
907
932
|
function OrgSwitcher() {
|
|
908
933
|
const { org, isSignedIn, switchOrg } = useAuth();
|
|
909
934
|
const githat = useGitHat();
|
|
910
|
-
const [orgs, setOrgs] = (0,
|
|
911
|
-
const [orgsLoading, setOrgsLoading] = (0,
|
|
912
|
-
const [open, setOpen] = (0,
|
|
913
|
-
const ref = (0,
|
|
914
|
-
(0,
|
|
935
|
+
const [orgs, setOrgs] = (0, import_react10.useState)([]);
|
|
936
|
+
const [orgsLoading, setOrgsLoading] = (0, import_react10.useState)(false);
|
|
937
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
938
|
+
const ref = (0, import_react10.useRef)(null);
|
|
939
|
+
(0, import_react10.useEffect)(() => {
|
|
915
940
|
if (isSignedIn) {
|
|
916
941
|
setOrgsLoading(true);
|
|
917
942
|
githat.getUserOrgs().then((data) => setOrgs(data.orgs || [])).catch(() => {
|
|
918
943
|
}).finally(() => setOrgsLoading(false));
|
|
919
944
|
}
|
|
920
945
|
}, [isSignedIn]);
|
|
921
|
-
(0,
|
|
946
|
+
(0, import_react10.useEffect)(() => {
|
|
922
947
|
const handleClickOutside = (e) => {
|
|
923
948
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
924
949
|
};
|
|
@@ -952,15 +977,15 @@ function OrgSwitcher() {
|
|
|
952
977
|
}
|
|
953
978
|
|
|
954
979
|
// src/components/VerifiedBadge.tsx
|
|
955
|
-
var
|
|
980
|
+
var import_react11 = require("react");
|
|
956
981
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
957
982
|
var CACHE_TTL = 5 * 60 * 1e3;
|
|
958
983
|
var cache = /* @__PURE__ */ new Map();
|
|
959
984
|
function VerifiedBadge({ type, identifier, label }) {
|
|
960
985
|
const githat = useGitHat();
|
|
961
|
-
const [verified, setVerified] = (0,
|
|
962
|
-
const mounted = (0,
|
|
963
|
-
(0,
|
|
986
|
+
const [verified, setVerified] = (0, import_react11.useState)(null);
|
|
987
|
+
const mounted = (0, import_react11.useRef)(true);
|
|
988
|
+
(0, import_react11.useEffect)(() => {
|
|
964
989
|
mounted.current = true;
|
|
965
990
|
const key = `${type}:${identifier}`;
|
|
966
991
|
const cached = cache.get(key);
|
|
@@ -968,8 +993,7 @@ function VerifiedBadge({ type, identifier, label }) {
|
|
|
968
993
|
setVerified(cached.verified);
|
|
969
994
|
return;
|
|
970
995
|
}
|
|
971
|
-
|
|
972
|
-
verify(identifier).then((data) => {
|
|
996
|
+
githat.verifyAgent(identifier).then((data) => {
|
|
973
997
|
if (mounted.current) {
|
|
974
998
|
setVerified(data.verified);
|
|
975
999
|
cache.set(key, { verified: data.verified, ts: Date.now() });
|
|
@@ -1006,7 +1030,7 @@ function ProtectedRoute({ children, fallback }) {
|
|
|
1006
1030
|
}
|
|
1007
1031
|
|
|
1008
1032
|
// src/components/ForgotPasswordForm.tsx
|
|
1009
|
-
var
|
|
1033
|
+
var import_react12 = require("react");
|
|
1010
1034
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1011
1035
|
function ForgotPasswordForm({
|
|
1012
1036
|
onSuccess,
|
|
@@ -1014,10 +1038,10 @@ function ForgotPasswordForm({
|
|
|
1014
1038
|
signInUrl = "/sign-in"
|
|
1015
1039
|
}) {
|
|
1016
1040
|
const { forgotPassword } = useGitHat();
|
|
1017
|
-
const [email, setEmail] = (0,
|
|
1018
|
-
const [isLoading, setIsLoading] = (0,
|
|
1019
|
-
const [sent, setSent] = (0,
|
|
1020
|
-
const [error, setError] = (0,
|
|
1041
|
+
const [email, setEmail] = (0, import_react12.useState)("");
|
|
1042
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
1043
|
+
const [sent, setSent] = (0, import_react12.useState)(false);
|
|
1044
|
+
const [error, setError] = (0, import_react12.useState)("");
|
|
1021
1045
|
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
1022
1046
|
const handleSubmit = async (e) => {
|
|
1023
1047
|
e.preventDefault();
|
|
@@ -1101,7 +1125,7 @@ function ForgotPasswordForm({
|
|
|
1101
1125
|
}
|
|
1102
1126
|
|
|
1103
1127
|
// src/components/ResetPasswordForm.tsx
|
|
1104
|
-
var
|
|
1128
|
+
var import_react13 = require("react");
|
|
1105
1129
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1106
1130
|
function ResetPasswordForm({
|
|
1107
1131
|
token,
|
|
@@ -1111,11 +1135,11 @@ function ResetPasswordForm({
|
|
|
1111
1135
|
minPasswordLength = 8
|
|
1112
1136
|
}) {
|
|
1113
1137
|
const { resetPassword } = useGitHat();
|
|
1114
|
-
const [password, setPassword] = (0,
|
|
1115
|
-
const [confirm, setConfirm] = (0,
|
|
1116
|
-
const [isLoading, setIsLoading] = (0,
|
|
1117
|
-
const [success, setSuccess] = (0,
|
|
1118
|
-
const [error, setError] = (0,
|
|
1138
|
+
const [password, setPassword] = (0, import_react13.useState)("");
|
|
1139
|
+
const [confirm, setConfirm] = (0, import_react13.useState)("");
|
|
1140
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
|
|
1141
|
+
const [success, setSuccess] = (0, import_react13.useState)(false);
|
|
1142
|
+
const [error, setError] = (0, import_react13.useState)("");
|
|
1119
1143
|
const handleSubmit = async (e) => {
|
|
1120
1144
|
e.preventDefault();
|
|
1121
1145
|
if (password !== confirm) {
|
|
@@ -1213,7 +1237,7 @@ function ResetPasswordForm({
|
|
|
1213
1237
|
}
|
|
1214
1238
|
|
|
1215
1239
|
// src/components/VerifyEmailStatus.tsx
|
|
1216
|
-
var
|
|
1240
|
+
var import_react14 = require("react");
|
|
1217
1241
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1218
1242
|
function VerifyEmailStatus({
|
|
1219
1243
|
token,
|
|
@@ -1223,9 +1247,9 @@ function VerifyEmailStatus({
|
|
|
1223
1247
|
redirectDelay = 3e3
|
|
1224
1248
|
}) {
|
|
1225
1249
|
const { verifyEmail } = useGitHat();
|
|
1226
|
-
const [status, setStatus] = (0,
|
|
1227
|
-
const [error, setError] = (0,
|
|
1228
|
-
(0,
|
|
1250
|
+
const [status, setStatus] = (0, import_react14.useState)("loading");
|
|
1251
|
+
const [error, setError] = (0, import_react14.useState)("");
|
|
1252
|
+
(0, import_react14.useEffect)(() => {
|
|
1229
1253
|
if (!token) {
|
|
1230
1254
|
setStatus("error");
|
|
1231
1255
|
setError("Missing verification token");
|
|
@@ -1276,7 +1300,7 @@ function VerifyEmailStatus({
|
|
|
1276
1300
|
}
|
|
1277
1301
|
|
|
1278
1302
|
// src/components/ChangePasswordForm.tsx
|
|
1279
|
-
var
|
|
1303
|
+
var import_react15 = require("react");
|
|
1280
1304
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1281
1305
|
function ChangePasswordForm({
|
|
1282
1306
|
onSuccess,
|
|
@@ -1284,12 +1308,12 @@ function ChangePasswordForm({
|
|
|
1284
1308
|
minPasswordLength = 8
|
|
1285
1309
|
}) {
|
|
1286
1310
|
const { changePassword } = useGitHat();
|
|
1287
|
-
const [current, setCurrent] = (0,
|
|
1288
|
-
const [newPass, setNewPass] = (0,
|
|
1289
|
-
const [confirm, setConfirm] = (0,
|
|
1290
|
-
const [isLoading, setIsLoading] = (0,
|
|
1291
|
-
const [error, setError] = (0,
|
|
1292
|
-
const [success, setSuccess] = (0,
|
|
1311
|
+
const [current, setCurrent] = (0, import_react15.useState)("");
|
|
1312
|
+
const [newPass, setNewPass] = (0, import_react15.useState)("");
|
|
1313
|
+
const [confirm, setConfirm] = (0, import_react15.useState)("");
|
|
1314
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
|
|
1315
|
+
const [error, setError] = (0, import_react15.useState)("");
|
|
1316
|
+
const [success, setSuccess] = (0, import_react15.useState)(false);
|
|
1293
1317
|
const handleSubmit = async (e) => {
|
|
1294
1318
|
e.preventDefault();
|
|
1295
1319
|
if (newPass !== confirm) {
|
|
@@ -1395,7 +1419,7 @@ function ChangePasswordForm({
|
|
|
1395
1419
|
}
|
|
1396
1420
|
|
|
1397
1421
|
// src/components/GitHubButton.tsx
|
|
1398
|
-
var
|
|
1422
|
+
var import_react16 = require("react");
|
|
1399
1423
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1400
1424
|
var GitHubIcon = () => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z" }) });
|
|
1401
1425
|
function GitHubButton({
|
|
@@ -1408,8 +1432,8 @@ function GitHubButton({
|
|
|
1408
1432
|
disabled = false
|
|
1409
1433
|
}) {
|
|
1410
1434
|
const { getGitHubOAuthUrl } = useGitHat();
|
|
1411
|
-
const [isLoading, setIsLoading] = (0,
|
|
1412
|
-
const handleClick = (0,
|
|
1435
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
1436
|
+
const handleClick = (0, import_react16.useCallback)(async () => {
|
|
1413
1437
|
if (isLoading || disabled) return;
|
|
1414
1438
|
setIsLoading(true);
|
|
1415
1439
|
try {
|
|
@@ -1496,7 +1520,7 @@ if (typeof document !== "undefined") {
|
|
|
1496
1520
|
}
|
|
1497
1521
|
|
|
1498
1522
|
// src/components/GitHubCallback.tsx
|
|
1499
|
-
var
|
|
1523
|
+
var import_react17 = require("react");
|
|
1500
1524
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1501
1525
|
function GitHubCallback({
|
|
1502
1526
|
redirectUrl = "/dashboard",
|
|
@@ -1508,9 +1532,9 @@ function GitHubCallback({
|
|
|
1508
1532
|
}) {
|
|
1509
1533
|
const { signInWithGitHub } = useGitHat();
|
|
1510
1534
|
const { config } = useAuth();
|
|
1511
|
-
const [error, setError] = (0,
|
|
1512
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
1513
|
-
(0,
|
|
1535
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
1536
|
+
const [isProcessing, setIsProcessing] = (0, import_react17.useState)(true);
|
|
1537
|
+
(0, import_react17.useEffect)(() => {
|
|
1514
1538
|
const handleCallback = async () => {
|
|
1515
1539
|
const params = new URLSearchParams(window.location.search);
|
|
1516
1540
|
const code = params.get("code");
|
|
@@ -1628,7 +1652,7 @@ if (typeof document !== "undefined") {
|
|
|
1628
1652
|
}
|
|
1629
1653
|
|
|
1630
1654
|
// src/components/CognitoButton.tsx
|
|
1631
|
-
var
|
|
1655
|
+
var import_react18 = require("react");
|
|
1632
1656
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1633
1657
|
var AWSIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M6.763 10.036c0 .296.032.535.088.71.064.176.144.368.256.576.04.063.056.127.056.183 0 .08-.048.16-.152.24l-.503.335a.383.383 0 0 1-.208.072c-.08 0-.16-.04-.239-.112a2.47 2.47 0 0 1-.287-.375 6.18 6.18 0 0 1-.248-.471c-.622.734-1.405 1.101-2.347 1.101-.67 0-1.205-.191-1.596-.574-.391-.384-.59-.894-.59-1.533 0-.678.239-1.23.726-1.644.487-.415 1.133-.623 1.955-.623.272 0 .551.024.846.064.296.04.6.104.918.176v-.583c0-.607-.127-1.03-.375-1.277-.255-.248-.686-.367-1.3-.367-.28 0-.568.031-.863.103-.295.072-.583.16-.862.272a2.287 2.287 0 0 1-.28.104.488.488 0 0 1-.127.023c-.112 0-.168-.08-.168-.247v-.391c0-.128.016-.224.056-.28a.597.597 0 0 1 .224-.167c.279-.144.614-.264 1.005-.36a4.84 4.84 0 0 1 1.246-.151c.95 0 1.644.216 2.091.647.439.43.662 1.085.662 1.963v2.586zm-3.24 1.214c.263 0 .534-.048.822-.144.287-.096.543-.271.758-.51.128-.152.224-.32.272-.512.047-.191.08-.423.08-.694v-.335a6.66 6.66 0 0 0-.735-.136 6.02 6.02 0 0 0-.75-.048c-.535 0-.926.104-1.19.32-.263.215-.39.518-.39.917 0 .375.095.655.295.846.191.2.47.296.838.296zm6.41.862c-.144 0-.24-.024-.304-.08-.064-.048-.12-.16-.168-.311L7.586 5.55a1.398 1.398 0 0 1-.072-.32c0-.128.064-.2.191-.2h.783c.151 0 .255.025.31.08.065.048.113.16.16.312l1.342 5.284 1.245-5.284c.04-.16.088-.264.151-.312a.549.549 0 0 1 .32-.08h.638c.152 0 .256.025.32.08.063.048.12.16.151.312l1.261 5.348 1.381-5.348c.048-.16.104-.264.16-.312a.52.52 0 0 1 .311-.08h.743c.127 0 .2.065.2.2 0 .04-.009.08-.017.128a1.137 1.137 0 0 1-.056.2l-1.923 6.17c-.048.16-.104.264-.168.312a.51.51 0 0 1-.303.08h-.687c-.151 0-.255-.024-.32-.08-.063-.056-.119-.16-.15-.32l-1.238-5.148-1.23 5.14c-.04.16-.087.264-.15.32-.065.056-.177.08-.32.08zm10.256.215c-.415 0-.83-.048-1.229-.143-.399-.096-.71-.2-.918-.32-.128-.071-.215-.151-.247-.223a.563.563 0 0 1-.048-.224v-.407c0-.167.064-.247.183-.247.048 0 .096.008.144.024.048.016.12.048.2.08.271.12.566.215.878.279.319.064.63.096.95.096.502 0 .894-.088 1.165-.264a.86.86 0 0 0 .415-.758.777.777 0 0 0-.215-.559c-.144-.151-.415-.287-.806-.415l-1.157-.36c-.583-.183-1.014-.454-1.277-.813a1.902 1.902 0 0 1-.4-1.158c0-.335.073-.63.216-.886.144-.255.336-.479.575-.654.24-.184.51-.32.83-.415.32-.096.655-.136 1.006-.136.176 0 .359.008.535.032.183.024.35.056.518.088.16.04.312.08.455.127.144.048.256.096.336.144a.69.69 0 0 1 .24.2.43.43 0 0 1 .071.263v.375c0 .168-.064.256-.184.256a.83.83 0 0 1-.303-.096 3.652 3.652 0 0 0-1.532-.311c-.455 0-.815.071-1.062.223-.248.152-.375.383-.375.71 0 .224.08.416.24.567.159.152.454.304.877.44l1.134.358c.574.184.99.44 1.237.767.247.327.367.702.367 1.117 0 .343-.072.655-.207.926-.144.272-.336.511-.583.703-.248.2-.543.343-.886.447-.36.111-.734.167-1.142.167z" }) });
|
|
1634
1658
|
function CognitoButton({
|
|
@@ -1641,8 +1665,8 @@ function CognitoButton({
|
|
|
1641
1665
|
disabled = false
|
|
1642
1666
|
}) {
|
|
1643
1667
|
const { getCognitoOAuthUrl } = useGitHat();
|
|
1644
|
-
const [isLoading, setIsLoading] = (0,
|
|
1645
|
-
const handleClick = (0,
|
|
1668
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
|
|
1669
|
+
const handleClick = (0, import_react18.useCallback)(async () => {
|
|
1646
1670
|
if (isLoading || disabled) return;
|
|
1647
1671
|
setIsLoading(true);
|
|
1648
1672
|
try {
|
|
@@ -1728,7 +1752,7 @@ if (typeof document !== "undefined") {
|
|
|
1728
1752
|
}
|
|
1729
1753
|
|
|
1730
1754
|
// src/components/CognitoCallback.tsx
|
|
1731
|
-
var
|
|
1755
|
+
var import_react19 = require("react");
|
|
1732
1756
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1733
1757
|
function CognitoCallback({
|
|
1734
1758
|
redirectUrl = "/dashboard",
|
|
@@ -1740,9 +1764,9 @@ function CognitoCallback({
|
|
|
1740
1764
|
}) {
|
|
1741
1765
|
const { signInWithCognito } = useGitHat();
|
|
1742
1766
|
const { config } = useAuth();
|
|
1743
|
-
const [error, setError] = (0,
|
|
1744
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
1745
|
-
(0,
|
|
1767
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
1768
|
+
const [isProcessing, setIsProcessing] = (0, import_react19.useState)(true);
|
|
1769
|
+
(0, import_react19.useEffect)(() => {
|
|
1746
1770
|
const handleCallback = async () => {
|
|
1747
1771
|
const params = new URLSearchParams(window.location.search);
|
|
1748
1772
|
const code = params.get("code");
|
|
@@ -1835,6 +1859,7 @@ function CognitoCallback({
|
|
|
1835
1859
|
VerifyEmailStatus,
|
|
1836
1860
|
useAuth,
|
|
1837
1861
|
useData,
|
|
1862
|
+
useEmail,
|
|
1838
1863
|
useGitHat
|
|
1839
1864
|
});
|
|
1840
1865
|
//# sourceMappingURL=index.js.map
|