Skip to content

feat: portfolio diversification, creator media kit, email broadcasts, passkey sign-in (#1474, #1475, #1476, #1477) - #1495

Open
Itodo-S wants to merge 4 commits into
accesslayerorg:devfrom
Itodo-S:feat/diversification-media-kit-broadcasts-passkey
Open

Itodo-S wants to merge 4 commits into
accesslayerorg:devfrom
Itodo-S:feat/diversification-media-kit-broadcasts-passkey

Conversation

@Itodo-S

@Itodo-S Itodo-S commented Nov 23, 2026

Copy link
Copy Markdown

Summary

Four issues, one commit each:

  • Add portfolio correlation and diversification analysis #1474 Portfolio correlation and diversification. DiversificationPanel on /portfolio, with Correlation and Concentration tabs.
    • usePortfolioCorrelation(range, positions) builds daily returns from each held key's snapshots (GET /keys/:id/snapshots).
    • The matrix is pairwise Pearson correlation. It renders as a heatmap plus a screen-reader table, and pairs above 0.8 are outlined, listed, and come with a suggestion to reduce the overlap.
    • Keys with fewer than 14 days of history are left out, with a notice.
    • Score = 100 × (1 − HHI) × (1 − max(0, weighted avg ρ)), so it changes with both correlation and position weights. It is shown with a plain-language label.
    • The hook takes positions as well as range, because the page already values each holding; this is a deliberate deviation from the spec's (range) signature.
  • Build creator media kit page with downloadable brand assets and stats #1475 Creator media kit. MediaKitPage at /creator/media-kit?key=<id>, linked from the creator dashboard and editable only by the key's creator wallet.
    • The public page is /k/:handle/press. It renders the 404 page while visibility is off and receives only the fields the creator enabled.
    • useMediaKit(keyId) returns price, holders, 24h volume and age, with the last-updated time. It uses the same resolvers and formatters as the key page, so the numbers match.
    • Canvas-generated PNG downloads: avatar at 128, 256 and 512 px, a 1500×500 banner and a 1080×1080 card.
    • Copy-ready text blocks, and a QR code that links to /keys/:id.
  • Add creator email broadcasts to holders with consent and unsubscribe handling #1476 Opt-in creator email broadcasts.
    • Holders opt in per key under Settings → Notification preferences. It is off by default and needs an email address.
    • BroadcastComposer is on the creator dashboard. Before sending it shows the audience size and an email preview; the audience is filtered by a minimum balance. Broadcasts can be sent now or scheduled.
    • useBroadcasts(keyId) follows the holders endpoint's cursor to count the audience.
    • Each key can send 4 broadcasts per calendar month (UTC). A fifth is blocked with an explanation, and the remaining allowance is shown.
    • Every email has a per-subscription unsubscribe link plus a List-Unsubscribe value. /unsubscribe/:token takes effect immediately, and scheduled broadcasts pick their audience at send time.
    • BroadcastHistory shows recipients, delivered, bounced and unsubscribed for each broadcast.
  • Add passkey and email sign-in with an embedded wallet option for new users #1477 Passkey and email sign-in with an embedded wallet.
    • SignInOptionsModal offers Connect wallet / Continue with passkey / Continue with email. It opens from the existing connect dialog.
    • usePasskeyAuth() runs WebAuthn against server-issued challenges.
    • SecurityNotice must be acknowledged before a wallet is created. This is enforced in the hook as well as the UI.
    • EmbeddedWalletAdapter implements Signer with server-assisted signing. It asks for a fresh passkey assertion when a transaction moves more than VITE_EMBEDDED_REAUTH_THRESHOLD_XLM (default 100), or when the amount can't be read from the XDR.
    • useSigner falls back to the embedded wallet when no browser wallet is installed.
    • Settings gets Export keys (after a passkey check, shown once, never stored) and Link self-custody wallet (a signed challenge), plus steps for moving holdings.
    • Browsers without WebAuthn get a fallback to wallet connection.

Closes #1474
Closes #1475
Closes #1476
Closes #1477

What needs backend work (not verified here)

  • Build creator media kit page with downloadable brand assets and stats #1475 and Add creator email broadcasts to holders with consent and unsubscribe handling #1476 storage: like the other creator tools in this repo, they persist through localCollection.service. Until server endpoints exist:
    • a public press page is only visible in the browser that saved it;
    • opt-ins and broadcasts live in local storage;
    • no real email is sent.
    • Delivered and bounced counts show "—" until a delivery report is recorded (recordDeliveryReport). They are not invented.
  • Add passkey and email sign-in with an embedded wallet option for new users #1477 server endpoints: the client calls endpoints that do not exist in accesslayer-server yet. They are listed at the top of src/services/embeddedWallet.service.ts (passkey register/login, email start/verify, reauth options, sign, export, link).
    • The server must verify WebAuthn and enforce the re-authentication threshold itself (respond 403 REAUTH_REQUIRED); the client check only decides when to prompt.
    • No wallet key material is created or stored in the browser. Only the public session is kept: the address and the sign-in method.
  • Re-authentication for email-only accounts: these accounts have no passkey, so signing above the threshold and exporting are refused with an explanation.
  • Contract calls (Soroban) always prompt: their XLM amount can't be read from the XDR, so they always ask for the passkey. This fails safe; trade flows could pass an amount estimate later.
  • Not tried in a real browser with a real authenticator; the WebAuthn calls are covered by unit tests with a fake navigator.credentials.

Testing

Compared against dev at 32f00b3 (the default branch):

  • pnpm lint: same 7 problems as dev (2 errors, 5 warnings, all in files this PR doesn't touch), none new.
  • pnpm build:
    • vite build succeeds.
    • tsc -p tsconfig.app.json has the same 26 errors as dev (useBenchmarks, useScreener, ScreenerPage, …), none new.
    • So pnpm build (tsc -b && vite build) still fails exactly as it does on dev.
  • vitest run: 402 failed / 4024 passed. dev is 402 failed / 3934 passed, so there are 90 new tests and they all pass.
    • The same 402 tests fail on both, and nothing that passes on dev fails here.
  • Mutation checks: for each key rule I broke the code and confirmed a test fails, then restored it. Rules covered:
    • 0.8 highlight, matrix symmetry, 14-day exclusion, score formula;
    • visibility 404, hidden fields, asset sizes, QR target, creator-only editing;
    • monthly limit, opt-in filter, min balance, unsubscribe exclusion, scheduled audience, unsubscribe link, holder pagination;
    • reauth threshold, fail-safe on unknown amounts, custody notice in hook and UI, passkey fallback, secure-context check, public-only session storage, export reauth, useSigner fallback, no-passkey guard.
  • One existing test changed: NotificationPreferencesPage.test.tsx now stubs the new opt-in section, which has its own tests and needs a QueryClient that test does not set up.

Checklist

…ayerorg#1474)

The portfolio page gets a DiversificationPanel with Correlation and
Concentration tabs.

- usePortfolioCorrelation(range, positions) fetches each held key's daily
  snapshots, builds daily returns from consecutive closing prices, and
  computes pairwise Pearson correlation over the days two keys share.
  Keys with fewer than 14 days of history are left out with a notice.
- CorrelationMatrix renders a heatmap (symmetric, ones on the diagonal)
  and the same values as a screen-reader table; the heatmap is hidden
  from assistive technology. Pairs above 0.8 are outlined and listed with
  a suggestion to reduce the overlap.
- The diversification score is 100 x (1 - HHI) x (1 - max(0, weighted
  average correlation)), with pair weights w_i x w_j, mapped to a
  plain-language label, so it moves with both holdings and weights.
  Concentration shows each key's share of the analysed value.

Closes accesslayerorg#1474
- MediaKitPage at /creator/media-kit?key=<id>, linked from the creator
  dashboard and editable only by the key's creator wallet: handle, short
  bio, talking points, contact email, per-field visibility and a public
  toggle (off by default).
- PublicPressPage at /k/:handle/press renders the 404 page unless the
  creator turned visibility on, and receives only the fields they
  enabled (hidden fields are dropped in the service, not just hidden).
- useMediaKit(keyId) returns price, holders, 24h volume and key age with
  the last-updated time, using the same resolvers and formatters as the
  key page's stat row so the numbers match.
- Canvas-generated PNG downloads: avatar at 128/256/512, a 1500x500
  banner and a 1080x1080 card, falling back to initials when the avatar
  cannot be drawn.
- Copy-ready text blocks and a QR code linking to /keys/:id.

Media kits are stored through the shared local collection like the other
creator tools, so a public page is only visible in the browser that saved
it until a backend endpoint exists.

Closes accesslayerorg#1475
- Holders opt in per held key under Settings > Notification preferences
  (off by default, needs an email address).
- BroadcastComposer on the creator dashboard (key creator only): subject,
  message, minimum keys held, a live audience count before sending, an
  email preview with its unsubscribe footer, and send now or schedule.
- useBroadcasts(keyId) follows the holders endpoint's cursor to count the
  audience, and exposes send, schedule, cancel and history. Scheduled
  broadcasts take their audience when they go out, so later opt-outs are
  respected.
- Each key can send 4 broadcasts per calendar month (UTC); scheduled ones
  count against the month they go out in. A fifth is blocked with an
  explanation and the remaining allowance is shown.
- Every email carries a per-subscription unsubscribe link and a
  List-Unsubscribe value; /unsubscribe/:token opts the holder out at once
  and counts it against that broadcast.
- BroadcastHistory shows recipients, delivered, bounced and unsubscribed.
  Delivered and bounced stay "—" until a delivery report is recorded.

Opt-ins and broadcasts are stored through the shared local collection like
the other creator tools; sending real email and receiving delivery reports
need a backend endpoint and an email provider.

The NotificationPreferencesPage test now stubs the new opt-in section,
which has its own tests and needs a QueryClient.

Closes accesslayerorg#1476
…yerorg#1477)

- SignInOptionsModal offers Connect wallet, Continue with passkey and
  Continue with email; it opens from the existing connect dialog. In
  browsers without WebAuthn (or outside a secure context) the passkey
  option is disabled and points to wallet connection.
- usePasskeyAuth() runs WebAuthn registration and authentication against
  server-issued challenges and verifies through the embedded wallet
  service; useEmailSignIn() handles the one-time code flow.
- SecurityNotice explains the custody trade-offs. Creating a wallet is
  blocked until it is acknowledged, both in the UI and in the hook, and
  the accepted notice version is sent to the server.
- EmbeddedWalletAdapter implements Signer with server-assisted signing.
  Transactions moving more than VITE_EMBEDDED_REAUTH_THRESHOLD_XLM
  (default 100), or whose amount cannot be read from the XDR, need a fresh
  passkey assertion first. useSigner falls back to it when no browser
  wallet is installed.
- Settings gets Export keys (after a passkey check; shown once, never
  stored) and Link self-custody wallet (signed challenge from Freighter)
  with steps for moving holdings.

No wallet key material is created or stored in the browser; the client
keeps only the public session (address, sign-in method). The server
endpoints this calls are documented in embeddedWallet.service.ts and do
not exist in accesslayer-server yet; the server must enforce the
re-authentication threshold itself.

Closes accesslayerorg#1477
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Itodo-S Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant