From 7430eb6b21518214bc3b3a1d410e75f685368929 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sun, 1 Nov 2026 12:27:54 +0000 Subject: [PATCH] feat: import OpenProfile from CoinPay --- package.json | 2 +- pnpm-lock.yaml | 26 +++++++++++++++++--------- src/core/coinpay.ts | 8 ++++++++ src/views/me.tsx | 1 + 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2abe208..4ce4ad2 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@profullstack/footer": "latest", "@profullstack/hqtui": "^0.11.1", "@profullstack/leaderboard": "^0.3.1", - "@profullstack/profile": "0.1.6", + "@profullstack/profile": "0.1.7", "@profullstack/redeem-credits": "^0.2.0", "@profullstack/synconfig": "^0.1.3", "@profullstack/x402-gateway": "^0.16.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a42cbd..a0a07dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: version: 1.0.3 '@profullstack/footer': specifier: latest - version: 0.5.0 + version: 0.6.15 '@profullstack/hqtui': specifier: ^0.11.1 version: 0.11.1 @@ -30,8 +30,8 @@ importers: specifier: ^0.3.1 version: 0.3.1 '@profullstack/profile': - specifier: 0.1.6 - version: 0.1.6 + specifier: 0.1.7 + version: 0.1.7 '@profullstack/redeem-credits': specifier: ^0.2.0 version: 0.2.0 @@ -166,8 +166,8 @@ packages: '@profullstack/emailer@1.0.3': resolution: {integrity: sha512-VyAtCcfnSI6LOwJvWogCr3ZNmEsaZw+iuWrqnosLsdcKsbRyCrCmXigMNZJZEjlgYlR+lK//PwNPG+xtCFvWAw==} - '@profullstack/footer@0.5.0': - resolution: {integrity: sha512-TrllS87nK7J0c/UgYckaFIWVhLOtr6m73XXFSHIuSfOg7NfuWUdwjtsfMXGaZiiUnmMYj3zhGcfzW0DicDwl8w==} + '@profullstack/footer@0.6.15': + resolution: {integrity: sha512-kkkSG8Xw0VnyzYk76ko0aiIgVT/MXmKkKUiJ5u1DZkeLZcDh0d2GjFShwTcCd8AsQr5fBet39wbzSwPeUYwuWg==} engines: {node: '>=18'} hasBin: true peerDependencies: @@ -189,8 +189,12 @@ packages: resolution: {integrity: sha512-LbxLwy+RvT/Qez0mfWCk4o9hvcq0kzwBZ0vF+CYp+oGvyqJWUaSTLhCHWGtKKAI3c0ZUXj6ll0iuRjbuZUE2Sg==} engines: {node: '>=20.11'} - '@profullstack/profile@0.1.6': - resolution: {integrity: sha512-xkn0P3ANz151QJdlBwcBXkHk813qW9qAmuTZKcuvpEZYkyHDC9J9KfvpVSRepfjECzz4ONGHWO5Zwc4BHpfK8g==} + '@profullstack/openprofile@0.2.0': + resolution: {integrity: sha512-cdFsBbfRXurvy5KqHDNcKXxurK2s/YlfVgnILFRpVl2hq3860rExqDee8IfsFGxw5cPdqGv2fxUxtek1Xy2U5Q==} + engines: {node: '>=22'} + + '@profullstack/profile@0.1.7': + resolution: {integrity: sha512-N7UkypkkY2JkSBKzmdmyy6+DCoxI048qUZQksEjSRwSIyy4mjU9H1qW4yhZD+LJBhTEupgJv//Uxwhiy2FuGmA==} engines: {node: '>=20'} hasBin: true peerDependencies: @@ -976,7 +980,7 @@ snapshots: '@profullstack/emailer@1.0.3': {} - '@profullstack/footer@0.5.0': {} + '@profullstack/footer@0.6.15': {} '@profullstack/hqtui@0.11.1': {} @@ -984,7 +988,11 @@ snapshots: '@profullstack/leaderboard@0.3.1': {} - '@profullstack/profile@0.1.6': {} + '@profullstack/openprofile@0.2.0': {} + + '@profullstack/profile@0.1.7': + dependencies: + '@profullstack/openprofile': 0.2.0 '@profullstack/redeem-credits@0.2.0': {} diff --git a/src/core/coinpay.ts b/src/core/coinpay.ts index 4e407be..3dd3f52 100644 --- a/src/core/coinpay.ts +++ b/src/core/coinpay.ts @@ -27,6 +27,8 @@ import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto'; import { checkIdToken, sameState } from '@profullstack/coinpay-onboard/oauth'; import type pg from 'pg'; +import { saveOpenProfileContact } from '@profullstack/profile'; +import { profileStore } from './profile.ts'; import type { CoinPayConfig } from '../config.ts'; export const REQUIRED_SCOPE = 'wallet:read'; @@ -56,6 +58,7 @@ export interface UserInfo { sub: string; email: string | null; name: string | null; + openprofile_url?: string; wallets: Wallet[]; } @@ -292,6 +295,7 @@ export function createCoinPay(config: CoinPayConfig, fetchImpl: Fetch = fetch): sub, email: str(result.body['email']), name: str(result.body['name']), + ...(typeof result.body['openprofile_url'] === 'string' ? { openprofile_url: result.body['openprofile_url'] } : {}), wallets: normaliseWallets(result.body['wallets']), }; }, @@ -612,6 +616,10 @@ export async function finishConnect( } const account = await saveAccount(pool, pending.user_id, tokens, info); + if (info.openprofile_url) { + try { await saveOpenProfileContact(profileStore(pool), pending.user_id, info.openprofile_url); } + catch { console.warn('[coinpay] OpenProfile import skipped'); } + } return { kind: 'connected', userId: pending.user_id, redirect: pending.redirect, account }; } diff --git a/src/views/me.tsx b/src/views/me.tsx index 147ab19..4c47448 100644 --- a/src/views/me.tsx +++ b/src/views/me.tsx @@ -34,6 +34,7 @@ export const ProfileCard: FC<{
{raw( renderProfileFields({ + importOpenProfile: true, fields: PROFILE_COLUMNS, values, errors,