natureco-cli 5.51.2 → 5.51.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/utils/natureco-account.js +45 -13
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to NatureCo CLI will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [5.51.4] - 2026-07-11 — "account: OTP kodu magiclink tipini de dener"
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **6/8 haneli kodla giriş** (`{{ .Token }}` şablona eklenmişse) çalışır: kod doğrulaması `type:email` başarısızsa `type:magiclink` ile tekrar denenir; boşluklar temizlenir. (Kod tek kullanımlık — her `account login` yeni kod üretir, EN SON e-postadaki kodu kullan.)
|
|
9
|
+
|
|
10
|
+
## [5.51.3] - 2026-07-11 — "account: implicit magic link (fragment access_token)"
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Giriş linki fragment'inde `access_token`+`refresh_token` doğrudan geldiğinde de çalışır** (Supabase implicit-flow / SiteURL redirect). Link `#access_token=...&refresh_token=...` biçimindeyse /verify gerekmez — CLI tokenları doğrudan kaydeder, kullanıcıyı JWT'den çözer. (5.51.2 yalnız token_hash biçimini işliyordu.)
|
|
14
|
+
|
|
5
15
|
## [5.51.2] - 2026-07-11 — "account: giriş linki (magic link) desteği"
|
|
6
16
|
|
|
7
17
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.51.
|
|
3
|
+
"version": "5.51.4",
|
|
4
4
|
"description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"natureco": "bin/natureco.js"
|
|
@@ -70,26 +70,58 @@ async function sendOtp(email) {
|
|
|
70
70
|
return { sent: true, email };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* OTP kodunu doğrula → oturum. Supabase'de e-postayla gelen kodun doğrulama tipi
|
|
75
|
+
* şablona göre 'email' ya da 'magiclink' olabilir → ikisini de dener.
|
|
76
|
+
*/
|
|
74
77
|
async function verifyOtp(email, token) {
|
|
75
|
-
|
|
78
|
+
const code = String(token).replace(/\s+/g, '');
|
|
79
|
+
try {
|
|
80
|
+
return saveSession(_shape(await _post('/verify', { type: 'email', email, token: code })));
|
|
81
|
+
} catch (e1) {
|
|
82
|
+
try {
|
|
83
|
+
return saveSession(_shape(await _post('/verify', { type: 'magiclink', email, token: code })));
|
|
84
|
+
} catch (_) {
|
|
85
|
+
throw e1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// JWT access_token içinden kullanıcıyı çöz (imza doğrulaması yok — sadece görüntüleme)
|
|
91
|
+
function _userFromJwt(token) {
|
|
92
|
+
try {
|
|
93
|
+
const p = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString('utf8'));
|
|
94
|
+
return { id: p.sub, email: p.email };
|
|
95
|
+
} catch (_) { return null; }
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
/**
|
|
79
|
-
* E-postadan gelen GİRİŞ LİNKİ'ni
|
|
80
|
-
*
|
|
99
|
+
* E-postadan gelen GİRİŞ LİNKİ'ni işle (şablon 6 haneli kod yerine magic link
|
|
100
|
+
* gönderdiğinde). İki biçim:
|
|
101
|
+
* 1) Implicit: link fragment'inde ZATEN access_token+refresh_token var → doğrudan oturum.
|
|
102
|
+
* 2) token_hash: /verify ile doğrula.
|
|
81
103
|
*/
|
|
82
104
|
async function verifyLink(link) {
|
|
83
|
-
let
|
|
84
|
-
try {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
let u;
|
|
106
|
+
try { u = new URL(link.trim()); }
|
|
107
|
+
catch (e) { throw new Error('Geçersiz link', { cause: e }); }
|
|
108
|
+
const q = u.searchParams;
|
|
109
|
+
const frag = new URLSearchParams((u.hash || '').replace(/^#/, ''));
|
|
110
|
+
const pick = (k) => frag.get(k) || q.get(k);
|
|
111
|
+
|
|
112
|
+
const access_token = pick('access_token');
|
|
113
|
+
if (access_token) {
|
|
114
|
+
return saveSession(_shape({
|
|
115
|
+
access_token,
|
|
116
|
+
refresh_token: pick('refresh_token'),
|
|
117
|
+
token_type: pick('token_type') || 'bearer',
|
|
118
|
+
expires_at: parseInt(pick('expires_at') || '0', 10) || null,
|
|
119
|
+
expires_in: parseInt(pick('expires_in') || '0', 10) || null,
|
|
120
|
+
user: _userFromJwt(access_token),
|
|
121
|
+
}));
|
|
92
122
|
}
|
|
123
|
+
const token_hash = pick('token_hash') || pick('token');
|
|
124
|
+
const type = pick('type') || 'magiclink';
|
|
93
125
|
if (!token_hash) throw new Error("Linkte doğrulama token'ı bulunamadı");
|
|
94
126
|
return saveSession(_shape(await _post('/verify', { type, token_hash })));
|
|
95
127
|
}
|