@insignia-education/api-sdk-js 0.15.10 → 0.15.11
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 -0
- package/src/api/v1/TwoFactor.js +20 -0
- package/src/api/v1/Users.js +4 -5
- package/src/api/v1/index.js +2 -0
package/package.json
CHANGED
package/src/api/v1/Auth.js
CHANGED
|
@@ -7,6 +7,7 @@ export default class Auth {
|
|
|
7
7
|
|
|
8
8
|
loginOrRegister(email) { return this.#client.get(`/auth/login-register-check?email=${encodeURIComponent(email)}`); }
|
|
9
9
|
register(data) { return this.#client.put('/auth/register', data); }
|
|
10
|
+
/** May resolve to { two_factor_required: true } — then call twoFactor({ pin }). */
|
|
10
11
|
login(data) { return this.#client.post('/auth/login', data); }
|
|
11
12
|
googleLogin(data) { return this.#client.post('/auth/google', data); }
|
|
12
13
|
refresh() { return this.#client.post('/auth/refresh'); }
|
|
@@ -18,5 +19,6 @@ export default class Auth {
|
|
|
18
19
|
magicLinkVerify(data) { return this.#client.post('/auth/magic-link/verify', data); }
|
|
19
20
|
facebookLogin(data) { return this.#client.post('/auth/facebook', data); }
|
|
20
21
|
emailVerify(data) { return this.#client.post('/auth/email-verify', data); }
|
|
22
|
+
/** Second login step when two_factor_required: exchange { pin } for a session. */
|
|
21
23
|
twoFactor(data) { return this.#client.post('/auth/2fa', data); }
|
|
22
24
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOTP two-factor management for the authenticated user.
|
|
3
|
+
* The login-time verification step lives on Auth.twoFactor().
|
|
4
|
+
*/
|
|
5
|
+
export default class TwoFactor {
|
|
6
|
+
#client;
|
|
7
|
+
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.#client = client;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** { enabled: boolean } */
|
|
13
|
+
status() { return this.#client.get('/2fa/status'); }
|
|
14
|
+
/** Provision a secret (2FA stays OFF). Returns { secret, otpauth_url } for the QR. */
|
|
15
|
+
setup() { return this.#client.post('/2fa/setup'); }
|
|
16
|
+
/** Confirm a code and turn 2FA on. data: { pin } */
|
|
17
|
+
enable(data) { return this.#client.post('/2fa/enable', data); }
|
|
18
|
+
/** Verify a code and turn 2FA off. data: { pin } */
|
|
19
|
+
disable(data) { return this.#client.post('/2fa/disable', data); }
|
|
20
|
+
}
|
package/src/api/v1/Users.js
CHANGED
|
@@ -63,22 +63,21 @@ export default class Users {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** Read-only: points are granted/revoked by internal jobs, not over the API. */
|
|
66
67
|
points(userId) {
|
|
67
68
|
const base = `/users/${userId}/points`;
|
|
68
69
|
const client = this.#client;
|
|
69
70
|
return {
|
|
70
|
-
get:
|
|
71
|
-
create: (data) => client.put(base, data),
|
|
72
|
-
delete: (id) => client.del(`${base}/${id}`),
|
|
71
|
+
get: (id = null) => id ? client.get(`${base}/${id}`) : client.get(base),
|
|
73
72
|
};
|
|
74
73
|
}
|
|
75
74
|
|
|
75
|
+
/** Read-only: money moves are created by internal jobs, not over the API. */
|
|
76
76
|
moneyMoves(userId) {
|
|
77
77
|
const base = `/users/${userId}/money-moves`;
|
|
78
78
|
const client = this.#client;
|
|
79
79
|
return {
|
|
80
|
-
get:
|
|
81
|
-
create: (data) => client.put(base, data),
|
|
80
|
+
get: (id = null) => id ? client.get(`${base}/${id}`) : client.get(base),
|
|
82
81
|
};
|
|
83
82
|
}
|
|
84
83
|
|
package/src/api/v1/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import Surveys from './Surveys.js';
|
|
|
26
26
|
import Taxes from './Taxes.js';
|
|
27
27
|
import Teacher from './Teacher.js';
|
|
28
28
|
import Telegram from './Telegram.js';
|
|
29
|
+
import TwoFactor from './TwoFactor.js';
|
|
29
30
|
import UserSessionTypes from './UserSessionTypes.js';
|
|
30
31
|
import UserTypes from './UserTypes.js';
|
|
31
32
|
import Users from './Users.js';
|
|
@@ -71,6 +72,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
|
|
|
71
72
|
this.taxes = new Taxes(this);
|
|
72
73
|
this.teacher = new Teacher(this);
|
|
73
74
|
this.telegram = new Telegram(this);
|
|
75
|
+
this.twoFactor = new TwoFactor(this);
|
|
74
76
|
this.userSessionTypes = new UserSessionTypes(this);
|
|
75
77
|
this.userTypes = new UserTypes(this);
|
|
76
78
|
this.users = new Users(this);
|