Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="theme-color" content="#0494f4" />
<title>GitPlus</title>
<meta name="description" content="GitPlus by Gothwad Tech. Sign in with Gothwad Accounts, connect GitHub, and manage repositories, code and ZIP sync." />
<meta name="description" content="GitPlus by Bansify. Sign in with Bansify Accounts, connect GitHub, and manage repositories, code and ZIP sync." />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
Expand Down
20 changes: 10 additions & 10 deletions server/accountsSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BRAND } from '../shared/brand';
import { firstPartyOrigin, publicIdentity, record, validSelector, type AccountSession } from '../shared/accounts';

export interface SessionEnv { GITPLUS_ORIGIN?: string; ACCOUNTS_API_ORIGIN?: string }
const COOKIE_NAME = /^gothwad_(?:at|rt|sid|active|accounts|sess_[a-f])$/;
const COOKIE_NAME = /^bansify_(?:at|rt|sid|active|accounts|sess_[a-f])$/;

export function accountCookies(header: string): string {
return header.split(';').map((pair) => pair.trim()).filter((pair) => COOKIE_NAME.test(pair.split('=')[0])).join('; ');
Expand Down Expand Up @@ -39,15 +39,15 @@ export async function handleSession(request: Request, env: SessionEnv, fetcher:
const url = new URL(request.url);
const origin = firstPartyOrigin(env.GITPLUS_ORIGIN || BRAND.productionOrigin);
const apiOrigin = firstPartyOrigin(env.ACCOUNTS_API_ORIGIN || BRAND.accountsApiOrigin);
if (!origin || !apiOrigin || apiOrigin === origin) return unavailable('invalid_configuration', 'Configure distinct HTTPS GitPlus and Accounts API origins under gothwadtech.com.');
if (!origin || !apiOrigin || apiOrigin === origin) return unavailable('invalid_configuration', 'Configure distinct HTTPS GitPlus and Accounts API origins under bansify.com.');
if (request.headers.get('Sec-Fetch-Site') === 'cross-site' || (request.headers.has('Origin') && request.headers.get('Origin') !== url.origin)) {
return sessionJson({ error: 'origin_not_allowed' }, 403);
}
if (url.origin !== origin) return sessionJson({ status: 'unsupported', code: 'first_party_domain_required', message: 'Automatic Gothwad Accounts sign-in requires the configured Gothwad Tech custom domain. Shared cookies are not available on pages.dev, localhost or Arena previews.', productionOrigin: origin });
if (url.origin !== origin) return sessionJson({ status: 'unsupported', code: 'first_party_domain_required', message: 'Automatic Bansify Accounts sign-in requires the configured Bansify custom domain. Shared cookies are not available on pages.dev, localhost or Arena previews.', productionOrigin: origin });
const selector = url.searchParams.get('authuser');
if (selector !== null && !validSelector(selector)) return sessionJson({ error: 'invalid_authuser' }, 400);
const cookie = accountCookies(request.headers.get('Cookie') || '');
if (!cookie) return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'Sign in with Gothwad Accounts to continue to GitPlus.' }, 401);
if (!cookie) return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'Sign in with Bansify Accounts to continue to GitPlus.' }, 401);
const headers = new Headers({ Accept: 'application/json', Cookie: cookie });
if (selector !== null) headers.set('X-Gothwad-Authuser', selector);
// No incoming Authorization header, arbitrary URL, password, or GitHub token is forwarded.
Expand All @@ -60,29 +60,29 @@ export async function handleSession(request: Request, env: SessionEnv, fetcher:
if (response.status === 401 || response.status === 403) {
// Accounts currently clears every slot on a failed /me. Do not propagate global sign-out
// from a read-only GitPlus probe (especially when a selected slot disappears).
return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'The selected Gothwad session has expired. Sign in again.' }, 401);
return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'The selected Bansify session has expired. Sign in again.' }, 401);
}
if (response.status === 429) {
const reply = unavailable('accounts_rate_limited', 'Accounts is rate-limited. Wait before retrying.', 429);
const retry = response.headers.get('Retry-After');
if (retry && /^\d{1,5}$/.test(retry)) reply.headers.set('Retry-After', retry);
return reply;
}
if (!response.ok) return unavailable('accounts_unavailable', 'Gothwad Accounts is temporarily unavailable. Retry without signing out.');
if (!response.ok) return unavailable('accounts_unavailable', 'Bansify Accounts is temporarily unavailable. Retry without signing out.');
if (!response.headers.get('Content-Type')?.toLowerCase().includes('application/json')) return unavailable('accounts_not_json', 'Accounts returned a non-JSON page. Verify the API Worker route.');
const raw: unknown = await response.json();
// Only secure allowlisted cookies from the fixed Accounts endpoint can reach the browser.
cookies = rotationCookies(response.headers);
if (record(raw)?.authenticated === false) return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'Sign in with Gothwad Accounts to continue.' }, 401);
if (record(raw)?.authenticated === false) return sessionJson({ status: 'anonymous', code: 'signed_out', message: 'Sign in with Bansify Accounts to continue.' }, 401);
const identity = publicIdentity(raw);
if (!identity) return unavailable('accounts_invalid_identity', 'Accounts returned an incomplete identity. Retry or contact Gothwad Tech support.', 503, cookies);
if (!identity) return unavailable('accounts_invalid_identity', 'Accounts returned an incomplete identity. Retry or contact Bansify support.', 503, cookies);
// Accounts currently falls back to slots[0] for a missing explicit selector. Reject that
// fallback rather than silently attaching another person's GitHub credentials.
if (selector !== null && (/^[a-f]$/.test(selector) ? identity.activeSlot !== selector : identity.authuser !== Number(selector))) {
return sessionJson({ status: 'anonymous', code: 'account_selection_changed', message: 'The selected account is no longer available. Choose a Gothwad account again.' }, 409, cookies);
return sessionJson({ status: 'anonymous', code: 'account_selection_changed', message: 'The selected account is no longer available. Choose a Bansify account again.' }, 409, cookies);
}
return sessionJson(identity, 200, cookies);
} catch {
return unavailable('accounts_network_error', 'Could not verify Gothwad Accounts within the time limit. Check the connection and retry.', 503, cookies);
return unavailable('accounts_network_error', 'Could not verify Bansify Accounts within the time limit. Check the connection and retry.', 503, cookies);
} finally { clearTimeout(timer); }
}
2 changes: 1 addition & 1 deletion server/githubOAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function oauthRequest(request: Request, env: GitHubOAuthEnv, fetcher: type
const account = await verifiedAccount(request, env, txn.selector, fetcher);
if (!account.ok) { account.response.headers.append('Set-Cookie', clearOAuthCookie()); return account.response; }
const cookies = [...account.cookies, ...cleared];
if (account.session.user.id !== txn.owner) return jsonResponse({ error: 'account_changed', message: 'Your Gothwad account changed. Start the GitHub connection again.' }, 409, cookies);
if (account.session.user.id !== txn.owner) return jsonResponse({ error: 'account_changed', message: 'Your Bansify account changed. Start the GitHub connection again.' }, 409, cookies);
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), 10_000);
try {
Expand Down
6 changes: 3 additions & 3 deletions shared/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BRAND } from './brand';

export interface GothwadUser {
export interface BansifyUser {
id: string;
username: string;
name: string;
Expand All @@ -14,7 +14,7 @@ export interface GothwadAccount {
}
export interface AuthenticatedSession {
status: 'authenticated';
user: GothwadUser;
user: BansifyUser;
activeSlot: string | null;
authuser: number;
accounts: GothwadAccount[];
Expand Down Expand Up @@ -79,7 +79,7 @@ export function firstPartyOrigin(value: string): string | null {
}
export function signInUrl(origin: string, selector: string | null = null, choose = false): string {
const safeOrigin = firstPartyOrigin(origin);
if (!safeOrigin) throw new Error('Gothwad SSO requires a configured Gothwad Tech HTTPS domain.');
if (!safeOrigin) throw new Error('Bansify SSO requires a configured Bansify HTTPS domain.');
const next = new URL('/', safeOrigin);
next.searchParams.set(RETURN_MARKER, '1');
if (selector && validSelector(selector)) next.searchParams.set('authuser', selector);
Expand Down
12 changes: 6 additions & 6 deletions shared/brand.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** GitPlus is a Gothwad Tech product. Keep public product identity consistent. */
/** GitPlus is a Bansify product. Keep public product identity consistent. */
export const BRAND = {
name: 'GitPlus',
company: 'Gothwad Tech',
company: 'Bansify',
version: '0.2.0',
domain: 'gothwadtech.com',
accountsWebOrigin: 'https://accounts.gothwadtech.com',
accountsApiOrigin: 'https://api.gothwadtech.com',
productionOrigin: 'https://gitplus.gothwadtech.com',
domain: 'bansify.com',
accountsWebOrigin: 'https://accounts.bansify.com',
accountsApiOrigin: 'https://api.bansify.com',
productionOrigin: 'https://gitplus.bansify.com',
} as const;
6 changes: 3 additions & 3 deletions shared/githubOAuthErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const OAUTH_ERRORS = {
github_exchange_failed: 'An older GitPlus backend reported a GitHub token-exchange failure without a specific reason. Check that the custom domain is serving the latest Pages Functions deployment; do not assume the secret is wrong.',
oauth_response_unrecognized: 'The OAuth endpoint returned JSON that does not match the expected GitPlus error contract. Check the API deployment and any proxy/Worker route on this domain. This response does not establish that the OAuth credentials are wrong.',
oauth_not_configured: 'The deployed Pages Function is missing OAuth configuration. Set the two credentials in Pages Settings → Variables and secrets, then redeploy.',
first_party_domain_required: 'Open GitPlus on its configured Gothwad Tech custom domain before connecting GitHub.',
first_party_domain_required: 'Open GitPlus on its configured Bansify custom domain before connecting GitHub.',
origin_not_allowed: 'GitPlus rejected the request origin. Open the custom domain directly in the same browser tab and start again.',
method_not_allowed: 'The OAuth request reached an endpoint with an unsupported method. Check the deployed Functions routing.',
json_required: 'The OAuth endpoint did not receive the expected JSON request.',
Expand All @@ -15,8 +15,8 @@ export const OAUTH_ERRORS = {
invalid_state: 'The GitHub callback cookie/state could not be validated. The attempt may have expired or been replaced. Start again in the same browser tab.',
invalid_callback: 'GitHub returned without a usable authorization code. Start a new connection attempt.',
denied: 'GitHub authorization was cancelled. Try again or connect with a PAT.',
account_changed: 'Your Gothwad account changed during GitHub authorization. Start again.',
account_unavailable: 'Your Gothwad session could not be verified during authorization. Retry your connection.',
account_changed: 'Your Bansify account changed during GitHub authorization. Start again.',
account_unavailable: 'Your Bansify session could not be verified during authorization. Retry your connection.',
github_client_credentials: 'GitHub rejected the OAuth App Client ID / Client Secret pair. Check that the deployed Pages secrets belong to the same OAuth App, then redeploy.',
github_redirect_mismatch: 'GitHub rejected the callback URL. The OAuth App callback must exactly match the GitPlus custom-domain /api/github/callback URL.',
github_bad_code: 'GitHub rejected an expired, already-used or invalid authorization code. Start a fresh connection; do not reload the callback.',
Expand Down
8 changes: 4 additions & 4 deletions src/components/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ export const AuthScreen: React.FC<AuthScreenProps> = ({ onSuccess, initialError
GitPlus
</h1>
<p className="text-xs sm:text-sm text-[#5f6368] dark:text-[#9aa0a6] mt-1 max-w-md mx-auto">
A Gothwad Tech product · Connect GitHub to browse repositories, edit code and sync ZIP files.
A Bansify product · Connect GitHub to browse repositories, edit code and sync ZIP files.
</p>
</div>
</div>

{/* Auth Card */}
<div className="bg-white dark:bg-[#292a2d] border border-[#dadce0] dark:border-[#3c4043] rounded-3xl p-6 sm:p-7 shadow-sm space-y-5 transition-colors duration-200">
<p className="text-sm text-[#5f6368] dark:text-[#9aa0a6]">
You are signed in with Gothwad Accounts. GitHub access is a separate connection; your Gothwad password is never requested here.
You are signed in with Bansify Accounts. GitHub access is a separate connection; your Bansify password is never requested here.
</p>
{error && (
<div id="github-connection-error" role="alert" tabIndex={-1} className="p-3 bg-[#ea4335]/10 border border-[#ea4335]/30 rounded-xl text-xs text-[#ea4335] flex items-start gap-2">
Expand All @@ -182,7 +182,7 @@ export const AuthScreen: React.FC<AuthScreenProps> = ({ onSuccess, initialError
<label className="flex items-center gap-2 text-xs"><input id="oauth-allow-delete" type="checkbox" checked={allowDelete} onChange={(e) => setAllowDelete(e.target.checked)} disabled={oauthLoading} />Request repository deletion access (destructive permission)</label>
<button id="github-oauth-connect" type="button" disabled={oauthEnabled !== true || oauthLoading || loading} onClick={connectOAuth} className="w-full flex items-center justify-center gap-2 rounded-xl bg-[#0494f4] px-4 py-3 text-white font-bold text-sm disabled:opacity-50 disabled:cursor-not-allowed"><Github size={18} />{oauthLoading ? 'Opening GitHub…' : 'Connect with GitHub'}</button>
{oauthEnabled !== true && <p id="oauth-configuration-note" className="text-xs text-[#5f6368] dark:text-[#9aa0a6]">{oauthEnabled === null ? 'Checking OAuth availability…' : 'OAuth is unavailable or not configured. The administrator must configure the GitHub OAuth App runtime credentials. You can still use a PAT below.'}</p>}
<p className="text-[11px] text-[#5f6368] dark:text-[#9aa0a6]">Saved only in this tab session, bound to your Gothwad account. No D1 storage or cross-device sync. Unchecking deletion does not revoke an earlier GitHub grant; revoke it in GitHub settings.</p>
<p className="text-[11px] text-[#5f6368] dark:text-[#9aa0a6]">Saved only in this tab session, bound to your Bansify account. No D1 storage or cross-device sync. Unchecking deletion does not revoke an earlier GitHub grant; revoke it in GitHub settings.</p>
</section>
<div className="border-t border-[#dadce0] dark:border-[#3c4043] pt-4 text-xs font-semibold">Or connect manually with a PAT</div>
{/* Quick Create Token Link Banner */}
Expand Down Expand Up @@ -281,7 +281,7 @@ export const AuthScreen: React.FC<AuthScreenProps> = ({ onSuccess, initialError
<div className="pt-2 border-t border-[#dadce0] dark:border-[#3c4043] flex items-center justify-between text-[11px] text-[#5f6368] dark:text-[#9aa0a6]">
<div className="flex items-center gap-1.5">
<Lock className="w-3.5 h-3.5 text-[#34a853]" />
<span>GitHub connection is scoped to this Gothwad account and tab.</span>
<span>GitHub connection is scoped to this Bansify account and tab.</span>
</div>
<button
type="button"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const Header: React.FC<HeaderProps> = ({
</div>
) : (
<span className="text-xs sm:text-sm font-bold text-[#5f6368] dark:text-[#9aa0a6] tracking-tight">
by Gothwad Tech
by Bansify
</span>
)}

Expand Down
Loading
Loading