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 apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@profullstack/live-translate": "^0.3.0",
"@profullstack/notifications": "0.1.4",
"@profullstack/pairux-embed": "workspace:*",
"@profullstack/profile": "0.1.6",
"@profullstack/profile": "0.1.7",
"@profullstack/redeem-credits": "^0.2.0",
"@profullstack/stack": "^0.5.0",
"@profullstack/x402-gateway": "^0.13.1",
Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/app/api/v1/coinpay/oauth/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { createServerClient, type CookieOptions } from '@supabase/ssr';
import type { SupabaseClient } from '@supabase/supabase-js';
import { NextResponse, type NextRequest } from 'next/server';
import { finishSignIn, sameState } from '@profullstack/coinpay-onboard/oauth';
import { saveOpenProfileContact } from '@profullstack/profile';
import { profileStore } from '@/lib/profile';
import { createClient } from '@/lib/supabase/server';
import { serviceClient } from '@/lib/supabase/service';
import {
Expand Down Expand Up @@ -80,6 +82,13 @@ export async function GET(request: NextRequest) {
return fail('failed');
}
if (!result.ok) return fail(result.code);
if (pending.mode === 'connect' && claims.openprofile_url) {
try {
await saveOpenProfileContact(profileStore(), result.userId, claims.openprofile_url);
} catch {
console.warn('[coinpay] OpenProfile import skipped');
}
}
if (pending.mode === 'connect') return go('/settings?coinpay=connected');

const minted = await mintMagicLinkHash(admin, result.userId);
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/profile/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function ProfileCard() {
onChange={setValues}
errors={errors}
disabled={!loaded}
importOpenProfile
/>
{error && <p className="mt-3 text-sm text-red-600">{error}</p>}
<div className="mt-4 flex items-center gap-3">
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/lib/coinpay-signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,25 @@ export interface CoinpayClaims {
sub: string;
email: string | null;
name: string | null;
openprofile_url?: string;
}

/** Trim what CoinPay returned to what is stored; the email is contact info only. */
export function claimsFrom(r: {
sub: string;
email: string | null;
name: string | null;
userinfo?: object;
}): CoinpayClaims {
const email = typeof r.email === 'string' && r.email.includes('@') ? r.email.slice(0, 320) : null;
const name = typeof r.name === 'string' && r.name.trim() ? r.name.trim().slice(0, 200) : null;
return { sub: r.sub, email, name };
const openprofileUrl = (r.userinfo as { openprofile_url?: unknown } | undefined)?.openprofile_url;
return {
sub: r.sub,
email,
name,
...(typeof openprofileUrl === 'string' ? { openprofile_url: openprofileUrl } : {}),
};
}

export interface IdentityRow {
Expand Down
26 changes: 17 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading