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