@camstack/sdk 1.1.20 → 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 +41 -0
- package/dist/index.js +41 -0
- package/dist/system.d.ts +39 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -979,6 +979,36 @@ var System = class {
|
|
|
979
979
|
}
|
|
980
980
|
return result;
|
|
981
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* Usernameless (passkey-FIRST) login — step 1. Fetches discoverable-
|
|
984
|
+
* credential assertion options (EMPTY `allowCredentials`); the caller
|
|
985
|
+
* feeds `optionsJSON` to `@simplewebauthn/browser` `startAuthentication`
|
|
986
|
+
* and the browser's own passkey picker takes over. PUBLIC (pre-session,
|
|
987
|
+
* no challenge token — the WebAuthn challenge is the whole state).
|
|
988
|
+
*/
|
|
989
|
+
async passkeyLoginBegin() {
|
|
990
|
+
return await this._trpcClient.auth.passkeyLoginBegin.mutate();
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Usernameless login — step 2. Submits the browser assertion; on
|
|
994
|
+
* success the server resolves the credential's owner and mints the
|
|
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`.
|
|
1002
|
+
*/
|
|
1003
|
+
async passkeyLoginFinish(response) {
|
|
1004
|
+
const result = await this._trpcClient.auth.passkeyLoginFinish.mutate({ response });
|
|
1005
|
+
if (typeof result === "object" && result !== null && "token" in result) {
|
|
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);
|
|
1009
|
+
}
|
|
1010
|
+
return result;
|
|
1011
|
+
}
|
|
982
1012
|
async logout() {
|
|
983
1013
|
await this._trpcClient.auth.logout.mutate();
|
|
984
1014
|
}
|
|
@@ -1012,6 +1042,17 @@ var System = class {
|
|
|
1012
1042
|
async removeOwnPasskey(input) {
|
|
1013
1043
|
return await this._trpcClient.auth.removeOwnPasskey.mutate(input);
|
|
1014
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
|
+
}
|
|
1015
1056
|
/** Update the auth token (e.g. after login or token refresh). */
|
|
1016
1057
|
setToken(token) {
|
|
1017
1058
|
this.token = token;
|
package/dist/index.js
CHANGED
|
@@ -978,6 +978,36 @@ var System = class {
|
|
|
978
978
|
}
|
|
979
979
|
return result;
|
|
980
980
|
}
|
|
981
|
+
/**
|
|
982
|
+
* Usernameless (passkey-FIRST) login — step 1. Fetches discoverable-
|
|
983
|
+
* credential assertion options (EMPTY `allowCredentials`); the caller
|
|
984
|
+
* feeds `optionsJSON` to `@simplewebauthn/browser` `startAuthentication`
|
|
985
|
+
* and the browser's own passkey picker takes over. PUBLIC (pre-session,
|
|
986
|
+
* no challenge token — the WebAuthn challenge is the whole state).
|
|
987
|
+
*/
|
|
988
|
+
async passkeyLoginBegin() {
|
|
989
|
+
return await this._trpcClient.auth.passkeyLoginBegin.mutate();
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Usernameless login — step 2. Submits the browser assertion; on
|
|
993
|
+
* success the server resolves the credential's owner and mints the
|
|
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`.
|
|
1001
|
+
*/
|
|
1002
|
+
async passkeyLoginFinish(response) {
|
|
1003
|
+
const result = await this._trpcClient.auth.passkeyLoginFinish.mutate({ response });
|
|
1004
|
+
if (typeof result === "object" && result !== null && "token" in result) {
|
|
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);
|
|
1008
|
+
}
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
981
1011
|
async logout() {
|
|
982
1012
|
await this._trpcClient.auth.logout.mutate();
|
|
983
1013
|
}
|
|
@@ -1011,6 +1041,17 @@ var System = class {
|
|
|
1011
1041
|
async removeOwnPasskey(input) {
|
|
1012
1042
|
return await this._trpcClient.auth.removeOwnPasskey.mutate(input);
|
|
1013
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
|
+
}
|
|
1014
1055
|
/** Update the auth token (e.g. after login or token refresh). */
|
|
1015
1056
|
setToken(token) {
|
|
1016
1057
|
this.token = token;
|
package/dist/system.d.ts
CHANGED
|
@@ -219,6 +219,32 @@ export declare class System {
|
|
|
219
219
|
loginVerifyPasskey(challengeToken: string, response: Record<string, unknown>): Promise<{
|
|
220
220
|
token: string;
|
|
221
221
|
}>;
|
|
222
|
+
/**
|
|
223
|
+
* Usernameless (passkey-FIRST) login — step 1. Fetches discoverable-
|
|
224
|
+
* credential assertion options (EMPTY `allowCredentials`); the caller
|
|
225
|
+
* feeds `optionsJSON` to `@simplewebauthn/browser` `startAuthentication`
|
|
226
|
+
* and the browser's own passkey picker takes over. PUBLIC (pre-session,
|
|
227
|
+
* no challenge token — the WebAuthn challenge is the whole state).
|
|
228
|
+
*/
|
|
229
|
+
passkeyLoginBegin(): Promise<{
|
|
230
|
+
optionsJSON: Record<string, unknown>;
|
|
231
|
+
}>;
|
|
232
|
+
/**
|
|
233
|
+
* Usernameless login — step 2. Submits the browser assertion; on
|
|
234
|
+
* success the server resolves the credential's owner and mints the
|
|
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`.
|
|
242
|
+
*/
|
|
243
|
+
passkeyLoginFinish(response: Record<string, unknown>): Promise<{
|
|
244
|
+
token: string;
|
|
245
|
+
requiresTotp?: boolean;
|
|
246
|
+
secondFactors?: readonly SecondFactorKind[];
|
|
247
|
+
}>;
|
|
222
248
|
logout(): Promise<void>;
|
|
223
249
|
getMe(): Promise<UserInfo>;
|
|
224
250
|
changeOwnPassword(input: {
|
|
@@ -259,6 +285,19 @@ export declare class System {
|
|
|
259
285
|
}): Promise<{
|
|
260
286
|
success: true;
|
|
261
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
|
+
}>;
|
|
262
301
|
/** Update the auth token (e.g. after login or token refresh). */
|
|
263
302
|
setToken(token: string): void;
|
|
264
303
|
/**
|