Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Figmaプラグイン(非Webページ環境)での Supabaseログイン
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ryohei Ikegami
February 15, 2025
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Figmaプラグイン(非Webページ環境)での Supabaseログイン
https://hackermeshi.com/parties/688
2025年2月5日(水) フロントエンド交流会での発表です。
Ryohei Ikegami
February 15, 2025
More Decks by Ryohei Ikegami
See All by Ryohei Ikegami
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
19
9.5k
AIでAIデザインツールを作った 1年間の実践
seanchas116
2
700
共同編集ドローツールの作り方
seanchas116
3
1.1k
FigmaからTailwind HTMLを 生成するプラグインの開発
seanchas116
6
4.6k
Web Componentsを作れる デザインツールの開発
seanchas116
0
960
RubyとQML/Qt Quickで デスクトップアプリを 書けるようにした
seanchas116
0
1.3k
C++視点からのRuby紹介
seanchas116
0
460
Other Decks in Programming
See All in Programming
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
350
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
ソフトウェアラスタライザ
fadis
1
480
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
360
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.9k
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
240
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
460
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.5k
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
250
メールのエイリアス機能を履き違えない
isshinfunada
0
250
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
470
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
220
Leo the Paperboy
mayatellez
8
2.2k
Skip the Path - Find Your Career Trail
mkilby
1
190
WENDY [Excerpt]
tessaabrams
11
39k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Mobile First: as difficult as doing things right
swwweet
225
10k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Six Lessons from altMBA
skipperchong
29
4.5k
Transcript
seanchas116 Figmaプラグイン(非Webページ環境)での Supabaseログイン フロントエンド交流会 2025/02/05
自己紹介 フロントエンドメインのフリーランスエンジニア 複雑GUI(グラフィックスエディタ) AI/ML活用系など 池上 涼平 seanchas116 github.com/seanchas116 twitter.com/seanchas_t rera-inc.com
開発中のFigmaプラグイン Figma内で動くAIチャット UIが生成できる
技術構成 Figmaプラグイン Vite / React / TypeScript Supabase Anthropic API
Claude 3.5 Sonnet Next.js (Vercel)
Figmaプラグインでの Supabaseログイン
Figmaプラグイン (Webブラウザ外) でのSupabaseログイン FigmaプラグインはFigma内で動くiframe 他のサイトの表示はできない → OAuthログインなどはブラウザに遷移して行う
supabase.auth.setSession const await { data, error } = supabase.auth.setSession({ access_token,
refresh_token }) これならFigmaプラグイン内でも Supabaseのセッションを獲得できる
const token = uuidv4(); .open( ); window ` /sign-in/plugin?token= `
${SERVER_URL} ${token} プラグインがワンタイムトークンを生成 そのトークンをクエリパラメータとして Webアプリのログイン画面を開く ワンタイムトークンの生成
const await await session = supabase.auth.getSession(); prisma.onetimeLoginToken.create({ : { token,
: user.id, : session.access_token, : session.refresh_token, }, }); // トークンとセッション情報を紐付けて保存 data userId accessToken refreshToken ユーザーがWebアプリで Supabaseを使って認証 認証成功後、ワンタイムトークンと Supabaseのセッショントークンを紐 付けてDBに保存 ワンタイムトークンは pg_cronで定期的に削除 テーブルはフロントエンドから 直アクセスできないように (RLS無効化) Webアプリでの認証
プラグインでのセッション復元 const await const await await response = fetch( );
{ access_token, refresh_token } = response.json(); figma.clientStorage.setAsync( , access_token); figma.clientStorage.setAsync( , refresh_token); supabase.auth.setSession({ access_token, refresh_token }); ` /api/auth/exchange-token?token= ` "supabaseAccessToken" "supabaseRefreshToken" ${SERVER_URL} ${token} // トークンをプラグインのストレージに保存 // Supabaseセッションを復元 ユーザがープラグインに戻ったら (window.onfocusで検知) ワンタイムトークンを使って セッショントークンを取得 取得したトークンを プラグインのストレージに保存 Supabaseのセッションを復元
課題 アクセストークンとリフレッシュトークンをDBに保存してしまっていG ) リフレッシュトークンは元々SupabaseのDBに格納されているので大丈夫そ ) アクセストークンはすぐ有効期限切れるから大丈夫か...?
おまけ このスライドの詳細説明部分は Clineで作成 直接コードを読んで 内容を生成してくれました