@camstack/sdk 0.1.44 → 0.1.45
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/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/system.d.ts +12 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1049,6 +1049,22 @@ class System {
|
|
|
1049
1049
|
// ── Auth ──────────────────────────────────────────────────────────
|
|
1050
1050
|
async login(username, password) {
|
|
1051
1051
|
const result = await this._trpcClient.auth.login.mutate({ username, password });
|
|
1052
|
+
if (typeof result === "object" && result !== null && "token" in result) {
|
|
1053
|
+
const r = result;
|
|
1054
|
+
const token = r.token;
|
|
1055
|
+
if (typeof token === "string" && r.requiresTotp !== true) this.setToken(token);
|
|
1056
|
+
}
|
|
1057
|
+
return result;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Second leg of the 2FA login. The caller passes the challenge
|
|
1061
|
+
* token returned by `login` (when `requiresTotp: true`) plus the
|
|
1062
|
+
* 6-digit code from the user's authenticator app. On success the
|
|
1063
|
+
* server mints the real session JWT, which we set as the active
|
|
1064
|
+
* token on this client.
|
|
1065
|
+
*/
|
|
1066
|
+
async loginVerifyTotp(challengeToken, code) {
|
|
1067
|
+
const result = await this._trpcClient.auth.loginVerifyTotp.mutate({ challengeToken, code });
|
|
1052
1068
|
if (typeof result === "object" && result !== null && "token" in result) {
|
|
1053
1069
|
const token = result.token;
|
|
1054
1070
|
if (typeof token === "string") this.setToken(token);
|