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
110
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
8.6k
AIでAIデザインツールを作った 1年間の実践
seanchas116
2
670
共同編集ドローツールの作り方
seanchas116
3
1.1k
FigmaからTailwind HTMLを 生成するプラグインの開発
seanchas116
6
4.6k
Web Componentsを作れる デザインツールの開発
seanchas116
0
950
RubyとQML/Qt Quickで デスクトップアプリを 書けるようにした
seanchas116
0
1.3k
C++視点からのRuby紹介
seanchas116
0
450
Other Decks in Programming
See All in Programming
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
130
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
770
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
540
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
4
1k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
250
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
Contextとはなにか
chiroruxx
1
320
Vite+ Unified Toolchain for the Web
naokihaba
0
310
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
540
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
Oxcを導入して開発体験が向上した話
yug1224
4
310
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
280
Featured
See All Featured
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
230
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Believing is Seeing
oripsolob
1
140
Context Engineering - Making Every Token Count
addyosmani
9
970
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
330
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Odyssey Design
rkendrick25
PRO
2
700
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で作成 直接コードを読んで 内容を生成してくれました