@camstack/sdk 1.1.21 → 1.1.22

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 CHANGED
@@ -993,12 +993,19 @@ var System = class {
993
993
  * Usernameless login — step 2. Submits the browser assertion; on
994
994
  * success the server resolves the credential's owner and mints the
995
995
  * real session JWT, which we set as the active token on this client.
996
+ *
997
+ * Second-factor aware (mirrors `login`): when the account still has a
998
+ * second factor to satisfy (TOTP — 2FA applies uniformly after any
999
+ * primary method), the server returns a short-lived CHALLENGE token +
1000
+ * `secondFactors`. That token is NOT persisted as the active session
1001
+ * — the caller completes the remaining factor via `loginVerifyTotp`.
996
1002
  */
997
1003
  async passkeyLoginFinish(response) {
998
1004
  const result = await this._trpcClient.auth.passkeyLoginFinish.mutate({ response });
999
1005
  if (typeof result === "object" && result !== null && "token" in result) {
1000
- const token = result.token;
1001
- if (typeof token === "string") this.setToken(token);
1006
+ const r = result;
1007
+ const requiresSecondFactor = r.requiresTotp === true || Array.isArray(r.secondFactors) && r.secondFactors.length > 0;
1008
+ if (typeof r.token === "string" && !requiresSecondFactor) this.setToken(r.token);
1002
1009
  }
1003
1010
  return result;
1004
1011
  }
@@ -1035,6 +1042,17 @@ var System = class {
1035
1042
  async removeOwnPasskey(input) {
1036
1043
  return await this._trpcClient.auth.removeOwnPasskey.mutate(input);
1037
1044
  }
1045
+ /**
1046
+ * Own passkey second-factor preference (opt-in, default OFF).
1047
+ * Enrolling a passkey only enables passkey-first sign-in; this flag
1048
+ * additionally demands the passkey after every password login.
1049
+ */
1050
+ async getOwnPasskeySecondFactorPreference() {
1051
+ return await this._trpcClient.auth.getOwnPasskeySecondFactorPreference.query();
1052
+ }
1053
+ async setOwnPasskeySecondFactorPreference(input) {
1054
+ return await this._trpcClient.auth.setOwnPasskeySecondFactorPreference.mutate(input);
1055
+ }
1038
1056
  /** Update the auth token (e.g. after login or token refresh). */
1039
1057
  setToken(token) {
1040
1058
  this.token = token;
package/dist/index.js CHANGED
@@ -992,12 +992,19 @@ var System = class {
992
992
  * Usernameless login — step 2. Submits the browser assertion; on
993
993
  * success the server resolves the credential's owner and mints the
994
994
  * real session JWT, which we set as the active token on this client.
995
+ *
996
+ * Second-factor aware (mirrors `login`): when the account still has a
997
+ * second factor to satisfy (TOTP — 2FA applies uniformly after any
998
+ * primary method), the server returns a short-lived CHALLENGE token +
999
+ * `secondFactors`. That token is NOT persisted as the active session
1000
+ * — the caller completes the remaining factor via `loginVerifyTotp`.
995
1001
  */
996
1002
  async passkeyLoginFinish(response) {
997
1003
  const result = await this._trpcClient.auth.passkeyLoginFinish.mutate({ response });
998
1004
  if (typeof result === "object" && result !== null && "token" in result) {
999
- const token = result.token;
1000
- if (typeof token === "string") this.setToken(token);
1005
+ const r = result;
1006
+ const requiresSecondFactor = r.requiresTotp === true || Array.isArray(r.secondFactors) && r.secondFactors.length > 0;
1007
+ if (typeof r.token === "string" && !requiresSecondFactor) this.setToken(r.token);
1001
1008
  }
1002
1009
  return result;
1003
1010
  }
@@ -1034,6 +1041,17 @@ var System = class {
1034
1041
  async removeOwnPasskey(input) {
1035
1042
  return await this._trpcClient.auth.removeOwnPasskey.mutate(input);
1036
1043
  }
1044
+ /**
1045
+ * Own passkey second-factor preference (opt-in, default OFF).
1046
+ * Enrolling a passkey only enables passkey-first sign-in; this flag
1047
+ * additionally demands the passkey after every password login.
1048
+ */
1049
+ async getOwnPasskeySecondFactorPreference() {
1050
+ return await this._trpcClient.auth.getOwnPasskeySecondFactorPreference.query();
1051
+ }
1052
+ async setOwnPasskeySecondFactorPreference(input) {
1053
+ return await this._trpcClient.auth.setOwnPasskeySecondFactorPreference.mutate(input);
1054
+ }
1037
1055
  /** Update the auth token (e.g. after login or token refresh). */
1038
1056
  setToken(token) {
1039
1057
  this.token = token;
package/dist/system.d.ts CHANGED
@@ -233,9 +233,17 @@ export declare class System {
233
233
  * Usernameless login — step 2. Submits the browser assertion; on
234
234
  * success the server resolves the credential's owner and mints the
235
235
  * real session JWT, which we set as the active token on this client.
236
+ *
237
+ * Second-factor aware (mirrors `login`): when the account still has a
238
+ * second factor to satisfy (TOTP — 2FA applies uniformly after any
239
+ * primary method), the server returns a short-lived CHALLENGE token +
240
+ * `secondFactors`. That token is NOT persisted as the active session
241
+ * — the caller completes the remaining factor via `loginVerifyTotp`.
236
242
  */
237
243
  passkeyLoginFinish(response: Record<string, unknown>): Promise<{
238
244
  token: string;
245
+ requiresTotp?: boolean;
246
+ secondFactors?: readonly SecondFactorKind[];
239
247
  }>;
240
248
  logout(): Promise<void>;
241
249
  getMe(): Promise<UserInfo>;
@@ -277,6 +285,19 @@ export declare class System {
277
285
  }): Promise<{
278
286
  success: true;
279
287
  }>;
288
+ /**
289
+ * Own passkey second-factor preference (opt-in, default OFF).
290
+ * Enrolling a passkey only enables passkey-first sign-in; this flag
291
+ * additionally demands the passkey after every password login.
292
+ */
293
+ getOwnPasskeySecondFactorPreference(): Promise<{
294
+ enabled: boolean;
295
+ }>;
296
+ setOwnPasskeySecondFactorPreference(input: {
297
+ enabled: boolean;
298
+ }): Promise<{
299
+ success: true;
300
+ }>;
280
301
  /** Update the auth token (e.g. after login or token refresh). */
281
302
  setToken(token: string): void;
282
303
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/sdk",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",