@insignia-education/api-sdk-js 0.15.11 → 0.15.14
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/package.json +1 -1
- package/src/api/v1/Auth.js +2 -2
- package/src/api/v1/Webauthn.js +27 -0
- package/src/api/v1/index.js +2 -0
package/package.json
CHANGED
package/src/api/v1/Auth.js
CHANGED
|
@@ -5,7 +5,7 @@ export default class Auth {
|
|
|
5
5
|
this.#client = client;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
loginOrRegister(email)
|
|
8
|
+
loginOrRegister(email, turnstile_token) { return this.#client.get(`/auth/login-register-check?email=${encodeURIComponent(email)}&turnstile_token=${encodeURIComponent(turnstile_token)}`); }
|
|
9
9
|
register(data) { return this.#client.put('/auth/register', data); }
|
|
10
10
|
/** May resolve to { two_factor_required: true } — then call twoFactor({ pin }). */
|
|
11
11
|
login(data) { return this.#client.post('/auth/login', data); }
|
|
@@ -13,7 +13,7 @@ export default class Auth {
|
|
|
13
13
|
refresh() { return this.#client.post('/auth/refresh'); }
|
|
14
14
|
logout() { return this.#client.post('/auth/logout'); }
|
|
15
15
|
user() { return this.#client.get('/auth/user'); }
|
|
16
|
-
forgotPassword(email)
|
|
16
|
+
forgotPassword(email, turnstile_token) { return this.#client.post('/auth/forgot-password', { email, turnstile_token }); }
|
|
17
17
|
resetPassword(data) { return this.#client.post('/auth/reset-password', data); }
|
|
18
18
|
magicLinkSend(email) { return this.#client.post('/auth/magic-link/send', { email }); }
|
|
19
19
|
magicLinkVerify(data) { return this.#client.post('/auth/magic-link/verify', data); }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebAuthn — security keys / passkeys.
|
|
3
|
+
*
|
|
4
|
+
* Enrollment (authenticated): registerOptions() -> register().
|
|
5
|
+
* Passwordless login (public): loginOptions() -> loginVerify().
|
|
6
|
+
*
|
|
7
|
+
* The `credential` passed to register()/loginVerify() is the JSON produced by
|
|
8
|
+
* the browser ceremony (navigator.credentials.create/get, serialized).
|
|
9
|
+
*/
|
|
10
|
+
export default class Webauthn {
|
|
11
|
+
#client;
|
|
12
|
+
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.#client = client;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Enrollment
|
|
18
|
+
registerOptions() { return this.#client.post('/webauthn/register/options'); }
|
|
19
|
+
register(credential, name = null) { return this.#client.post('/webauthn/register', { credential, name }); }
|
|
20
|
+
credentials() { return this.#client.get('/webauthn/credentials'); }
|
|
21
|
+
deleteCredential(id) { return this.#client.del(`/webauthn/credentials/${id}`); }
|
|
22
|
+
|
|
23
|
+
// Passwordless login. Pass { email } to scope to a user, or nothing for a
|
|
24
|
+
// usernameless discoverable-passkey login.
|
|
25
|
+
loginOptions(data = {}) { return this.#client.post('/auth/webauthn/login/options', data); }
|
|
26
|
+
loginVerify(credential) { return this.#client.post('/auth/webauthn/login', { credential }); }
|
|
27
|
+
}
|
package/src/api/v1/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import UserSessionTypes from './UserSessionTypes.js';
|
|
|
31
31
|
import UserTypes from './UserTypes.js';
|
|
32
32
|
import Users from './Users.js';
|
|
33
33
|
import Utm from './Utm.js';
|
|
34
|
+
import Webauthn from './Webauthn.js';
|
|
34
35
|
import Zoom from './Zoom.js';
|
|
35
36
|
|
|
36
37
|
export default class InsigniaApiV1 extends InsigniaApi {
|
|
@@ -77,6 +78,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
|
|
|
77
78
|
this.userTypes = new UserTypes(this);
|
|
78
79
|
this.users = new Users(this);
|
|
79
80
|
this.utm = new Utm(this);
|
|
81
|
+
this.webauthn = new Webauthn(this);
|
|
80
82
|
this.zoom = new Zoom(this);
|
|
81
83
|
}
|
|
82
84
|
}
|